protected static boolean isDelegatedRefactoring(AbstractRefactoring abstractRefactoring) { return abstractRefactoring.getContext().lookup(DelegatedRefactoring.class) != null; } }
@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; }
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]; } }
CsmProject[] prjs = refactoring.getContext().lookup(CsmProject[].class); if (prjs != null && prjs.length != 0) { for (CsmReference csmReference : refs) {
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) {
private void initRefactorings(Collection<EncapsulateFieldInfo> refactorFields, Set<CsmVisibility> methodModifier, Set<CsmVisibility> fieldModifier, boolean alwaysUseAccessors, boolean methodInline) { refactorings = new ArrayList<EncapsulateFieldRefactoringPlugin>(refactorFields.size()); CsmFile[] declDefFiles = null; for (EncapsulateFieldInfo info : refactorFields) { if (declDefFiles == null) { declDefFiles = GeneratorUtils.getDeclarationDefinitionFiles(info.getField().getContainingClass()); } EncapsulateFieldRefactoring ref = new EncapsulateFieldRefactoring(info.getField(), declDefFiles[0], declDefFiles[1]); ref.setGetterName(info.getGetterName()); ref.setSetterName(info.getSetterName()); ref.setMethodModifiers(methodModifier); ref.setFieldModifiers(fieldModifier); ref.setAlwaysUseAccessors(alwaysUseAccessors); ref.setMethodInline(methodInline); ref.setDefaultGetter(info.getDefaultGetter()); ref.setDefaultSetter(info.getDefaultSetter()); ref.getContext().add(refactoring.getContext().lookup(InsertPoint.class)); ref.getContext().add(refactoring.getContext().lookup(Documentation.class)); ref.getContext().add(refactoring.getContext().lookup(SortBy.class)); refactorings.add(new EncapsulateFieldRefactoringPlugin(ref)); } }
@Override protected void processFile(CsmFile csmFile, ModificationResult mr, AtomicReference<Problem> outProblem) { InsertPoint insPt = refactoring.getContext().lookup(InsertPoint.class); CsmField field = refactoring.getSourceField(); CsmFile classDeclarationFile = refactoring.getClassDeclarationFile();