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


Java ElementHandle.getQualifiedName方法代码示例

本文整理汇总了Java中org.netbeans.api.java.source.ElementHandle.getQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Java ElementHandle.getQualifiedName方法的具体用法?Java ElementHandle.getQualifiedName怎么用?Java ElementHandle.getQualifiedName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.api.java.source.ElementHandle的用法示例。


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

示例1: check

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@Override
public WhiteListQuery.Result check(ElementHandle<?> element, WhiteListQuery.Operation operation) {
    if (!operation.equals(WhiteListQuery.Operation.USAGE)) {
        return OK;
    }

        if (element != null && (element.getKind().isClass() || element.getKind().isInterface())) {
            String qualifiedName = element.getQualifiedName();
            if (qualifiedName!=null && qualifiedName.lastIndexOf(".") > 0) {
                qualifiedName = qualifiedName.substring(0, qualifiedName.lastIndexOf("."));
                synchronized (IMPL_LOCK) {
                    if (privatePackages.contains(qualifiedName)) {
                        List<WhiteListQuery.RuleDescription> descs = new ArrayList<WhiteListQuery.RuleDescription>();
                        descs.add(new WhiteListQuery.RuleDescription("Private package dependency access", "Element comes from private package of spec version dependency", null));
                        return new WhiteListQuery.Result(descs);
                    }
                }
            }
        }
        return OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProjectWhiteListQueryImplementation.java

示例2: check

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@Override
public WhiteListQuery.Result check(ElementHandle<?> element, WhiteListQuery.Operation operation) {
    if (!operation.equals(WhiteListQuery.Operation.USAGE)) {
        return OK;
    }
    List<WhiteListQuery.RuleDescription> rds = new ArrayList<WhiteListQuery.RuleDescription>();
    if (element.getKind() == ElementKind.CLASS || element.getKind() == ElementKind.INTERFACE) {
        String qn = element.getQualifiedName();
        if (qn.lastIndexOf('.') > 0) {
            String pack = qn.substring(0, qn.lastIndexOf("."));
            synchronized (IMPL_LOCK) {
                if (privatePackages.contains(pack)) {
                    rds.add(PRIVATE_RD);
                }
                if (transitivePackages.contains(pack)) {
                    rds.add(TRANSITIVE_RD);
                }
            }
            if (!rds.isEmpty()) {
                return new WhiteListQuery.Result(rds);
            }
        }
    }
    return OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:MavenWhiteListQueryImpl.java

示例3: compare

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@Override
public int compare(ElementHandle<TypeElement> o1, ElementHandle<TypeElement> o2) {
    String fn1 = o1.getQualifiedName();
    String fn2 = o2.getQualifiedName();
    
    int dot1 = fn1.lastIndexOf('.');
    int dot2 = fn2.lastIndexOf('.');
    
    String sn1 = dot1 == -1 ? fn1 : fn1.substring(dot1 + 1);
    String sn2 = dot2 == -1 ? fn2 : fn2.substring(dot2 + 1);
    
    int diff = sn1.compareToIgnoreCase(sn2);
    if (diff != 0) {
        return diff;
    }
    return fn1.compareToIgnoreCase(fn2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ClassCompleter.java

示例4: getTypeOfClass

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
 * Find the ElementHandle of TypeElement of clazz in the passed ClassIndex.
 * Look in boot, compile and sources.
 * @param ci ClassIndex in which we are looking.
 * @param clazz class for which TypeElement we are looking
 * @return null if no such EH found in ci otherwise first found class with same fqn.
 */
protected final ElementHandle<TypeElement> getTypeOfClass(ClassIndex ci, String classfqn) {
    String searchedString = getSimpleNameFromFQN(classfqn);
    NameKind kind = NameKind.SIMPLE_NAME;
    Set<SearchScope> searchScope = EnumSet.of(SearchScope.DEPENDENCIES, SearchScope.SOURCE);
    Set<ElementHandle<TypeElement>> res = ci.getDeclaredTypes(searchedString, kind, searchScope);

    // Find if there is a ElementHandle<TypeElement> with same FQN as the ancestor.
    for (ElementHandle<TypeElement> eh : res) {
        String qn = eh.getQualifiedName();
        if (classfqn.equals(qn)) {
            return eh;
        }
    }
    return null;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:23,代码来源:AbstractCrawler.java

示例5: getMainClass

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private String getMainClass(Lookup context) {
    FileObject[] files = ActionUtils.findSelectedFiles(context, null, ".java", true); // NOI18N
    if (files.length == 1) {
        FileObject f = files[0];
        Collection<ElementHandle<TypeElement>> mcs = SourceUtils.getMainClasses(f);
        if (mcs.size() > 0) {
            ElementHandle<TypeElement> h = mcs.iterator().next();
            String qname = h.getQualifiedName();
            return qname;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ModuleActions.java

示例6: LazyTypeCompletionItem

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private LazyTypeCompletionItem(int substitutionOffset, ElementHandle<TypeElement> eh, JavaSource javaSource) {
    super(substitutionOffset);
    this.eh = eh;
    this.javaSource = javaSource;
    this.name = eh.getQualifiedName();
    int idx = name.lastIndexOf('.'); //NOI18N
    this.simpleName = idx > -1 ? name.substring(idx + 1) : name;
    this.pkgName = idx > -1 ? name.substring(0, idx) : ""; //NOI18N
    this.sortText = this.simpleName + SpringXMLConfigCompletionItem.getImportanceLevel(this.pkgName) + "#" + this.pkgName; // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LazyTypeCompletionItem.java

示例7: loadFromAllTypes

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private Set<ElementHandle<TypeElement>> loadFromAllTypes() {
    ClasspathInfo info = ctx.getClasspathInfo();
    Set<ElementHandle<TypeElement>> els = 
            new HashSet<ElementHandle<TypeElement>>(
                info.getClassIndex().getDeclaredTypes(namePrefix, ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX, 
                EnumSet.of(ClassIndex.SearchScope.DEPENDENCIES, ClassIndex.SearchScope.SOURCE)
            ));

    TypeMirror pt = getPropertyType();
    if (pt == null) {
        return els;
    }
    for (Iterator<ElementHandle<TypeElement>> it = els.iterator(); it.hasNext(); ) {
        ElementHandle<TypeElement> teh = it.next();
        String qn = teh.getQualifiedName();
        int lastDot = qn.lastIndexOf('.');
        String sn = lastDot == -1 ? qn : qn.substring(lastDot + 1);
        if (!acceptsQName(qn, sn)) {
            continue;
        }
        TypeElement t = teh.resolve(ctx.getCompilationInfo());
        if (t == null || 
            !acceptsType(t)) {
            it.remove();
        }
    }
    return els;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ClassCompleter.java

示例8: simpleName

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
@NonNull
private static String simpleName(@NullAllowed final ElementHandle<TypeElement> eh) {
    if (eh == null) {
        return "";  //NOI18N
    }
    final String qn = eh.getQualifiedName();
    int index = qn.lastIndexOf('.');    //NOI18N
    return index < 0 ? qn : qn.substring(index+1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ProfilesAnalyzer.java

示例9: TypeItem

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private TypeItem(ElementHandle<TypeElement> handle, EnumSet<ElementKind> kinds, int substitutionOffset, ReferencesCount referencesCount, Source source, boolean insideNew, boolean addTypeVars, boolean afterExtends, WhiteListQuery.WhiteList whiteList) {
    super(substitutionOffset, handle, source, whiteList);
    this.kinds = kinds;
    this.insideNew = insideNew;
    this.addTypeVars = addTypeVars;
    this.afterExtends = afterExtends;
    this.name = handle.getQualifiedName();
    int idx = name.lastIndexOf('.');
    this.simpleName = idx > -1 ? name.substring(idx + 1) : name;
    this.pkgName = idx > -1 ? name.substring(0, idx) : ""; //NOI18N
    this.sortText = new LazySortText(this.simpleName, this.pkgName, handle, referencesCount);
    this.referencesCount = referencesCount;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:LazyJavaCompletionItem.java

示例10: LazyTypeCompletionItem

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private LazyTypeCompletionItem(int substitutionOffset, ElementHandle<TypeElement> eh, JavaSource javaSource) {
    super(substitutionOffset);
    this.eh = eh;
    this.javaSource = javaSource;
    this.name = eh.getQualifiedName();
    int idx = name.lastIndexOf('.'); //NOI18N
    this.simpleName = idx > -1 ? name.substring(idx + 1) : name;
    this.pkgName = idx > -1 ? name.substring(0, idx) : ""; //NOI18N
    this.sortText = this.simpleName + HibernateCompletionItem.getImportanceLevel(this.pkgName) + "#" + this.pkgName; // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LazyTypeCompletionItem.java

示例11: run

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
 * Go through all classes in the set and check which ones are acceptable
 * to be filtered out. In this case, we require classes to be <ul>
 * <li>nonabstract</li> <li>public</li> </ul>
 *
 * @param cc
 * @throws Exception
 */
@Override
public void run(CompilationController cc) throws Exception {
    String annotationFQN = PrimitiveInfo.class.getCanonicalName();
    TypeMirror annotationType = getTypeMirror4Class(cc, annotationFQN);

    if (annotationType == null) {
        throw new ClassNotFoundException("Unable to find class " + annotationFQN);
    }

    result = new HashSet<PrimitiveData>();

    for (ElementHandle<TypeElement> element : set) {
        TypeElement type = element.resolve(cc);
        if (!isAbstract(type) && isPublic(type)) {
            String classFQN = element.getQualifiedName();

            // Go through annotation of class if exists and fill the data
            AnnotationMirror annotation = findAnnotationMirror(type, annotationType);
            if (annotation != null) {
                result.add(getInfo(classFQN, type, annotation));
            } else {
                result.add(new PrimitiveData(classFQN));
            }
        }
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:35,代码来源:ClassCrawler.java

示例12: run

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
/**
 * Go through all classes in the set and check which ones are acceptable to be filtered out.
 * In this case, we require classes to be
 * <ul>
 *  <li>nonabstract</li>
 *  <li>public</li>
 * </ul>
 * @param cc
 * @throws Exception
 */
@Override
public void run(CompilationController cc) throws Exception {
    String annotationFQN = PrimitiveInfo.class.getCanonicalName();
    TypeMirror annotationType = getTypeMirror4Class(cc, annotationFQN);

    if (annotationType == null) {
        throw new ClassNotFoundException("Unable to find class " + annotationFQN);
    }

    result = new HashSet<PrimitiveData>();

    for (ElementHandle<TypeElement> element : set) {
        TypeElement type = element.resolve(cc);
        if (!isAbstract(type) && isPublic(type)) {
            String classFQN = element.getQualifiedName();

            // Go through annotation of class if exists and fill the data
            AnnotationMirror annotation = findAnnotationMirror(type, annotationType);
            if (annotation != null) {
                result.add(getInfo(classFQN, annotation));
            } else {
                result.add(new PrimitiveData(classFQN, null, null, new String[0]));
            }
        }
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:37,代码来源:ClassCrawler.java

示例13: loadDescenantsOfNode2

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
Set<ElementHandle<TypeElement>> loadDescenantsOfNode2() {
    // get javafx.scene.Node descendants
    TypeElement baseClass = getBaseClass();
    if (baseClass == null) {
        // something wrong, fxml rt class does not exist
        LOG.warning("javafx.scene.Node class not fond");
        return Collections.emptySet();
    }
    
    ClasspathInfo info = ctx.getClasspathInfo();
    
    ElementHandle<TypeElement> nodeHandle = ElementHandle.create (baseClass);
    
    Set<ElementHandle<TypeElement>> allTypesSeen = new HashSet<ElementHandle<TypeElement>>();
    Deque<ElementHandle<TypeElement>> handles = new LinkedList<ElementHandle<TypeElement>>();
    handles.add(nodeHandle);
    
    long time = System.currentTimeMillis();

    allTypesSeen.add(nodeHandle);
    while (!handles.isEmpty()) {
        ElementHandle<TypeElement> baseHandle = handles.poll();
        LOG.log(Level.FINE, "Loading descendants of {0}", baseHandle);
        Set<ElementHandle<TypeElement>> descendants = new HashSet<ElementHandle<TypeElement>>(
                info.getClassIndex().getElements(baseHandle,
                    EnumSet.of(ClassIndex.SearchKind.IMPLEMENTORS), 
                    EnumSet.of(ClassIndex.SearchScope.DEPENDENCIES, ClassIndex.SearchScope.SOURCE)
                )
        );
        // eliminate duplicates
        descendants.removeAll(allTypesSeen);
        allTypesSeen.addAll(descendants);
        handles.addAll(descendants);
        LOG.log(Level.FINE, "Unique descendants: {0}", descendants);
    }
    long diff = System.currentTimeMillis();
    LOG.log(Level.FINE, "Loading Node descendants took: {0}ms", diff);

    Set<ElementHandle<TypeElement>> result = new HashSet<ElementHandle<TypeElement>>();
    // add descendants not yet seen to the next processing round
    for (ElementHandle<TypeElement> htype : allTypesSeen) {
        if (!(
            htype.getKind() == ElementKind.CLASS || htype.getKind() == ElementKind.INTERFACE)) {
            continue;
        }
        String n = htype.getQualifiedName();
        if (n.length() < namePrefix.length()) {
            // shorter name, does not match prefix
            continue;
        }
        
        int lastDot = n.lastIndexOf('.');
        if (lastDot != -1 && packagePrefix != null && (
            lastDot < packagePrefix.length() || !n.startsWith(packagePrefix))) {
                continue;
        }
        
        if (CompletionUtils.startsWith(n.substring(lastDot + 1), namePrefix)) {
            result.add(htype);
        }
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:65,代码来源:ClassCompleter.java

示例14: isAnnonInner

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private static boolean isAnnonInner(ElementHandle<TypeElement> elem) {
    String name = elem.getQualifiedName();
    int idx = name.lastIndexOf('.'); //NOI18N
    String simpleName = idx > -1 ? name.substring(idx + 1) : name;
    return simpleName.length() == 0 || Character.isDigit(simpleName.charAt(0));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:JavadocCompletionQuery.java

示例15: StaticMemberItem

import org.netbeans.api.java.source.ElementHandle; //导入方法依赖的package包/类
private StaticMemberItem(ElementHandle<TypeElement> handle, String name, int substitutionOffset, boolean addSemicolon, ReferencesCount referencesCount, Source source, WhiteListQuery.WhiteList whiteList) {
    super(substitutionOffset, handle, source, whiteList);
    this.name = name;
    this.sortText = new LazySortText(this.name, handle.getQualifiedName(), handle, referencesCount);
    this.addSemicolon = addSemicolon;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:LazyJavaCompletionItem.java


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