Java Code Examples for javax.tools.DiagnosticListener#report()
The following examples show how to use
javax.tools.DiagnosticListener#report() .
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: GqlModel.java From manifold with Apache License 2.0 | 6 votes |
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() ) ); } }
Example 2
Source File: JsonModel.java From manifold with Apache License 2.0 | 6 votes |
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() ) ); } }
Example 3
Source File: JavascriptCodeGen.java From manifold with Apache License 2.0 | 6 votes |
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() ) ); } } }
Example 4
Source File: TemplateModel.java From manifold with Apache License 2.0 | 5 votes |
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() ) ); } }
Example 5
Source File: Model.java From manifold with Apache License 2.0 | 5 votes |
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() ) ); } }
Example 6
Source File: ExtCodeGen.java From manifold with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: FavsParser.java From manifold with Apache License 2.0 | 4 votes |
Map<Token, Token> parseFavsForType( Set<IFile> files, String extensionClassFqn, DiagnosticListener<JavaFileObject> errorHandler ) { // Using LinkedHashMap to preserve insertion order, an impl detail currently required by the IJ plugin for rename // refactoring i.e., renaming a json property should result in a source file that differs only in the naming // difference -- there should be no difference in ordering of methods etc. Map<Token, Token> mapFavToValue = new LinkedHashMap<>(); for( IFile file : files ) { Objects.requireNonNull( file ); List<List<Token>> rows = tokenize( file ); Token token = null; for( List<Token> line : rows ) { Iterator<Token> tokens = line.iterator(); 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; } Token fqn = token = tokens.next(); String extensionFqn = Model.makeExtensionClassName( fqn.toString() ); if( extensionFqn.equals( extensionClassFqn ) ) { if( !tokens.hasNext() ) { errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fqn._pos + fqn._value.length()-1, 0, 0, "Expecting a 'favorite' name" ) ); continue; } Token fav = token = tokens.next(); if( !tokens.hasNext() ) { errorHandler.report( new JavacDiagnostic( makeJavaObjectFile( file ), Diagnostic.Kind.ERROR, fav._pos + fav._value.length()-1, 0, 0, "Expecting a value for '" + fav._value + "'" ) ); continue; } Token value = token = tokens.next(); mapFavToValue.put( fav, value ); } } } return mapFavToValue; }