当前位置: 首页>>代码示例>>Java>>正文


Java ImportDeclaration.isAsterisk方法代码示例

本文整理汇总了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();

    }
 
开发者ID:Nosorog,项目名称:nosorog-core,代码行数:27,代码来源:Importer.java

示例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);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:17,代码来源:ASTDumpVisitor.java

示例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));
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:19,代码来源:JavaParser2JCTree.java

示例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);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:26,代码来源:DumpVisitor.java

示例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();
        }
    };
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:17,代码来源:ReferenceToConstantsAnalyzer.java

示例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();
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:32,代码来源:SrcRemapper.java

示例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);
}
 
开发者ID:revelc,项目名称:impsort-maven-plugin,代码行数:36,代码来源:ImpSort.java

示例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;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:13,代码来源:CloneVisitor.java

示例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);
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:15,代码来源:DumpVisitor.java

示例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())
    );
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:10,代码来源:NodeToImportCompiler.java

示例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);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:15,代码来源:DumpVisitor.java

示例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);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:13,代码来源:CloneVisitor.java

示例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;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:7,代码来源:ImportDeclarationMerger.java


注:本文中的com.github.javaparser.ast.ImportDeclaration.isAsterisk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。