本文整理汇总了Java中javax.lang.model.util.Elements.isDeprecated方法的典型用法代码示例。如果您正苦于以下问题:Java Elements.isDeprecated方法的具体用法?Java Elements.isDeprecated怎么用?Java Elements.isDeprecated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.util.Elements
的用法示例。
在下文中一共展示了Elements.isDeprecated方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPackageContent
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void addPackageContent(final Env env, PackageElement pe, EnumSet<ElementKind> kinds, DeclaredType baseType, boolean insideNew, boolean srcOnly) throws IOException {
Set<? extends TypeMirror> smartTypes = options.contains(Options.ALL_COMPLETION) ? null : getSmartTypes(env);
CompilationController controller = env.getController();
Elements elements = controller.getElements();
Types types = controller.getTypes();
Trees trees = controller.getTrees();
ElementUtilities eu = controller.getElementUtilities();
Scope scope = env.getScope();
for (Element e : pe.getEnclosedElements()) {
if (e.getKind().isClass() || e.getKind().isInterface()) {
String name = e.getSimpleName().toString();
if ((env.getExcludes() == null || !env.getExcludes().contains(e))
&& startsWith(env, name) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
&& trees.isAccessible(scope, (TypeElement) e)
&& isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
&& !Utilities.isExcluded(eu.getElementName(e, true))) {
results.add(itemFactory.createTypeItem(env.getController(), (TypeElement) e, (DeclaredType) e.asType(), anchorOffset, null, elements.isDeprecated(e), insideNew, insideNew || env.isInsideClass(), true, isOfSmartType(env, e.asType(), smartTypes), false));
}
}
}
String pkgName = pe.getQualifiedName() + "."; //NOI18N
addPackages(env, pkgName, srcOnly);
}
示例2: addTypes
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void addTypes(Env env, EnumSet<ElementKind> kinds, DeclaredType baseType) throws IOException {
if (options.contains(Options.ALL_COMPLETION)) {
if (baseType == null) {
addAllTypes(env, kinds);
} else {
Elements elements = env.getController().getElements();
Set<? extends Element> excludes = env.getExcludes();
for (DeclaredType subtype : getSubtypesOf(env, baseType)) {
TypeElement elem = (TypeElement) subtype.asElement();
if ((excludes == null || !excludes.contains(elem)) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(elem)) && !Utilities.isExcluded(elem.getQualifiedName()) && (!env.isAfterExtends() || !elem.getModifiers().contains(Modifier.FINAL))) {
results.add(itemFactory.createTypeItem(env.getController(), elem, subtype, anchorOffset, env.getReferencesCount(), elements.isDeprecated(elem), env.isInsideNew(), env.isInsideNew() || env.isInsideClass(), false, true, false));
}
}
}
} else {
addLocalAndImportedTypes(env, kinds, baseType);
hasAdditionalClasses = true;
}
addPackages(env, null, kinds.isEmpty());
}
示例3: addTypes
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void addTypes(EnumSet<ElementKind> kinds, DeclaredType baseType,
Set<? extends Element> toExclude, String prefix,
int substitutionOffset, JavadocContext jdctx) {
if (queryType == CompletionProvider.COMPLETION_ALL_QUERY_TYPE) {
if (baseType == null) {
addAllTypes(jdctx, kinds, toExclude, prefix, substitutionOffset);
} else {
Elements elements = jdctx.javac.getElements();
for(DeclaredType subtype : getSubtypesOf(baseType, prefix, jdctx)) {
TypeElement elem = (TypeElement)subtype.asElement();
if ((toExclude == null || !toExclude.contains(elem)) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(elem)))
items.add(JavaCompletionItem.createTypeItem(jdctx.javac, elem, subtype, substitutionOffset, jdctx.getReferencesCount(), elements.isDeprecated(elem), false, false, false, false, false, null));
}
}
} else {
addLocalAndImportedTypes(jdctx, kinds, baseType, toExclude, prefix, substitutionOffset);
hasAdditionalItems = true;
}
}
示例4: addInnerClasses
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void addInnerClasses(TypeElement te, EnumSet<ElementKind> kinds, DeclaredType baseType, Set<? extends Element> toExclude, String prefix, int substitutionOffset, JavadocContext jdctx) {
CompilationInfo controller = jdctx.javac;
Element srcEl = jdctx.handle.resolve(controller);
Elements elements = controller.getElements();
Types types = controller.getTypes();
Trees trees = controller.getTrees();
TreeUtilities tu = controller.getTreeUtilities();
TreePath docpath = srcEl != null ? trees.getPath(srcEl) : null;
Scope scope = docpath != null ? trees.getScope(docpath) : tu.scopeFor(caretOffset);
for (Element e : controller.getElementUtilities().getMembers(te.asType(), null)) {
if ((e.getKind().isClass() || e.getKind().isInterface()) && (toExclude == null || !toExclude.contains(e))) {
String name = e.getSimpleName().toString();
if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) && trees.isAccessible(scope, (TypeElement)e) && isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)) {
items.add(JavadocCompletionItem.createTypeItem(jdctx.javac, (TypeElement) e, substitutionOffset, null, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
}
}
}
}
示例5: addPackageContent
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void addPackageContent(PackageElement pe, EnumSet<ElementKind> kinds, DeclaredType baseType, Set<? extends Element> toExclude, String prefix, int substitutionOffset, JavadocContext jdctx) {
CompilationInfo controller = jdctx.javac;
Element srcEl = jdctx.handle.resolve(controller);
Elements elements = controller.getElements();
Types types = controller.getTypes();
Trees trees = controller.getTrees();
TreeUtilities tu = controller.getTreeUtilities();
ElementUtilities eu = controller.getElementUtilities();
TreePath docpath = srcEl != null ? trees.getPath(srcEl) : null;
Scope scope = docpath != null ? trees.getScope(docpath) : tu.scopeFor(caretOffset);
for(Element e : pe.getEnclosedElements()) {
if ((e.getKind().isClass() || e.getKind().isInterface()) && (toExclude == null || !toExclude.contains(e))) {
String name = e.getSimpleName().toString();
if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
&& trees.isAccessible(scope, (TypeElement)e)
&& isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
&& !Utilities.isExcluded(eu.getElementName(e, true))) {
items.add(JavadocCompletionItem.createTypeItem(jdctx.javac, (TypeElement) e, substitutionOffset, null, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
}
}
}
}
示例6: createArrayItem
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
public static JavaCompletionItem createArrayItem(CompilationInfo info, ArrayType type, int substitutionOffset, ReferencesCount referencesCount, Elements elements, WhiteListQuery.WhiteList whiteList) {
int dim = 0;
TypeMirror tm = type;
while(tm.getKind() == TypeKind.ARRAY) {
tm = ((ArrayType)tm).getComponentType();
dim++;
}
if (tm.getKind().isPrimitive()) {
return new KeywordItem(tm.toString(), dim, null, substitutionOffset, true);
}
if (tm.getKind() == TypeKind.DECLARED || tm.getKind() == TypeKind.ERROR) {
DeclaredType dt = (DeclaredType)tm;
TypeElement elem = (TypeElement)dt.asElement();
switch (elem.getKind()) {
case CLASS:
return new ClassItem(info, elem, dt, dim, substitutionOffset, referencesCount, elements.isDeprecated(elem), false, false, false, true, false, whiteList);
case INTERFACE:
return new InterfaceItem(info, elem, dt, dim, substitutionOffset, referencesCount, elements.isDeprecated(elem), false, false, false, true, false, whiteList);
case ENUM:
return new EnumItem(info, elem, dt, dim, substitutionOffset, referencesCount, elements.isDeprecated(elem), false, false, true, false, whiteList);
case ANNOTATION_TYPE:
return new AnnotationTypeItem(info, elem, dt, dim, substitutionOffset, referencesCount, elements.isDeprecated(elem), false, false, true, false, whiteList);
}
}
throw new IllegalArgumentException("array element kind=" + tm.getKind());
}
示例7: getExtendedModifiers
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private static String getExtendedModifiers(Elements elements, Element el) {
StringBuilder sb = new StringBuilder();
for (Modifier m : el.getModifiers())
sb.append(m.name());
if (elements.isDeprecated(el))
sb.append(DEPRECATED);
if (el.getKind() == ElementKind.FIELD) {
Object v = ((VariableElement) el).getConstantValue();
if (v != null) {
sb.append(v.getClass().getName());
sb.append(String.valueOf(v));
}
}
return sb.toString();
}
示例8: insideCatch
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void insideCatch(Env env) throws IOException {
TreePath path = env.getPath();
CatchTree ct = (CatchTree) path.getLeaf();
CompilationController controller = env.getController();
TokenSequence<JavaTokenId> last = findLastNonWhitespaceToken(env, ct, env.getOffset());
if (last != null && last.token().id() == JavaTokenId.LPAREN) {
addKeyword(env, FINAL_KEYWORD, SPACE, false);
if (!options.contains(Options.ALL_COMPLETION)) {
TreeUtilities tu = controller.getTreeUtilities();
TreePath tryPath = tu.getPathElementOfKind(Tree.Kind.TRY, path);
Set<TypeMirror> exs = tu.getUncaughtExceptions(tryPath != null ? tryPath : path.getParentPath());
Elements elements = controller.getElements();
for (TypeMirror ex : exs) {
if (ex.getKind() == TypeKind.DECLARED && startsWith(env, ((DeclaredType) ex).asElement().getSimpleName().toString())
&& (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(((DeclaredType) ex).asElement()))
&& !Utilities.isExcluded(((TypeElement)((DeclaredType) ex).asElement()).getQualifiedName())) {
env.addToExcludes(((DeclaredType) ex).asElement());
results.add(itemFactory.createTypeItem(env.getController(), (TypeElement) ((DeclaredType) ex).asElement(), (DeclaredType) ex, anchorOffset, env.getReferencesCount(), elements.isDeprecated(((DeclaredType) ex).asElement()), false, false, false, true, false));
}
}
}
TypeElement te = controller.getElements().getTypeElement("java.lang.Throwable"); //NOI18N
if (te != null) {
addTypes(env, EnumSet.of(CLASS, INTERFACE, TYPE_PARAMETER), controller.getTypes().getDeclaredType(te));
}
}
}
示例9: insideUnionType
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void insideUnionType(Env env) throws IOException {
TreePath path = env.getPath();
UnionTypeTree dtt = (UnionTypeTree) path.getLeaf();
CompilationController controller = env.getController();
TokenSequence<JavaTokenId> last = findLastNonWhitespaceToken(env, dtt, env.getOffset());
if (last != null && last.token().id() == JavaTokenId.BAR) {
if (!options.contains(Options.ALL_COMPLETION)) {
TreeUtilities tu = controller.getTreeUtilities();
TreePath tryPath = tu.getPathElementOfKind(Tree.Kind.TRY, path);
Set<TypeMirror> exs = tu.getUncaughtExceptions(tryPath);
if (!exs.isEmpty()) {
Trees trees = controller.getTrees();
Types types = controller.getTypes();
for (Tree t : dtt.getTypeAlternatives()) {
TypeMirror tm = trees.getTypeMirror(new TreePath(path, t));
if (tm != null && tm.getKind() != TypeKind.ERROR) {
for (Iterator<TypeMirror> it = exs.iterator(); it.hasNext();) {
if (types.isSubtype(tm, it.next())) {
it.remove();
}
}
}
}
Elements elements = controller.getElements();
for (TypeMirror ex : exs) {
if (ex.getKind() == TypeKind.DECLARED && startsWith(env, ((DeclaredType) ex).asElement().getSimpleName().toString())
&& (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(((DeclaredType) ex).asElement()))
&& !Utilities.isExcluded(((TypeElement)((DeclaredType) ex).asElement()).getQualifiedName())) {
env.addToExcludes(((DeclaredType) ex).asElement());
results.add(itemFactory.createTypeItem(env.getController(), (TypeElement) ((DeclaredType) ex).asElement(), (DeclaredType) ex, anchorOffset, env.getReferencesCount(), elements.isDeprecated(((DeclaredType) ex).asElement()), false, false, false, true, false));
}
}
}
}
TypeElement te = controller.getElements().getTypeElement("java.lang.Throwable"); //NOI18N
if (te != null) {
addTypes(env, EnumSet.of(CLASS, INTERFACE, TYPE_PARAMETER), controller.getTypes().getDeclaredType(te));
}
}
}
示例10: getDelegate
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
@Override
protected JavaCompletionItem getDelegate(CompilationInfo info, Scope scope, TypeElement te) {
Elements elements = info.getElements();
if (te != null && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(te)) && info.getTrees().isAccessible(scope, te)) {
if (isOfKind(te, kinds) && (!afterExtends || !te.getModifiers().contains(Modifier.FINAL)) && (!isInDefaultPackage(te) || isInDefaultPackage(scope.getEnclosingClass())) && !Utilities.isExcluded(te.getQualifiedName())) {
return createTypeItem(info, te, (DeclaredType) te.asType(), substitutionOffset, referencesCount, elements.isDeprecated(te), insideNew, addTypeVars, false, false, false, getWhiteList());
}
}
return null;
}
示例11: insideParens
import javax.lang.model.util.Elements; //导入方法依赖的package包/类
private void insideParens(Env env) throws IOException {
TreePath path = env.getPath();
ParenthesizedTree pa = (ParenthesizedTree) path.getLeaf();
SourcePositions sourcePositions = env.getSourcePositions();
CompilationUnitTree root = env.getRoot();
Tree exp = unwrapErrTree(pa.getExpression());
if (exp == null || env.getOffset() <= sourcePositions.getStartPosition(root, exp)) {
if (!options.contains(Options.ALL_COMPLETION) && path.getParentPath().getLeaf().getKind() != Tree.Kind.SWITCH) {
Set<? extends TypeMirror> smarts = getSmartTypes(env);
if (smarts != null) {
Elements elements = env.getController().getElements();
for (TypeMirror smart : smarts) {
if (smart != null) {
if (smart.getKind() == TypeKind.DECLARED) {
for (DeclaredType subtype : getSubtypesOf(env, (DeclaredType) smart)) {
TypeElement elem = (TypeElement) subtype.asElement();
if ((Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(elem)) && !Utilities.isExcluded(elem.getQualifiedName())) {
results.add(itemFactory.createTypeItem(env.getController(), elem, subtype, anchorOffset, env.getReferencesCount(), elements.isDeprecated(elem), false, false, false, true, false));
}
env.addToExcludes(elem);
}
} else if (smart.getKind() == TypeKind.ARRAY) {
try {
TypeMirror tm = smart;
while (tm.getKind() == TypeKind.ARRAY) {
tm = ((ArrayType) tm).getComponentType();
}
if (tm.getKind().isPrimitive() && startsWith(env, tm.toString())) {
results.add(itemFactory.createArrayItem(env.getController(), (ArrayType) smart, anchorOffset, env.getReferencesCount(), env.getController().getElements()));
} else if ((tm.getKind() == TypeKind.DECLARED || tm.getKind() == TypeKind.ERROR) && startsWith(env, ((DeclaredType) tm).asElement().getSimpleName().toString())) {
results.add(itemFactory.createArrayItem(env.getController(), (ArrayType) smart, anchorOffset, env.getReferencesCount(), env.getController().getElements()));
}
} catch (IllegalArgumentException iae) {
}
}
}
}
}
}
addLocalMembersAndVars(env);
addTypes(env, EnumSet.of(CLASS, INTERFACE, ENUM, ANNOTATION_TYPE, TYPE_PARAMETER), null);
addPrimitiveTypeKeywords(env);
addValueKeywords(env);
} else {
insideExpression(env, new TreePath(path, exp));
}
}