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

Java ReferenceMode类代码示例

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

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



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

示例1: memberReferenceSuffix

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
JCExpression memberReferenceSuffix(int pos1, JCExpression t) {
    checkMethodReferences();
    mode = EXPR;
    List<JCExpression> typeArgs = null;
    if (token.kind == LT) {
        typeArgs = typeArguments(false);
    }
    Name refName;
    ReferenceMode refMode;
    if (token.kind == NEW) {
        refMode = ReferenceMode.NEW;
        refName = names.init;
        nextToken();
    } else {
        refMode = ReferenceMode.INVOKE;
        refName = ident();
    }
    return toP(F.at(t.getStartPosition()).Reference(refMode, refName, t, typeArgs));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:JavacParser.java


示例2: lambda

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
JCLambda lambda() {
    int prevPos = make.pos;
    try {
        make.at(tree);

        //body generation - this can be either a method call or a
        //new instance creation expression, depending on the member reference kind
        VarSymbol rcvr = addParametersReturnReceiver();
        JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE)
                ? expressionInvoke(rcvr)
                : expressionNew();

        JCLambda slam = make.Lambda(params.toList(), expr);
        slam.targets = tree.targets;
        slam.type = tree.type;
        slam.pos = tree.pos;
        return slam;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:LambdaToMethod.java


示例3: matchMemberReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
/**
 * Detect member references that implement an interface that return Object, but resolve to a
 * method that returns Future.
 */
@Override
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
  Description description = super.matchMemberReference(tree, state);
  if (Description.NO_MATCH == description) {
    if (allOf(
            (t, s) -> t.getMode() == ReferenceMode.INVOKE,
            FutureReturnValueIgnored::isObjectReturningMethodReferenceExpression,
            not((t, s) -> isWhitelistedInterfaceType(((JCMemberReference) t).type, s)),
            not((t, s) -> isThrowingFunctionalInterface(s, ((JCMemberReference) t).type)),
            specializedMatcher())
        .matches(tree, state)) {
      return describeMatch(tree);
    }
  }
  return description;
}
 
开发者ID:google,项目名称:error-prone,代码行数:21,代码来源:FutureReturnValueIgnored.java


示例4: matchMemberReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
@Override
public Description matchMemberReference(MemberReferenceTree tree, VisitorState state) {
  if (allOf(
          (t, s) -> t.getMode() == ReferenceMode.INVOKE,
          AbstractReturnValueIgnored::isVoidReturningMethodReferenceExpression,
          // Skip cases where the method we're referencing really does return void. We're only
          // looking for cases where the referenced method does not return void, but it's being
          // used on a void-returning functional interface.
          not((t, s) -> ASTHelpers.isVoidType(ASTHelpers.getSymbol(tree).getReturnType(), s)),
          not((t, s) -> isThrowingFunctionalInterface(s, ((JCMemberReference) t).type)),
          specializedMatcher())
      .matches(tree, state)) {
    return describeMatch(tree);
  }

  return Description.NO_MATCH;
}
 
开发者ID:google,项目名称:error-prone,代码行数:18,代码来源:AbstractReturnValueIgnored.java


示例5: visitReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
@Override
public void visitReference(JCMemberReference tree) {
    printExpr(tree.expr);
    print(cs.spaceAroundMethodReferenceDoubleColon() ? " :: " : "::");
    if (tree.typeargs != null && !tree.typeargs.isEmpty()) {
        print("<");
        printExprs(tree.typeargs);
        print(">");
    }
    if (tree.getMode() == ReferenceMode.INVOKE) print(tree.name);
    else print("new");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:VeryPretty.java


示例6: MemberReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
public MemberReferenceTree MemberReference(ReferenceMode refMode, CharSequence name, ExpressionTree expression, List<? extends ExpressionTree> typeArguments) {
    ListBuffer<JCExpression> targs;
    
    if (typeArguments != null) {
        targs = new ListBuffer<JCExpression>();
        for (ExpressionTree t : typeArguments)
            targs.append((JCExpression)t);
    } else {
        targs = null;
    }
    
    return make.at(NOPOS).Reference(refMode, names.fromString(name.toString()), (JCExpression) expression, targs != null ? targs.toList() : null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TreeFactory.java


示例7: testPrintMemberReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
public void testPrintMemberReference() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = null;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitLiteral(LiteralTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                    return super.visitLiteral(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:LambdaTest.java


示例8: visitReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
public void visitReference(JCMemberReference tree) {
    try {
        printExpr(tree.expr);
        print("::");
        if (tree.typeargs != null) {
            print("<");
            printExprs(tree.typeargs);
            print(">");
        }
        print(tree.getMode() == ReferenceMode.INVOKE ? tree.name : "new");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Pretty.java


示例9: needsConversionToLambda

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
/**
 * Does this reference need to be converted to a lambda
 * (i.e. var args need to be expanded or "super" is used)
 */
final boolean needsConversionToLambda() {
    return interfaceParameterIsIntersectionType() ||
            isSuper ||
            needsVarArgsConversion() ||
            isArrayOp() ||
            isPrivateInOtherClass() ||
            !receiverAccessible() ||
            (tree.getMode() == ReferenceMode.NEW &&
              tree.kind != ReferenceKind.ARRAY_CTOR &&
              (tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:LambdaToMethod.java


示例10: needsConversionToLambda

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
/**
 * Does this reference need to be converted to a lambda
 * (i.e. var args need to be expanded or "super" is used)
 */
final boolean needsConversionToLambda() {
    return interfaceParameterIsIntersectionType() ||
            isSuper ||
            needsVarArgsConversion() ||
            isArrayOp() ||
            isPrivateInOtherClass() ||
            isProtectedInSuperClassOfEnclosingClassInOtherPackage() ||
            !receiverAccessible() ||
            (tree.getMode() == ReferenceMode.NEW &&
              tree.kind != ReferenceKind.ARRAY_CTOR &&
              (tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:LambdaToMethod.java


示例11: visitReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
@Override
public void visitReference(JCMemberReference tree) {
  super.visitReference(tree);
  if (tree.getMode() != ReferenceMode.NEW) {
    return;
  }
  if (memberOfEnclosing(owner, state, tree.expr.type.tsym)) {
    referencesOuter = true;
  }
}
 
开发者ID:google,项目名称:error-prone,代码行数:11,代码来源:CanBeStaticAnalyzer.java


示例12: ReferenceKind

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
private ReferenceKind(ReferenceMode mode, boolean unbound) {
    this.mode = mode;
    this.unbound = unbound;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:JCTree.java


示例13: JCMemberReference

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
    this.mode = mode;
    this.name = name;
    this.expr = expr;
    this.typeargs = typeargs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:JCTree.java


示例14: getMode

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
@Override
public ReferenceMode getMode() { return mode; }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:3,代码来源:JCTree.java


示例15: memberReferenceQualifierResult

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
ResultInfo memberReferenceQualifierResult(JCMemberReference tree) {
    //if this is a constructor reference, the expected kind must be a type
    return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:Attr.java


示例16: memberReferenceQualifierResult

import com.sun.source.tree.MemberReferenceTree.ReferenceMode; //导入依赖的package包/类
ResultInfo memberReferenceQualifierResult(JCMemberReference tree) {
    //if this is a constructor reference, the expected kind must be a type
    return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ?
                          KindSelector.VAL_TYP : KindSelector.TYP,
                          Type.noType);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:Attr.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Accessible类代码示例发布时间:2022-05-22
下一篇:
Java FullWalletRequest类代码示例发布时间: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