本文整理汇总了Java中com.github.javaparser.ast.ImportDeclaration.isAsterisk方法的典型用法代码示例。如果您正苦于以下问题:Java ImportDeclaration.isAsterisk方法的具体用法?Java ImportDeclaration.isAsterisk怎么用?Java ImportDeclaration.isAsterisk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.ImportDeclaration
的用法示例。
在下文中一共展示了ImportDeclaration.isAsterisk方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrelude
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
public String getPrelude() {
for (ImportDeclaration node : nodes) {
try {
if (node.isStatic()) {
if (node.isAsterisk()) {
importStatic(node.getName().toString());
} else {
QualifiedNameExpr fqn = (QualifiedNameExpr) node.getChildrenNodes().get(0);
importMethod(fqn.getQualifier().toString(), fqn.getName());
}
} else if (node.isAsterisk()) {
importPackage(node.getName().toString());
} else {
importClass(node.getName().toString());
}
} catch (ClassNotFoundException | NoSuchMethodException ex) {
LOG.log(Level.WARNING, null, ex);
}
}
return prelude.toString();
}
示例2: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public void visit(final ImportDeclaration n, final Object arg) {
printer.printLn("ImportDeclaration");
printJavaComment(n.getComment(), arg);
printer.print("import ");
if (n.isStatic()) {
printer.print("static ");
}
n.getName().accept(this, arg);
if (n.isAsterisk()) {
printer.print(".*");
}
printer.printLn(";");
printOrphanCommentsEnding(n);
}
示例3: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public JCTree visit(final ImportDeclaration n, final Object arg) {
//ARG0: JCTree qualid
JCTree arg0;
JCExpression packagename = (JCExpression) n.getName().accept(this, arg);
// JavaParser remove asterisk from name. Adding it back;
if (n.isAsterisk()) {
arg0 = new AJCFieldAccess(make.Select(packagename, names.fromString("*")), null);
} else {
arg0 = packagename;
}
//ARG1: boolean importStatic
boolean arg1 = n.isStatic();
return new AJCImport(make.Import(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例4: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public void visit(final ImportDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
if (printer instanceof MemberBuffer) {
if (n.isStatic()) {
((MemberBuffer)printer).addImportStatic(n.getName()
+ (n.isAsterisk() ? ".*" : ""));
} else {
((MemberBuffer)printer).addImport(n.getName()
+ (n.isAsterisk() ? ".*" : ""));
}
} else {
printer.print("import ");
if (n.isStatic()) {
printer.print("static ");
}
n.getName().accept(this, arg);
if (n.isAsterisk()) {
printer.print(".*");
}
printer.println(";");
}
printOrphanCommentsEnding(n);
}
示例5: toImportedType
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
private static Function<? super ImportDeclaration, ? extends String> toImportedType() {
return new Function<ImportDeclaration, String>() {
@Nullable
@Override
public String apply(@Nullable ImportDeclaration input) {
if (input == null) {
return null;
}
NameExpr name = input.getName();
if (input.isStatic() && !input.isAsterisk()) {
name = QualifiedNameExpr.class.cast(name).getQualifier();
}
return name.toString();
}
};
}
示例6: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public void visit(CompilationUnit n, Context arg) {
if (n.getPackageDeclaration().isPresent()) {
String pkg = n.getPackageDeclaration().get().getNameAsString();
arg.pkg = pkg;
arg.wildcardImports.add(pkg.replace('.', '/')+'/'); // TODO: verify ordering
} else {
arg.wildcardImports.add("");
}
arg.wildcardImports.add("java/lang/");
for (ImportDeclaration imp : n.getImports()) {
if (imp.isStatic()) continue;
if (imp.isAsterisk()) {
arg.wildcardImports.add(imp.getNameAsString().replace('.', '/')+'/');
} else {
String name = imp.getNameAsString();
int pos = name.lastIndexOf('.');
if (pos != -1) arg.imports.put(name.substring(pos + 1), name.replace('.', '/'));
}
}
n.getTypes().forEach(p -> p.accept(this, arg));
arg.pkg = null;
arg.imports.clear();
arg.wildcardImports.clear();
}
示例7: convertAndAddImport
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
private static void convertAndAddImport(LinkedHashSet<Import> allImports, List<Node> thisImport) {
boolean isStatic = false;
String importItem = null;
String prefix = "";
String suffix = "";
for (Node n : thisImport) {
if (n instanceof Comment) {
if (importItem == null) {
prefix += n.toString();
} else {
suffix += n.toString();
}
}
if (n instanceof ImportDeclaration) {
ImportDeclaration i = (ImportDeclaration) n;
isStatic = i.isStatic();
importItem = i.getName().asString() + (i.isAsterisk() ? ".*" : "");
}
}
suffix = suffix.trim();
if (!suffix.isEmpty()) {
suffix = " " + suffix;
}
Import imp = new Import(isStatic, importItem, prefix.trim(), suffix);
Iterator<Import> iter = allImports.iterator();
// this de-duplication can probably be made more efficient by doing it all at the end
while (iter.hasNext()) {
Import candidate = iter.next(); // potential duplicate
if (candidate.isDuplicatedBy(imp)) {
iter.remove();
imp = candidate.combineWith(imp);
}
}
allImports.add(imp);
}
示例8: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public Node visit(ImportDeclaration _n, Object _arg) {
NameExpr name = cloneNodes(_n.getName(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
ImportDeclaration r = new ImportDeclaration(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
name, _n.isStatic(), _n.isAsterisk()
);
r.setComment(comment);
return r;
}
示例9: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override public void visit(final ImportDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("import ");
if (n.isStatic()) {
printer.print("static ");
}
n.getName().accept(this, arg);
if (n.isAsterisk()) {
printer.print(".*");
}
printer.printLn(";");
printOrphanCommentsEnding(n);
}
示例10: doCompile
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public UnitCache<PackageElement> doCompile(ImportDeclaration unit) {
TypeMirror type = new EmulType(TypeKind.DECLARED);
Name name = new StringName(unit.getName().toString());
return new UnitCache<PackageElement>(
new EmulImportElement(type, parent, name, name, NestingKind.TOP_LEVEL, unit.isStatic(), unit.isAsterisk())
);
}
示例11: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override public void visit(final ImportDeclaration n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("import ");
if (n.isStatic()) {
printer.print("static ");
}
n.getName().accept(this, arg);
if (n.isAsterisk()) {
printer.print(".*");
}
printer.printLn(";");
printOrphanCommentsEnding(n);
}
示例12: visit
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override
public Node visit(ImportDeclaration _n, Object _arg) {
NameExpr name = cloneNodes(_n.getName(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
ImportDeclaration r = new ImportDeclaration(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
name, _n.isStatic(), _n.isAsterisk()
);
r.setComment(comment);
return copyExtras(_n, r);
}
示例13: doIsEquals
import com.github.javaparser.ast.ImportDeclaration; //导入方法依赖的package包/类
@Override public boolean doIsEquals(ImportDeclaration first, ImportDeclaration second) {
if(!isEqualsUseMerger(first.getName(),second.getName())) return false;
if(first.isStatic() != second.isStatic()) return false;
if(first.isAsterisk() != second.isAsterisk()) return false;
return true;
}