本文整理匯總了Java中org.netbeans.modules.refactoring.api.Problem類的典型用法代碼示例。如果您正苦於以下問題:Java Problem類的具體用法?Java Problem怎麽用?Java Problem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Problem類屬於org.netbeans.modules.refactoring.api包,在下文中一共展示了Problem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: preCheck
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
@Override
public final Problem preCheck() {
if (!shouldHandle()){
return null;
}
Problem result = null;
for (FileObject refactoringSource : getRefactoringSources()){
for (FileObject persistenceXml : getPersistenceXmls(refactoringSource)) {
try {
ProviderUtil.getPUDataObject(persistenceXml);
} 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.api.Problem; //導入依賴的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;
}
示例3: assertProblems
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
protected static void assertProblems(Iterable<? extends Problem> golden, Iterable<? extends Problem> real) {
Iterator<? extends Problem> g = golden.iterator();
Iterator<? extends Problem> r = real.iterator();
while (g.hasNext() && r.hasNext()) {
Problem gp = g.next();
Problem rp = r.next();
assertEquals(gp.isFatal(), rp.isFatal());
assertEquals(gp.getMessage(), rp.getMessage());
}
boolean goldenHasNext = g.hasNext();
boolean realHasNext = r.hasNext();
assertFalse(goldenHasNext?"Expected: " + g.next().getMessage():"", goldenHasNext);
assertFalse(realHasNext?"Unexpected: " + r.next().getMessage():"", realHasNext);
}
示例4: testVariableUsed
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public void testVariableUsed() throws Exception {
String source;
writeFilesAndWaitForScan(src,
new File("t/A.java", source = "package t; public class A {\n"
+ " int i;\n"
+ " public A() {\n"
+ " System.out.println(i)\n"
+ " }\n"
+ "}\n"));
performSafeDelete(src.getFileObject("t/A.java"), source.indexOf("i;") + 1, false, new Problem(false, "ERR_ReferencesFound"));
verifyContent(src,
new File("t/A.java", "package t; public class A {\n"
+ " public A() {\n"
+ " System.out.println(i)\n"
+ " }\n"
+ "}\n"));
}
示例5: chainProblems
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public static Problem chainProblems(Problem result, Problem problem) {
if (result == null) {
return problem;
}
if (problem == null) {
return result;
}
Problem value;
if(problem.isFatal()) {
problem.setNext(result);
value = problem;
} else {
Problem next = value = result;
while (next.getNext() != null) {
next = next.getNext();
}
next.setNext(problem);
}
return value;
}
示例6: testInvertMethodInterface
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public void testInvertMethodInterface() throws Exception {
writeFilesAndWaitForScan(src,
new File("test/Test.java", "package test;\n public interface Test { boolean test(int a); }\n"),
new File("test/Iface.java", "package test;"
+ "public class Iface implements Test {\n"
+ " @Override\n"
+ " public boolean test(int a) {\n"
+ " return false;\n"
+ " }\n"
+ "}\n"));
performMethodTest(0, new Problem(true, "ERR_InvertMethodInInterface"));
assertContent(src,
new File("test/Test.java", "package test;\n public interface Test { boolean test(int a); }\n"),
new File("test/Iface.java", "package test;"
+ "public class Iface implements Test {\n"
+ " @Override\n"
+ " public boolean test(int a) {\n"
+ " return false;\n"
+ " }\n"
+ "}\n")/*,
new File("META-INF/upgrade/test.Test.hint", "new test.Test($1, $2) :: $1 instanceof int && $2 instanceof java.util.List<java.lang.String> => test.Test.create($1, $2);;")*/
);
}
示例7: preparePackageDelete
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的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;
}
示例8: testCannotInlineMethodVoidReturn
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public void testCannotInlineMethodVoidReturn() throws Exception {
writeFilesAndWaitForScan(src,
new File("t/A.java", "package t;\n"
+ "public class A {\n"
+ " private void printGreeting() {\n"
+ " System.out.println(\"Hello World!\");\n"
+ " return\n"
+ " }\n"
+ " public static void testMethod() {\n"
+ " printGreeting();\n"
+ " }\n"
+ "}"));
final InlineRefactoring[] r = new InlineRefactoring[1];
createInlineMethodRefactoring(src.getFileObject("t/A.java"), 1, r);
performRefactoring(r, new Problem(true, "ERR_InlineMethodVoidReturn"));
}
示例9: testPolymorphicMultiple
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public void testPolymorphicMultiple() throws Exception {
String source;
writeFilesAndWaitForScan(src,
new File("t/A.java", "package t; public class A {\n"
+ " public void foo() {\n"
+ " A a = new A();\n"
+ " }\n"
+ "}\n"),
new File("t/I.java", "package t; public interface I {\n"
+ "public void foo();\n"
+ "}\n"),
new File("t/B.java", source = "package t; public class B extends A implements I {\n"
+ "public void foo() { }\n"
+ "}\n"));
performSafeDelete(src.getFileObject("t/B.java"), source.indexOf("foo") + 1, false, new Problem(false, "WRN_Implements"));
verifyContent(src,
new File("t/A.java", "package t; public class A {\n"
+ "}\n"),
new File("t/I.java", "package t; public interface I {\n"
+ "public void foo();\n"
+ "}\n"),
new File("t/B.java", "package t; public class B extends A implements I {\n"
+ "}\n"));
}
示例10: checkConstructorLayer
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的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;
}
示例11: addProblemsToEnd
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public static Problem addProblemsToEnd(Problem where, Problem what) {
Problem whereCopy = where;
err.log("Where: " + where);
err.log("What: " + what);
if (what != null) {
if (where == null) {
whereCopy = what;
} else {
while (where.getNext() != null) {
where = where.getNext();
}
err.log("Last where: " + where);
while (what != null) {
Problem elem = what;
err.log("Elem: " + elem);
where.setNext(elem);
where = where.getNext();
what = what.getNext();
}
}
}
err.log("wherecopy return: " + whereCopy);
return whereCopy;
}
示例12: test253063
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
public void test253063() throws Exception {
writeFilesAndWaitForScan(src,
new File("t/A.java", "package t;\n"
+ "public enum A implements ATest {\n"
+ " AAA { void foo() { } }\n"
+ "}"),
new File("t/ATest.java", "package t;\n"
+ "\n"
+ "public interface ATest {\n"
+ " void foo();\n"
+ "}"));
JavaRenameProperties props = new JavaRenameProperties();
performRename(src.getFileObject("t/ATest.java"), 0, -1, "foos", props, false, new Problem(false, "ERR_IsOverridden"));
verifyContent(src,
new File("t/A.java", "package t;\n"
+ "public enum A implements ATest {\n"
+ " AAA { void foos() { } }\n"
+ "}"),
new File("t/ATest.java", "package t;\n"
+ "\n"
+ "public interface ATest {\n"
+ " void foos();\n"
+ "}"));
}
示例13: setParameters
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
@Override
public Problem setParameters() {
refactoring.setMode(panel.getSelectedMode());
refactoring.setSelectorType(panel.getSelectorType());
switch(panel.getSelectedMode()) {
case refactorToExistingEmbeddedSection:
refactoring.setExistingEmbeddedCssSection(panel.getSelectedEmbeddedSection());
break;
case refactorToNewEmbeddedSection:
break;
case refactorToReferedExternalSheet:
case refactorToExistingExternalSheet:
refactoring.setExternalSheet(panel.getSelectedExternalStyleSheet());
break;
default:
break;
}
return null;
}
示例14: performMove
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
void performMove(FileObject source, final int position, final URL target, Problem... expectedProblems) throws IOException, IllegalArgumentException, InterruptedException {
final MoveRefactoring[] r = new MoveRefactoring[1];
JavaSource.forFileObject(source).runUserActionTask(new Task<CompilationController>() {
@Override
public void run(CompilationController info) throws Exception {
info.toPhase(JavaSource.Phase.RESOLVED);
CompilationUnitTree cut = info.getCompilationUnit();
ClassTree classTree = (ClassTree) cut.getTypeDecls().get(position);
TreePath classPath = info.getTrees().getPath(cut, classTree);
r[0] = new MoveRefactoring(Lookups.singleton(TreePathHandle.create(classPath, info)));
r[0].setTarget(Lookups.singleton(target));
}
}, true);
RefactoringSession rs = RefactoringSession.create("Session");
List<Problem> problems = new LinkedList<Problem>();
addAllProblems(problems, r[0].preCheck());
if (!problemIsFatal(problems)) {
addAllProblems(problems, r[0].prepare(rs));
}
if (!problemIsFatal(problems)) {
addAllProblems(problems, rs.doRefactoring(true));
}
assertProblems(Arrays.asList(expectedProblems), problems);
}
示例15: checkParameters
import org.netbeans.modules.refactoring.api.Problem; //導入依賴的package包/類
@Override
public Problem checkParameters() {
if (!isRenameTestClass() && !isRenameTestClassMethod()) {
return null;
}
initDelegates();
Problem p = null;
for (RenameRefactoring delegate : renameDelegates) {
p = JavaPluginUtils.chainProblems(p, delegate.checkParameters());
if (p != null && p.isFatal()) {
return p;
}
}
return JavaPluginUtils.chainProblems(p, super.checkParameters());
}