[jbosstools-commits] JBoss Tools SVN: r42635 - in trunk: cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker and 2 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Jul 18 18:04:01 EDT 2012
Author: dazarov
Date: 2012-07-18 18:04:00 -0400 (Wed, 18 Jul 2012)
New Revision: 42635
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java
Log:
Make CDI Quick Fixes work for As-You-Type validator annotations https://issues.jboss.org/browse/JBIDE-12328
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -25,6 +25,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
@@ -68,15 +69,15 @@
@Override
public void run(IMarker marker) {
- internal_run(false);
+ do_run(false, false);
}
@Override
public void runForTest(IMarker marker) {
- internal_run(true);
+ do_run(false, true);
}
- private void internal_run(boolean test){
+ private void do_run(boolean leaveDirty, boolean test){
if(!test){
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
boolean cont = MessageDialog.openQuestion(shell, CDIUIMessages.QUESTION, CDIUIMessages.DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS);
@@ -92,6 +93,9 @@
CompilationUnitChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
+ if(leaveDirty){
+ change.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
change.perform(new NullProgressMonitor());
cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
@@ -168,7 +172,7 @@
@Override
public void apply(IDocument document) {
- internal_run(false);
+ do_run(true, false);
}
@Override
Modified: trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -2,7 +2,10 @@
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.cdi.internal.core.validation.CDICoreValidator;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationErrorManager;
+import org.jboss.tools.cdi.ui.marker.MakeFieldStaticMarkerResolution;
+import org.jboss.tools.common.base.test.MarkerResolutionTestUtil;
import org.jboss.tools.common.base.test.QuickFixTestUtil;
import org.jboss.tools.common.ui.marker.ConfigureProblemSeverityMarkerResolution;
@@ -15,6 +18,7 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonStaticProducerBroken.qfxresult",
CDIValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME,
CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID,
- ConfigureProblemSeverityMarkerResolution.class);
- }
+ MakeFieldStaticMarkerResolution.class);
+ }
+
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -18,6 +18,7 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.swt.graphics.Point;
import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.quickfix.IQuickFix;
@@ -40,14 +41,17 @@
return label;
}
- protected void run_internal(){
+ protected void do_run(boolean leaveDirty){
try{
if(cUnit != null){
ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
- TextChange change = getChange(compilationUnit);
+ TextFileChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
+ if(leaveDirty){
+ change.setSaveMode(TextFileChange.LEAVE_DIRTY);
+ }
change.perform(new NullProgressMonitor());
cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
@@ -60,7 +64,7 @@
@Override
public final void run(IMarker marker) {
- run_internal();
+ do_run(false);
}
@Override
@@ -99,7 +103,7 @@
@Override
public void apply(IDocument document) {
- run_internal();
+ do_run(true);
}
@Override
@@ -127,5 +131,5 @@
return 100;
}
- abstract protected TextChange getChange(ICompilationUnit compilationUnit);
+ abstract protected TextFileChange getChange(ICompilationUnit compilationUnit);
}
Modified: trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java 2012-07-18 18:07:02 UTC (rev 42634)
+++ trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java 2012-07-18 22:04:00 UTC (rev 42635)
@@ -24,7 +24,6 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
-import org.jboss.tools.common.base.test.validation.TestUtil;
import org.jboss.tools.common.quickfix.QuickFixManager;
import org.jboss.tools.common.refactoring.TestableResolutionWithDialog;
import org.jboss.tools.common.refactoring.TestableResolutionWithRefactoringProcessor;
@@ -89,6 +88,10 @@
// Find annotation
TempJavaProblemAnnotation[] annotations = waitForProblemAnnotationAppearance(viewer);
+ System.out.println("ANNOTATIONS Before...");
+ for(TempJavaProblemAnnotation a : annotations){
+ System.out.println(a.getText());
+ }
Assert.assertTrue("No annotations found", annotations.length > 0);
@@ -116,16 +119,21 @@
} else if(proposal instanceof TestableResolutionWithDialog){
((TestableResolutionWithDialog) proposal).runForTest(null);
} else {
- //proposal.apply(document);
+ proposal.apply(document);
}
//TestUtil.validate(file);
- //TempJavaProblemAnnotation[] newAnnotations = waitForProblemAnnotationAppearance(viewer);
+ TempJavaProblemAnnotation[] newAnnotations = waitForProblemAnnotationAppearance(viewer);
+ System.out.println("ANNOTATIONS After...");
+ for(TempJavaProblemAnnotation a : newAnnotations){
+ System.out.println(a.getText());
+ }
+
- //Assert.assertTrue("Quick fix did not decrease number of problems. was: "+annotations.length+" now: "+newAnnotations.length, newAnnotations.length < annotations.length);
+ Assert.assertTrue("Quick fix did not decrease number of problems. was: "+annotations.length+" now: "+newAnnotations.length, newAnnotations.length <= annotations.length);
- //checkResults(project, fileNames, results);
+ checkResults(file, document.get());
return;
}
@@ -151,16 +159,10 @@
return proposals.toArray(new IJavaCompletionProposal[]{});
}
- private static void checkResults(IProject project, String[] fileNames, String[] results) throws CoreException{
- for(int i = 0; i < results.length; i++){
- IFile file = project.getFile(fileNames[i]);
- IFile resultFile = project.getFile(results[i]);
-
- String fileContent = FileUtil.readStream(file);
- String resultContent = FileUtil.readStream(resultFile);
-
- Assert.assertEquals("Wrong result of resolution", resultContent, fileContent);
- }
+ private static void checkResults(IFile file, String text) throws CoreException{
+ String fileContent = FileUtil.readStream(file);
+
+ Assert.assertEquals("Wrong result of resolution", fileContent, text);
}
protected TempJavaProblemAnnotation[] waitForProblemAnnotationAppearance(final ISourceViewer viewer) {
@@ -170,7 +172,8 @@
public void run() {
int secondsLeft = MAX_SECONDS_TO_WAIT;
boolean isFirstPass = true;
- while (secondsLeft-- > 0) {
+ boolean found = false;
+ while (secondsLeft-- > 0 && !found) {
if (!isFirstPass) {
JobUtils.delay(1000);
@@ -189,6 +192,7 @@
if (o instanceof TempJavaProblemAnnotation){
annotations.add((TempJavaProblemAnnotation) o);
+ found = true;
}
}
More information about the jbosstools-commits
mailing list