/** Add imports as single node to foldable tree */ protected void addImportsTree() { @SuppressWarnings("unchecked") final List<ImportDeclaration> imports = (List<ImportDeclaration>) cu.imports(); if (!imports.isEmpty()) { // Get range of imports (starting after first import statement) final ImportDeclaration firstImport = imports.get(0); final int startChar = firstImport.getStartPosition() + firstImport.getLength() - 1; final ImportDeclaration lastImport = imports.get(imports.size() - 1); final int endChar = lastImport.getStartPosition() + lastImport.getLength() - 1; // Add import identifiers to identifier list final List<String> importIdentifiers = Lists.newArrayList(); for (final ImportDeclaration importNode : imports) putTokenizedImports(importIdentifiers, importNode.getName().getFullyQualifiedName()); // Remove import identifiers from root token list tree.getRoot().removeTerms(importIdentifiers); // Add imports as single node to tree final ImportDeclaration node = cu.getAST().newImportDeclaration(); node.setSourceRange(startChar, endChar - startChar + 1); final FoldableNode fn = tree.new FoldableNode(node); fn.addTerms(importIdentifiers); tree.getRoot().addChild(fn); // Add import range to allFolds importBlock = Range.closed(startChar, endChar); allFolds.add(importBlock); } }
ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
@Override ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
ASTNode clone0(AST target) { ImportDeclaration result = new ImportDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setOnDemand(isOnDemand()); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.setStatic(isStatic()); } result.setName((Name) getName().clone(target)); return result; }
public ImportDeclaration convertImport(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) { final ImportDeclaration importDeclaration = new ImportDeclaration(this.ast); Name name = getImportName(importReference); importDeclaration.setName(name); final boolean onDemand = (importReference.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0; importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers; if (modifiers != ClassFileConstants.AccDefault) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED); break; default : if (modifiers == ClassFileConstants.AccStatic) { importDeclaration.setStatic(true); } else { importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED); } } } if (this.resolveBindings) { recordNodes(importDeclaration, importReference); } return importDeclaration; }
public ImportDeclaration convertImport(org.eclipse.jdt.internal.compiler.ast.ImportReference importReference) { final ImportDeclaration importDeclaration = new ImportDeclaration(this.ast); Name name = getImportName(importReference); importDeclaration.setName(name); final boolean onDemand = (importReference.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.OnDemand) != 0; importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers; if (modifiers != ClassFileConstants.AccDefault) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED); break; default : if (modifiers == ClassFileConstants.AccStatic) { importDeclaration.setStatic(true); } else { importDeclaration.setFlags(importDeclaration.getFlags() | ASTNode.MALFORMED); } } } if (this.resolveBindings) { recordNodes(importDeclaration, importReference); } return importDeclaration; }
importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers;
importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers;
importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers;
importDeclaration.setSourceRange(importReference.declarationSourceStart, importReference.declarationEnd - importReference.declarationSourceStart + 1); importDeclaration.setOnDemand(onDemand); int modifiers = importReference.modifiers;