public void reportInfo( String msg ) { report( (Diagnostic<? extends T>)new JavacDiagnostic( null, Diagnostic.Kind.NOTE, 0, 0, 0, msg ) ); }
public void reportError( String msg ) { report( (Diagnostic<? extends T>)new JavacDiagnostic( null, Diagnostic.Kind.ERROR, 0, 0, 0, msg ) ); }
public void reportWarning( String msg ) { report( (Diagnostic<? extends T>)new JavacDiagnostic( null, Diagnostic.Kind.WARNING, 0, 0, 0, msg ) ); }
private void deriveAdditionalSourcePath( List<String> inputFiles, Set<String> sourcePath ) { outer: for( String inputFile : inputFiles ) { for( String sp : sourcePath ) { if( inputFile.startsWith( sp + File.separatorChar ) ) { continue outer; } } String pkg = extractPackageName( inputFile ); if( pkg != null ) { int iDot = inputFile.lastIndexOf( '.' ); String ext = iDot > 0 ? inputFile.substring( iDot ) : ""; String fqn = pkg + '.' + new File( inputFile ).getName(); fqn = fqn.substring( 0, fqn.length() - ext.length() ); String path = derivePath( fqn, inputFile ); sourcePath.add( path ); } else { //noinspection unchecked getIssueReporter().report( new JavacDiagnostic( null, Diagnostic.Kind.WARNING, 0, 0, 0, IssueMsg.MSG_COULD_NOT_FIND_TYPE_FOR_FILE.get( inputFile ) ) ); } } }
if( !tokens.hasNext() ) errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, token == null ? 0 : token._pos, 0, 0, "Expecting a qualified type name" ) ); continue; errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fqn._pos + fqn._value.length()-1, 0, 0, "Expecting a 'favorite' name" ) ); continue; errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fav._pos + fav._value.length()-1, 0, 0, "Expecting a value for '" + fav._value + "'" ) ); continue;
if( !tokens.hasNext() ) errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, token == null ? 0 : token._pos, 0, 0, "Expecting a qualified type name" ) ); continue; errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fqn._pos + fqn._value.length()-1, 0, 0, "Expecting a 'favorite' name" ) ); continue; errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fav._pos + fav._value.length()-1, 0, 0, "Expecting a value for '" + fav._value + "'" ) ); continue;
public void report( JCTree tree, Diagnostic.Kind kind, String msg ) { IssueReporter<JavaFileObject> reporter = new IssueReporter<>( _javacTask::getContext ); JavaFileObject file = getFile( tree ); reporter.report( new JavacDiagnostic( file, kind, tree.getStartPosition(), 0, 0, msg ) ); }
errorHandler.report( new JavacDiagnostic( file, Diagnostic.Kind.ERROR, 0, 1, 1, "The type, " + fqn + ", has conflicting type manifolds:\n" + "'" + found.getClass().getName() + "' and '" + sp.getClass().getName() + "'.\n" +
void report( DiagnosticListener<JavaFileObject> errorHandler ) { if( errorHandler == null ) { return; } List<IIssue> issues = getIssues(); if( issues.isEmpty() ) { return; } JavaFileObject file = new SourceJavaFileObject( getFile().toURI() ); for( IIssue issue : issues ) { Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING; errorHandler.report( new JavacDiagnostic( file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage() ) ); } }
getIssueReporter().report( new JavacDiagnostic( null, Diagnostic.Kind.WARNING, 0, 0, 0, IssueMsg.MSG_COULD_NOT_FIND_TYPE_FOR_FILE.get( inputFile ) ) );
void report( DiagnosticListener<JavaFileObject> errorHandler ) { if( _issues == null || errorHandler == null ) { return; } JavaFileObject file = new SourceJavaFileObject( getFile().toURI() ); for( IIssue issue : _issues.getIssues() ) { Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING; errorHandler.report( new JavacDiagnostic( file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage() ) ); } }
void report( DiagnosticListener errorHandler ) { if( _issues.isEmpty() || errorHandler == null ) { return; } JavaFileObject file = new SourceJavaFileObject( getFile().toURI() ); for( IIssue issue: _issues.getIssues() ) { Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING; errorHandler.report( new JavacDiagnostic( file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage() ) ); } }
void report( DiagnosticListener errorHandler ) { if( _issues.isEmpty() || errorHandler == null ) { return; } JavaFileObject file = new SourceJavaFileObject( getFile().toURI() ); for( IIssue issue: _issues.getIssues() ) { Diagnostic.Kind kind = issue.getKind() == IIssue.Kind.Error ? Diagnostic.Kind.ERROR : Diagnostic.Kind.WARNING; errorHandler.report( new JavacDiagnostic( file, kind, issue.getStartOffset(), issue.getLine(), issue.getColumn(), issue.getMessage() ) ); } }
private void reportErrors( DiagnosticListener<JavaFileObject> errorHandler, ProgramNode programNode ) { if( programNode.errorCount() > 0 ) { JavaFileObject file; try { file = new SourceJavaFileObject( _file.toURI() ); } catch( Exception e ) { file = null; } for( ParseError error : programNode.getErrorList() ) { Token token = error.getToken(); errorHandler.report( new JavacDiagnostic( file, Diagnostic.Kind.ERROR, token.getOffset(), token.getLineNumber(), token.getCol(), error.getMessage() ) ); } } }
private void reportErrors( DiagnosticListener<JavaFileObject> errorHandler, ProgramNode programNode ) { if( programNode.errorCount() > 0 ) { JavaFileObject file; try { file = new SourceJavaFileObject( _file.toURI() ); } catch( Exception e ) { file = null; } for( ParseError error : programNode.getErrorList() ) { Token token = error.getToken(); errorHandler.report( new JavacDiagnostic( file, Diagnostic.Kind.ERROR, token.getOffset(), token.getLineNumber(), token.getCol(), error.getMessage() ) ); } } }
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; }