JCDiagnostic.Factory factory = JCDiagnostic.Factory.instance(context); JCDiagnostic.DiagnosticType type = JCDiagnostic.DiagnosticType.ERROR; DiagnosticPosition pos = description.position; break; log.report(factory.create(type, log.currentSource(), pos, MESSAGE_BUNDLE_KEY, message)); } finally { if (originalSource != null) {
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. * @param key The key for the localized notification message. * @param args Fields of the notification message. */ public void mandatoryNote(final JavaFileObject file, String key, Object ... args) { JCDiagnostic.DiagnosticSource wrapper = null; if (file != null) { wrapper = new JCDiagnostic.DiagnosticSource() { public JavaFileObject getFile() { return file; } public CharSequence getName() { return JavacFileManager.getJavacBaseFileName(getFile()); } public int getLineNumber(int pos) { return Log.this.getLineNumber(pos); } public int getColumnNumber(int pos) { return Log.this.getColumnNumber(pos); } public Map<JCTree, Integer> getEndPosTable() { return (endPosTables == null ? null : endPosTables.get(file)); } }; } if (enforceMandatoryWarnings) report(diags.mandatoryNote(wrapper, key, args)); else report(diags.note(wrapper, null, key, args)); }
/** * Constructor * @param programName Name of the program (for error messages). * @param errWriter Stream for error messages * @param warnWriter Stream for warnings * @param noticeWriter Stream for other messages */ @SuppressWarnings("deprecation") protected Messager(Context context, String programName, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) { super(context, errWriter, warnWriter, noticeWriter); messages = JavacMessages.instance(context); messages.add("com.sun.tools.javadoc.resources.javadoc"); javadocDiags = new JCDiagnostic.Factory(messages, "javadoc"); this.programName = programName; }
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); } // </editor-fold>
public void logFatalError(Log log, Context context) { String version = ErrorProneVersion.loadVersionFromPom().or("unknown version"); JavaFileObject originalSource = log.useSource(source); Factory factory = Factory.instance(context); try { log.report( factory.create( DiagnosticType.ERROR, log.currentSource(), pos, "error.prone.crash", Throwables.getStackTraceAsString(cause), version, checkName)); } finally { log.useSource(originalSource); } }
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); } // </editor-fold>
protected Flow(Context context) { context.put(flowKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); types = Types.instance(context); chk = Check.instance(context); lint = Lint.instance(context); rs = Resolve.instance(context); diags = JCDiagnostic.Factory.instance(context); Source source = Source.instance(context); allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); enforceThisDotInit = source.enforceThisDotInit(); }
public static void preRegister(Context context, final String programName, final PrintWriter errWriter, final PrintWriter warnWriter, final PrintWriter noticeWriter) { context.put(logKey, new Context.Factory<Log>() { public Log make(Context c) { return new Messager(c, programName, errWriter, warnWriter, noticeWriter); } }); }
protected Flow(Context context) { context.put(flowKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); types = Types.instance(context); chk = Check.instance(context); lint = Lint.instance(context); rs = Resolve.instance(context); diags = JCDiagnostic.Factory.instance(context); Source source = Source.instance(context); allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); }
protected Infer(Context context) { context.put(inferKey, this); rs = Resolve.instance(context); chk = Check.instance(context); syms = Symtab.instance(context); types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); inferenceException = new InferenceException(diags); Options options = Options.instance(context); allowGraphInference = Source.instance(context).allowGraphInference() && options.isUnset("useLegacyInference"); }
protected Infer(Context context) { context.put(inferKey, this); rs = Resolve.instance(context); chk = Check.instance(context); syms = Symtab.instance(context); types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); inferenceException = new InferenceException(diags); Options options = Options.instance(context); allowGraphInference = Source.instance(context).allowGraphInference() && options.isUnset("useLegacyInference"); }
protected RichDiagnosticFormatter(Context context) { super((AbstractDiagnosticFormatter)Log.instance(context).getDiagnosticFormatter()); setRichPrinter(new RichPrinter()); this.syms = Symtab.instance(context); this.diags = JCDiagnostic.Factory.instance(context); this.types = Types.instance(context); this.messages = JavacMessages.instance(context); whereClauses = new EnumMap<WhereClauseKind, Map<Type, JCDiagnostic>>(WhereClauseKind.class); configuration = new RichConfiguration(Options.instance(context), formatter); for (WhereClauseKind kind : WhereClauseKind.values()) whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>()); }
/** Create a tree maker with NOPOS as initial position. */ protected DocTreeMaker(Context context) { context.put(treeMakerKey, this); diags = JCDiagnostic.Factory.instance(context); this.pos = Position.NOPOS; }
/** Report a warning. * @param lc The lint category for the diagnostic * @param pos The source position at which to report the warning. * @param key The key for the localized warning message. * @param args Fields of the warning message. */ public void mandatoryWarning(LintCategory lc, DiagnosticPosition pos, String key, Object ... args) { report(diags.mandatoryWarning(lc, source, pos, key, args)); }
/** Get the Factory instance for this context. */ public static Factory instance(Context context) { Factory instance = context.get(diagnosticFactoryKey); if (instance == null) instance = new Factory(context); return instance; }
/** Report a warning. * @param pos The source position at which to report the warning. * @param key The key for the localized warning message. * @param args Fields of the warning message. */ public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) { report(diags.mandatoryWarning(source, pos, key, args)); }
/** Provide a non-fatal notification, unless suppressed by the -nowarn option. * @param key The key for the localized notification message. * @param args Fields of the notification message. */ public void mandatoryNote(final JavaFileObject file, String key, Object ... args) { report(diags.mandatoryNote(getSource(file), key, args)); }
/** Report an error, unless another error was already reported at same * source position. * @param flag A flag to set on the diagnostic * @param pos The source position at which to report the error. * @param key The key for the localized error message. * @param args Fields of the error message. */ public void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object ... args) { JCDiagnostic d = diags.error(source, pos, key, args); d.setFlag(flag); report(d); }
/** Report an error, unless another error was already reported at same * source position. * @param key The key for the localized error message. * @param args Fields of the error message. */ public void error(String key, Object ... args) { report(diags.error(source, null, key, args)); }
public static void preRegister(Context context, final String programName) { context.put(logKey, new Context.Factory<Log>() { public Log make(Context c) { return new Messager(c, programName); } }); } public static void preRegister(Context context,