@Override public boolean isDefaultPackage() { return unit.getPackage() == null; }
@Override public boolean isDefaultPackage() { return unit.getPackage() == null; }
private static Javadoc getPackageJavadocNode(IJavaElement element, String cuSource) { CompilationUnit cu = createAST(element, cuSource); if (cu != null) { PackageDeclaration packDecl = cu.getPackage(); if (packDecl != null) { return packDecl.getJavadoc(); } } return null; }
private static Javadoc getPackageJavadocNode(IJavaElement element, String cuSource) { CompilationUnit cu= createAST(element, cuSource); if (cu != null) { PackageDeclaration packDecl= cu.getPackage(); if (packDecl != null) { return packDecl.getJavadoc(); } } return null; }
@Override public String getPackage() { PackageDeclaration pkg = unit.getPackage(); if (pkg != null) { return pkg.getName().getFullyQualifiedName(); } return null; }
private void findHeader() { if (this.astRoot instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) this.astRoot; List<TypeDeclaration> types = unit.types(); ASTNode firstElement = types.isEmpty() ? unit.getPackage() : types.get(0); if (firstElement != null) { int headerEndIndex = this.tokenManager.firstIndexIn(firstElement, -1); this.tokenManager.setHeaderEndIndex(headerEndIndex); } } }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == PACKAGE_PROPERTY) { if (get) { return getPackage(); } else { setPackage((PackageDeclaration) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
private static Javadoc getPackageJavadocNode(IJavaElement element, String cuSource) { CompilationUnit cu= createAST(element, cuSource); if (cu != null) { PackageDeclaration packDecl= cu.getPackage(); if (packDecl != null) { return packDecl.getJavadoc(); } } return null; }
private void findHeader() { if (this.astRoot instanceof CompilationUnit) { CompilationUnit unit = (CompilationUnit) this.astRoot; List<TypeDeclaration> types = unit.types(); ASTNode firstElement = types.isEmpty() ? unit.getPackage() : types.get(0); if (firstElement != null) { int headerEndIndex = this.tokenManager.firstIndexIn(firstElement, -1); this.tokenManager.setHeaderEndIndex(headerEndIndex); } } }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == PACKAGE_PROPERTY) { if (get) { return getPackage(); } else { setPackage((PackageDeclaration) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
public static String qnameOfTopTypeDecl(SimpleName name) { String refName = name.getIdentifier(); CompilationUnit cu = FindUpper.cu(name); if (cu == null) { throw new IllegalArgumentException("The name is not in a CompilationUnit!"); } return cu.getPackage().getName().toString().trim() + "." + refName; }
@SuppressWarnings("unchecked") @Override public O setPackage(final String name) { if (unit.getPackage() == null) { unit.setPackage(unit.getAST().newPackageDeclaration()); } unit.getPackage().setName(unit.getAST().newName(name)); return (O) this; }
public static String getPackageName(final Path path) { final CompilationUnit unit = JavaSourceUtils.getCompilationUnit(path); final PackageDeclaration myPackage = unit.getPackage(); if (myPackage != null) { final Name name = myPackage.getName(); if (name != null) { return name.getFullyQualifiedName(); } } return ""; }
@Override public O setPackage(final String name) { if (unit.getPackage() == null) { unit.setPackage(unit.getAST().newPackageDeclaration()); } unit.getPackage().setName(unit.getAST().newName(name)); return (O) this; }
private void copyPackageDeclarationToDestination(IPackageDeclaration declaration, ASTRewrite targetRewrite, CompilationUnit sourceCuNode, CompilationUnit destinationCuNode) throws JavaModelException { if (destinationCuNode.getPackage() != null) { return; } PackageDeclaration sourceNode= ASTNodeSearchUtil.getPackageDeclarationNode(declaration, sourceCuNode); PackageDeclaration copiedNode= (PackageDeclaration) ASTNode.copySubtree(targetRewrite.getAST(), sourceNode); targetRewrite.set(destinationCuNode, CompilationUnit.PACKAGE_PROPERTY, copiedNode, null); }
private void copyPackageDeclarationToDestination(IPackageDeclaration declaration, ASTRewrite targetRewrite, CompilationUnit sourceCuNode, CompilationUnit destinationCuNode) throws JavaModelException { if (destinationCuNode.getPackage() != null) return; PackageDeclaration sourceNode= ASTNodeSearchUtil.getPackageDeclarationNode(declaration, sourceCuNode); PackageDeclaration copiedNode= (PackageDeclaration) ASTNode.copySubtree(targetRewrite.getAST(), sourceNode); targetRewrite.set(destinationCuNode, CompilationUnit.PACKAGE_PROPERTY, copiedNode, null); }
private void copyPackageDeclarationToDestination(IPackageDeclaration declaration, ASTRewrite targetRewrite, CompilationUnit sourceCuNode, CompilationUnit destinationCuNode) throws JavaModelException { if (destinationCuNode.getPackage() != null) return; PackageDeclaration sourceNode= ASTNodeSearchUtil.getPackageDeclarationNode(declaration, sourceCuNode); PackageDeclaration copiedNode= (PackageDeclaration) ASTNode.copySubtree(targetRewrite.getAST(), sourceNode); targetRewrite.set(destinationCuNode, CompilationUnit.PACKAGE_PROPERTY, copiedNode, null); }
void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getPackage()); acceptChildren(visitor, this.imports); acceptChildren(visitor, this.types); } visitor.endVisit(this); }
void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getPackage()); acceptChildren(visitor, this.imports); acceptChildren(visitor, this.types); } visitor.endVisit(this); }
void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getPackage()); acceptChildren(visitor, this.imports); acceptChildren(visitor, this.types); } visitor.endVisit(this); }