本文整理汇总了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;
}
示例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;
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}
示例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);
}
});
}
示例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;
}
示例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;
}
}