com.sun.source.tree.MemberReferenceTree.ReferenceMode Java Examples
The following examples show how to use
com.sun.source.tree.MemberReferenceTree.ReferenceMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavacParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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)); }
Example #2
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } }
Example #3
Source File: JavacParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
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)); }
Example #4
Source File: LambdaToMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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); } }
Example #5
Source File: JavacParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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)); }
Example #6
Source File: JavacParser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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)); }
Example #7
Source File: JavacParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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)); }
Example #8
Source File: LambdaToMethod.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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); } }
Example #9
Source File: LambdaToMethod.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #10
Source File: JavacParser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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)); }
Example #11
Source File: JavacParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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)); }
Example #12
Source File: JavacParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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)); }
Example #13
Source File: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #14
Source File: LambdaToMethod.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); } }
Example #15
Source File: JavacParser.java From hottub with GNU General Public License v2.0 | 6 votes |
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)); }
Example #16
Source File: LambdaToMethod.java From hottub with GNU General Public License v2.0 | 6 votes |
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); } }
Example #17
Source File: LambdaToMethod.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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())); }
Example #18
Source File: Pretty.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #19
Source File: Pretty.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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); } }
Example #20
Source File: LambdaToMethod.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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())); }
Example #21
Source File: LambdaToMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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())); }
Example #22
Source File: LambdaTest.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example #23
Source File: LambdaTest.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example #24
Source File: Pretty.java From hottub with GNU General Public License v2.0 | 5 votes |
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); } }
Example #25
Source File: TreeFactory.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example #26
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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())); }
Example #27
Source File: VeryPretty.java From netbeans with Apache License 2.0 | 5 votes |
@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"); }
Example #28
Source File: Pretty.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); } }
Example #29
Source File: LambdaToMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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())); }
Example #30
Source File: Pretty.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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); } }