本文整理汇总了Java中com.sun.tools.javac.comp.Attr类的典型用法代码示例。如果您正苦于以下问题:Java Attr类的具体用法?Java Attr怎么用?Java Attr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attr类属于com.sun.tools.javac.comp包,在下文中一共展示了Attr类的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: validateParameterCompatibility
import com.sun.tools.javac.comp.Attr; //导入依赖的package包/类
@Override
public void validateParameterCompatibility(List<Parameter> params, Attr attr, Env<AttrContext> env)
throws ParameterValidationException {
List<Column> columns = insertQuery.getInsertColumns();
if (insertQuery.getValuesCount() > 0 && insertQuery.getValuesCount() % columns.size() == 0) {
// expect to have simple types
super.validateParameterCompatibility(params, attr, env);
} else if (insertQuery.isObjectInsert()) {
validateAllColumnsFillable();
} else {
// wrong column count
log.error("sql.insert.wrong.column.count", insertQuery.getValuesCount(), columns.size());
throw new ParameterValidationException();
}
validateUpsertIdColumns();
validateIllegalNullParameters(params);
}
示例4: validateProjectionCompatibility
import com.sun.tools.javac.comp.Attr; //导入依赖的package包/类
public void validateProjectionCompatibility(List<ProjectionItem> projections, Attr attr, Env<AttrContext> env, JCSqlQuery sqlQuery) {
Type expectedType = sqlQuery.getExpectedType();
if (typesHelper.isResultSet(expectedType)) {
// the projections for expected ResultSets are not validated anymore
return;
}
Type expectedRawType = typesHelper.getRawType(expectedType);
if (typesHelper.isSimpleType(expectedRawType)) {
validateTypeCompatibility(
expectedRawType, Iterables.getOnlyElement(projections).getTypeName());
} else if (typesHelper.isMapType(expectedType)) {
validateMapCompatibility(expectedRawType, projections);
} else {
// expect object type (or list of that)
BiMap<ProjectionItem, FlatObjectAttribute> projectionMapping =
validateObjectCompatibility(expectedRawType, projections);
sqlQuery.setProjectionsMapping(projectionMapping);
}
}
示例5: 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);
}
};
}
示例6: 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;
}
示例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 = 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: preRegister
import com.sun.tools.javac.comp.Attr; //导入依赖的package包/类
public static void preRegister(Context context) {
context.put(attrKey, new Context.Factory<Attr>() {
public Attr make(Context c) {
return new NBAttr(c);
}
});
}
示例12: visitNewClass
import com.sun.tools.javac.comp.Attr; //导入依赖的package包/类
@Override
public void visitNewClass(JCNewClass tree) {
super.visitNewClass(tree);
if (tree.def != null && tree.def.sym == null) {
try {
Field envField = Attr.class.getDeclaredField("env");
envField.setAccessible(true);
Env<AttrContext> env = (Env<AttrContext>) envField.get(this);
env = env.dup(tree);
attribStat(tree.def, env);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
Logger.getLogger(NBAttr.class.getName()).log(Level.FINE, null, ex);
}
}
}
示例13: 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);
}
示例14: setLazyConstValue
import com.sun.tools.javac.comp.Attr; //导入依赖的package包/类
public void setLazyConstValue(final Env<AttrContext> env,
final Attr attr,
final JCTree.JCExpression initializer)
{
setData(new Callable<Object>() {
public Object call() {
return attr.attribLazyConstantValue(env, initializer, type);
}
});
}
示例15: 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;
}