if ((cls.getModifiers().flags & ENUM) != 0) {
boolean printed = false; if (localClass || (getScope().anonymousClasses.contains(newClass.def) && !newClass.def.getModifiers().getFlags().contains(Modifier.STATIC))) { print("this"); if (!newClass.args.isEmpty()) {
if (parent != null) { getScope().innerClass = true; if (!classdecl.getModifiers().getFlags().contains(Modifier.STATIC)) { getScope().innerClassNotStatic = true; if (parent.getTypeParameters() != null) { if (classdecl.getModifiers().getFlags().contains(Modifier.ABSTRACT)) { print("abstract "); } else if (isAnonymousClass() && classdecl.getModifiers().getFlags().contains(Modifier.STATIC)) { JCNewClass newClass = getScope(1).anonymousClassesConstructors .get(getScope(1).anonymousClasses.indexOf(classdecl)); if (!getScope().interfaceScope && classdecl.getModifiers().getFlags().contains(Modifier.ABSTRACT)) { List<MethodSymbol> methods = new ArrayList<>(); for (Type t : implementedInterfaces) {
public void checkFunctionalInterface(JCClassDecl tree, ClassSymbol cs) { Compound functionalType = cs.attribute(syms.functionalInterfaceType.tsym); if (functionalType != null) { try { types.findDescriptorSymbol((TypeSymbol)cs); } catch (Types.FunctionDescriptorLookupError ex) { DiagnosticPosition pos = tree.pos(); for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) { pos = a.pos(); break; } } log.error(pos, "bad.functional.intf.anno.1", ex.getDiagnostic()); } } } }
@Override public Description matchMethod(MethodTree method, VisitorState state) { if (!CAN_BE_A_MULTIBINDS_METHOD.matches(method, state)) { return NO_MATCH; } JCClassDecl enclosingClass = ASTHelpers.findEnclosingNode(state.getPath(), JCClassDecl.class); // Check to see if this is in a Dagger 1 module b/c it doesn't support @Multibinds for (JCAnnotation annotation : enclosingClass.getModifiers().getAnnotations()) { if (ASTHelpers.getSymbol(annotation.getAnnotationType()) .getQualifiedName() .contentEquals("dagger.Module") && HAS_DAGGER_ONE_MODULE_ARGUMENT.matches(annotation, state)) { return NO_MATCH; } } return fixByModifyingMethod(state, enclosingClass, method); }
private SrcClass makeStubFromSource() { List<CompilationUnitTree> trees = new ArrayList<>(); _model.getHost().getJavaParser().parseText( _existingSource, trees, null, null, null ); JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl)trees.get( 0 ).getTypeDecls().get( 0 ); SrcClass srcExtended = new SrcClass( _fqn, classDecl.getKind() == Tree.Kind.CLASS ? SrcClass.Kind.Class : SrcClass.Kind.Interface ) .modifiers( classDecl.getModifiers().getFlags() ); if( classDecl.extending != null ) { srcExtended.superClass( classDecl.extending.toString() ); } for( JCTree.JCExpression iface : classDecl.implementing ) { srcExtended.addInterface( iface.toString() ); } return srcExtended; }
private Description fixByModifyingMethod( VisitorState state, JCClassDecl enclosingClass, MethodTree method) { JCModifiers methodModifiers = ((JCMethodDecl) method).getModifiers(); String replacementModifiersString = createReplacementMethodModifiers(state, methodModifiers); JCModifiers enclosingClassModifiers = enclosingClass.getModifiers(); String enclosingClassReplacementModifiersString = createReplacementClassModifiers(state, enclosingClassModifiers); SuggestedFix.Builder fixBuilder = SuggestedFix.builder() .addImport("dagger.multibindings.Multibinds") .replace(methodModifiers, replacementModifiersString) .replace(method.getBody(), ";"); fixBuilder = (enclosingClassModifiers.pos == -1) ? fixBuilder.prefixWith(enclosingClass, enclosingClassReplacementModifiersString) : fixBuilder.replace(enclosingClassModifiers, enclosingClassReplacementModifiersString); return describeMatch(method, fixBuilder.build()); }
private SrcClass makeStubFromSource() { List<CompilationUnitTree> trees = new ArrayList<>(); _model.getHost().getJavaParser().parseText( _existingSource, trees, null, null, null ); JCTree.JCClassDecl classDecl = (JCTree.JCClassDecl)trees.get( 0 ).getTypeDecls().get( 0 ); SrcClass srcExtended = new SrcClass( _fqn, classDecl.getKind() == Tree.Kind.CLASS ? SrcClass.Kind.Class : SrcClass.Kind.Interface ) .modifiers( classDecl.getModifiers().getFlags() ); if( classDecl.extending != null ) { srcExtended.superClass( classDecl.extending.toString() ); } for( JCTree.JCExpression iface : classDecl.implementing ) { srcExtended.addInterface( iface.toString() ); } return srcExtended; }
private void precompileClasses( JCTree.JCClassDecl tree ) { Map<String, Set<String>> typeNames = new HashMap<>(); for( JCTree.JCAnnotation anno: tree.getModifiers().getAnnotations() ) { if( anno.getAnnotationType().type.toString().equals( Precompile.class.getCanonicalName() ) ) { getTypesToCompile( anno, typeNames ); } } if( !typeNames.isEmpty() ) { precompile( typeNames ); } }
private Set<Object> findDrivers( JCTree.JCClassDecl tree ) { Set<Object> drivers = new HashSet<>(); for( JCTree.JCAnnotation anno: tree.getModifiers().getAnnotations() ) { if( anno.getAnnotationType().type.toString().equals( IncrementalCompile.class.getCanonicalName() ) ) { getIncrementalCompileDrivers( anno, drivers ); } } _tp.addDrivers( drivers ); return _tp.getDrivers(); }
private Set<Object> findDrivers( JCTree.JCClassDecl tree ) { Set<Object> drivers = new HashSet<>(); for( JCTree.JCAnnotation anno: tree.getModifiers().getAnnotations() ) { if( anno.getAnnotationType().type.toString().equals( IncrementalCompile.class.getCanonicalName() ) ) { getIncrementalCompileDrivers( anno, drivers ); } } _tp.addDrivers( drivers ); return _tp.getDrivers(); }
private boolean okToInsertBootstrap( JCTree.JCClassDecl tree ) { return !annotatedWith_NoBootstrap( tree.getModifiers().getAnnotations() ) && !JavacPlugin.instance().isNoBootstrapping() && !skipForOtherReasons( tree ); }
@Override public void visitClassDef( JCTree.JCClassDecl classDef ) { process( classDef.getModifiers(), () -> super.visitClassDef( classDef ) ); }
private boolean isExtensionClass( Tree parent ) { if( parent instanceof JCTree.JCClassDecl ) { return hasAnnotation( ((JCTree.JCClassDecl)parent).getModifiers().getAnnotations(), Extension.class ); } return false; }
private void precompileClasses( JCTree.JCClassDecl tree ) { Map<String, Set<String>> typeNames = new HashMap<>(); for( JCTree.JCAnnotation anno: tree.getModifiers().getAnnotations() ) { if( anno.getAnnotationType().type.toString().equals( Precompile.class.getCanonicalName() ) ) { getTypesToCompile( anno, typeNames ); } } precompile( typeNames ); }
private boolean isEnum(Tree tree) { if (tree instanceof FieldGroupTree) return ((FieldGroupTree) tree).isEnum(); if (tree instanceof VariableTree) return (((JCVariableDecl) tree).getModifiers().flags & Flags.ENUM) != 0; if (tree instanceof ClassTree) return (((JCClassDecl) tree).getModifiers().flags & Flags.ENUM) != 0; return false; }
private boolean isExtensionClass( Tree parent ) { if( parent instanceof JCTree.JCClassDecl ) { return hasAnnotation( ((JCTree.JCClassDecl)parent).getModifiers().getAnnotations(), Extension.class ); } return false; }
int anonymousClassIndex = initAnonymousClass(newClass); print("new ").print(getScope().name + "." + getScope().name + ANONYMOUS_PREFIX + anonymousClassIndex); if (newClass.def.getModifiers().getFlags().contains(Modifier.STATIC)) { printAnonymousClassTypeArgs(newClass);
private Description fixByModifyingMethod( VisitorState state, JCClassDecl enclosingClass, MethodTree method) { JCModifiers methodModifiers = ((JCMethodDecl) method).getModifiers(); String replacementModifiersString = createReplacementMethodModifiers(state, methodModifiers); JCModifiers enclosingClassModifiers = enclosingClass.getModifiers(); String enclosingClassReplacementModifiersString = createReplacementClassModifiers(state, enclosingClassModifiers); SuggestedFix.Builder fixBuilder = SuggestedFix.builder() .addImport("dagger.multibindings.Multibinds") .replace(methodModifiers, replacementModifiersString) .replace(method.getBody(), ";"); fixBuilder = (enclosingClassModifiers.pos == -1) ? fixBuilder.prefixWith(enclosingClass, enclosingClassReplacementModifiersString) : fixBuilder.replace(enclosingClassModifiers, enclosingClassReplacementModifiersString); return describeMatch(method, fixBuilder.build()); }
@Override public Description matchMethod(MethodTree method, VisitorState state) { if (!CAN_BE_A_MULTIBINDS_METHOD.matches(method, state)) { return NO_MATCH; } JCClassDecl enclosingClass = ASTHelpers.findEnclosingNode(state.getPath(), JCClassDecl.class); // Check to see if this is in a Dagger 1 module b/c it doesn't support @Multibinds for (JCAnnotation annotation : enclosingClass.getModifiers().getAnnotations()) { if (ASTHelpers.getSymbol(annotation.getAnnotationType()) .getQualifiedName() .contentEquals("dagger.Module") && HAS_DAGGER_ONE_MODULE_ARGUMENT.matches(annotation, state)) { return NO_MATCH; } } return fixByModifyingMethod(state, enclosingClass, method); }