Copyright (c) 2000, 2010 IBM Corporation and others.
This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
IBM Corporation - initial API and implementation
/*******************************************************************************
* Copyright (c) 2000, 2010 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.*;
See Also: - IPackageDeclaration
/**
* @see IPackageDeclaration
*/
public class PackageDeclaration extends SourceRefElement implements IPackageDeclaration {
String name;
protected PackageDeclaration(CompilationUnit parent, String name) {
super(parent);
this.name = name;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof PackageDeclaration)) return false;
return super.equals(o);
}
@Override
public String getElementName() {
return this.name;
}
See Also: - IJavaElement
/**
* @see IJavaElement
*/
@Override
public int getElementType() {
return PACKAGE_DECLARATION;
}
See Also: - getHandleMemento.getHandleMemento()
/**
* @see JavaElement#getHandleMemento()
*/
@Override
protected char getHandleMementoDelimiter() {
return JavaElement.JEM_PACKAGEDECLARATION;
}
See Also: - getNameRange.getNameRange()
/**
* @see IPackageDeclaration#getNameRange()
*/
@Override
public ISourceRange getNameRange() throws JavaModelException {
AnnotatableInfo info = (AnnotatableInfo) getElementInfo();
return info.getNameRange();
}
@Override
public IJavaElement getPrimaryElement(boolean checkOwner) {
CompilationUnit cu = (CompilationUnit)getAncestor(COMPILATION_UNIT);
if (checkOwner && cu.isPrimary()) return this;
return cu.getPackageDeclaration(this.name);
}
@private Debugging purposes
/**
* @private Debugging purposes
*/
@Override
protected void toStringInfo(int tab, StringBuffer buffer, Object info, boolean showResolvedInfo) {
buffer.append(tabString(tab));
buffer.append("package "); //$NON-NLS-1$
toStringName(buffer);
if (info == null) {
buffer.append(" (not open)"); //$NON-NLS-1$
}
}
}