private ImportDeclaration createImport(String fullName) { ImportDeclaration importDecl = ast.newImportDeclaration(); if (fullName.endsWith(".*")) { fullName = fullName.substring(0, fullName.lastIndexOf('.')); importDecl.setName(ast.newName(fullName)); importDecl.setOnDemand(true); } else { importDecl.setName(ast.newName(fullName)); } return importDecl; }
@Override public Import setName(final String name) { if (name.endsWith(".*")) { imprt.setName(ast.newName(Types.tokenizeClassName(name.replaceAll("\\.\\*", "")))); imprt.setOnDemand(true); } else { imprt.setName(ast.newName(Types.tokenizeClassName(name))); } return this; }
@Override public Import setName(final String name) { if (name.endsWith(".*")) { imprt.setName(ast.newName(Types.tokenizeClassName(name.replaceAll("\\.\\*", "")))); imprt.setOnDemand(true); } else { imprt.setName(ast.newName(Types.tokenizeClassName(name))); } return this; }
if (onDemand) importDeclaration.setOnDemand(true); return importDeclaration;
if (onDemand) importDeclaration.setOnDemand(true); return importDeclaration;
@Override final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == ON_DEMAND_PROPERTY) { if (get) { return isOnDemand(); } else { setOnDemand(value); return false; } } if (property == STATIC_PROPERTY) { if (get) { return isStatic(); } else { setStatic(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); }
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; }
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; }
AST ast = AST.newAST(AST.JLS3); CompilationUnit unit = ast.newCompilationUnit(); PackageDeclaration packageDeclaration = ast.newPackageDeclaration(); packageDeclaration.setName(ast.newSimpleName("example")); unit.setPackage(packageDeclaration); ImportDeclaration importDeclaration = ast.newImportDeclaration(); QualifiedName name = ast.newQualifiedName( ast.newSimpleName("java"), ast.newSimpleName("util")); importDeclaration.setName(name); importDeclaration.setOnDemand(true); unit.imports().add(importDeclaration); TypeDeclaration type = ast.newTypeDeclaration(); type.setInterface(false); type.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); type.setName(ast.newSimpleName("HelloWorld")); // ....