本文整理汇总了Java中com.sun.tools.javac.util.Log.instance方法的典型用法代码示例。如果您正苦于以下问题:Java Log.instance方法的具体用法?Java Log.instance怎么用?Java Log.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.Log
的用法示例。
在下文中一共展示了Log.instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArbitrarySource
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
public static CompilationUnitTree parseArbitrarySource(JavacTask task, JavaFileObject file) throws IOException {
JavacTaskImpl taskImpl = (JavacTaskImpl) task;
com.sun.tools.javac.util.Context context = taskImpl.getContext();
Log log = Log.instance(context);
JavaFileObject prevSource = log.useSource(file);
try {
ParserFactory fac = ParserFactory.instance(context);
JCCompilationUnit cut = fac.newParser(file.getCharContent(true), true, true, true).parseCompilationUnit();
cut.sourcefile = file;
return cut;
} finally {
log.useSource(prevSource);
}
}
示例2: Round
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
/** Create a round (common code). */
private Round(Context context, int number, int priorErrors, int priorWarnings,
Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
this.context = context;
this.number = number;
compiler = JavaCompiler.instance(context);
log = Log.instance(context);
log.nerrors = priorErrors;
log.nwarnings = priorWarnings;
if (number == 1) {
Assert.checkNonNull(deferredDiagnosticHandler);
this.deferredDiagnosticHandler = deferredDiagnosticHandler;
} else {
this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
}
// the following is for the benefit of JavacProcessingEnvironment.getContext()
JavacProcessingEnvironment.this.context = context;
// the following will be populated as needed
topLevelClasses = List.nil();
packageInfoFiles = List.nil();
}
示例3: 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<>();
}
示例4: 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);
}
示例5: 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();
}
示例6: JNIWriter
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
/** Construct a class writer, given an options table.
*/
private JNIWriter(Context context) {
context.put(jniWriterKey, this);
fileManager = context.get(JavaFileManager.class);
log = Log.instance(context);
Options options = Options.instance(context);
verbose = options.isSet(VERBOSE);
checkAll = options.isSet("javah:full");
this.context = context; // for lazyInit()
}
示例7: attributeTreeTo
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
private static Scope attributeTreeTo(JavacTaskImpl jti, Tree tree, Scope scope, Tree to, final List<Diagnostic<? extends JavaFileObject>> errors) {
Log log = Log.instance(jti.getContext());
JavaFileObject prev = log.useSource(new DummyJFO());
Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
@Override
public void report(JCDiagnostic diag) {
errors.add(diag);
}
};
NBResolve resolve = NBResolve.instance(jti.getContext());
resolve.disableAccessibilityChecks();
// Enter enter = Enter.instance(jti.getContext());
// enter.shadowTypeEnvs(true);
// ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
// ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
try {
Attr attr = Attr.instance(jti.getContext());
Env<AttrContext> env = getEnv(scope);
Env<AttrContext> result = tree instanceof JCExpression ?
attr.attribExprToTree((JCExpression) tree, env, (JCTree) to) :
attr.attribStatToTree((JCTree) tree, env, (JCTree) to);
try {
Constructor<JavacScope> c = JavacScope.class.getDeclaredConstructor(Env.class);
c.setAccessible(true);
return c.newInstance(result);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new IllegalStateException(ex);
}
} finally {
// cacheContext.leave();
log.useSource(prev);
log.popDiagnosticHandler(discardHandler);
resolve.restoreAccessbilityChecks();
// enter.shadowTypeEnvs(false);
}
}
示例8: constructScope
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
public static Scope constructScope(CompilationInfo info, String... importedClasses) {
StringBuilder clazz = new StringBuilder();
clazz.append("package $$;\n");
for (String i : importedClasses) {
clazz.append("import ").append(i).append(";\n");
}
clazz.append("public class $").append(inc++).append("{");
clazz.append("private void test() {\n");
clazz.append("}\n");
clazz.append("}\n");
JavacTaskImpl jti = JavaSourceAccessor.getINSTANCE().getJavacTask(info);
Context context = jti.getContext();
JavaCompiler jc = JavaCompiler.instance(context);
Log.instance(context).nerrors = 0;
JavaFileObject jfo = FileObjects.memoryFileObject("$$", "$", new File("/tmp/t.java").toURI(), System.currentTimeMillis(), clazz.toString());
try {
CompilationUnitTree cut = ParserFactory.instance(context).newParser(jfo.getCharContent(true), true, true, true).parseCompilationUnit();
jti.analyze(jti.enter(Collections.singletonList(cut)));
return new ScannerImpl().scan(cut, info);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
return null;
} finally {
}
}
示例9: attributeTree
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
private static TypeMirror attributeTree(JavacTaskImpl jti, Tree tree, Scope scope, final List<Diagnostic<? extends JavaFileObject>> errors) {
Log log = Log.instance(jti.getContext());
JavaFileObject prev = log.useSource(new DummyJFO());
Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
@Override
public void report(JCDiagnostic diag) {
errors.add(diag);
}
};
NBResolve resolve = NBResolve.instance(jti.getContext());
resolve.disableAccessibilityChecks();
// Enter enter = Enter.instance(jti.getContext());
// enter.shadowTypeEnvs(true);
// ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
// ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
try {
Attr attr = Attr.instance(jti.getContext());
Env<AttrContext> env = ((JavacScope) scope).getEnv();
if (tree instanceof JCExpression)
return attr.attribExpr((JCTree) tree,env, Type.noType);
return attr.attribStat((JCTree) tree,env);
} finally {
// cacheContext.leave();
log.useSource(prev);
log.popDiagnosticHandler(discardHandler);
resolve.restoreAccessbilityChecks();
// enter.shadowTypeEnvs(false);
}
}
示例10: attributeTree
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
private static TypeMirror attributeTree(JavacTaskImpl jti, Tree tree, Scope scope,
final List<Diagnostic<? extends JavaFileObject>> errors, @NullAllowed final Diagnostic.Kind filter) {
Log log = Log.instance(jti.getContext());
JavaFileObject prev = log.useSource(new DummyJFO());
Enter enter = Enter.instance(jti.getContext());
Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
private Diagnostic.Kind f = filter == null ? Diagnostic.Kind.ERROR : filter;
@Override
public void report(JCDiagnostic diag) {
if (diag.getKind().compareTo(f) >= 0) {
errors.add(diag);
}
}
};
// ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
// ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
try {
// enter.shadowTypeEnvs(true);
Attr attr = Attr.instance(jti.getContext());
Env<AttrContext> env = ((JavacScope) scope).getEnv();
if (tree instanceof JCTree.JCExpression) {
return attr.attribExpr((JCTree) tree,env, Type.noType);
}
return attr.attribStat((JCTree) tree,env);
} finally {
// cacheContext.leave();
log.useSource(prev);
log.popDiagnosticHandler(discardHandler);
// enter.shadowTypeEnvs(false);
}
}
示例11: instance
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
public static NBMessager instance(Context context) {
final Log log = Log.instance(context);
if (!(log instanceof NBMessager)) {
throw new InternalError("No NBMessager instance!"); //NOI18N
}
return (NBMessager) log;
}
示例12: ParserFactory
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
protected ParserFactory(Context context) {
super();
context.put(parserFactoryKey, this);
this.F = TreeMaker.instance(context);
this.log = Log.instance(context);
this.names = Names.instance(context);
this.keywords = Keywords.instance(context);
this.source = Source.instance(context);
this.options = Options.instance(context);
this.scannerFactory = ScannerFactory.instance(context);
}
示例13: AbstractCodingRulesAnalyzer
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
public AbstractCodingRulesAnalyzer(JavacTask task) {
BasicJavacTask impl = (BasicJavacTask)task;
Context context = impl.getContext();
log = Log.instance(context);
options = Options.instance(context);
rawDiagnostics = options.isSet("rawDiagnostics");
diags = JCDiagnostic.Factory.instance(context);
messages = new Messages();
syms = Symtab.instance(context);
elements = JavacElements.instance(context);
types = JavacTypes.instance(context);
}
示例14: ScannerFactory
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
/**
* Create a new scanner factory.
*/
protected ScannerFactory(Context context) {
context.put(scannerFactoryKey, this);
this.log = Log.instance(context);
this.names = Names.instance(context);
this.source = Source.instance(context);
this.tokens = Tokens.instance(context);
}
示例15: init
import com.sun.tools.javac.util.Log; //导入方法依赖的package包/类
private void init(Context 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);
javacTaskImpl = context.get(JavacTaskImpl.class);
}