本文整理汇总了Java中com.github.javaparser.ast.expr.QualifiedNameExpr类的典型用法代码示例。如果您正苦于以下问题:Java QualifiedNameExpr类的具体用法?Java QualifiedNameExpr怎么用?Java QualifiedNameExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QualifiedNameExpr类属于com.github.javaparser.ast.expr包,在下文中一共展示了QualifiedNameExpr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPrelude
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的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.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public void visit(final QualifiedNameExpr n, final Object arg) {
printer.printLn("QualifiedNameExpr");
printJavaComment(n.getComment(), arg);
n.getQualifier().accept(this, arg);
printer.print(".");
printer.print(n.getName());
printOrphanCommentsEnding(n);
}
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:11,代码来源:ASTDumpVisitor.java
示例3: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public JCTree visit(final QualifiedNameExpr n, final Object arg) {
//ARG0: JCExpression selected
JCExpression arg0 = (JCExpression) n.getQualifier().accept(this, arg);
//ARG1: Name selector
Name arg1 = names.fromString(n.getName());
return new AJCFieldAccess(make.Select(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:11,代码来源:JavaParser2JCTree.java
示例4: asQualifiedNameExpr
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public NameExpr asQualifiedNameExpr(NameExpr nameExpr) {
if (nameExpr instanceof QualifiedNameExpr) {
return nameExpr;
} else return importDeclarations.stream()
.filter(i -> i.getName().getName().equals(nameExpr.getName()))
.map(i -> new QualifiedNameExpr(((QualifiedNameExpr) i.getName()).getQualifier(), nameExpr.getName()))
.findFirst()
.map(NameExpr.class::cast)
.orElse(nameExpr);
}
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:12,代码来源:SpringWebValidatorMojo.java
示例5: toQualifiedNameString
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
public static String toQualifiedNameString(final NameExpr nameExpr) {
NameExpr pointer = nameExpr;
final LinkedList<NameExpr> elements = new LinkedList<>();
do {
elements.push(pointer);
if (pointer instanceof QualifiedNameExpr) {
pointer = ((QualifiedNameExpr) pointer).getQualifier();
} else {
pointer = null;
}
} while (pointer != null);
return elements.stream().map(NameExpr::getName).collect(joining("."));
}
开发者ID:hubrick,项目名称:raml-maven-plugin,代码行数:16,代码来源:ASTUtils.java
示例6: doMerge
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override public QualifiedNameExpr doMerge(QualifiedNameExpr first, QualifiedNameExpr second) {
QualifiedNameExpr qne = new QualifiedNameExpr();
qne.setName(first.getName());
qne.setQualifier(mergeSingle(first.getQualifier(),second.getQualifier()));
return qne;
}
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:9,代码来源:QualifiedNameExprMerger.java
示例7: apply
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
public String apply(Node node) {
if (node instanceof NamedNode) {
String name = ((NamedNode)node).getName();
Node current = node;
while (!(current instanceof CompilationUnit)) {
current = current.getParentNode();
}
CompilationUnit compilationUnit = (CompilationUnit) current;
for (ImportDeclaration importDecl : compilationUnit.getImports()) {
NameExpr importExpr = importDecl.getName();
if (importExpr instanceof QualifiedNameExpr) {
QualifiedNameExpr qualifiedNameExpr = (QualifiedNameExpr) importExpr;
String className = qualifiedNameExpr.getName();
if (name.equals(className)) {
return qualifiedNameExpr.getQualifier().toString();
}
} else if (importDecl.getName().getName().endsWith(SEPARATOR + name)) {
String importName = importDecl.getName().getName();
return importName.substring(0, importName.length() - name.length() -1);
}
}
try {
Class.forName(JAVA_LANG + "." + name);
return JAVA_LANG;
} catch (ClassNotFoundException ex) {
return compilationUnit.getPackage().getPackageName();
}
}
return null;
}
开发者ID:sundrio,项目名称:sundrio,代码行数:34,代码来源:Sources.java
示例8: getClassOrInterfaceType
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
/**
* Converts the indicated {@link NameExpr} into a
* {@link ClassOrInterfaceType}.
* <p>
* Note that no effort is made to manage imports etc.
*
* @param nameExpr to convert (required)
* @return the corresponding {@link ClassOrInterfaceType} (never null)
*/
public static ClassOrInterfaceType getClassOrInterfaceType(
final NameExpr nameExpr) {
Validate.notNull(nameExpr, "Java type required");
if (nameExpr instanceof QualifiedNameExpr) {
final QualifiedNameExpr qne = (QualifiedNameExpr) nameExpr;
if (StringUtils.isNotBlank(qne.getQualifier().getName())) {
return new ClassOrInterfaceType(qne.getQualifier().getName()
+ "." + qne.getName());
}
return new ClassOrInterfaceType(qne.getName());
}
return new ClassOrInterfaceType(nameExpr.getName());
}
开发者ID:BenDol,项目名称:Databind,代码行数:23,代码来源:JavaParserUtils.java
示例9: getImportDeclarationFor
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
/**
* Looks up the import declaration applicable to the presented name
* expression.
* <p>
* If a fully-qualified name is passed to this method, the corresponding
* import will be evaluated for a complete match. If a simple name is passed
* to this method, the corresponding import will be evaluated if its simple
* name matches. This therefore reflects the normal Java semantics for using
* simple type names that have been imported.
*
* @param compilationUnitService the types in the compilation unit
* (required)
* @param nameExpr the expression to locate an import for (which would
* generally be a {@link NameExpr} and thus not have a package
* identifier; required)
* @return the relevant import, or null if there is no import for the
* expression
*/
private static ImportDeclaration getImportDeclarationFor(
final CompilationUnitService compilationUnitService,
final NameExpr nameExpr) {
Validate.notNull(compilationUnitService,
"Compilation unit services required");
Validate.notNull(nameExpr, "Name expression required");
final List<ImportDeclaration> imports = compilationUnitService
.getImports();
for (final ImportDeclaration candidate : imports) {
final NameExpr candidateNameExpr = candidate.getName();
if (!candidate.toString().contains("*")) {
if(!(candidateNameExpr instanceof QualifiedNameExpr)) {
System.out.println("Expected import '" + candidate
+ "' to use a fully-qualified type name");
}
}
if (nameExpr instanceof QualifiedNameExpr) {
// User is asking for a fully-qualified name; let's see if there
// is a full match
if (isEqual(nameExpr, candidateNameExpr)) {
return candidate;
}
}
else {
// User is not asking for a fully-qualified name, so let's do a
// simple name comparison that discards the import's
// qualified-name package
if (candidateNameExpr.getName().equals(nameExpr.getName())) {
return candidate;
}
}
}
return null;
}
开发者ID:BenDol,项目名称:Databind,代码行数:55,代码来源:JavaParserUtils.java
示例10: getNameExpr
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
/**
* Converts the presented class name into a name expression (either a
* {@link NameExpr} or {@link QualifiedNameExpr} depending on whether a
* package was presented).
*
* @param className to convert (required; can be fully qualified or simple
* name only)
* @return a compatible expression (never returns null)
*/
public static NameExpr getNameExpr(final String className) {
Validate.notEmpty(className, "Class name required");
if (className.contains(".")) {
final int offset = className.lastIndexOf(".");
final String packageName = className.substring(0, offset);
final String typeName = className.substring(offset + 1);
return new QualifiedNameExpr(new NameExpr(packageName), typeName);
}
return new NameExpr(className);
}
开发者ID:BenDol,项目名称:Databind,代码行数:20,代码来源:JavaParserUtils.java
示例11: getImportDeclarationFor
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
/**
* Looks up the import declaration applicable to the presented name
* expression.
* <p>
* If a fully-qualified name is passed to this method, the corresponding
* import will be evaluated for a complete match. If a simple name is passed
* to this method, the corresponding import will be evaluated if its simple
* name matches. This therefore reflects the normal Java semantics for using
* simple type names that have been imported.
*
* @param compilationUnit the types in the compilation unit
* (required)
* @param nameExpr the expression to locate an import for (which would
* generally be a {@link NameExpr} and thus not have a package
* identifier; required)
* @return the relevant import, or null if there is no import for the
* expression
*/
public static ImportDeclaration getImportDeclarationFor(
final CompilationUnit compilationUnit,
final NameExpr nameExpr) {
Validate.notNull(compilationUnit,
"Compilation unit services required");
Validate.notNull(nameExpr, "Name expression required");
final List<ImportDeclaration> imports = compilationUnit
.getImports();
for (final ImportDeclaration candidate : imports) {
final NameExpr candidateNameExpr = candidate.getName();
if (!candidate.toString().contains("*")) {
if(!(candidateNameExpr instanceof QualifiedNameExpr)) {
System.out.println("Expected import '" + candidate
+ "' to use a fully-qualified type name");
}
}
if (nameExpr instanceof QualifiedNameExpr) {
// User is asking for a fully-qualified name; let's see if there
// is a full match
if (NameUtil.isEqual(nameExpr, candidateNameExpr)) {
return candidate;
}
}
else {
// User is not asking for a fully-qualified name, so let's do a
// simple name comparison that discards the import's
// qualified-name package
if (candidateNameExpr.getName().equals(nameExpr.getName())) {
return candidate;
}
}
}
return null;
}
开发者ID:BenDol,项目名称:Databind,代码行数:55,代码来源:TypeUtil.java
示例12: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override public Boolean visit(final QualifiedNameExpr n1, final Node arg) {
final QualifiedNameExpr n2 = (QualifiedNameExpr) arg;
if (!nodeEquals(n1.getQualifier(), n2.getQualifier())) {
return false;
}
if (!objEquals(n1.getName(), n2.getName())) {
return false;
}
return true;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:14,代码来源:EqualsVisitor.java
示例13: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public Node visit(QualifiedNameExpr _n, Object _arg) {
NameExpr scope = cloneNodes(_n.getQualifier(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
QualifiedNameExpr r = new QualifiedNameExpr(
_n.getRange(),
scope, _n.getName()
);
r.setComment(comment);
return r;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:13,代码来源:CloneVisitor.java
示例14: prepend
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Nonnull
public static StringBuilder prepend(@Nonnull NameExpr nameExpr, @Nonnull StringBuilder buffy) {
for (; ; ) {
prependSeparatorIfNecessary('.', buffy).insert(0, nameExpr.getName());
if (!QualifiedNameExpr.class.isInstance(nameExpr)) {
return buffy;
}
nameExpr = QualifiedNameExpr.class.cast(nameExpr).getQualifier();
}
}
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:11,代码来源:Nodes.java
示例15: prependsQualifiedNameExpression
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Test
public void prependsQualifiedNameExpression() {
QualifiedNameExpr qualifiedNameExpr =
new QualifiedNameExpr(new QualifiedNameExpr(new NameExpr("de"), "is24"), "foo");
StringBuilder buffy = Nodes.prepend(qualifiedNameExpr, new StringBuilder("Bar"));
assertThat(buffy.toString(), is("de.is24.foo.Bar"));
}
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:9,代码来源:A_Nodes.java
示例16: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public void visit(QualifiedNameExpr n, Script arg) {
}
开发者ID:Nosorog,项目名称:nosorog-core,代码行数:4,代码来源:NoOpVisitor.java
示例17: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override public Node visit(final QualifiedNameExpr n, final A arg) {
n.setQualifier((NameExpr) n.getQualifier().accept(this, arg));
return n;
}
开发者ID:plum-umd,项目名称:java-sketch,代码行数:5,代码来源:ModifierVisitorAdapter.java
示例18: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override public void visit(final QualifiedNameExpr n, final A arg) {
visitComment(n.getComment(), arg);
n.getQualifier().accept(this, arg);
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:5,代码来源:VoidVisitorAdapter.java
示例19: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override public Node visit(final QualifiedNameExpr n, final A arg) {
visitComment(n, arg);
n.setQualifier((NameExpr) n.getQualifier().accept(this, arg));
return n;
}
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:6,代码来源:ModifierVisitorAdapter.java
示例20: visit
import com.github.javaparser.ast.expr.QualifiedNameExpr; //导入依赖的package包/类
@Override
public void visit(final QualifiedNameExpr n, final Context ctx) {
visitNode(n, ctx);
super.visit(n, ctx);
}
开发者ID:jooby-project,项目名称:jooby,代码行数:7,代码来源:LocalVariableCollector.java
注:本文中的com.github.javaparser.ast.expr.QualifiedNameExpr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论