本文整理汇总了Java中com.sun.tools.javac.comp.Attr.instance方法的典型用法代码示例。如果您正苦于以下问题:Java Attr.instance方法的具体用法?Java Attr.instance怎么用?Java Attr.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.comp.Attr
的用法示例。
在下文中一共展示了Attr.instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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;
}
示例2: DocEnv
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
private DocEnv(Context context) {
context.put(docEnvKey, this);
messager = Messager.instance0(context);
syms = Symtab.instance(context);
reader = JavadocClassReader.instance0(context);
enter = JavadocEnter.instance0(context);
attr = Attr.instance(context);
names = Name.Table.instance(context);
externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
}
示例3: CodeTranslator
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
public CodeTranslator(ProcessingEnvironment processingEnv) {
this.trees = Trees.instance(processingEnv);
this.SystemType = (DeclaredType) processingEnv.getElementUtils().getTypeElement(System.class.getName()).asType();
this.ThrowableType = (DeclaredType) processingEnv.getElementUtils().getTypeElement(Throwable.class.getName()).asType();
Context context = ((JavacProcessingEnvironment)processingEnv).getContext();
this.attr = Attr.instance(context);
this.typeUtils = processingEnv.getTypeUtils();
this.factory = new TypeMirrorFactory(processingEnv.getElementUtils(), processingEnv.getTypeUtils()) {
@Override
public TypeInfo create(TypeUse use, TypeMirror type) {
if (type.getKind() == TypeKind.WILDCARD) {
WildcardType wildcardType = (WildcardType) type;
if (wildcardType.getExtendsBound() != null) {
return super.create(wildcardType.getExtendsBound());
} else if (wildcardType.getSuperBound() != null) {
return super.create(use, wildcardType.getSuperBound());
}
}
return super.create(use, type);
}
};
}
示例4: TreeScannerStateful
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
public TreeScannerStateful(CompilationTask task, JCCompilationUnit jcc) {
this.jcc = jcc ;
trees = Trees.instance(task);
treesC = (JavacTrees)trees;
//Rabbit hole to Wonderland
context = ((BasicJavacTask)task).getContext() ;
this.task = ((BasicJavacTask)task) ;
//Initialize magical classes !
make = TreeMaker.instance(context) ;
names = Names.instance(context) ;
syms = Symtab.instance(context);
types = Types.instance(context) ;
typesC = JavacTypes.instance(context) ;
attr = Attr.instance(context) ;
enter = Enter.instance(context) ;
resolve = Resolve.instance(context) ;
memberEnter = MemberEnter.instance(context) ;
javacElements = JavacElements.instance(context) ;
info = TreeInfo.instance(context) ;
sourcePositions = trees.getSourcePositions();
elements = ((JavacTask)task).getElements();
elementsC = (JavacElements)elements;
}
示例5: attributeTree
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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 = getEnv(scope);
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);
}
}
示例6: attributeTreeTo
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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);
}
}
示例7: attributeTree
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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);
}
}
示例8: attributeTree
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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);
}
}
示例9: init
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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);
}
示例10: init
import com.sun.tools.javac.comp.Attr; //导入方法依赖的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);
names = Names.instance(context);
types = Types.instance(context);
JavacTask t = context.get(JavacTask.class);
if (t instanceof JavacTaskImpl)
javacTaskImpl = (JavacTaskImpl) t;
}
示例11: TypeAnnotations
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
protected TypeAnnotations(Context context) {
context.put(typeAnnosKey, this);
names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
annotate = Annotate.instance(context);
attr = Attr.instance(context);
Options options = Options.instance(context);
}
示例12: TypeAnnotations
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
protected TypeAnnotations(Context context) {
context.put(typeAnnosKey, this);
names = Names.instance(context);
log = Log.instance(context);
syms = Symtab.instance(context);
annotate = Annotate.instance(context);
attr = Attr.instance(context);
}
示例13: JavacTrees
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
private JavacTrees(Context context) {
context.put(JavacTrees.class, this);
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);
}
示例14: AptEnv
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
private AptEnv(Context context) {
context.put(aptEnvKey, this);
names = Name.Table.instance(context);
symtab = Symtab.instance(context);
jctypes = Types.instance(context);
enter = Enter.instance(context);
attr = Attr.instance(context);
typeMaker = TypeMaker.instance(context);
declMaker = DeclarationMaker.instance(context);
}
示例15: AptEnv
import com.sun.tools.javac.comp.Attr; //导入方法依赖的package包/类
private AptEnv(Context context) {
context.put(aptEnvKey, this);
names = Names.instance(context);
symtab = Symtab.instance(context);
jctypes = Types.instance(context);
enter = Enter.instance(context);
attr = Attr.instance(context);
typeMaker = TypeMaker.instance(context);
declMaker = DeclarationMaker.instance(context);
}