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


Java RefactoringElementsBag类代码示例

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


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

示例1: doPrepare

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
/**
 * Prepares the rename.
 *
 * @param refactoringElementsBag
 * @param folder the folder or package to be renamed.
 * @param oldName the old FQN of the folder / package.
 * @param newName the new FQN of the folder / package.
 */
private Problem doPrepare(RefactoringElementsBag refactoringElementsBag, FileObject folder, String oldName, String newName){
    Problem result = null;
    
    for (FileObject each : getPersistenceXmls(folder)){
        try {
            PUDataObject pUDataObject = ProviderUtil.getPUDataObject(each);
            for (String clazz : getClasses(folder, new ArrayList<String>())){
                List<PersistenceUnit> punits = getAffectedPersistenceUnits(pUDataObject, clazz);
                String newClassName = clazz.replace(oldName, newName);
                for (PersistenceUnit persistenceUnit : punits) {
                    refactoringElementsBag.add(getRefactoring(),
                            new PersistenceXmlPackageRenameRefactoringElement(persistenceUnit, clazz, newClassName, pUDataObject, each));
                }
            }
        } catch (InvalidPersistenceXmlException ex) {
            Problem newProblem =
                    new Problem(false, NbBundle.getMessage(PersistenceXmlRefactoring.class, "TXT_PersistenceXmlInvalidProblem", ex.getPath()));
            
            result = RefactoringUtil.addToEnd(newProblem, result);
        }
    }
    return result;
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:PersistenceXmlPackageRename.java

示例2: prepare

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
@Override
public Problem prepare(RefactoringElementsBag refactoringElementsBag) {

    MetadataModel<EntityMappingsMetadata> emModel = getEntityMappingsModel();
    if (emModel == null) {
        return null;
    }

    EntityAssociationResolver resolver = new EntityAssociationResolver(treePathHandle, emModel);
    try {
        List<EntityAnnotationReference> references = resolver.resolveReferences();
        for (EntityAnnotationReference ref : references) {
            EntityRenameElement element = new EntityRenameElement(ref, rename);
            refactoringElementsBag.add(rename, element);
        }
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:EntityRename.java

示例3: preparePackageDelete

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
private Problem preparePackageDelete(NonRecursiveFolder folder, RefactoringElementsBag refactoringElements) {
    DataFolder dataFolder = DataFolder.findFolder(folder.getFolder());
    // First; delete all files except packages
    DataObject children[] = dataFolder.getChildren();
    boolean empty = true;
    for( int i = 0; children != null && i < children.length; i++ ) {
        FileObject fileObject = children[i].getPrimaryFile();
        if ( !fileObject.isFolder() ) {
            refactoringElements.addFileChange(refactoring, new DeleteFile(fileObject, refactoringElements));
        }
        else {
            empty = false;
        }
    }

    // If empty delete itself
    if ( empty ) {
        refactoringElements.addFileChange(refactoring, new PackageDeleteElem(folder));
    }
        
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PackageDeleteRefactoringPlugin.java

示例4: createInstance

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

示例5: checkMethodLayer

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
protected final Problem checkMethodLayer(InfoHolder info, FileObject fo, RefactoringElementsBag refactoringElements) {
    Problem problem = null;
    // do our check just on static methods
    // #167439: o.n.core.startup.layers.BinaryFS explicitly allows for private methods
    if (!info.isStatic) {
        return problem;
    }
    // with no parameters or with parameter of type FileObject
    if (!info.hasFileObjectParam && !info.hasNoParams) {
        return problem;
    }
    Project project = FileOwnerQuery.getOwner(fo);
    if (project != null) {
        LayerHandle handle = LayerHandle.forProject(project);
        FileSystem fs = handle.layer(false);
        if (fs != null) {
            checkFileObject(fs.getRoot(), info.name, null, info.fullName, refactoringElements, handle);
        }
    }
    return problem;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AbstractRefactoringPlugin.java

示例6: checkConstructorLayer

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
protected final Problem checkConstructorLayer(InfoHolder info, FileObject fo, RefactoringElementsBag refactoringElements) {
    Problem problem = null;
    // just consider public constructors with no params..
    if (!info.isPublic || !info.hasNoParams) {
        return problem;
    }
    Project project = FileOwnerQuery.getOwner(fo);
    if (project != null) {
        LayerHandle handle = LayerHandle.forProject(project);
        FileSystem fs = handle.layer(false);
        if (fs != null) {
            checkFileObject(fs.getRoot(), null, info.name, info.fullName, refactoringElements, handle);
        }
    }
    return problem;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AbstractRefactoringPlugin.java

示例7: createAndAddElements

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

示例8: prepare

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
@Override
public Problem prepare(RefactoringElementsBag reb) {
    if (!isRenameTestClass() && !isRenameTestClassMethod()) {
        return null;
    }
    initDelegates();
    fireProgressListenerStart(ProgressEvent.START, renameDelegates.length);
    Problem p = null;
    for (RenameRefactoring delegate : renameDelegates) {
        p = JavaPluginUtils.chainProblems(p, delegate.prepare(reb.getSession()));
        if (p != null && p.isFatal()) {
            return p;
        }
        fireProgressListenerStep();
    }
    fireProgressListenerStop();
    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RenameTestClassRefactoringPlugin.java

示例9: prepare

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
public Problem prepare(RefactoringElementsBag refactoringElements) {
    cancel.set(false);

    //Collection<MessageImpl> problems = refactoring.isQuery() ? performSearchForPattern(refactoringElements) : performApplyPattern(refactoringElements);
    
    Collection<MessageImpl> problems = performSearchForPattern(refactoringElements);
    problems.addAll(performApplyPattern(refactoringElements));
    
    Problem current = null;

    for (MessageImpl problem : problems) {
        Problem p = new Problem(problem.kind == MessageKind.ERROR, problem.text);

        if (current != null)
            p.setNext(current);
        current = p;
    }

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

示例10: performSearchForPattern

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
@Messages("WARN_HasQueries=The selected configuration contains inspections that do not provide any transformations. " +
          "No diff will be provided for code detected by such inspections. Use Source/Inspect... to perform code analysis.")
private List<MessageImpl> performSearchForPattern(final RefactoringElementsBag refactoringElements) {
    ProgressHandleWrapper w = new ProgressHandleWrapper(this, 10, 90);
    Iterable<? extends HintDescription> queries = filterQueries(refactoring.getPattern(), true);
    BatchResult candidates = BatchSearch.findOccurrences(queries, refactoring.getScope(), w, /*XXX:*/HintsSettings.getGlobalSettings());
    List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);

    if (queries.iterator().hasNext()) {
        problems.add(new MessageImpl(MessageKind.WARNING, Bundle.WARN_HasQueries()));
    }
    
    prepareElements(candidates, w, refactoringElements, refactoring.isVerify(), problems);

    w.finish();

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

示例11: prepare

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
@Override
public Problem prepare( RefactoringElementsBag bag ) {
    Project project = getProject();

    GwtModuleAcceptor acceptor = getAcceptor();
    Set<FileObject> files = getAffectedJavaFiles(project, acceptor);
    Set<FileObject> additionalFiles =
            getAffectedConfigFiles(project, acceptor);
    fireProgressListenerStart(AbstractRefactoring.PREPARE, files.size()
            + additionalFiles.size());
    Problem problem =
            createAndAddElements(files, getTransformTask(), bag,
                    getRefactoring());
    Problem configProblem =
            createAndAddConfigElements(additionalFiles, bag);
    fireProgressListenerStop();
    if (problem != null) {
        problem.setNext(configProblem);
        return problem;
    }
    else {
        return configProblem;
    }
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:25,代码来源:AbstractRefactoringPlugin.java

示例12: setWidgetsetAddon

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
protected Problem setWidgetsetAddon( RefactoringElementsBag bag ) {
    Project project = getProject();
    VaadinSupport support = project.getLookup().lookup(VaadinSupport.class);
    if (support == null || support.isWeb()) {
        return null;
    }
    List<String> widgetsets = support.getAddonWidgetsets();
    if (widgetsets == null || widgetsets.size() != 1) {
        return null;
    }
    if (getAcceptor().accept(widgetsets.get(0))) {
        return bag.add(
                getRefactoring(),
                new AddOnRefactoringElementImplementation(support, support
                        .getAddonWidgetsets(), null));
    }
    else {
        return null;
    }
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:21,代码来源:DeletePackageRefactoringPlugin.java

示例13: setWidgetsetAddon

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
protected Problem setWidgetsetAddon( RefactoringElementsBag bag ) {
    Project project = getTargetProject();
    VaadinSupport support = project.getLookup().lookup(VaadinSupport.class);
    if (support == null || support.isWeb()) {
        return null;
    }
    List<String> widgetsets = support.getAddonWidgetsets();
    if (!project.equals(getProject())) {
        if (widgetsets == null || widgetsets.size() == 0) {
            return bag.add(getRefactoring(),
                    new AddOnRefactoringElementImplementation(support,
                            null, getTargetWidgetset()));
        }
    }
    return null;
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:17,代码来源:AbstractCopyRefactoringPlugin.java

示例14: setWidgetsetAddon

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
protected Problem setWidgetsetAddon( RefactoringElementsBag bag ) {
    Project project = getProject();
    VaadinSupport support = project.getLookup().lookup(VaadinSupport.class);
    if (support == null || support.isWeb()) {
        return null;
    }
    String targetWidgetset = getTargetWidgetset(support);
    if (targetWidgetset == null) {
        return null;
    }
    else {
        return bag.add(
                getRefactoring(),
                new AddOnRefactoringElementImplementation(support, support
                        .getAddonWidgetsets(), targetWidgetset));
    }
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:18,代码来源:RenamePackageRefactoringPlugin.java

示例15: setWidgetsetAddon

import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入依赖的package包/类
@Override
protected Problem setWidgetsetAddon( RefactoringElementsBag bag ) {
    Project project = getTargetProject();
    VaadinSupport support = project.getLookup().lookup(VaadinSupport.class);
    if (support == null || support.isWeb()) {
        return null;
    }
    List<String> widgetsets = support.getAddonWidgetsets();
    if (widgetsets != null && project.equals(getProject())
            && widgetsets.size() == 1
            && getAcceptor().accept(widgetsets.get(0)))
    {
        return bag.add(getRefactoring(),
                new AddOnRefactoringElementImplementation(support,
                        widgetsets, getTargetWidgetset()));
    }
    else {
        return super.setWidgetsetAddon(bag);
    }
}
 
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:21,代码来源:MoveRefactoringPlugin.java


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