本文整理汇总了Java中com.sun.tools.javac.util.Log类的典型用法代码示例。如果您正苦于以下问题:Java Log类的具体用法?Java Log怎么用?Java Log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Log类属于com.sun.tools.javac.util包,在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Round
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
/** Create the first round. */
Round(List<JCCompilationUnit> roots,
List<ClassSymbol> classSymbols,
Set<JCCompilationUnit> treesToClean,
Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
this(1, treesToClean, deferredDiagnosticHandler);
this.roots = roots;
genClassFiles = new HashMap<>();
// The reverse() in the following line is to maintain behavioural
// compatibility with the previous revision of the code. Strictly speaking,
// it should not be necessary, but a javah golden file test fails without it.
topLevelClasses =
getTopLevelClasses(roots).prependList(classSymbols.reverse());
packageInfoFiles = getPackageInfoFiles(roots);
moduleInfoFiles = getModuleInfoFiles(roots);
findAnnotationsPresent();
}
示例2: preRegister
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
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>() {
@Override
public Log make(Context c) {
return new NBMessager(
c,
programName,
errWriter,
warnWriter,
noticeWriter);
}
});
}
示例3: getPluginLogger
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
@NotNull
private TrautePluginLogger getPluginLogger(@Nullable File logFile, @Nullable Log log) {
WeakReference<AbstractLogger> ref = loggerRef.get();
AbstractLogger logger = null;
if (logFile != null) {
logger = new FileLogger(logFile);
} else if (log != null) {
logger = new CompilerOutputLogger(log);
}
if (ref != null) {
AbstractLogger cached = ref.get();
if (cached != null && logger != null && cached.getKey() == logger.getKey()) {
return cached;
}
}
if (logger == null) {
throw new IllegalStateException(
"Can't create a logger instance - neither log file nor javac logger are specified"
);
}
loggerRef.set(new WeakReference<>(logger));
return logger;
}
示例4: Analyzer
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
protected Analyzer(Context context) {
context.put(analyzerKey, this);
types = Types.instance(context);
log = Log.instance(context);
attr = Attr.instance(context);
deferredAttr = DeferredAttr.instance(context);
argumentAttr = ArgumentAttr.instance(context);
make = TreeMaker.instance(context);
names = Names.instance(context);
Options options = Options.instance(context);
String findOpt = options.get("find");
//parse modes
Source source = Source.instance(context);
allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
}
示例5: helpSynopsis
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
/**
* Composes the initial synopsis of one of the forms for this option.
* @param name the name of this form of the option
* @param log the log used to localize the description of the arguments
* @return the synopsis
*/
private String helpSynopsis(String name, Log log) {
StringBuilder sb = new StringBuilder();
sb.append(name);
if (argsNameKey == null) {
if (choices != null) {
if (!name.endsWith(":"))
sb.append(" ");
String sep = "{";
for (String choice : choices) {
sb.append(sep);
sb.append(choice);
sep = ",";
}
sb.append("}");
}
} else {
if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT)
sb.append(" ");
sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
}
return sb.toString();
}
示例6: CompiledTypeProcessor
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
CompiledTypeProcessor( JavacTask javacTask )
{
_javacTask = javacTask;
javacTask.addTaskListener( this );
Context context = ((BasicJavacTask)javacTask).getContext();
JavaCompiler compiler = JavaCompiler.instance( context );
compiler.shouldStopPolicyIfNoError = CompileState.max( compiler.shouldStopPolicyIfNoError, CompileState.FLOW );
_issueReporter = new IssueReporter<>( Log.instance( context ) );
_types = Types.instance( context );
// DiagnosticListener dl = context.get( DiagnosticListener.class );
// context.put( DiagnosticListener.class, (DiagnosticListener)null );
// context.put( DiagnosticListener.class, new WrappedDiagnosticListener( dl ) );
_typesToProcess = new HashMap<>();
_innerClassForGeneration = new HashMap<>();
}
示例7: init
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
private void init(Context context) {
modules = Modules.instance(context);
attr = Attr.instance(context);
enter = Enter.instance(context);
elements = JavacElements.instance(context);
log = Log.instance(context);
resolve = Resolve.instance(context);
treeMaker = TreeMaker.instance(context);
memberEnter = MemberEnter.instance(context);
names = Names.instance(context);
types = Types.instance(context);
docTreeMaker = DocTreeMaker.instance(context);
parser = ParserFactory.instance(context);
syms = Symtab.instance(context);
fileManager = context.get(JavaFileManager.class);
JavacTask t = context.get(JavacTask.class);
if (t instanceof JavacTaskImpl)
javacTaskImpl = (JavacTaskImpl) t;
}
示例8: Enter
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
protected Enter(Context context) {
context.put(enterKey, this);
log = Log.instance(context);
reader = ClassReader.instance(context);
make = TreeMaker.instance(context);
syms = Symtab.instance(context);
chk = Check.instance(context);
memberEnter = MemberEnter.instance(context);
types = Types.instance(context);
annotate = Annotate.instance(context);
lint = Lint.instance(context);
names = Names.instance(context);
predefClassDef = make.ClassDef(
make.Modifiers(PUBLIC),
syms.predefClass.name, null, null, null, null);
predefClassDef.sym = syms.predefClass;
todo = Todo.instance(context);
fileManager = context.get(JavaFileManager.class);
Options options = Options.instance(context);
pkginfoOpt = PkgInfo.get(options);
}
示例9: parse
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
@Nullable
public JCTree.JCCompilationUnit parse(final String src) {
if (!canParse) return null;
long time = System.currentTimeMillis();
SimpleJavaFileObject source = new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) {
@Override
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return src;
}
};
Log.instance(context).useSource(source);
Parser parser = parserFactory.newParser(src,
/*keepDocComments=*/ true,
/*keepEndPos=*/ true,
/*keepLineMap=*/ true);
JCTree.JCCompilationUnit unit;
unit = parser.parseCompilationUnit();
unit.sourcefile = source;
android.util.Log.d(TAG, "parse: time " + (System.currentTimeMillis() - time) + " ms");
return unit;
}
示例10: showHelp
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
/**
* Writes the "command line help" for given kind of option to the log.
* @param log the log
* @param kind the kind of options to select
*/
private static void showHelp(Log log, OptionKind kind) {
Comparator<Option> comp = new Comparator<Option>() {
final Collator collator = Collator.getInstance(Locale.US);
{ collator.setStrength(Collator.PRIMARY); }
@Override
public int compare(Option o1, Option o2) {
return collator.compare(o1.primaryName, o2.primaryName);
}
};
getJavaCompilerOptions()
.stream()
.filter(o -> o.kind == kind)
.sorted(comp)
.forEach(o -> {
o.help(log);
});
}
示例11: Round
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
/** Create the first round. */
Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols,
Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
this(context, 1, 0, 0, deferredDiagnosticHandler);
this.roots = roots;
genClassFiles = new HashMap<String,JavaFileObject>();
compiler.todo.clear(); // free the compiler's resources
// The reverse() in the following line is to maintain behavioural
// compatibility with the previous revision of the code. Strictly speaking,
// it should not be necessary, but a javah golden file test fails without it.
topLevelClasses =
getTopLevelClasses(roots).prependList(classSymbols.reverse());
packageInfoFiles = getPackageInfoFiles(roots);
findAnnotationsPresent();
}
示例12: compileClass
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
public PrintWriter compileClass(String src, String out) {
List<String> options = new ArrayList<>();
options.add("-Xstdout");
options.add(out);
options.add(src);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
Main compiler = new Main("javac", pw);
compiler.compile(options.toArray(new String[options.size()]));
pw.flush();
if (sw.getBuffer().length() > 0) {
System.err.println(sw.toString());
}
return compiler.log.getWriter(Log.WriterKind.NOTICE);
}
示例13: getStandardFileManager
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER)
public JavacFileManager getStandardFileManager(
DiagnosticListener<? super JavaFileObject> diagnosticListener,
Locale locale,
Charset charset) {
Context context = new Context();
context.put(Locale.class, locale);
if (diagnosticListener != null)
context.put(DiagnosticListener.class, diagnosticListener);
PrintWriter pw = (charset == null)
? new PrintWriter(System.err, true)
: new PrintWriter(new OutputStreamWriter(System.err, charset), true);
context.put(Log.errKey, pw);
CacheFSInfo.preRegister(context);
return new JavacFileManager(context, true, charset);
}
示例14: PostFlowAnalysis
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
private PostFlowAnalysis(Context ctx) {
log = Log.instance(ctx);
types = Types.instance(ctx);
enter = Enter.instance(ctx);
names = Names.instance(ctx);
syms = Symtab.instance(ctx);
outerThisStack = List.nil();
}
示例15: Operators
import com.sun.tools.javac.util.Log; //导入依赖的package包/类
protected Operators(Context context) {
context.put(operatorsKey, this);
syms = Symtab.instance(context);
names = Names.instance(context);
log = Log.instance(context);
types = Types.instance(context);
noOpSymbol = new OperatorSymbol(names.empty, Type.noType, -1, syms.noSymbol);
initOperatorNames();
initUnaryOperators();
initBinaryOperators();
}