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


Java TreePathHandle.getKind方法代码示例

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


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

示例1: prepare

import org.netbeans.api.java.source.TreePathHandle; //导入方法依赖的package包/类
public Problem prepare(RefactoringElementsBag refactoringElements) {
    TreePathHandle treePathHandle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);

    if (treePathHandle != null && treePathHandle.getKind() == Kind.METHOD) {
        return prepareMethodRefactoring(refactoringElements, treePathHandle);
    }

    return prepareClassRefactoring(refactoringElements, treePathHandle);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:SpringRenamePlugin.java

示例2: prepare

import org.netbeans.api.java.source.TreePathHandle; //导入方法依赖的package包/类
public Problem prepare(RefactoringElementsBag refactoringElementsBag) {
    if (!refactoring.getBooleanValue(WhereUsedQuery.FIND_REFERENCES)) {
        return null;
    }
    final TreePathHandle treePathHandle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
    if (treePathHandle != null && treePathHandle.getKind() == Kind.METHOD) {
        return prepareMethodRefactoring(refactoringElementsBag, treePathHandle);
    }
    
    if (treePathHandle != null && TreeUtilities.CLASS_TREE_KINDS.contains(treePathHandle.getKind())) {
        return prepareClassRefactoring(refactoringElementsBag, treePathHandle);
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:SpringFindUsagesPlugin.java

示例3: createInstance

import org.netbeans.api.java.source.TreePathHandle; //导入方法依赖的package包/类
@Override public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
    if (!(refactoring instanceof WhereUsedQuery)) {
        return null;
    }
    TreePathHandle handle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
    if (handle == null) {
        return null;
    }
    Tree.Kind kind = handle.getKind();
    if (TreeUtilities.CLASS_TREE_KINDS.contains(kind) || kind == Tree.Kind.IDENTIFIER || kind == Tree.Kind.MEMBER_SELECT) {
        FileObject fo = handle.getFileObject();
        Project p = FileOwnerQuery.getOwner(fo);
        if (p == null) {
            FileObject root = FileUtil.getArchiveFile(fo);
            if (root != null && root.getNameExt().endsWith("-sources.jar")) {
                LOG.log(Level.FINE, "considering usages from {0} in a Maven binary artifact", fo.toURI());
                return new MavenRefactoringPlugin((WhereUsedQuery) refactoring, handle);
            } else {
                LOG.log(Level.FINE, "binary file of no particular interest: {0}", fo.toURI());
                return null;
            }
        } else if (p.getLookup().lookup(NbMavenProject.class) != null) {
            LOG.log(Level.FINE, "considering usages from {0} in a Maven project", fo.toURI());
            return new MavenRefactoringPlugin((WhereUsedQuery) refactoring, handle);
        } else {
            LOG.log(Level.FINE, "not in a Maven project: {0}", fo.toURI());
            return null;
        }
    } else {
        LOG.log(Level.FINE, "ignoring {0} of kind {1}", new Object[] {handle, kind});
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:MavenRefactoringPluginFactory.java

示例4: prepare

import org.netbeans.api.java.source.TreePathHandle; //导入方法依赖的package包/类
public Problem prepare(RefactoringElementsBag refactoringElements) {
    final TreePathHandle treePathHandle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
    FileObject fo = null;
    if (treePathHandle != null &&
            (TreeUtilities.CLASS_TREE_KINDS.contains(treePathHandle.getKind()) ||
            treePathHandle.getKind() == Kind.VARIABLE ||
            treePathHandle.getKind() == Kind.MEMBER_SELECT ||
            treePathHandle.getKind() == Kind.IDENTIFIER)) {
        fo = treePathHandle.getFileObject();
    }
    if (fo == null) {
        fo = refactoring.getRefactoringSource().lookup(FileObject.class);
    }
    boolean recursive = true;
    if (fo == null) {
        NonRecursiveFolder folder = refactoring.getRefactoringSource().lookup(NonRecursiveFolder.class);
        if (folder != null) {
            recursive = false;
            fo = folder.getFolder();
        }
    }
    if (fo == null) {
        return null;
    }

    // Find the mapping files in this project
    Project proj = org.netbeans.api.project.FileOwnerQuery.getOwner(fo);
    if(proj == null){
        //file is not part of any project
        return null;
    }
    HibernateEnvironment env = proj.getLookup().lookup(HibernateEnvironment.class);
    if (env == null) {
        // The project does not support Hibernate framework
        return null;
    }
    mFileObjs = env.getAllHibernateMappingFileObjects();
    if (mFileObjs == null || mFileObjs.size() == 0) {
        // OK, no mapping files at all. 
        return null;
    }

    try {
        if (treePathHandle != null) {
            if (TreeUtilities.CLASS_TREE_KINDS.contains(treePathHandle.getKind())) {
                // A Java class is being renamed
                renameJavaClass(refactoringElements, treePathHandle, fo);
            } else if (treePathHandle.getKind() == Kind.VARIABLE ||
                    treePathHandle.getKind() == Kind.MEMBER_SELECT ||
                    treePathHandle.getKind() == Kind.IDENTIFIER) {
                // A Java field is being renamed
                renameJavaField(refactoringElements, treePathHandle, fo);
            }
        } else if (fo.isFolder()) {
            // A Java package is being renamed
            renameJavaPackage(refactoringElements, treePathHandle, fo, recursive);
        }
    } catch (IOException ex) {
        ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:HibernateRenamePlugin.java

示例5: prepare

import org.netbeans.api.java.source.TreePathHandle; //导入方法依赖的package包/类
public Problem prepare(RefactoringElementsBag refactoringElements) {

        if (query.getBooleanValue(WhereUsedQuery.FIND_REFERENCES)) {

            final TreePathHandle treePathHandle = query.getRefactoringSource().lookup(TreePathHandle.class);
            FileObject fo = null;
            if (treePathHandle != null &&
                    (TreeUtilities.CLASS_TREE_KINDS.contains(treePathHandle.getKind()) ||
                    treePathHandle.getKind() == Kind.VARIABLE ||
                    treePathHandle.getKind() == Kind.MEMBER_SELECT ||
                    treePathHandle.getKind() == Kind.IDENTIFIER)) {

                fo = treePathHandle.getFileObject();
            }

            if (fo == null) {
                // TODO: return a Problem
                return null;
            }

            // Find the mapping files in this project
            Project proj = org.netbeans.api.project.FileOwnerQuery.getOwner(fo);
            if(proj == null) {
                // See issue 141117
                return null;
            }
            HibernateEnvironment env = proj.getLookup().lookup(HibernateEnvironment.class);
            if(env == null) {
                // The project does not have Hibernate framework support
                return null;
            }
            mappingFileObjs = env.getAllHibernateMappingFileObjects();
            if (mappingFileObjs == null || mappingFileObjs.size() == 0) {
                // OK, no mapping files at all. 
                return null;
            }

            try {
                if (treePathHandle != null) {
                    if (TreeUtilities.CLASS_TREE_KINDS.contains(treePathHandle.getKind())) {
                        findJavaClassUsage(treePathHandle, refactoringElements, fo);
                    } else /*if (treePathHandle.getKind() == Kind.VARIABLE ||
                            treePathHandle.getKind() == Kind.MEMBER_SELECT ||
                            treePathHandle.getKind() == Kind.IDENTIFIER)*/ {
                        findJavaClassFieldUsage(treePathHandle, refactoringElements, fo);

                    }
                }
            } catch (IOException ex) {
                ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, ex);
            }
        }

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


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