protected Context getContext() { return abstractRefactoring.getContext(); }
protected static boolean isDelegatedRefactoring(AbstractRefactoring abstractRefactoring) { return abstractRefactoring.getContext().lookup(DelegatedRefactoring.class) != null; } }
protected CsmModificationRefactoringPlugin(AbstractRefactoring refactoring) { this.refactoring = refactoring; this.startReferenceObject = refactoring.getRefactoringSource().lookup(CsmObject.class); this.editorContext = refactoring.getRefactoringSource().lookup(CsmContext.class); assert startReferenceObject != null || editorContext != null: "no start reference or editor context"; modificationHooks = new ArrayList<CheckModificationHook>(refactoring.getContext().lookupAll(CheckModificationHook.class)); if (modificationHooks.isEmpty()) { modificationHooks.add(new DefaultHookImpl()); } }
@Override public GuardedBlockHandler createInstance(AbstractRefactoring refactoring) { RefactoringInfo refInfo = refactoring.getContext().lookup(RefactoringInfo.class); return new GuardedBlockHandlerImpl(refInfo); }
public GuardedBlockHandler createInstance(AbstractRefactoring refactoring) { /* * It is unknown for me why custom refactoring InstaceRenameRefactoring * is not passed here as argument ( never I mean ). * Instead of InstaceRenameRefactoring refactoring engine * passes here delegate refactoring instances . In my case * this is two RenameRefactoring ( if accessor is also refactored ). * So I changed code to support RenameRefactoring with special Context. if ( refactoring instanceof InstaceRenameRefactoring ){ return new GuardedBlockHandlerImpl( (InstaceRenameRefactoring) refactoring ); }*/ if ( refactoring instanceof RenameRefactoring && refactoring.getContext().lookup( InstaceRenameRefactoring.RefactoringInfo.class )!= null ) { return new GuardedBlockHandlerImpl( refactoring ); } return null; }
RenameRefactoringUI(NonRecursiveFolder jmiObject, String newName) { this.refactoring = new RenameRefactoring(Lookups.singleton(jmiObject)); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(jmiObject.getFolder()); // if (classpath != null) { // refactoring.getContext().add(classpath); // } //this.jmiObject = jmiObject; oldName = newName; //[FIXME] this should be oldName of refactored object this.dispOldName = newName; fromListener = true; pkgRename = true; // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
public static Element resolveElement(final AbstractRefactoring refactoring, final TreePathHandle treePathHandle) { final ClasspathInfo cpInfo = refactoring.getContext().lookup(ClasspathInfo.class); final Element[] element = new Element[1]; JavaSource source = JavaSource.create(cpInfo, new FileObject[]{treePathHandle.getFileObject()}); try { source.runUserActionTask(new Task<CompilationController>() { @Override public void run(CompilationController info) throws Exception { info.toPhase(JavaSource.Phase.RESOLVED); element[0] = treePathHandle.resolveElement(info); } }, true); } catch (IOException exception) { LOGGER.log(Level.WARNING, "Exception by refactoring:", exception); //NOI18NN } return element[0]; } }
@Override public final void run() { CsmObject ctx = CsmRefactoringUtils.findContextObject(context); if (!CsmRefactoringUtils.isSupportedReference(ctx)) { return; } ui = createRefactoringUI(ctx); Collection<? extends CheckModificationHook> hooks = context.lookupAll(CheckModificationHook.class); for (CheckModificationHook hook : hooks) { ui.getRefactoring().getContext().add(hook); } if (ui != null) { openRefactoringUI(ui); } else { JOptionPane.showMessageDialog(null, NbBundle.getMessage(RefactoringActionsProvider.class, "ERR_CannotRefactorLoc")); } }
public RenameRefactoringUI(NonRecursiveFolder file) { this.refactoring = new RenameRefactoring(Lookups.singleton(file)); oldName = RetoucheUtils.getPackageName(file.getFolder()); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(file.getFolder()); // if (classpath != null) { // refactoring.getContext().add(classpath); // } dispOldName = oldName; pkgRename = true; //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
public RenameRefactoringUI(JsElementCtx handle) { this.jmiObject = handle; stripPrefix = handle.getStripPrefix(); this.refactoring = new RenameRefactoring(Lookups.singleton(handle)); //oldName = handle.resolveElement(info).getSimpleName().toString(); oldName = handle.getSimpleName(); // XXX: parsingapi // ClasspathInfo classpath = RetoucheUtils.getClasspathInfoFor(handle); // if (classpath != null) { // refactoring.getContext().add(classpath); // } dispOldName = oldName; //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
RenameRefactoringUI(FileObject jmiObject, String newName, JsElementCtx handle) { if (handle!=null) { this.refactoring = new RenameRefactoring(Lookups.fixed(jmiObject, handle)); } else { this.refactoring = new RenameRefactoring(Lookups.fixed(jmiObject)); } //this.jmiObject = jmiObject; oldName = newName; //[FIXME] this should be oldName of refactored object this.dispOldName = newName; // XXX: parsingapi // ClasspathInfo cpInfo = handle==null?RetoucheUtils.getClasspathInfoFor(jmiObject):RetoucheUtils.getClasspathInfoFor(handle); // if (cpInfo != null) { // refactoring.getContext().add(cpInfo); // } fromListener = true; // Force refresh! this.refactoring.getContext().add(true); }
String[] oldNames = nameList.toArray(new String[nameList.size()]); RefactoringInfo refInfo = new RefactoringInfo(refactoring, changeType, originalFiles, oldNames); refactoring.getContext().add(refInfo); // to be accessible to the GuardedBlockHandlerFactoryImpl return new RefactoringPluginImpl(refInfo);
public RenameRefactoringUI(FileObject file, JsElementCtx handle) { if (handle!=null) { jmiObject = handle; this.refactoring = new RenameRefactoring(Lookups.fixed(file, handle)); //oldName = jmiObject.resolveElement(info).getSimpleName().toString(); oldName = jmiObject.getSimpleName(); } else { this.refactoring = new RenameRefactoring(Lookups.fixed(file)); oldName = file.getName(); } dispOldName = oldName; // XXX: parsingapi // ClasspathInfo cpInfo = handle==null?RetoucheUtils.getClasspathInfoFor(file):RetoucheUtils.getClasspathInfoFor(handle); // if (cpInfo != null) { // refactoring.getContext().add(cpInfo); // } //this(jmiObject, (FileObject) null, true); // Force refresh! this.refactoring.getContext().add(UI.Constants.REQUEST_PREVIEW); }
Collection<CsmFile> relevantFiles = new HashSet<CsmFile>(); Collection<CsmProject> relevantPrjs = new HashSet<CsmProject>(); CsmProject[] prjs = refactoring.getContext().lookup(CsmProject[].class); CsmFile declFile = CsmRefactoringUtils.getCsmFile(referencedObject); if (prjs == null || prjs.length == 0 || declFile == null) {