本文整理汇总了Java中org.netbeans.modules.refactoring.spi.RefactoringElementsBag.add方法的典型用法代码示例。如果您正苦于以下问题:Java RefactoringElementsBag.add方法的具体用法?Java RefactoringElementsBag.add怎么用?Java RefactoringElementsBag.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.modules.refactoring.spi.RefactoringElementsBag
的用法示例。
在下文中一共展示了RefactoringElementsBag.add方法的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;
}
示例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;
}
示例3: 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;
}
}
示例4: 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;
}
示例5: 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));
}
}
示例6: 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);
}
}
示例7: prepareMethodRefactoring
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
private Problem prepareMethodRefactoring(RefactoringElementsBag refactoringElements, final TreePathHandle treePathHandle) {
FileObject fo = treePathHandle.getFileObject();
try {
RenamedProperty prop = null;
JavaSource js = JavaSource.forFileObject(fo);
if (js != null) {
prop = SpringRefactorings.getRenamedProperty(treePathHandle, js, refactoring.getNewName());
}
SpringScope scope = SpringScope.getSpringScope(fo);
if (scope == null) {
return null;
}
if (prop != null) {
String newName = prop.getNewName();
String oldName = prop.getOldName();
if (newName != null && oldName != null) {
Modifications mods = new Modifications();
for (Occurrence occurrence : Occurrences.getPropertyOccurrences(prop, js, scope)) {
refactoringElements.add(refactoring,
SpringRefactoringElement.createPropertyRefModification(occurrence, mods, prop.getOldName(), prop.getNewName()));
}
refactoringElements.registerTransaction(new RefactoringCommit(Collections.singleton(mods)));
}
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
示例8: prepareClassRefactoring
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
private Problem prepareClassRefactoring(RefactoringElementsBag refactoringElementsBag, final TreePathHandle treePathHandle) {
FileObject fo = treePathHandle.getFileObject();
SpringScope scope = SpringScope.getSpringScope(fo);
if (scope == null) {
return null;
}
try {
JavaSource source = JavaSource.forFileObject(fo);
// #253033
if (source == null) {
return null;
}
final String[] className = new String[] { null };
source.runUserActionTask(new Task<CompilationController>() {
public void run(CompilationController compilationController) throws Exception {
compilationController.toPhase(JavaSource.Phase.RESOLVED);
TypeElement type = (TypeElement) treePathHandle.resolveElement(compilationController);
if (type != null) {
className[0] = ElementUtilities.getBinaryName(type);
}
}
}, true);
if (className[0] != null) {
for (Occurrences.Occurrence item : Occurrences.getJavaClassOccurrences(className[0], scope)) {
refactoringElementsBag.add(refactoring, SpringRefactoringElement.create(item));
}
}
} catch (IOException e) {
Exceptions.printStackTrace(e);
}
return null;
}
示例9: prepareMethodRefactoring
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
private Problem prepareMethodRefactoring(RefactoringElementsBag refactoringElements, final TreePathHandle treePathHandle) {
FileObject fo = treePathHandle.getFileObject();
try {
RenamedProperty prop = null;
JavaSource js = JavaSource.forFileObject(fo);
if (js != null) {
prop = SpringRefactorings.getRenamedProperty(treePathHandle, js, null);
}
SpringScope scope = SpringScope.getSpringScope(fo);
if (scope == null) {
return null;
}
if (prop != null) {
String oldName = prop.getOldName();
if (oldName != null) {
for (Occurrence occurrence : Occurrences.getPropertyOccurrences(prop, js, scope)) {
refactoringElements.add(refactoring, SpringRefactoringElement.create(occurrence));
}
}
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
return null;
}
示例10: refactorProjectPropertyFiles
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
private void refactorProjectPropertyFiles(FileObject folder, RefactoringElementsBag refactoringElements) {
Project project = FileOwnerQuery.getOwner(folder);
NbModuleProvider moduleProvider = project.getLookup().lookup(NbModuleProvider.class);
if (moduleProvider == null) {
// take just netbeans module development into account..
return;
}
Sources srcs = org.netbeans.api.project.ProjectUtils.getSources(project);
SourceGroup[] srcGrps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
SourceGroup[] rscGrps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
StringBuffer relPath = new StringBuffer();
String newName = ((RenameRefactoring)refactoring).getNewName().replace('.', '/');
if(isProjectPropertiesFilePath(srcGrps, folder, relPath)
|| isProjectPropertiesFilePath(rscGrps, folder, relPath)) {
refactoringElements.add(refactoring, new ManifestMoveRefactoringElement(moduleProvider.getManifestFile(),
relPath.toString().replace('.', '/'), newName));
}
NbRefactoringProvider refactoringProvider = project.getLookup().lookup(NbRefactoringProvider.class);
if(refactoringProvider == null) {
return;
}
List<NbRefactoringProvider.ProjectFileRefactoring> projectFilesRefactoring = refactoringProvider.getProjectFilesRefactoring(
new NbRefactoringContext(folder, newName, relPath.toString().replace('.', '/')));
if(projectFilesRefactoring!=null) {
for(NbRefactoringProvider.ProjectFileRefactoring projectFileRefIter : projectFilesRefactoring) {
refactoringElements.add(refactoring, new ProjectFileMoveRefactoringElement(projectFileRefIter));
}
}
}
示例11: prepare
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
@Override
public Problem prepare(final RefactoringElementsBag refactoringElements) {
//rename refactoring of files refered from html pages
Lookup lookup = refactoring.getRefactoringSource();
FileObject file = lookup.lookup(FileObject.class);
if (file == null) {
return null;
}
Project project = FileOwnerQuery.getOwner(file);
if (project == null) {
return null;
}
HtmlIndex index;
try {
index = HtmlIndex.get(project);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
return null;
}
ModificationResult modificationResult = new ModificationResult();
if(file.isFolder()) {
refactorFolder(file, modificationResult, index);
} else {
refactorFile(file, modificationResult, index);
}
refactoringElements.registerTransaction(new RefactoringCommit(Collections.singletonList(modificationResult)));
for (FileObject fo : modificationResult.getModifiedFileObjects()) {
for (Difference diff : modificationResult.getDifferences(fo)) {
refactoringElements.add(refactoring, DiffElement.create(diff, fo, modificationResult));
}
}
return null;
}
示例12: create
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
public static void create(RefactoringElementsBag bag, FileObject fo, ExtractInterfaceRefactoring refactoring, ElementHandle<TypeElement> sourceType) throws IOException {
JavaSource js = JavaSource.forFileObject(fo);
ModificationResult modification = js.runModificationTask(new UpdateClassTask(refactoring, sourceType));
List<? extends ModificationResult.Difference> diffs = modification.getDifferences(fo);
for (ModificationResult.Difference diff : diffs) {
bag.add(refactoring, DiffElement.create(diff, fo, modification));
}
bag.registerTransaction(createTransaction(Collections.singletonList(modification)));
}
示例13: prepare
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
@Override
public Problem prepare(RefactoringElementsBag refactoringElements) {
for (FileObject fileobject : refactoring.getRefactoringSource().lookupAll(FileObject.class)) {
refactoringElements.add(refactoring, new CopyClass(fileobject));
}
return null;
}
示例14: createAndAddElements
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
public static void createAndAddElements(AbstractRefactoring refactoring, RefactoringElementsBag elements, Collection<ModificationResult> results) {
elements.registerTransaction(JavaRefactoringPlugin.createTransaction(results));
for (ModificationResult result:results) {
for (FileObject jfo : result.getModifiedFileObjects()) {
for (ModificationResult.Difference diff: result.getDifferences(jfo)) {
elements.add(refactoring, DiffElement.create(diff, jfo, result));
}
}
}
}
示例15: prepare
import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; //导入方法依赖的package包/类
@Override
@NbBundle.Messages({
"rename.variable=Rename variable",
"rename.mixin=Rename mixin"
})
public Problem prepare(final RefactoringElementsBag refactoringElements) {
try {
if (cancelled) {
return null;
}
ModificationResult modificationResult = new ModificationResult();
Node element = context.getElement();
if (element != null) {
switch (element.type()) {
case cp_variable:
refactorElements(modificationResult, context, CPWhereUsedQueryPlugin.findVariables(context), Bundle.rename_variable());
break;
case cp_mixin_name:
refactorElements(modificationResult, context, CPWhereUsedQueryPlugin.findMixins(context), Bundle.rename_mixin());
break;
}
//commit the transaction and add the differences to the result
refactoringElements.registerTransaction(new RefactoringCommit(Collections.singletonList(modificationResult)));
for (FileObject fo : modificationResult.getModifiedFileObjects()) {
for (Difference diff : modificationResult.getDifferences(fo)) {
refactoringElements.add(refactoring, DiffElement.create(diff, fo, modificationResult));
}
}
}
return null; //no problem
} catch (IOException | ParseException ex) {
Exceptions.printStackTrace(ex);
return new Problem(true, ex.getLocalizedMessage() == null ? ex.toString() : ex.getLocalizedMessage());
}
}