@Override public Import setStatic(final boolean value) { imprt.setStatic(value); return this; }
@Override public Import setStatic(final boolean value) { imprt.setStatic(value); return this; }
importDeclaration.setStatic(Flags.isStatic(this.flags));
private void addImport(AST ast, ASTRewrite rewriter, CompilationUnit astRoot, String imp, boolean isStatic) { ListRewrite lr = rewriter.getListRewrite(astRoot, CompilationUnit.IMPORTS_PROPERTY); ImportDeclaration id = ast.newImportDeclaration(); id.setStatic(isStatic); id.setName(ast.newName(imp)); lr.insertFirst(id, null); }
/** * Return whether the specified import was added without a collision. */ // TODO handle collisions (e.g. java.util.Date vs. java.sql.Date) protected void addImportTo(CompilationUnit astRoot, String importName, boolean static_) { List<ImportDeclaration> imports = this.imports(astRoot); if (this.importsInclude(imports, importName, static_)) { return; } AST ast = astRoot.getAST(); ImportDeclaration import_ = ast.newImportDeclaration(); import_.setName(ast.newName(importName)); import_.setStatic(static_); imports.add(import_); }
@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; }
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; }
public ASTRewrite createRewriter(CompilationUnit astRoot, AST ast) { final ASTRewrite result = ASTRewrite.create(astRoot.getAST()); TestNGVisitor visitor = new TestNGVisitor(); astRoot.accept(visitor); // // Add a static import for this method // ListRewrite lr = result.getListRewrite(astRoot, CompilationUnit.IMPORTS_PROPERTY); ImportDeclaration id = ast.newImportDeclaration(); id.setStatic(true); id.setName(ast.newName("org.testng.AssertJUnit." + m_assert)); lr.insertFirst(id, null); 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; }
@SuppressWarnings("unchecked") @Test public void test_Existing_Static_Imports2() { AST ast = AST.newAST(AST.JLS4); CompilationUnit cu = ast.newCompilationUnit(); PackageDeclaration packageDeclaration = ast.newPackageDeclaration(); packageDeclaration.setName(ast.newName("org.kissmda.test.junit")); cu.setPackage(packageDeclaration); ImportDeclaration importDeclaration = ast.newImportDeclaration(); importDeclaration .setName(ast.newName("org.junit.Assert.assertNotNull")); importDeclaration.setStatic(true); cu.imports().add(importDeclaration); logger.info(cu.toString()); new ImportPacker(cu).pack(); logger.info(cu.toString()); assertEquals("package org.kissmda.test.junit;\n" // + "import static org.junit.Assert.assertNotNull;", cu .toString().trim()); }