if (member instanceof JCMethodDecl) { if (((JCMethodDecl) member).sym.isConstructor() && ((JCMethodDecl) member).getModifiers().getFlags().contains(Modifier.PUBLIC)) { if (mainConstructor == null || mainConstructor.getParameters().size() < ((JCMethodDecl) member) .getParameters().size()) { mainConstructor = ((JCMethodDecl) member);
/** Tokenizes as little of the {@code tree} as possible to ensure we grab all the annotations. */ private static ImmutableList<ErrorProneToken> annotationTokens( Tree tree, VisitorState state, int annotationEnd) { int endPos; if (tree instanceof JCMethodDecl) { JCMethodDecl methodTree = (JCMethodDecl) tree; endPos = methodTree.getBody() == null ? state.getEndPosition(methodTree) : methodTree.getBody().getStartPosition(); } else if (tree instanceof JCVariableDecl) { endPos = ((JCVariableDecl) tree).getType().getStartPosition(); } else if (tree instanceof JCClassDecl) { JCClassDecl classTree = (JCClassDecl) tree; endPos = classTree.getMembers().isEmpty() ? state.getEndPosition(classTree) : classTree.getMembers().get(0).getStartPosition(); } else { throw new AssertionError(); } return ErrorProneTokens.getTokens( state.getSourceCode().subSequence(annotationEnd, endPos).toString(), state.context); }
public static JCMethodDecl findFirstMethodDeclaration(JCClassDecl typeDeclaration, String methodName) { return findMethodDeclarations(typeDeclaration).stream() // .filter(methodDecl -> methodDecl.getName().toString().equals(methodName)) // .findFirst().orElse(null); }
JCExpression defaultValue) JCMethodDecl tree = new JCMethodDecl(mods, name, restype,
JCExpression defaultValue) JCMethodDecl tree = new JCMethodDecl(mods, name, restype,
posHint = oldT.restype != null ? oldT.restype.getStartPosition() : oldT.getStartPosition(); } else { posHint = oldT.typarams.iterator().next().getStartPosition(); PositionEstimator est = EstimatorFactory.throwz(oldT.getThrows(), newT.getThrows(), diffContext); localPointer = diffList2(oldT.thrown, newT.thrown, posHint, est); if (oldT.defaultValue != newT.defaultValue) {
MethodSymbol prevMethod = chk.setMethod(m); try { deferredLintHandler.flush(tree.pos()); chk.checkDeprecatedAnnotation(tree.pos(), m); chk.checkHideClashes(tree.pos(), env.enclClass.type, m); } else { chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m); chk.validateAnnotationMethod(tree.pos(), m); log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); if (tree.defaultValue != null) { if ((owner.flags() & ANNOTATION) == 0) log.error(tree.pos(), "default.allowed.in.intf.annotation.member"); log.error(tree.body.pos(), "intf.meth.cant.have.body"); } else { log.error(tree.pos(), "abstract.meth.cant.have.body"); log.error(tree.pos(), "native.meth.cant.have.body"); } else {
MethodSymbol prevMethod = chk.setMethod(m); try { deferredLintHandler.flush(tree.pos()); chk.checkDeprecatedAnnotation(tree.pos(), m); chk.checkHideClashes(tree.pos(), env.enclClass.type, m); } else { chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m); chk.validateAnnotationMethod(tree.pos(), m); log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); if (tree.defaultValue != null) { if ((owner.flags() & ANNOTATION) == 0) log.error(tree.pos(), "default.allowed.in.intf.annotation.member"); log.error(tree.body.pos(), "intf.meth.cant.have.body"); } else { log.error(tree.pos(), "abstract.meth.cant.have.body"); log.error(tree.pos(), "native.meth.cant.have.body"); } else {
for( JCTree.JCVariableDecl var : md.getParameters() )
Lint prevLint = chk.setLint(lint); try { chk.checkDeprecatedAnnotation(tree.pos(), m); chk.validateAnnotationMethod(tree.pos(), m); (tree.mods.flags & (ABSTRACT | NATIVE)) == 0 && !relax) log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); if (tree.defaultValue != null) { if ((owner.flags() & ANNOTATION) == 0) log.error(tree.pos(), "default.allowed.in.intf.annotation.member"); log.error(tree.body.pos(), "intf.meth.cant.have.body"); } else if ((tree.mods.flags & ABSTRACT) != 0) { log.error(tree.pos(), "abstract.meth.cant.have.body"); } else if ((tree.mods.flags & NATIVE) != 0) { log.error(tree.pos(), "native.meth.cant.have.body"); } else {
Lint prevLint = chk.setLint(lint); try { chk.checkDeprecatedAnnotation(tree.pos(), m); chk.validateAnnotationMethod(tree.pos(), m); (tree.mods.flags & (ABSTRACT | NATIVE)) == 0 && !relax) log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); if (tree.defaultValue != null) { if ((owner.flags() & ANNOTATION) == 0) log.error(tree.pos(), "default.allowed.in.intf.annotation.member"); log.error(tree.body.pos(), "intf.meth.cant.have.body"); } else if ((tree.mods.flags & ABSTRACT) != 0) { log.error(tree.pos(), "abstract.meth.cant.have.body"); } else if ((tree.mods.flags & NATIVE) != 0) { log.error(tree.pos(), "native.meth.cant.have.body"); } else {
JCVariableDecl nameParam = make_at(tree.pos()). Param(names.fromString(target.syntheticNameChar() + "enum" + target.syntheticNameChar() + "name"),
utils.makeCall( classType, md.pos(), pos, lockGet, lockType, utils.fromString( "lock" ), List.<JCTree.JCExpression>nil() ) ) ); utils.makeCall( classType, md.pos(), pos, unlockGet, lockType, utils.fromString( "unlock" ), utils.make.Try( md.getBody(), List.<JCTree.JCCatch>nil(), utils.block( 0, unlock ) ) );
String name = md.getName().toString(); JCTree.JCModifiers modifiers = md.getModifiers(); final String methodModifier = parseModifiers(context, modifiers); Range nameRange = Range.create(src, preferredPos, preferredPos + name.length()); if (!name.equals("<init>")) { JCTree returnTypeExpr = md.getReturnType(); if (nonNull(returnTypeExpr)) { Type type = returnTypeExpr.type; for (JCTree.JCVariableDecl vd : md.getParameters()) { String s = vd.toString(); if (s.contains("...")) { List<JCTree.JCExpression> throwsList = md.getThrows(); if (nonNull(throwsList)) { for (JCTree.JCExpression expr : throwsList) { analyzeParsedTree(context, md.getBody()); addMethodNameIndex( src, scope.range.begin.line, scope.range.begin.column, methodName);
for( JCTree.JCVariableDecl param : md.getParameters() ) "Parameter " + param.getName() + " of method " + md.getName() + " must be declared final.", e ); fail = true; if( md.getReturnType() instanceof JCTree.JCPrimitiveTypeTree && JCTree.JCPrimitiveTypeTree.class.cast( md.getReturnType() ).getPrimitiveTypeKind() == TypeKind.VOID ) "Method " + md.getName() + " currently not supported.", e );
List<JCTree.JCVariableDecl> parameters = tree.getParameters(); for( int i = 0; i < parameters.size(); i++ ) long methodModifiers = tree.getModifiers().flags; if( hasAnnotation( param.getModifiers().getAnnotations(), This.class ) ) if( thisAnnoFound || hasAnnotation( tree.getModifiers().getAnnotations(), Extension.class ) ) long methodModifiers = tree.getModifiers().flags; if( !Modifier.isStatic( (int)methodModifiers ) ) _tp.report( tree, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_MUST_BE_STATIC.get( tree.getName() ) ); _tp.report( tree, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_MUST_NOT_BE_PRIVATE.get( tree.getName() ) );