• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ElementHandle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ElementHandle类属于org.netbeans.api.java.source包,在下文中一共展示了ElementHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: Property

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
Property( PropertyPattern pp, CompilationInfo javac, BiAnalyser bia ) throws GenerateBeanException {
    super( pp, bia );
    mode = pp.getMode();
    pattern = pp;

    TypeElement declaringClass = pattern.getDeclaringClass().resolve(javac);
    declaringClassName = declaringClass.getQualifiedName().toString();
    ElementHandle<ExecutableElement> getterHandle = pattern.getGetterMethod();
    getterName = getterHandle == null? null: getterHandle.resolve(javac).getSimpleName().toString();
    ElementHandle<ExecutableElement> setterHandle = pattern.getSetterMethod();
    setterName = setterHandle == null? null: setterHandle.resolve(javac).getSimpleName().toString();

    if (LOG.isLoggable(Level.FINE) && getClass() == Property.class) {
        debugTooltip = String.format("<html><body><b>Field:</b> %s<br><b>Getter:</b> %s<br><b>Setter:</b> %s</body></html>", // NOI18N
                pp.getEstimatedField() == null
                        ? null
                        : ElementHeaders.getHeader(pp.getEstimatedField().resolve(javac), javac, ElementHeaders.NAME +
                                " : " + ElementHeaders.TYPE) + " :: " + // NOI18N
                                ((TypeElement) pp.getEstimatedField().resolve(javac).getEnclosingElement()).getQualifiedName(),
                printMethodHandleTip(getterHandle, javac),
                printMethodHandleTip(setterHandle, javac)
                );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:BiFeature.java


示例2: CreateEnumConstant

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public CreateEnumConstant(CompilationInfo info, String name, Set<Modifier> modifiers, TypeElement target, TypeMirror proposedType, FileObject targetFile) {
    this.name = name;
    this.inFQN = target.getQualifiedName().toString();
    this.cpInfo = info.getClasspathInfo();
    this.targetFile = targetFile;
    this.target = ElementHandle.create(target);
    if (proposedType.getKind() == TypeKind.NULL) {
        TypeElement tel = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
        if (tel != null) {
            proposedType = tel.asType();
            this.proposedType = TypeMirrorHandle.create(proposedType);
        } else {
            this.proposedType = null;
        }
    } else {
        this.proposedType = TypeMirrorHandle.create(proposedType);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CreateEnumConstant.java


示例3: AbstractCreateRelationshipHint

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public AbstractCreateRelationshipHint(FileObject fileObject,
        ElementHandle<TypeElement> classHandle,
        AccessType accessType,
        String localAttrName,
        String targetEntityClassName,
        String annotationClass,
        String complimentaryAnnotationClassName) {
    
    this.classHandle = classHandle;
    this.fileObject = fileObject;
    this.accessType = accessType;
    this.targetEntityClassName = targetEntityClassName;
    this.annotationClass = annotationClass;
    this.complimentaryAnnotationClassName = complimentaryAnnotationClassName;
    this.localAttrName = localAttrName;
    
    int dotPos = annotationClass.lastIndexOf('.');
    relationName = dotPos > -1 ? annotationClass.substring(dotPos+1) : annotationClass;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractCreateRelationshipHint.java


示例4: getFileObjectFromClassName

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public static FileObject getFileObjectFromClassName(String qualifiedClassName, Project project) throws IOException {
    FileObject root = findSourceRoot(project);
    ClasspathInfo cpInfo = ClasspathInfo.create(root);
    ClassIndex ci = cpInfo.getClassIndex();
    int beginIndex = qualifiedClassName.lastIndexOf('.')+1;
    String simple = qualifiedClassName.substring(beginIndex);
    Set<ElementHandle<TypeElement>> handles = ci.getDeclaredTypes(
            simple, ClassIndex.NameKind.SIMPLE_NAME, 
            Collections.singleton(ClassIndex.SearchScope.SOURCE));
    for (ElementHandle<TypeElement> handle : handles) {
        if (qualifiedClassName.equals(handle.getQualifiedName())) {
            return SourceUtils.getFile(handle, cpInfo);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SourceGroupSupport.java


示例5: getFile

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
@Override
public FileObject getFile() {
    ElementHandle<TypeElement> eh = handle;
    ClasspathInfo ci = cpInfo;
    synchronized(this) {
        if (src == null) {
            src = SourceUtils.getFile(eh, ci);
            if (src == null) {
                String resName = eh.getBinaryName().replace('.', '/').concat(".class"); // NOI18N
                src = ci.getClassPath(ClasspathInfo.PathKind.BOOT).findResource(resName);
                if (src == null) {
                    src = ci.getClassPath(ClasspathInfo.PathKind.COMPILE).findResource(resName);
                    if (src == null) {
                        src = ci.getClassPath(ClasspathInfo.PathKind.SOURCE).findResource(resName);
                    }
                }
            }
        }
        return src;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:JavacClassInfo.java


示例6: FixImport

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public FixImport(FileObject file, String fqn, ElementHandle<Element> toImport, String sortText, boolean isValid, CompilationInfo info, @NullAllowed TreePath replacePath, @NullAllowed String replaceSuffix, 
        boolean doOrganize) {
    super(file, fqn, toImport, sortText, isValid);
    if (replacePath != null) {
        this.replacePathHandle = TreePathHandle.create(replacePath, info);
        this.suffix = replaceSuffix;
        while (replacePath != null && replacePath.getLeaf().getKind() != Kind.IMPORT) {
            replacePath = replacePath.getParentPath();
        }
        this.statik = replacePath != null ? ((ImportTree) replacePath.getLeaf()).isStatic() : false;
    } else {
        this.replacePathHandle = null;
        this.suffix = null;
        this.statik = false;
    }
    this.doOrganize = doOrganize;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ImportClass.java


示例7: createItem

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
private CompletionItem createItem(ElementHandle<TypeElement> handle, int priority) {
    TypeElement el = handle.resolve(ctx.getCompilationInfo());
    if (el == null) {
        // element does not exist etc
        return null;
    }
    if (el.getKind() != ElementKind.CLASS && el.getKind() != ElementKind.ENUM) {
        // do not honour interfaces
        return null;
    }
    if (!el.getModifiers().contains(Modifier.PUBLIC)) {
        return null;
    }
    CompletionItem item = null;
    
    Collection<? extends ClassItemFactory> converters = MimeLookup.getLookup(JavaFXEditorUtils.FXML_MIME_TYPE).lookupAll(ClassItemFactory.class);
    for (ClassItemFactory converter : converters) {
        item = converter.convert(el, ctx, priority);
        if (item != null) {
            break;
        }
    }
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ClassCompleter.java


示例8: deleteSigFiles

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
private static void deleteSigFiles(final URL root, final List<? extends ElementHandle<TypeElement>> toRemove) throws IOException {
    File cacheFolder = JavaIndex.getClassFolder(root);
    if (cacheFolder.exists()) {
        if (toRemove.size() > CLEAN_ALL_LIMIT) {
            //Todo: do as SlowIOTask
            FileObjects.deleteRecursively(cacheFolder);
        } else {
            for (ElementHandle<TypeElement> eh : toRemove) {
                final StringBuilder sb = new StringBuilder(FileObjects.convertPackage2Folder(eh.getBinaryName(),File.separatorChar));
                sb.append('.'); //NOI18N
                sb.append(FileObjects.SIG);
                final File f = new File (cacheFolder, sb.toString());
                f.delete();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavaBinaryIndexer.java


示例9: analyze

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public void analyze(
        @NonNull final Iterable<? extends CompilationUnitTree> trees,
        @NonNull final JavacTaskImpl jt,
        @NonNull final CompileTuple active,
        @NonNull final Set<? super ElementHandle<TypeElement>> newTypes,
        @NonNull final Set<? super ElementHandle<ModuleElement>> newModules,
        @NonNull /*@Out*/ final boolean[] mainMethod) throws IOException {
    final SourceAnalyzerFactory.StorableAnalyzer analyzer = getSourceAnalyzer();
    assert analyzer != null;
    analyzer.analyse(trees, jt, active, newTypes, newModules, mainMethod);
    final Lookup pluginServices = getPluginServices(jt);
    for (CompilationUnitTree cu : trees) {
        for (JavaIndexerPlugin plugin : getPlugins()) {
            plugin.process(cu, active.indexable, pluginServices);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JavaParsingContext.java


示例10: findDependent

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
private static Map<URL, Set<URL>> findDependent(final URL root, final Collection<ElementHandle<TypeElement>> classes, boolean includeFilesInError) throws IOException {
    //get dependencies
    Map<URL, List<URL>> deps = IndexingController.getDefault().getRootDependencies();
    Map<URL, List<URL>> peers = IndexingController.getDefault().getRootPeers();
    //create inverse dependencies
    final Map<URL, List<URL>> inverseDeps = new HashMap<URL, List<URL>> ();
    for (Map.Entry<URL,List<URL>> entry : deps.entrySet()) {
        final URL u1 = entry.getKey();
        final List<URL> l1 = entry.getValue();
        for (URL u2 : l1) {
            List<URL> l2 = inverseDeps.get(u2);
            if (l2 == null) {
                l2 = new ArrayList<URL>();
                inverseDeps.put (u2,l2);
            }
            l2.add (u1);
        }
    }
    return findDependent(root, deps, inverseDeps, peers, classes, includeFilesInError, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaCustomIndexer.java


示例11: getTypeReferenceCount

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
/**
 * Returns an estimate of a number of classes on given source path (source root) which are
 * using given type.
 * @param type the type type to find the usage frequency for.
 * @return number of classes using the type.
 */
public int getTypeReferenceCount(@NonNull final ElementHandle<? extends TypeElement> type) {
    Parameters.notNull("binaryName", type);   //NOI18N
    if (!type.getKind().isClass() &&
        !type.getKind().isInterface() &&
         type.getKind() != ElementKind.OTHER) {
        throw new IllegalArgumentException(type.toString());
    }
    try {
        init();
        final Integer count = typeFreqs.get(SourceUtils.getJVMSignature(type)[0]);
        return count == null ? 0 : count;
    } catch (InterruptedException ie) {
        return 0;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ReferencesCount.java


示例12: addOccurrences

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public void addOccurrences(List<Occurrence> result) throws BadLocationException {
    Collection<ElementHandle<ExecutableElement>> methodHandles = renamedProperty.getMethodHandles();
    Collection<ExecutableElement> methods = JavaUtils.getMethodsFromHandles(cc, methodHandles);

    List<SpringBean> beans = docAccess.getSpringBeans().getFileBeans(docAccess.getFileObject()).getBeans();
    for (SpringBean bean : beans) {
        Set<SpringBeanProperty> properties = bean.getProperties();
        if (properties.isEmpty()) {
            continue;
        }

        // resolve bean's class
        String className = new BeanClassFinder(bean, docAccess.getFileObject()).findImplementationClass(false);
        if (className == null) {
            continue;
        }
        TypeElement beanTypeElement = JavaUtils.findClassElementByBinaryName(className, cc);
        if (beanTypeElement == null) {
            continue;
        }

        for (SpringBeanProperty property : properties) {
            processPropertyOccurrence(property, bean, beanTypeElement, methods, result);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PropertyRefFinder.java


示例13: 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


示例14: findMethod

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
@NbBundle.Messages("JavaUtils.title.method.searching=Searching Method")
public static ElementHandle<ExecutableElement> findMethod(FileObject fileObject, final String classBinName,
        final String methodName, int argCount, Public publicFlag, Static staticFlag) {
    JavaSource js = JavaUtils.getJavaSource(fileObject);
    if (js != null) {
        MethodFinder methodFinder = new MethodFinder(js, classBinName, methodName, argCount, publicFlag, staticFlag);
        methodFinder.runAsUserTask();
        if (methodFinder.getMethodHandle() == null && SourceUtils.isScanInProgress()) {
            if (!ScanDialog.runWhenScanFinished(methodFinder, Bundle.JavaUtils_title_method_searching())) {
                return methodFinder.getMethodHandle();
            } else {
                return null;
            }
        } else {
            return methodFinder.getMethodHandle();
        }
    }

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


示例15: findSource

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
@CheckForNull
private static FileObject findSource(
        @NonNull final FileObject file,
        @NonNull final ElementHandle<?> elementHandle) {
    FileObject owner = null;
    for (String id : new String[] {
            ClassPath.EXECUTE,
            ClassPath.COMPILE,
            ClassPath.BOOT}) {
        final ClassPath cp = ClassPath.getClassPath(file, id);
        if (cp != null) {
            owner = cp.findOwnerRoot(file);
            if (owner != null) {
                break;
            }
        }
    }
    return owner == null ?
        owner :
        SourceUtils.getFile(
            elementHandle,
            ClasspathInfo.create(
                ClassPathSupport.createClassPath(owner),
                ClassPath.EMPTY,
                ClassPath.EMPTY));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:OpenAction.java


示例16: MethodItem

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
public MethodItem(int substitutionOffset, ExecutableElement element, boolean isInherited, boolean isDeprecated) {
    super(substitutionOffset);
    this.elementHandle = ElementHandle.create(element);
    this.isDeprecated = isDeprecated;
    this.isInherited = isInherited;
    this.simpleName = element.getSimpleName().toString();
    this.modifiers = element.getModifiers();
    this.params = new ArrayList<ParamDesc>();
    Iterator<? extends VariableElement> it = element.getParameters().iterator();
    Iterator<? extends TypeMirror> tIt = ((ExecutableType) element.asType()).getParameterTypes().iterator();
    while(it.hasNext() && tIt.hasNext()) {
        TypeMirror tm = tIt.next();
        this.params.add(new ParamDesc(tm.toString(), getTypeName(tm, false, element.isVarArgs() && !tIt.hasNext()).toString(), it.next().getSimpleName().toString()));
    }
    TypeMirror retType = element.getReturnType();

    this.typeName = getTypeName(retType, false).toString();
    this.isPrimitive = retType.getKind().isPrimitive() || retType.getKind() == TypeKind.VOID;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SpringXMLConfigCompletionItem.java


示例17: initClassesModel

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
private void initClassesModel (final Collection<ElementHandle<TypeElement>> mainClasses) {
    final List<ElementHandle<TypeElement>> sortedMainClasses = new ArrayList<ElementHandle<TypeElement>>(mainClasses);
    Collections.sort(sortedMainClasses, new MainClassComparator());
    possibleMainClasses = mainClasses;
    jMainClassList.setListData(sortedMainClasses.toArray());
    jMainClassList.setSelectedIndex (0);
    scanningLabel.setVisible(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MainClassChooser.java


示例18: getSelectedMainClass

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
/** Returns the selected main class.
 *
 * @return name of class or null if no class with the main method is selected
 */    
public String getSelectedMainClass () {
    if (isValidMainClassName (jMainClassList.getSelectedValue ())) {
        return ((ElementHandle)jMainClassList.getSelectedValue()).getQualifiedName();
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:MainClassChooser.java


示例19: JavaTypeDescription

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
JavaTypeDescription(
        @NonNull final JavaTypeProvider.CacheItem cacheItem,
        @NonNull final ElementHandle<TypeElement> handle) {
   this.cacheItem = cacheItem;
   this.handle = handle;
   init();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:JavaTypeDescription.java


示例20: visitNewClass

import org.netbeans.api.java.source.ElementHandle; //导入依赖的package包/类
@Override
public Void visitNewClass(NewClassTree node, Map<Tree,WhiteListQuery.Result> p) {
    final Element e = trees.getElement(getCurrentPath());
    final WhiteListQuery.Result res;
    if (e != null && !(res=whiteList.check(ElementHandle.create(e),WhiteListQuery.Operation.USAGE)).isAllowed()) {
        p.put(node,res);
    }
    scan(node.getTypeArguments(), p);
    scan(node.getArguments(), p);
    scan(node.getClassBody(), p);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:WhiteListSupport.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RC564Engine类代码示例发布时间:2022-05-22
下一篇:
Java EdgeLabelRenderer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap