com.sun.tools.javac.util.DiagnosticSource Java Examples
The following examples show how to use
com.sun.tools.javac.util.DiagnosticSource.
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: DocCommentParser.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #2
Source File: DocCommentParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #3
Source File: DocCommentParser.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #4
Source File: DocCommentParser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #5
Source File: DocCommentParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #6
Source File: DocCommentParser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #7
Source File: Analyzer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
void doAnalysis(RewritingContext rewriting) { DiagnosticSource prevSource = log.currentSource(); LocalCacheContext localCacheContext = argumentAttr.withLocalCacheContext(); try { log.useSource(rewriting.env.toplevel.getSourceFile()); JCStatement treeToAnalyze = (JCStatement)rewriting.originalTree; if (rewriting.env.info.scope.owner.kind == Kind.TYP) { //add a block to hoist potential dangling variable declarations treeToAnalyze = make.Block(Flags.SYNTHETIC, List.of((JCStatement)rewriting.originalTree)); } //TODO: to further refine the analysis, try all rewriting combinations deferredAttr.attribSpeculative(treeToAnalyze, rewriting.env, attr.statInfo, new TreeRewriter(rewriting), t -> rewriting.diagHandler(), argumentAttr.withLocalCacheContext()); rewriting.analyzer.process(rewriting.oldTree, rewriting.replacement, rewriting.erroneous); } catch (Throwable ex) { Assert.error("Analyzer error when processing: " + rewriting.originalTree); } finally { log.useSource(prevSource.getFile()); localCacheContext.leave(); } }
Example #8
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkSymbol(DiagnosticPosition pos, Symbol sym) { if (sym != null && sym.kind == TYP) { Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym); if (classEnv != null) { DiagnosticSource prevSource = log.currentSource(); try { log.useSource(classEnv.toplevel.sourcefile); scan(classEnv.tree); } finally { log.useSource(prevSource.getFile()); } } else if (sym.kind == TYP) { checkClass(pos, sym, List.nil()); } } else { //not completed yet partialCheck = true; } }
Example #9
Source File: DocCommentParser.java From hottub with GNU General Public License v2.0 | 6 votes |
DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale; Options options = fac.options; boolean useBreakIterator = options.isSet("breakIterator"); if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) sentenceBreaker = BreakIterator.getSentenceInstance(locale); initTagParsers(); }
Example #10
Source File: DocCommentParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; initTagParsers(); }
Example #11
Source File: ErrorBuilder.java From NullAway with MIT License | 5 votes |
static int getLineNumForElement(Element uninitField, VisitorState state) { Tree tree = getTreesInstance(state).getTree(uninitField); if (tree == null) throw new RuntimeException( "When getting the line number for uninitialized field, can't get the tree from the element."); DiagnosticPosition position = (DiagnosticPosition) tree; // Expect Tree to be JCTree and thus implement DiagnosticPosition TreePath path = state.getPath(); JCCompilationUnit compilation = (JCCompilationUnit) path.getCompilationUnit(); JavaFileObject file = compilation.getSourceFile(); DiagnosticSource source = new DiagnosticSource(file, null); return source.getLineNumber(position.getStartPosition()); }
Example #12
Source File: ManLog_8.java From manifold with Apache License 2.0 | 5 votes |
private ManLog_8( Context ctx, DiagnosticHandler diagnosticHandler, DiagnosticSource source, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter ) { super( ctx, errWriter, warnWriter, noticeWriter ); ReflectUtil.field( this, "diagnosticHandler" ).set( diagnosticHandler ); ensureDiagnosticHandlersEnclosingClassIsThis( diagnosticHandler ); ReflectUtil.field( this, "source" ).set( source ); _suspendedIssues = new HashMap<>(); _extensionTransformerClass = LocklessLazyVar.make( () -> ReflectUtil.type( "manifold.ext.ExtensionTransformer" ) ); reassignLog( ctx ); }
Example #13
Source File: DocCommentParser.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource, Comment comment) { this.fac = fac; this.diagSource = diagSource; this.comment = comment; names = fac.names; m = fac.docTreeMaker; initTagParsers(); }
Example #14
Source File: DCTree.java From hottub with GNU General Public License v2.0 | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(diagSource, this, code, args); }
Example #15
Source File: DocTreeMaker.java From hottub with GNU General Public License v2.0 | 4 votes |
public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #16
Source File: DCTree.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(diagSource, this, code, args); }
Example #17
Source File: JavacTrees.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DocCommentTree getDocCommentTree(FileObject fileObject) { JavaFileObject jfo = asJavaFileObject(fileObject); DiagnosticSource diagSource = new DiagnosticSource(jfo, log); final Comment comment = new Comment() { int offset = 0; @Override public String getText() { try { CharSequence rawDoc = fileObject.getCharContent(true); Pattern bodyPat = Pattern.compile("(?is).*?<body\\b[^>]*>(.*)</body\\b.*"); Matcher m = bodyPat.matcher(rawDoc); if (m.matches()) { offset = m.end(1); return m.group(1); } else { // Assume doclint will do the right thing. return ""; } } catch (IOException ignore) { // do nothing } return ""; } @Override public int getSourcePos(int index) { return offset + index; } @Override public CommentStyle getStyle() { throw new UnsupportedOperationException(); } @Override public boolean isDeprecated() { throw new UnsupportedOperationException(); } }; return new DocCommentParser(parser, diagSource, comment).parse(); }
Example #18
Source File: DocTreeMaker.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #19
Source File: DCTree.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(diagSource, this, code, args); }
Example #20
Source File: DocTreeMaker.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public DCErroneous newErroneousTree(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #21
Source File: DCTree.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(null, diagSource, this, code, args); }
Example #22
Source File: DocTreeMaker.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #23
Source File: DocTreeMaker.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #24
Source File: DCTree.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(diagSource, this, code, args); }
Example #25
Source File: TreeFactory.java From netbeans with Apache License 2.0 | 4 votes |
public com.sun.source.doctree.ErroneousTree Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { String msg = "Erroneous tree implemented: " + text + " " + code; throw new AssertionError(msg); }
Example #26
Source File: LambdaToMethod.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void visitClassDef(JCClassDecl tree) { List<Frame> prevStack = frameStack; int prevLambdaCount = lambdaCount; SyntheticMethodNameCounter prevSyntheticMethodNameCounts = syntheticMethodNameCounts; Map<ClassSymbol, Symbol> prevClinits = clinits; DiagnosticSource prevSource = log.currentSource(); try { log.useSource(tree.sym.sourcefile); lambdaCount = 0; syntheticMethodNameCounts = new SyntheticMethodNameCounter(); prevClinits = new HashMap<>(); if (tree.sym.owner.kind == MTH) { localClassDefs.put(tree.sym, tree); } if (directlyEnclosingLambda() != null) { tree.sym.owner = owner(); if (tree.sym.hasOuterInstance()) { //if a class is defined within a lambda, the lambda must capture //its enclosing instance (if any) TranslationContext<?> localContext = context(); final TypeSymbol outerInstanceSymbol = tree.sym.type.getEnclosingType().tsym; while (localContext != null && !localContext.owner.isStatic()) { if (localContext.tree.hasTag(LAMBDA)) { JCTree block = capturedDecl(localContext.depth, outerInstanceSymbol); if (block == null) break; ((LambdaTranslationContext)localContext) .addSymbol(outerInstanceSymbol, CAPTURED_THIS); } localContext = localContext.prev; } } } frameStack = frameStack.prepend(new Frame(tree)); super.visitClassDef(tree); } finally { log.useSource(prevSource.getFile()); frameStack = prevStack; lambdaCount = prevLambdaCount; syntheticMethodNameCounts = prevSyntheticMethodNameCounts; clinits = prevClinits; } }
Example #27
Source File: JavacTrees.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public DocCommentTree getDocCommentTree(FileObject fileObject) { JavaFileObject jfo = asJavaFileObject(fileObject); DiagnosticSource diagSource = new DiagnosticSource(jfo, log); final Comment comment = new Comment() { int offset = 0; @Override public String getText() { try { CharSequence rawDoc = fileObject.getCharContent(true); Pattern bodyPat = Pattern.compile("(?is).*?<body\\b[^>]*>(.*)</body\\b.*"); Matcher m = bodyPat.matcher(rawDoc); if (m.matches()) { offset = m.end(1); return m.group(1); } else { // Assume doclint will do the right thing. return ""; } } catch (IOException ignore) { // do nothing } return ""; } @Override public int getSourcePos(int index) { return offset + index; } @Override public CommentStyle getStyle() { throw new UnsupportedOperationException(); } @Override public boolean isDeprecated() { throw new UnsupportedOperationException(); } }; return new DocCommentParser(parser, diagSource, comment).parse(); }
Example #28
Source File: DocTreeMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public DCErroneous newErroneousTree(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }
Example #29
Source File: DCTree.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) { this.body = body; this.diag = diags.error(null, diagSource, this, code, args); }
Example #30
Source File: DocTreeMaker.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) { DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args); tree.pos = pos; return tree; }