当前位置: 首页>>代码示例>>Java>>正文


Java TypeKind.ERROR属性代码示例

本文整理汇总了Java中javax.lang.model.type.TypeKind.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java TypeKind.ERROR属性的具体用法?Java TypeKind.ERROR怎么用?Java TypeKind.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.type.TypeKind的用法示例。


在下文中一共展示了TypeKind.ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveReturnType

static TypeMirror resolveReturnType(
    ProcessingEnvironment processing,
    ExecutableElement method,
    TypeElement typeElement) {
  method = CachingElements.getDelegate(method);
  TypeMirror returnType = method.getReturnType();

  // We do not support parametrized accessor methods,
  // but we do support inheriting parametrized accessors, which
  // we supposedly parametrized with actual type parameters as
  // our target class could not define formal type parameters also.
  if (returnType.getKind() == TypeKind.TYPEVAR) {
    return asInheritedMemberReturnType(processing, typeElement, method);
  } else if (returnType.getKind() == TypeKind.DECLARED
      || returnType.getKind() == TypeKind.ERROR) {
    if (!((DeclaredType) returnType).getTypeArguments().isEmpty()) {
      return asInheritedMemberReturnType(processing, typeElement, method);
    }
  }
  return returnType;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:AccessorAttributesCollector.java

示例2: locateNestedTypes

private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
    // The number of "steps" to get from the full type to the
    // left-most outer type.
    ListBuffer<TypePathEntry> depth = new ListBuffer<>();

    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.append(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    if (depth.nonEmpty()) {
        p.location = p.location.prependList(depth.toList());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:TypeAnnotations.java

示例3: visitIdentifier

public Void visitIdentifier(IdentifierTree node, Void p) {
    TreePath path = getCurrentPath();
    Element element = info.getTrees().getElement(path);
    
    if (element != null && element.asType().getKind() != TypeKind.ERROR) {
        // solve the imports only when declared type!!!
        if (element.getKind().isClass() || element.getKind().isInterface()
                || (element.getKind().isField() && ((Symbol) element).isStatic())) {
            Tree parent = path.getParentPath() != null ? path.getParentPath().getLeaf() : null;
            
            if (   (parent != null && parent.getKind() == Kind.CASE && ((CaseTree) parent).getExpression() == node && element.getKind() == ElementKind.ENUM_CONSTANT)
                || (path.getCompilationUnit() != null && ((Symbol) element).enclClass() != null && path.getCompilationUnit().getSourceFile() == ((Symbol) element).enclClass().sourcefile)) {
                translateMap.put(node, make.Identifier(element.getSimpleName()));
            } else {
                translateMap.put(node, make.QualIdent(element));
            }
        } 
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TranslateIdentifier.java

示例4: checkConstantExpression

static boolean checkConstantExpression(final CompilationInfo info, TreePath path) {
    InstanceRefFinder finder = new InstanceRefFinder(info, path) {
        @Override
        public Object visitIdentifier(IdentifierTree node, Object p) {
            Element el = info.getTrees().getElement(getCurrentPath());
            if (el == null || el.asType() == null || el.asType().getKind() == TypeKind.ERROR) {
                return null;
            }
            if (el.getKind() == ElementKind.LOCAL_VARIABLE || el.getKind() == ElementKind.PARAMETER) {
                throw new StopProcessing();
            } else if (el.getKind() == ElementKind.FIELD) {
                if (!el.getModifiers().contains(Modifier.FINAL)) {
                    throw new StopProcessing();
                }
            }
            return super.visitIdentifier(node, p);
        }
    };
    try {
        finder.process();
        return  !(finder.containsInstanceReferences() || finder.containsLocalReferences() || finder.containsReferencesToSuper());
    } catch (StopProcessing e) {
        return false;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:IntroduceConstantFix.java

示例5: isStaticElement

private static boolean isStaticElement(Element el) {
    if (el == null) return false;

    if (el.asType() == null || el.asType().getKind() == TypeKind.ERROR) {
        return false;
    }

    if (el.getModifiers().contains(Modifier.STATIC)) {
        //XXX:
        if (!el.getKind().isClass() && !el.getKind().isInterface()) {
            return false;
        }

        return true;
    }

    if (el.getKind().isClass() || el.getKind().isInterface()) {
        return el.getEnclosingElement().getKind() == ElementKind.PACKAGE;
    }

    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavaFixUtilities.java

示例6: isElementAvail

/**
 * Checks if the element is still available. Tests if it is still valid.
 * (Was not deleted by matching mechanism.)
 * If element is available, returns null, otherwise it creates problem.
 * (Helper method for refactoring implementation as this problem is
 * general for all refactorings.)
 *
 * @param   e  element to check
 * @param info 
 * @return  problem message or null if the element is valid
 */
protected static Problem isElementAvail(TreePathHandle e, CompilationInfo info) {
    if (e==null) {
        //element is null or is not valid.
        return new Problem(true, NbBundle.getMessage(FindVisitor.class, "DSC_ElNotAvail")); // NOI18N
    } else {
        Element el = e.resolveElement(info);
        String elName = el != null ? el.getSimpleName().toString() : null;
        if (el == null || el.asType().getKind() == TypeKind.ERROR || "<error>".equals(elName)) { // NOI18N
            return new Problem(true, NbBundle.getMessage(FindVisitor.class, "DSC_ElementNotResolved"));
        }
        
        if ("this".equals(elName) || "super".equals(elName)) { // NOI18N
            return new Problem(true, NbBundle.getMessage(FindVisitor.class, "ERR_CannotRefactorThis", el.getSimpleName()));
        }
        
        // element is still available
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JavaRefactoringPlugin.java

示例7: collectUnresolvedInterface

private void collectUnresolvedInterface(TypeMirror typeMirror, TypevarContext context) {
  if (typeMirror.getKind() == TypeKind.ERROR) {
    DeclaredType declaredType = toDeclaredType(typeMirror);
    String stringified = stringify(declaredType, context);
    implementedInterfaceNames.add(stringified);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:TypeHierarchyCollector.java

示例8: conditions2Constraints

private static Map<String, TypeMirror> conditions2Constraints(CompilationInfo info, List<Condition> conditions) {
    Map<String, TypeMirror> constraints = new HashMap<String, TypeMirror>();

    for (Entry<String, String> e : org.netbeans.modules.java.hints.declarative.Utilities.conditions2Constraints(conditions).entrySet()) {
        TypeMirror designedType = Hacks.parseFQNType(info, e.getValue());

        if (designedType == null || designedType.getKind() == TypeKind.ERROR) {
            continue ;
        }

        constraints.put(e.getKey(), designedType);
    }
    
    return constraints;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:HintsTask.java

示例9: typeMatches

private boolean typeMatches(TreePath currentPath, String placeholderName) {
    TypeMirror designed = designedTypeHack != null ? designedTypeHack.get(placeholderName) : null;

    boolean bind;

    if (designed != null && designed.getKind() != TypeKind.ERROR) {
        TypeMirror real = info.getTrees().getTypeMirror(currentPath);
        if (real != null && !IGNORE_KINDS.contains(real.getKind())) {
            // special hack: if the designed type is DECLARED (assuming a boxed primitive) and the real type is 
            // not DECLARED or is null (assuming a real primitive), do not treat them as assignable.
            // this will stop matching constraint to boxed types against primitive subexpressions. Exclude j.l.Object
            // which will allow to match raw type parameters
            if (designed.getKind() == TypeKind.DECLARED &&
                real.getKind().ordinal() <= TypeKind.DOUBLE.ordinal() &&
                !((TypeElement)((DeclaredType)designed).asElement()).getQualifiedName().contentEquals("java.lang.Object")) { //NOI18N
                bind = false;
            } else {
                bind = info.getTypes().isAssignable(real, designed);
            }
        } else {
            bind = false;
        }
    } else {
        bind = designed == null;
    }
    return bind;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:CopyFinder.java

示例10: shouldProcessUndefined

/**
 * Determines if the Element should be processed as an undefined variable. Currently the implementation
 * only returns true if an undefinedSymbolScope is set, AND the undefined symbol might belong to that scope.
 * If the undefined symbol is qualified (by this. or class.this. or whatever else manner), the method will
 * only return true if the qualifier corresponds to the undefinedSymbolScope.
 * 
 */
private boolean shouldProcessUndefined(Element e) {
    if (e == null || undefinedSymbolScope == null ||
        e.asType().getKind() != TypeKind.ERROR) {
        return false;
    }
    if (e.getKind() == ElementKind.CLASS) {
        return referenceTarget == null || 
            referenceTarget == undefinedSymbolScope;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Flow.java

示例11: locateNestedTypes

private ListBuffer<TypePathEntry>
    locateNestedTypes(Type type,
                      ListBuffer<TypePathEntry> depth) {
    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.prepend(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    return depth;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TypeAnnotations.java

示例12: checkTypesAssignable

public static boolean checkTypesAssignable(CompilationInfo info, TypeMirror from, TypeMirror to) {
    Context c = ((JavacTaskImpl) info.impl.getJavacTask()).getContext();
    if (from.getKind() == TypeKind.TYPEVAR) {
        Types types = Types.instance(c);
        TypeVar t = types.substBound((TypeVar)from, com.sun.tools.javac.util.List.of((Type)from), com.sun.tools.javac.util.List.of(types.boxedTypeOrType((Type)to)));
        return info.getTypes().isAssignable(t.getUpperBound(), to)
                || info.getTypes().isAssignable(to, t.getUpperBound());
    }
    if (from.getKind() == TypeKind.WILDCARD) {
        from = Types.instance(c).wildUpperBound((Type)from);
    }
    return Check.instance(c).checkType(null, (Type)from, (Type)to).getKind() != TypeKind.ERROR;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SourceUtils.java

示例13: fastCheckParameters

@Override
protected Problem fastCheckParameters(CompilationController javac) throws IOException {
    Problem result = null;
    String newName = refactoring.getInterfaceName();
    TypeMirror parsedType = javac.getTreeUtilities().parseType(newName, classHandle.resolve(javac));
    if(parsedType != null && parsedType.getKind() != TypeKind.ERROR) {
        result = createProblem(result, true, NbBundle.getMessage(ExtractInterfaceRefactoringPlugin.class, "ERR_ClassClash", newName, pkgName)); // NOI18N
        return result;
    }
    return super.fastCheckParameters(javac);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ExtractInterfaceRefactoringPlugin.java

示例14: visitMemberSelect

@Override
public Number visitMemberSelect(MemberSelectTree node, Void p) {
    Element e = info.getTrees().getElement(getCurrentPath());

    if (e != null && (e.getKind() != ElementKind.CLASS || ((TypeElement) e).asType().getKind() != TypeKind.ERROR)) {
        //check correct dependency:
        checkDependency(info, e, canShowUI);

        if (isStaticElement(e) && !inImport) {
            rewrite(node, make.QualIdent(e));

            return null;
        }
    }
    
    MemberSelectTree nue = node;
    String selectedName = node.getIdentifier().toString();

    if (selectedName.startsWith("$") && parameterNames.get(selectedName) != null) {
        nue = make.MemberSelect(node.getExpression(), parameterNames.get(selectedName));
    }

    if (nue.getExpression().getKind() == Kind.IDENTIFIER) {
        String name = ((IdentifierTree) nue.getExpression()).getName().toString();

        if (name.startsWith("$") && parameters.get(name) == null) {
            //XXX: unbound variable, use identifier instead of member select - may cause problems?
            rewrite(node, make.Identifier(nue.getIdentifier()));
            return null;
        }
    }

    if (nue != node) {
        rewrite(node, nue);
    }
    
    return super.visitMemberSelect(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:JavaFixUtilities.java

示例15: isError

private static boolean isError(Element el) {
    return el == null || el.asType() == null || el.asType().getKind() == TypeKind.ERROR;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:3,代码来源:GoToSupport.java


注:本文中的javax.lang.model.type.TypeKind.ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。