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


Java AbstractRefactoring类代码示例

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


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

示例1: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {

    FileObject targetFile = refactoring.getRefactoringSource().lookup(FileObject.class);
    NonRecursiveFolder pkg = refactoring.getRefactoringSource().lookup(NonRecursiveFolder.class);
    TreePathHandle handle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);

    boolean folder = targetFile != null && targetFile.isFolder();
    boolean javaPackage = pkg != null && RefactoringUtil.isOnSourceClasspath(pkg.getFolder());
    boolean javaFile = targetFile != null && RefactoringUtil.isJavaFile(targetFile);
    boolean javaMember = handle != null;

    if (refactoring instanceof RenameRefactoring) {
        RenameRefactoring rename = (RenameRefactoring) refactoring;
        if (!javaFile && !(javaPackage || folder) && javaMember) {
            return new RelationshipMappingRename(rename);
        }
    } else if (refactoring instanceof WhereUsedQuery) {
        WhereUsedQuery whereUsedQuery = (WhereUsedQuery) refactoring;
        return new RelationshipMappingWhereUsed(whereUsedQuery);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:RelationshipMappingRefactoringFactory.java

示例2: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
    return new RefactoringPlugin() {
        @Override public Problem preCheck() { return null; }
        @Override
        public Problem checkParameters() { return null; }

        @Override
        public Problem fastCheckParameters() { return null; }

        @Override
        public void cancelRequest() { endTransaction(); }

        @Override
        public Problem prepare(RefactoringElementsBag refactoringElements) {
            beginTransaction();
            return null;
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ElementOverlay.java

示例3: createAndAddElements

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
protected final Problem createAndAddElements(Set<FileObject> files, CancellableTask<WorkingCopy> task, RefactoringElementsBag elements, AbstractRefactoring refactoring, ClasspathInfo info) {
    try {
        final Collection<ModificationResult> results = processFiles(files, task, info);
        elements.registerTransaction(createTransaction(results));
        for (ModificationResult result:results) {
            for (FileObject jfo : result.getModifiedFileObjects()) {
                for (Difference dif: result.getDifferences(jfo)) {
                        elements.add(refactoring,DiffElement.create(dif, jfo, result));
                }
            }
        }
    } catch (IOException e) {
        return createProblemAndLog(null, e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:JavaRefactoringPlugin.java

示例4: getClasspathInfo

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
protected ClasspathInfo getClasspathInfo(AbstractRefactoring refactoring) {
    List<TreePathHandle> handles = new ArrayList<TreePathHandle>(refactoring.getRefactoringSource().lookupAll(TreePathHandle.class));
    Lookup targetLookup = this.refactoring.getTarget();
    if(targetLookup != null) {
        TreePathHandle target = targetLookup.lookup(TreePathHandle.class);
        if(target != null) {
            handles.add(target);
        }
    }
    ClasspathInfo cpInfo;
    if (!handles.isEmpty()) {
        cpInfo = RefactoringUtils.getClasspathInfoFor(handles.toArray(new TreePathHandle[handles.size()]));
    } else {
        cpInfo = JavaRefactoringUtils.getClasspathInfoFor((FileObject)properties.getPreSelectedMembers()[0].getFileObject());
    }
    refactoring.getContext().add(cpInfo);
    return cpInfo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MoveMembersRefactoringPlugin.java

示例5: preCheck

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
protected Problem preCheck(CompilationController info) throws IOException {
    fireProgressListenerStart(AbstractRefactoring.PRE_CHECK, 4);
    Problem preCheckProblem = null;
    info.toPhase(JavaSource.Phase.RESOLVED);
    preCheckProblem = isElementAvail(treePathHandle, info);
    if (preCheckProblem != null) {
        return preCheckProblem;
    }
    Element el = treePathHandle.resolveElement(info);
    if (!(el.getKind() == ElementKind.CLASS || el.getKind() == ElementKind.INTERFACE)) {
        preCheckProblem = createProblem(preCheckProblem, true, NbBundle.getMessage(IntroduceLocalExtensionPlugin.class, "ERR_IntroduceLEWrongType")); // NOI18N
        return preCheckProblem;
    }
    for (Element element : el.getEnclosedElements()) {
        if((element.getKind().isClass() || element.getKind().isInterface()) && !element.getModifiers().contains(Modifier.PRIVATE)) {
            preCheckProblem = createProblem(preCheckProblem, true, NbBundle.getMessage(IntroduceLocalExtensionPlugin.class, "ERR_IntroduceLEInnerType")); // NOI18N
            return preCheckProblem;
        }
    }
    return preCheckProblem;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:IntroduceLocalExtensionPlugin.java

示例6: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
   public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
if (refactoring instanceof RenameRefactoring) {
    if (null != refactoring.getRefactoringSource().lookup(CssElementContext.class)) {
	return new CssRenameRefactoringPlugin((RenameRefactoring)refactoring);
    } else {
               //folder refactoring
               FileObject file = refactoring.getRefactoringSource().lookup(FileObject.class);
               if(file != null && file.isFolder()) {
                   return new CssRenameRefactoringPlugin((RenameRefactoring)refactoring);
               }
           }
} else if(refactoring instanceof WhereUsedQuery) {
           if (null != refactoring.getRefactoringSource().lookup(CssElementContext.class)) {
               return new CssWhereUsedQueryPlugin((WhereUsedQuery)refactoring);
           }
       }

return null;

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

示例7: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
    public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
	if (refactoring instanceof RenameRefactoring) {
	    if (null != refactoring.getRefactoringSource().lookup(RefactoringElementContext.class)) {
		return new CPRenameRefactoringPlugin((RenameRefactoring)refactoring);
	    } else {
                //folder refactoring - not yet supported
//                FileObject file = refactoring.getRefactoringSource().lookup(FileObject.class);
//                if(file != null && file.isFolder()) {
//                    return new CPRenameRefactoringPlugin((RenameRefactoring)refactoring);
//                }
            }
	} else if(refactoring instanceof WhereUsedQuery) {
            if (null != refactoring.getRefactoringSource().lookup(RefactoringElementContext.class)) {
                return new CPWhereUsedQueryPlugin((WhereUsedQuery)refactoring);
            }
        }

	return null;

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

示例8: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
    
    if (refactoring instanceof WhereUsedQuery) {
        if (isMappingFile(refactoring)) {
            return new HibernateMappingFindUsagesPlugin((WhereUsedQuery)refactoring);
        } else {
            return new HibernateFindUsagesPlugin((WhereUsedQuery) refactoring);
        }
    } else if (refactoring instanceof RenameRefactoring) {
        if (isMappingFile(refactoring)) {
            return new HibernateMappingRenamePlugin((RenameRefactoring) refactoring);
        } else {
            return new HibernateRenamePlugin((RenameRefactoring) refactoring);
        }
    } else if (refactoring instanceof MoveRefactoring) {
        if (isMappingFile(refactoring)) {
            return new HibernateMappingMovePlugin((MoveRefactoring)refactoring);
            
        } else {
            return new HibernateMovePlugin((MoveRefactoring) refactoring);
        }
    }

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

示例9: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
    
    FileObject targetFile = refactoring.getRefactoringSource().lookup(FileObject.class);
    NonRecursiveFolder pkg = refactoring.getRefactoringSource().lookup(NonRecursiveFolder.class);
    TreePathHandle handle = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
    
    boolean folder = targetFile != null && targetFile.isFolder();
    boolean javaPackage = pkg != null && RefactoringUtil.isOnSourceClasspath(pkg.getFolder());
    boolean javaFile = targetFile != null && RefactoringUtil.isJavaFile(targetFile);
    boolean javaMember = handle != null;
    
    if (refactoring instanceof RenameRefactoring) {
        RenameRefactoring rename = (RenameRefactoring) refactoring;
        if (javaFile){
            return new PersistenceXmlRename(rename);
        } else if (javaPackage || folder){
            return new PersistenceXmlPackageRename(rename);
        } else if (javaMember){
            return new EntityRename(rename);
        }
    } else if (refactoring instanceof MoveRefactoring) {
        MoveRefactoring move = (MoveRefactoring) refactoring;
        return new PersistenceXmlMoveClass(move);
    } else if (refactoring instanceof SafeDeleteRefactoring) {
        SafeDeleteRefactoring safeDeleteRefactoring = (SafeDeleteRefactoring) refactoring;
        return new PersistenceXmlSafeDelete(safeDeleteRefactoring);
    } else if (refactoring instanceof WhereUsedQuery) {
        WhereUsedQuery whereUsedQuery = (WhereUsedQuery) refactoring;
        return new PersistenceXmlWhereUsed(whereUsedQuery);
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:JPARefactoringFactory.java

示例10: resolveTreePathHandle

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
/**
 * Resolves the TreePathHandle for the given refactoring.
 * @param refactoring the refactoring.
 * @return the TreePathHandle or null if no handle could be resolved.
 */
public static TreePathHandle resolveTreePathHandle(AbstractRefactoring refactoring) throws IOException {
    Parameters.notNull("refactoring", refactoring); //NO18N
    
    TreePathHandle tph = refactoring.getRefactoringSource().lookup(TreePathHandle.class);
    if (tph != null) {
        return tph;
    }
    
    final TreePathHandle[] result = new TreePathHandle[1];
    JavaSource source = JavaSource.forFileObject(refactoring.getRefactoringSource().lookup(FileObject.class));
    
    source.runUserActionTask(new CancellableTask<CompilationController>() {
        @Override
        public void cancel() {
        }
        @Override
        public void run(CompilationController co) throws Exception {
            co.toPhase(JavaSource.Phase.RESOLVED);
            CompilationUnitTree cut = co.getCompilationUnit();
            result[0] = TreePathHandle.create(TreePath.getPath(cut, cut.getTypeDecls().get(0)), co);
        }
        
    }, true);
    
    return result[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:RefactoringUtil.java

示例11: isMappingFile

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
public static boolean isMappingFile(AbstractRefactoring refactoring) {
    Lookup refactoringSource = refactoring.getRefactoringSource();
    FileObject fileObject = refactoringSource.lookup(FileObject.class);
    if (fileObject != null &&
            fileObject.getMIMEType().equals(HibernateMappingDataLoader.REQUIRED_MIME)) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:HibernateRefactoringPluginFactory.java

示例12: getRefactoring

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@Override
public AbstractRefactoring getRefactoring() {
    switch (kind) {
        case MOVE: return new MoveRefactoring(l);
        case RENAME: return new RenameRefactoring(l);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ActionInvocationTest.java

示例13: setUpClass

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
    MockLookup.setInstances(new RefactoringPluginFactory() {

        @Override
        public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
            return new FilesCopyPlugin(refactoring);
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FilesCopyPluginTest.java

示例14: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的package包/类
public RefactoringPlugin createInstance(AbstractRefactoring refactoring) {
    if (refactoring instanceof WhereUsedQuery) {
        return new SpringFindUsagesPlugin((WhereUsedQuery) refactoring);
    } else if (refactoring instanceof RenameRefactoring) {
        return new SpringRenamePlugin((RenameRefactoring)refactoring);
    } else if (refactoring instanceof MoveRefactoring) {
        return new SpringMovePlugin((MoveRefactoring)refactoring);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SpringBeansRefactoringPluginFactory.java

示例15: createInstance

import org.netbeans.modules.refactoring.api.AbstractRefactoring; //导入依赖的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


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