private boolean warnIfDuplicate( AbstractSrcMethod method, SrcClass extendedType, DiagnosticListener<JavaFileObject> errorHandler ) { AbstractSrcMethod duplicate = findMethod( method, extendedType ); if( duplicate == null ) { return false; } ClassSymbols classSymbols = ClassSymbols.instance( getModule() ); Context ctx = JavacPlugin.instance() == null ? classSymbols.getJavacTask_PlainFileMgr().getContext() : JavacPlugin.instance().getContext(); Symbol.ClassSymbol sym = IDynamicJdk.instance().getLoadedClass( ctx, ((SrcClass)method.getOwner()).getName() ); if( sym == null ) { return false; } JavaFileObject file = sym.sourcefile; SrcAnnotationExpression anno = duplicate.getAnnotation( ExtensionMethod.class ); if( anno != null ) { errorHandler.report( new JavacDiagnostic( file.toUri().getScheme() == null ? null : new SourceJavaFileObject( file.toUri() ), Diagnostic.Kind.WARNING, 0, 0, 0, ExtIssueMsg.MSG_EXTENSION_DUPLICATION.get( method.signature(), ((SrcClass)method.getOwner()).getName(), anno.getArgument( ExtensionMethod.extensionClass ).getValue()) ) ); } else { errorHandler.report( new JavacDiagnostic( file.toUri().getScheme() == null ? null : new SourceJavaFileObject( file.toUri() ), Diagnostic.Kind.WARNING, 0, 0, 0, ExtIssueMsg.MSG_EXTENSION_SHADOWS.get( method.signature(), ((SrcClass)method.getOwner()).getName(), extendedType.getName()) ) ); } return true; }
private boolean warnIfDuplicate( AbstractSrcMethod method, SrcClass extendedType, DiagnosticListener<JavaFileObject> errorHandler ) { AbstractSrcMethod duplicate = findMethod( method, extendedType ); if( duplicate == null ) { return false; } ClassSymbols classSymbols = ClassSymbols.instance( getModule() ); Context ctx = JavacPlugin.instance() == null ? classSymbols.getJavacTask_PlainFileMgr().getContext() : JavacPlugin.instance().getContext(); Symbol.ClassSymbol sym = IDynamicJdk.instance().getLoadedClass( ctx, ((SrcClass)method.getOwner()).getName() ); if( sym == null ) { return false; } JavaFileObject file = sym.sourcefile; SrcAnnotationExpression anno = duplicate.getAnnotation( ExtensionMethod.class ); if( anno != null ) { errorHandler.report( new JavacDiagnostic( file.toUri().getScheme() == null ? null : new SourceJavaFileObject( file.toUri() ), Diagnostic.Kind.WARNING, 0, 0, 0, ExtIssueMsg.MSG_EXTENSION_DUPLICATION.get( method.signature(), ((SrcClass)method.getOwner()).getName(), anno.getArgument( ExtensionMethod.extensionClass ).getValue()) ) ); } else { errorHandler.report( new JavacDiagnostic( file.toUri().getScheme() == null ? null : new SourceJavaFileObject( file.toUri() ), Diagnostic.Kind.WARNING, 0, 0, 0, ExtIssueMsg.MSG_EXTENSION_SHADOWS.get( method.signature(), ((SrcClass)method.getOwner()).getName(), extendedType.getName()) ) ); } return true; }