本文整理汇总了Java中org.netbeans.spi.editor.hints.ChangeInfo类的典型用法代码示例。如果您正苦于以下问题:Java ChangeInfo类的具体用法?Java ChangeInfo怎么用?Java ChangeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChangeInfo类属于org.netbeans.spi.editor.hints包,在下文中一共展示了ChangeInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSubFixesLeak
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public void testSubFixesLeak() throws Exception {
class TestFix implements Fix {
@Override public String getText() { return null; }
@Override public ChangeInfo implement() throws Exception { return null; }
}
Fix main = new TestFix();
Fix sub = new TestFix();
HintsControllerImpl.attachSubfixes(main, Collections.singletonList(sub));
Reference<Fix> mainRef = new WeakReference<Fix>(main);
Reference<Fix> subRef = new WeakReference<Fix>(sub);
main = null;
sub = null;
assertGC("main", mainRef);
assertGC("sub", subRef);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HintsControllerImplTest.java
示例2: testSubFixesEquals
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public void testSubFixesEquals() throws Exception {
class TestFix implements Fix {
@Override public String getText() { return null; }
@Override public ChangeInfo implement() throws Exception { return null; }
@Override public int hashCode() { return 0; }
@Override public boolean equals(Object obj) {
return obj != null && this.getClass() == obj.getClass();
}
}
class SubFix implements Fix {
@Override public String getText() { return null; }
@Override public ChangeInfo implement() throws Exception { return null; }
}
Fix first = new TestFix();
Fix firstSub = new SubFix();
Fix second = new TestFix();
Fix secondSub = new SubFix();
HintsControllerImpl.attachSubfixes(first, Collections.singletonList(firstSub));
HintsControllerImpl.attachSubfixes(second, Collections.singletonList(secondSub));
assertSame(firstSub, HintsControllerImpl.getSubfixes(first).iterator().next());
assertSame(secondSub, HintsControllerImpl.getSubfixes(second).iterator().next());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:HintsControllerImplTest.java
示例3: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws Exception {
FileObject file = Accessor.INSTANCE.getFile(jf);
BatchUtilities.fixDependencies(file, Collections.singletonList(jf), new IdentityHashMap<Project, Set<String>>());
JavaSource js = JavaSource.forFileObject(file);
js.runModificationTask(new Task<WorkingCopy>() {
public void run(WorkingCopy wc) throws Exception {
if (wc.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
return;
}
Map<FileObject, byte[]> resourceContentChanges = new HashMap<FileObject, byte[]>();
Accessor.INSTANCE.process(jf, wc, true, resourceContentChanges, /*Ignored in editor:*/new ArrayList<RefactoringElementImplementation>());
Map<FileObject, List<Difference>> resourceContentDiffs = new HashMap<FileObject, List<Difference>>();
BatchUtilities.addResourceContentChanges(resourceContentChanges, resourceContentDiffs);
JavaSourceAccessor.getINSTANCE().createModificationResult(resourceContentDiffs, Collections.<Object, int[]>emptyMap()).commit();
}
}).commit();
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:JavaFixImpl.java
示例4: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (transform) {
final InspectAndTransformOpener o = Lookup.getDefault().lookup(InspectAndTransformOpener.class);
if (o != null) {
o.openIAT(metadata);
} else {
//warn
}
} else {
CodeAnalysis.open(WarningDescription.create("text/x-java:" + metadata.id, null, null, null));
}
}
});
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ErrorDescriptionFactory.java
示例5: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
final FileObject file = handle.getFileObject();
final JTextComponent comp = EditorRegistry.lastFocusedComponent();
if (file != null && file == getFileObject(comp)) {
final int[] pos = new int[]{-1};
JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>(){
@Override
public void run(CompilationController info) throws Exception {
info.toPhase(JavaSource.Phase.PARSED);
final TreePath tp = handle.resolve(info);
if (tp != null && tp.getLeaf().getKind() == Tree.Kind.VARIABLE) {
pos[0] = (int) info.getTrees().getSourcePositions().getEndPosition(
tp.getCompilationUnit(),
((VariableTree)tp.getLeaf()).getType()) + 1;
}
}
}, true);
invokeRefactoring (comp, pos[0]);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FieldEncapsulation.java
示例6: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
final FileObject file = handle.getFileObject();
final JTextComponent component = EditorRegistry.lastFocusedComponent();
if (file != null && file == getFileObject(component)) {
final int[] position = new int[] {-1};
JavaSource.forFileObject(file).runUserActionTask(new Task<CompilationController>() {
@Override
public void run(CompilationController controller) throws Exception {
controller.toPhase(JavaSource.Phase.PARSED);
final TreePath tp = handle.resolve(controller);
if (tp != null && TreeUtilities.CLASS_TREE_KINDS.contains(tp.getLeaf().getKind())) {
position[0] = (int) controller.getTrees().getSourcePositions().getStartPosition(
tp.getCompilationUnit(),
(ClassTree)tp.getLeaf())+1;
}
}
}, true);
invokeRefactoring(component, position[0]);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ClassEncapsulation.java
示例7: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws IOException, BadLocationException {
JButton btnOk = new JButton(NbBundle.getMessage(IntroduceHint.class, "LBL_Ok"));
btnOk.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(IntroduceHint.class, "AD_IntrHint_OK"));
JButton btnCancel = new JButton(NbBundle.getMessage(IntroduceHint.class, "LBL_Cancel"));
btnCancel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(IntroduceHint.class, "AD_IntrHint_Cancel"));
IntroduceFieldPanel panel = createPanel(btnOk);
FieldValidator fv = new FieldValidator(js, null, this.handle);
if (targetIsInterface) {
panel.setAllowAccess(false);
}
DialogDescriptor dd = new DialogDescriptor(panel, getCaption(), true, new Object[]{btnOk, btnCancel}, btnOk, DialogDescriptor.DEFAULT_ALIGN, null, null);
panel.setNotifier(dd.createNotificationLineSupport());
panel.setTarget(targetHandle);
panel.setValidator(fv);
if (DialogDisplayer.getDefault().notify(dd) != btnOk) {
return null; //cancel
}
js.runModificationTask(new Worker(panel.getFieldName(), permitDuplicates && panel.isReplaceAll(),
panel.isDeclareFinal(), panel.getAccess(), panel.getInitializeIn(),
fv.getLastResult(),
panel.isRefactorExisting())).commit();
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:IntroduceFieldFix.java
示例8: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws Exception {
JButton btnOk = new JButton(NbBundle.getMessage(IntroduceHint.class, "LBL_Ok"));
JButton btnCancel = new JButton(NbBundle.getMessage(IntroduceHint.class, "LBL_Cancel"));
IntroduceMethodPanel panel = new IntroduceMethodPanel("", duplicatesCount, targets, targetIsInterface); //NOI18N
String caption = NbBundle.getMessage(IntroduceHint.class, "CAP_IntroduceMethod");
DialogDescriptor dd = new DialogDescriptor(panel, caption, true, new Object[]{btnOk, btnCancel}, btnOk, DialogDescriptor.DEFAULT_ALIGN, null, null);
NotificationLineSupport notifier = dd.createNotificationLineSupport();
MethodValidator val = new MethodValidator(js, parameters, returnType);
panel.setNotifier(notifier);
panel.setValidator(val);
panel.setOkButton(btnOk);
if (DialogDisplayer.getDefault().notify(dd) != btnOk) {
return null; //cancel
}
boolean redoReferences = panel.isRefactorExisting();
final String name = panel.getMethodName();
final Set<Modifier> access = panel.getAccess();
final boolean replaceOther = panel.getReplaceOther();
final TargetDescription target = panel.getSelectedTarget();
js.runModificationTask(new TaskImpl(access, name, target, replaceOther, val.getResult(), redoReferences)).commit();
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:IntroduceMethodFix.java
示例9: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws IOException {
JavaSource js = JavaSource.forFileObject(file);
js.runModificationTask(new Task<WorkingCopy>() {
public void run(WorkingCopy copy) throws Exception {
copy.toPhase(Phase.PARSED);
CompilationUnitTree cut = copy.getCompilationUnit();
if (packageName.length() == 0) {
copy.rewrite(cut, copy.getTreeMaker().CompilationUnit(cut.getPackageAnnotations(), null, cut.getImports(), cut.getTypeDecls(), cut.getSourceFile()));
} else {
if (cut.getPackageName() == null) {
copy.rewrite(cut, copy.getTreeMaker().CompilationUnit(cut.getPackageAnnotations(), createForFQN(copy, packageName), cut.getImports(), cut.getTypeDecls(), cut.getSourceFile()));
} else {
copy.rewrite(cut.getPackageName(), createForFQN(copy, packageName));
}
}
}
}).commit();
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:WrongPackageSuggestion.java
示例10: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws IOException {
js.runModificationTask(new Task<WorkingCopy>() {
public void run(WorkingCopy wc) throws Exception {
wc.toPhase(Phase.RESOLVED);
Tree tree = wc.getTrees().getTree(method.resolve(wc));
if (tree == null) {
Logger.getLogger(UncaughtException.class.getName()).log(Level.WARNING, "Cannot resolve Handle." +
"fqn: " + fqn +
"method: " + Arrays.asList(SourceUtils.getJVMSignature(method)).toString());
return;
}
assert tree.getKind() == Kind.METHOD;
MethodTree nue = wc.getTreeMaker().addMethodThrows((MethodTree) tree, (ExpressionTree) wc.getTreeMaker().Type(thandle.resolve(wc)));
wc.rewrite(tree, nue);
}
}).commit();
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:UncaughtException.java
示例11: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
try {
ModificationResult.runModificationTask(Collections.singleton(source), new UserTask() {
@Override
public void run(ResultIterator resultIterator) throws Exception {
WorkingCopy wc = WorkingCopy.get(resultIterator.getParserResult(offset));
wc.toPhase(Phase.PARSED);
TreePath path = pathHandle.resolve(wc);
if (path != null && path.getLeaf().getKind() == Kind.METHOD) {
MethodTree mt = (MethodTree) path.getLeaf();
wc.rewrite(mt, wc.getTreeMaker().setLabel(mt, newConstructorName));
}
}
}).commit();
} catch (IOException e) {
Exceptions.printStackTrace(e);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RenameConstructor.java
示例12: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
ChangeInfo info = new ChangeInfo();
if (!mdl.getState().equals(Model.State.VALID)) {
return info;
}
PomModelUtils.implementInTransaction(mdl, new Runnable() {
@Override
public void run() {
org.netbeans.modules.maven.model.pom.Project prj = mdl.getProject();
ModelUtils.updatePluginVersion(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, "3.6.1", prj);
ModelUtils.openAtPlugin(mdl, Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER);
}
});
return info;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CompilerPluginVersionError.java
示例13: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement(){
CancellableTask<WorkingCopy> task = new CancellableTask<WorkingCopy>(){
public void cancel() {}
public void run(WorkingCopy workingCopy) throws Exception {
workingCopy.toPhase(JavaSource.Phase.RESOLVED);
TypeElement clazz = classHandle.resolve(workingCopy);
if (clazz != null){
ClassTree clazzTree = workingCopy.getTrees().getTree(clazz);
GenerationUtils genUtils = GenerationUtils.newInstance(workingCopy);
ClassTree modifiedClazz = genUtils.addImplementsClause(clazzTree, "java.io.Serializable"); // NOI18N
workingCopy.rewrite(clazzTree, modifiedClazz);
}
}
};
JavaSource javaSource = JavaSource.forFileObject(fileObject);
try{
javaSource.runModificationTask(task).commit();
} catch (IOException e){
JPAProblemFinder.LOG.log(Level.SEVERE, e.getMessage(), e);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ImplementSerializable.java
示例14: createChangeInfo
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
protected ChangeInfo createChangeInfo( ModificationResult... results )
throws IOException
{
ChangeInfo changeInfo = new ChangeInfo();
for (ModificationResult result : results) {
List<? extends Difference> differences =
result.getDifferences(getFileObject());
if (differences != null) {
for (Difference difference : differences) {
changeInfo.add(getFileObject(), difference.getStartPosition(),
difference.getEndPosition());
}
}
}
return changeInfo;
}
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:17,代码来源:AbstractJavaFix.java
示例15: doImplement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
protected ChangeInfo doImplement( String stateFqn ) throws IOException {
ModificationResult result =
addGetStateMethod(JavaSource.forFileObject(getFileObject()),
getHandle(), stateFqn);
if (result == null) {
return null;
}
if (getPairHandle() == null) {
return createChangeInfo(result);
}
else {
ModificationResult pairResult =
addGetStateMethod(
JavaSource.forFileObject(myPairFileObject),
getPairHandle(), stateFqn);
return createChangeInfo(result, pairResult);
}
}
开发者ID:vaadin,项目名称:netbeans-plugin,代码行数:19,代码来源:StateAccessorFix.java
示例16: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws Exception {
NbDocument.runAtomic(doc, new Runnable() {
public void run() {
try {
doc.remove(start, end - start);
doc.insertString(start, text, null);
} catch (BadLocationException ex) {
throw new IllegalStateException(ex);
}
}
});
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:EditorTestPerformer.java
示例17: addStandardAnnotationHint
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
/**
* Add an annotation-oriented warning hint following the standard pattern.
* @param fix what to do for a fix (see e.g. {@link #findAndModifyDeclaration}); no change info
* @see #addHint
* @see #standardAnnotationDescription
* @see #standardAnnotationFixDescription
*/
public void addStandardAnnotationHint(final Callable<Void> fix) {
addHint(Severity.WARNING, standardAnnotationDescription(), new Fix() {
public @Override String getText() {
return standardAnnotationFixDescription();
}
public @Override ChangeInfo implement() throws Exception {
fix.call();
return null;
}
});
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Hinter.java
示例18: process
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo process(JavaFix jf, WorkingCopy wc, boolean canShowUI, Map<FileObject, byte[]> resourceContent, Collection<? super RefactoringElementImplementation> fileChanges) throws Exception {
TreePath tp = jf.handle.resolve(wc);
if (tp == null) {
Logger.getLogger(JavaFix.class.getName()).log(Level.SEVERE, "Cannot resolve handle={0}", jf.handle);
return null;
}
GeneratorUtilities.get(wc).importComments(tp.getLeaf(), wc.getCompilationUnit());
jf.performRewrite(new TransformationContext(wc, tp, canShowUI, resourceContent, fileChanges));
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:JavaFix.java
示例19: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
public ChangeInfo implement() throws Exception {
JavaSource js = JavaSource.forFileObject(file);
try {
js.runModificationTask(this).commit();
}
catch( IOException e ) {
Exceptions.printStackTrace(e);
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AssignmentToItself.java
示例20: implement
import org.netbeans.spi.editor.hints.ChangeInfo; //导入依赖的package包/类
@Override
public ChangeInfo implement() throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Node[] activatedNodes = TopComponent.getRegistry().getActivatedNodes();
if (activatedNodes.length > 0) {
EditorCookie ec = activatedNodes[0].getLookup().lookup(EditorCookie.class);
Action a = JavaRefactoringActionsFactory.introduceParameterAction().createContextAwareInstance(Lookups.fixed(activatedNodes[0],ec));
a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
}
}
});
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:IntroduceParameterFix.java
注:本文中的org.netbeans.spi.editor.hints.ChangeInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论