本文整理了Java中com.github.javaparser.ast.CompilationUnit.getPackage()
方法的一些代码示例,展示了CompilationUnit.getPackage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CompilationUnit.getPackage()
方法的具体详情如下:
包路径:com.github.javaparser.ast.CompilationUnit
类名称:CompilationUnit
方法名:getPackage
暂无
代码示例来源:origin: ImmobilienScout24/deadcode4j
@Nonnull
@Override
protected String calculatePrefix(@Nonnull Qualifier<?> topQualifier) {
PackageDeclaration aPackage = Nodes.getCompilationUnit(topQualifier.getNode()).getPackage();
if (aPackage == null) {
return "";
}
return prepend(aPackage.getName(), new StringBuilder("")).append(".").toString();
}
代码示例来源:origin: com.agapsys.libs/scanner-maven-plugin-lib
@Override
public void visit(CompilationUnit n, Object arg) {
currentPackage = n.getPackage() != null ? n.getPackage().getName().toString() : "";
imports = new LinkedList<String>();
for (ImportDeclaration importDec : n.getImports()) {
imports.add(importDec.getName().toString());
}
super.visit(n, arg);
}
代码示例来源:origin: com.agapsys/scanner-maven-plugin-lib
@Override
public void visit(CompilationUnit n, Object arg) {
currentPackage = n.getPackage() != null ? n.getPackage().getName().toString() : "";
imports = new LinkedList<String>();
for (ImportDeclaration importDec : n.getImports()) {
imports.add(importDec.getName().toString());
}
super.visit(n, arg);
}
代码示例来源:origin: org.jooby/jooby-spec
@Override
public String visit(final ClassOrInterfaceDeclaration n, final Object arg) {
StringBuilder name = new StringBuilder();
Node it = n.getParentNode();
while (it instanceof ClassOrInterfaceDeclaration) {
ClassOrInterfaceDeclaration superclass = (ClassOrInterfaceDeclaration) it;
name.append(superclass.getName()).append(".");
it = it.getParentNode();
}
if (it instanceof CompilationUnit) {
if (name.length() == 0) {
name.append(((CompilationUnit) it).getPackage().getName().toString()).append(".");
} else {
name.insert(0, ((CompilationUnit) it).getPackage().getName().toString() + ".");
}
}
name.append(n.getName());
return name.toString();
}
}
代码示例来源:origin: ImmobilienScout24/deadcode4j
if (compilationUnit.getPackage() != null) {
prepend(compilationUnit.getPackage().getName(), buffy);
代码示例来源:origin: beihaifeiwu/dolphin
@Override
public boolean doIsEquals(CompilationUnit first, CompilationUnit second) {
// 检测包声明
if (!isEqualsUseMerger(first.getPackage(), second.getPackage())) return false;
// 检查公共类声明
for (TypeDeclaration outer : first.getTypes()) {
for (TypeDeclaration inner : second.getTypes()) {
if (ModifierSet.isPublic(outer.getModifiers()) && ModifierSet.isPublic(inner.getModifiers())) {
if (outer.getName().equals(inner.getName())) {
return true;
}
}
}
}
return false;
}
代码示例来源:origin: beihaifeiwu/dolphin
@Override
public CompilationUnit doMerge(CompilationUnit first, CompilationUnit second) {
CompilationUnit unit = new CompilationUnit();
unit.setPackage(mergeSingle(first.getPackage(), second.getPackage()));
unit.setImports(mergeCollections(first.getImports(), second.getImports()));
unit.setTypes(mergeCollections(first.getTypes(), second.getTypes()));
return unit;
}
代码示例来源:origin: beihaifeiwu/dolphin
public static String mergeContent(CompilationUnit one, CompilationUnit two) throws Exception {
// 包声明不同,返回null
if (!one.getPackage().equals(two.getPackage())) return null;
CompilationUnit cu = new CompilationUnit();
// add package declaration to the compilation unit
PackageDeclaration pd = new PackageDeclaration();
pd.setName(one.getPackage().getName());
cu.setPackage(pd);
// check and merge file comment;
Comment fileComment = mergeSelective(one.getComment(), two.getComment());
cu.setComment(fileComment);
// check and merge imports
List<ImportDeclaration> ids = mergeListNoDuplicate(one.getImports(), two.getImports());
cu.setImports(ids);
// check and merge Types
List<TypeDeclaration> types = mergeTypes(one.getTypes(), two.getTypes());
cu.setTypes(types);
return cu.toString();
}
内容来源于网络,如有侵权,请联系作者删除!