當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。