• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ThisExpr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.javaparser.ast.expr.ThisExpr的典型用法代码示例。如果您正苦于以下问题:Java ThisExpr类的具体用法?Java ThisExpr怎么用?Java ThisExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ThisExpr类属于com.github.javaparser.ast.expr包,在下文中一共展示了ThisExpr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public void visit(final ThisExpr n, final Object arg) {
    printer.printLn("ThisExpr");
    printJavaComment(n.getComment(), arg);
    if (n.getClassExpr() != null) {
        n.getClassExpr().accept(this, arg);
        printer.print(".");
    }
    printer.print("this");
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:11,代码来源:ASTDumpVisitor.java


示例2: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public JCTree visit(final ThisExpr n, final Object arg) {
    //ARG0: JCExpression selected
    JCExpression arg0;

    //ARG1: Name selector
    Name arg1 = names.names._this;

    if (n.getClassExpr() == null) {
        return new AJCIdent(make.Ident(arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
    }
    arg0 = (JCExpression) n.getClassExpr().accept(this, arg);

    return new AJCFieldAccess(make.Select(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:16,代码来源:JavaParser2JCTree.java


示例3: getDefaultConstructorBlockStatement

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
/**
 * Generates the contents of the constructor.
 *
 * @param valueString The string representing the field that this will be assigned to
 * @return The constructor block
 */
private BlockStmt getDefaultConstructorBlockStatement(String valueString) {
  BlockStmt block = new BlockStmt();
  AssignExpr assignment = new AssignExpr(new FieldAccessExpr(new ThisExpr(), valueString), new
      NameExpr(valueString), AssignExpr.Operator.assign);
  ASTHelper.addStmt(block, assignment);
  return block;
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:14,代码来源:Enumeration.java


示例4: thisInAnonymousClass

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Test
public void thisInAnonymousClass() throws ParseException {
    CompilationUnit cu = parseSample("ThisInAnonymousClass");
    ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "Bar");

    ThisExpr thisExpression = Navigator.findNodeOfGivenClass(clazz, ThisExpr.class);

    ResolvedType type = JavaParserFacade.get(new ReflectionTypeSolver()).getType(thisExpression);
    assertEquals(true, type.isReferenceType());
    assertEquals(true, type.asReferenceType().getTypeDeclaration() instanceof JavaParserAnonymousClassDeclaration);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:12,代码来源:MethodsResolutionTest.java


示例5: typeParamOnReturnTypeStep1

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Test
public void typeParamOnReturnTypeStep1() throws ParseException {
    CompilationUnit cu = parseSample("TypeParamOnReturnType");
    ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "TypeParamOnReturnType");
    MethodDeclaration method = Navigator.demandMethod(clazz, "nodeEquals");
    ThisExpr thisExpr = Navigator.findNodeOfGivenClass(method, ThisExpr.class);

    ResolvedType type = JavaParserFacade.get(new ReflectionTypeSolver()).getType(thisExpr);

    assertEquals(false, type.isTypeVariable());
    assertEquals("TypeParamOnReturnType", type.describe());
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:13,代码来源:GenericsResolutionTest.java


示例6: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override public Boolean visit(final ThisExpr n1, final Node arg) {
	final ThisExpr n2 = (ThisExpr) arg;

	if (!nodeEquals(n1.getClassExpr(), n2.getClassExpr())) {
		return false;
	}

	return true;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:10,代码来源:EqualsVisitor.java


示例7: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public Node visit(ThisExpr _n, Object _arg) {
	Expression classExpr = cloneNodes(_n.getClassExpr(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	ThisExpr r = new ThisExpr(
			_n.getRange(),
			classExpr
	);
	r.setComment(comment);
	return r;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:13,代码来源:CloneVisitor.java


示例8: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override public Node visit(final ThisExpr n, final A arg) {
	visitComment(n, arg);
	if (n.getClassExpr() != null) {
		n.setClassExpr((Expression) n.getClassExpr().accept(this, arg));
	}
	return n;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:8,代码来源:ModifierVisitorAdapter.java


示例9: solveSymbol

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public SymbolReference<? extends ValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
    if (wrappedNode.getField().toString().equals(name)) {
        if (wrappedNode.getScope() instanceof ThisExpr) {
            Type typeOfThis = JavaParserFacade.get(typeSolver).getTypeOfThisIn(wrappedNode);
            return new SymbolSolver(typeSolver).solveSymbolInType(typeOfThis.asReferenceType().getTypeDeclaration(), name);
        }
    }
    return JavaParserFactory.getContext(getParentNode(wrappedNode), typeSolver).solveSymbol(name, typeSolver);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:11,代码来源:FieldAccessContext.java


示例10: solveSymbol

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public SymbolReference<? extends ResolvedValueDeclaration> solveSymbol(String name, TypeSolver typeSolver) {
    if (wrappedNode.getField().toString().equals(name)) {
        if (wrappedNode.getScope() instanceof ThisExpr) {
            ResolvedType typeOfThis = JavaParserFacade.get(typeSolver).getTypeOfThisIn(wrappedNode);
            return new SymbolSolver(typeSolver).solveSymbolInType(typeOfThis.asReferenceType().getTypeDeclaration(), name);
        }
    }
    return JavaParserFactory.getContext(requireParentNode(wrappedNode), typeSolver).solveSymbol(name, typeSolver);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:11,代码来源:FieldAccessContext.java


示例11: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public void visit(ThisExpr n, Script arg) {
}
 
开发者ID:Nosorog,项目名称:nosorog-core,代码行数:4,代码来源:NoOpVisitor.java


示例12: parseExpression

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
/**
 *
 * @param expression
 *  a github javaparser Expression
 * @param attributes
 *      the list of attributes of the class,
 *      to potentially get a type from the name
 * @param lineNumber
 *      the starting line number of the parse method or constructor
 * @return
 *      an Expression structure
 */
public Expr parseExpression(Expression expression, List<Attribute> attributes, int lineNumber) {
    if (expression instanceof AssignExpr) { // this.bar = "bar";
        AssignExpr assExpr = (AssignExpr) expression;
        return parseExpression(assExpr.getTarget(), attributes, lineNumber);
    } else if (expression instanceof MethodCallExpr) {
        MethodCallExpr mcEx = (MethodCallExpr) expression;
        return parseMethodCallExpression(mcEx, attributes, lineNumber);
    } else if (expression instanceof NameExpr) { // ident
        NameExpr nEx = (NameExpr) expression;
        Ident nameExpr = new Ident(nEx.getName());
        return nameExpr;
    } else if (expression instanceof LiteralExpr) { // basic lit
        return parseLiteralExpr((LiteralExpr) expression);
    } else if (expression instanceof FieldAccessExpr) {
        FieldAccessExpr fieldExpr = (FieldAccessExpr) expression;
        Ident ident = new Ident(ParserUtils.parseTarget(expression.toString()).get("name"));
        AttributeRef attrRef = new AttributeRef(ident);
        return attrRef;
    } else if (expression instanceof ObjectCreationExpr) {
        ObjectCreationExpr objConExpr = (ObjectCreationExpr) expression;
        return parseObjectCreationExpression(objConExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayAccessExpr) {
        ArrayAccessExpr arryExpr = (ArrayAccessExpr) expression;
        return parseArrayAccessExpression(arryExpr);
    } else if (expression instanceof UnaryExpr) {
        UnaryExpr unExpr = (UnaryExpr) expression;
        return parseUnaryExpression(unExpr, attributes, lineNumber);
    } else if (expression instanceof ConditionalExpr) {
        ConditionalExpr condExpr = (ConditionalExpr) expression;
        return parseConditionalExpression(condExpr, attributes, lineNumber);
    } else if (expression instanceof CastExpr) {
        CastExpr castExpr = (CastExpr) expression;
        return parseExpression(castExpr.getExpr(), attributes, lineNumber);
    } else if (expression instanceof BinaryExpr) {
        BinaryExpr binEx = (BinaryExpr) expression;
        return parseBinaryExpression(binEx, attributes, lineNumber);
    } else if (expression instanceof EnclosedExpr) {
        EnclosedExpr enclosedExpr = (EnclosedExpr) expression;
        return parseExpression(enclosedExpr.getInner(), attributes, lineNumber);
    } else if (expression instanceof InstanceOfExpr) {
        InstanceOfExpr intExpr = (InstanceOfExpr) expression;
        return parseInstanceOfExpression(intExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayCreationExpr) {
        ArrayCreationExpr arryCreaExpr = (ArrayCreationExpr) expression;
        return parseArrayCreationExpression(arryCreaExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayInitializerExpr) {
        ArrayInitializerExpr arryInEx = (ArrayInitializerExpr) expression;
        return parseArrayInitializerExpression(arryInEx, attributes, lineNumber);
    } else if (expression instanceof ThisExpr) {
        return new Ident("this");
    } else if (expression instanceof SuperExpr) {
        return new Ident("super");
    } else if (expression instanceof ClassExpr) {
        return new Ident(expression.toString());
    } else if (expression instanceof VariableDeclarationExpr) { // int foo = 42;
        // should be parsed by parseVariableDeclarationExpression()
        Log.e(TAG, "Unreachable case :: expression : ".concat(expression.toString()));
        return null;
    } else {
        Log.e(TAG, "The type of expression '".concat(expression.getClass().toString()).concat("' is not managed by the parser"));
        return null;
    }
}
 
开发者ID:DevMine,项目名称:parsers,代码行数:76,代码来源:Parser.java


示例13: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override public Node visit(final ThisExpr n, final A arg) {
	if (n.getClassExpr() != null) {
		n.setClassExpr((Expression) n.getClassExpr().accept(this, arg));
	}
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:7,代码来源:ModifierVisitorAdapter.java


示例14: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override public void visit(final ThisExpr n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getClassExpr() != null) {
		n.getClassExpr().accept(this, arg);
	}
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:7,代码来源:VoidVisitorAdapter.java


示例15: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public void visit(final ThisExpr n, final Context ctx) {
  visitNode(n, ctx);
  super.visit(n, ctx);

}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:7,代码来源:LocalVariableCollector.java


示例16: visit

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override
public void visit(ThisExpr n, Void arg) {
    out.println("ThisExpr: " + (extended ? n : n));
    super.visit(n, arg);
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:6,代码来源:TraceVisitor.java


示例17: doMerge

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
@Override public ThisExpr doMerge(ThisExpr first, ThisExpr second) {
  ThisExpr te = new ThisExpr();

  te.setClassExpr(mergeSingle(first.getClassExpr(),second.getClassExpr()));

  return te;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:8,代码来源:ThisExprMerger.java


示例18: fieldUpdaterLazySet

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
/**
 * Generates something like
 * <code>P_INDEX_UPDATER.lazySet(this, newValue)</code>
 * 
 * @param fieldUpdaterFieldName
 * @param newValueName
 * @return
 */
private static BlockStmt fieldUpdaterLazySet(String fieldUpdaterFieldName, String newValueName) {
    BlockStmt body = new BlockStmt();
    body.addStatement(new ExpressionStmt(
            methodCallExpr(fieldUpdaterFieldName, "lazySet", new ThisExpr(), new NameExpr(newValueName))));
    return body;
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:15,代码来源:JavaParsingAtomicArrayQueueGenerator.java


示例19: fieldUpdaterCompareAndSet

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
/**
 * Generates something like
 * <code>return P_INDEX_UPDATER.compareAndSet(this, expectedValue, newValue)</code>
 * 
 * @param fieldUpdaterFieldName
 * @param expectedValueName
 * @param newValueName
 * @return
 */
private static BlockStmt fieldUpdaterCompareAndSet(String fieldUpdaterFieldName, String expectedValueName,
        String newValueName) {
    BlockStmt body = new BlockStmt();
    body.addStatement(new ReturnStmt(methodCallExpr(fieldUpdaterFieldName, "compareAndSet", new ThisExpr(),
            new NameExpr(expectedValueName), new NameExpr(newValueName))));
    return body;
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:17,代码来源:JavaParsingAtomicArrayQueueGenerator.java


示例20: fieldUpdaterGetAndSet

import com.github.javaparser.ast.expr.ThisExpr; //导入依赖的package包/类
/**
 * Generates something like
 * <code>return P_INDEX_UPDATER.getAndSet(this, newValue)</code>
 * 
 * @param fieldUpdaterFieldName
 * @param newValueName
 * @return
 */
private static BlockStmt fieldUpdaterGetAndSet(String fieldUpdaterFieldName, String newValueName) {
    BlockStmt body = new BlockStmt();
    body.addStatement(new ReturnStmt(
            methodCallExpr(fieldUpdaterFieldName, "getAndSet", new ThisExpr(), new NameExpr(newValueName))));
    return body;
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:15,代码来源:JavaParsingAtomicLinkedQueueGenerator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KeyProvider类代码示例发布时间:2022-05-22
下一篇:
Java DeserializerProvider类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap