[jbosstools-commits] JBoss Tools SVN: r44074 - in trunk: common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker and 1 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Sep 26 20:02:00 EDT 2012
Author: dazarov
Date: 2012-09-26 20:02:00 -0400 (Wed, 26 Sep 2012)
New Revision: 44074
Modified:
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.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java
Log:
Configure Problem Severity should open project settings if they are enabled for the project https://issues.jboss.org/browse/JBIDE-12538
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-09-26 23:45:28 UTC (rev 44073)
+++ trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/marker/CDIQuickFixTest.java 2012-09-27 00:02:00 UTC (rev 44074)
@@ -2,6 +2,7 @@
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.AddAnnotationMarkerResolution;
import org.jboss.tools.cdi.ui.marker.AddLocalBeanMarkerResolution;
@@ -18,27 +19,23 @@
public class CDIQuickFixTest extends TCKTest {
private QuickFixTestUtil util = new QuickFixTestUtil();
-// private static boolean isSuspendedValidationDefaultValue;
-// public void setUp() throws Exception {
-// super.setUp();
-// isSuspendedValidationDefaultValue = ValidationFramework.getDefault().isSuspended();
-// ValidationFramework.getDefault().suspendAllValidation(false);
-// tckProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
-// tckProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
-// }
-//
-// public void tearDown() throws Exception {
-// ValidationFramework.getDefault().suspendAllValidation(isSuspendedValidationDefaultValue);
-// super.tearDown();
-// }
+ public void setUp() throws Exception {
+ super.setUp();
+
+ // register Preference Info
+ new CDICoreValidator();
+ }
+
public void testMakeFieldStatic() throws CoreException {
util.checkProposal(tckProject,
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/MakeFieldStatic.java",
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/MakeFieldStatic.qfxresult",
"@Produces",
CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID,
- MakeFieldStaticMarkerResolution.class, true);
+ MakeFieldStaticMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testAddLocalBeanResolution() throws CoreException {
@@ -47,7 +44,10 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/AddLocalBean.qfxresult",
"@Produces",
CDIValidationErrorManager.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN_ID,
- AddLocalBeanMarkerResolution.class, true);
+ AddLocalBeanMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
+
}
public void testMakeProducerMethodPublicResolution() throws CoreException {
@@ -56,8 +56,10 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/MakeMethodPublic.qfxresult",
"@Produces",
CDIValidationErrorManager.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN_ID,
- MakeMethodPublicMarkerResolution.class, true);
- }
+ MakeMethodPublicMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
+}
public void testAddSerializableInterfaceResolution() throws CoreException{
@@ -66,7 +68,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/AddSerializable.qfxresult",
"AddSerializable",
CDIValidationErrorManager.NOT_PASSIVATION_CAPABLE_BEAN_ID,
- AddSerializableInterfaceMarkerResolution.class, true);
+ AddSerializableInterfaceMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testAddRetentionToQualifierResolution() throws CoreException{
@@ -75,7 +79,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/AddRetention.qfxresult",
"AddRetention",
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID,
- AddRetentionAnnotationMarkerResolution.class, true);
+ AddRetentionAnnotationMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testChangeRetentionToQualifierResolution() throws CoreException{
@@ -84,7 +90,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/ChangeAnnotation.qfxresult",
"@Retention(value = null)",
CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID,
- ChangeAnnotationMarkerResolution.class, true);
+ ChangeAnnotationMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testAddTargetToScopeResolution() throws CoreException{
@@ -93,7 +101,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/AddTarget.qfxresult",
"AddTarget",
CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE_ID,
- AddTargetAnnotationMarkerResolution.class, true);
+ AddTargetAnnotationMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testAddNonbindingToAnnotationMemberOfQualifierResolution() throws CoreException{
@@ -102,7 +112,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/AddAnnotation.qfxresult",
"abc",
CDIValidationErrorManager.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID,
- AddAnnotationMarkerResolution.class, true);
+ AddAnnotationMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testDeleteDisposesAnnotationFromParameterResolution() throws CoreException{
@@ -111,7 +123,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/DeleteAnnotation.qfxresult",
"@Inject",
CDIValidationErrorManager.CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES_ID,
- DeleteAnnotationMarkerResolution.class, true);
+ DeleteAnnotationMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testCreateBeanClassResolution() throws CoreException{
@@ -120,7 +134,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonExistingAlternative.qfxresult",
"com.acme.NonExistingClass",
CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME_ID,
- CreateCDIElementMarkerResolution.class, false);
+ CreateCDIElementMarkerResolution.class,
+ true,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testCreateStereotypeResolution() throws CoreException{
@@ -129,7 +145,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonExistingStereotype.qfxresult",
"com.acme.NotExistingStereotype",
CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME_ID,
- CreateCDIElementMarkerResolution.class, false);
+ CreateCDIElementMarkerResolution.class,
+ false,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testCreateDecoratorResolution() throws CoreException{
@@ -138,7 +156,9 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonExistingDecorator.qfxresult",
"com.acme.NonExistingDecoratorClass",
CDIValidationErrorManager.UNKNOWN_DECORATOR_BEAN_CLASS_NAME_ID,
- CreateCDIElementMarkerResolution.class, false);
+ CreateCDIElementMarkerResolution.class,
+ false,
+ CDICoreValidator.PROBLEM_TYPE);
}
public void testCreateInterceptorResolution() throws CoreException{
@@ -147,6 +167,8 @@
"JavaSource/org/jboss/jsr299/tck/tests/jbt/quickfixes/NonExistingInterceptor.qfxresult",
"com.acme.NonExistingInterceptorClass",
CDIValidationErrorManager.UNKNOWN_INTERCEPTOR_CLASS_NAME_ID,
- CreateCDIElementMarkerResolution.class, false);
+ CreateCDIElementMarkerResolution.class,
+ false,
+ CDICoreValidator.PROBLEM_TYPE);
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-09-26 23:45:28 UTC (rev 44073)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-09-27 00:02:00 UTC (rev 44074)
@@ -33,6 +33,7 @@
import org.jboss.tools.common.ui.CommonUIPlugin;
import org.jboss.tools.common.validation.IPreferenceInfo;
import org.jboss.tools.common.validation.PreferenceInfoManager;
+import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.common.validation.ValidationErrorManager;
import org.jboss.tools.common.validation.java.TempJavaProblemAnnotation;
@@ -118,6 +119,15 @@
@Override
public boolean hasResolutions(IMarker marker) {
+ try {
+ String preferenceKey = getPreferenceKey(marker);
+ String markerType = getProblemType(marker);
+ IPreferenceInfo info = PreferenceInfoManager.getPreferenceInfo(markerType);
+ if(preferenceKey != null && markerType != null && info != null)
+ return true;
+ } catch (CoreException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
return true;
}
@@ -131,7 +141,18 @@
}
private String getProblemType(Annotation annotation){
- return annotation.getType();
+ if(annotation instanceof TemporaryAnnotation){
+ if(((TemporaryAnnotation)annotation).getAttributes() != null){
+ String attribute = (String)((TemporaryAnnotation)annotation).getAttributes().get(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME);
+ return attribute;
+ }
+ }else if(annotation instanceof TempJavaProblemAnnotation){
+ if(((TempJavaProblemAnnotation)annotation).getAttributes() != null){
+ String attribute = (String)((TempJavaProblemAnnotation)annotation).getAttributes().get(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME);
+ return attribute;
+ }
+ }
+ return null;
}
private String getPreferencePageId(IMarker marker)throws CoreException{
@@ -171,7 +192,14 @@
@Override
public boolean hasProposals(Annotation annotation, Position position) {
- return true;
+ String preferenceKey = getPreferenceKey(annotation);
+ String problemType = getProblemType(annotation);
+ IPreferenceInfo info = PreferenceInfoManager.getPreferenceInfo(problemType);
+
+ if(preferenceKey != null && problemType != null && info != null)
+ return true;
+
+ return false;
}
@Override
@@ -185,14 +213,19 @@
String propertyPageId = info.getPropertyPageId();
String pluginId = info.getPluginId();
if(preferenceKey != null && preferencePageId != null && propertyPageId != null && pluginId != null){
- IFile file = MarkerResolutionUtils.getFile();
+ IFile file = null;
if(annotation instanceof TempJavaProblemAnnotation){
TempJavaProblemAnnotation tAnnotation = (TempJavaProblemAnnotation)annotation;
- if(JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(tAnnotation.getType())){
- int offset = position.getOffset();
-
- if(file != null){
+ try {
+ file = (IFile) tAnnotation.getCompilationUnit().getUnderlyingResource();
+ } catch (JavaModelException e) {
+ CommonUIPlugin.getDefault().logError(e);
+ }
+ if(file != null){
+ if(JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE.equals(tAnnotation.getType())){
+ int offset = position.getOffset();
+
IJavaElement element = findJavaElement(tAnnotation, offset);
if(element != null){
if(element instanceof IMethod){
@@ -208,9 +241,14 @@
proposals.add(new AddSuppressWarningsMarkerResolution(file, element, preferenceKey, tAnnotation.getCompilationUnit()));
}
}
+
}
+ }else{
+ file = MarkerResolutionUtils.getFile();
}
- proposals.add(new ConfigureProblemSeverityMarkerResolution(file.getProject(), preferencePageId, propertyPageId, preferenceKey, pluginId));
+ if(file != null){
+ proposals.add(new ConfigureProblemSeverityMarkerResolution(file.getProject(), preferencePageId, propertyPageId, preferenceKey, pluginId));
+ }
}
}
return proposals.toArray(new IJavaCompletionProposal[]{});
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-09-26 23:45:28 UTC (rev 44073)
+++ trunk/common/tests/org.jboss.tools.common.base.test/src/org/jboss/tools/common/base/test/QuickFixTestUtil.java 2012-09-27 00:02:00 UTC (rev 44074)
@@ -104,7 +104,7 @@
}
}
- public void checkProposal(IProject project, String fileName, String newFile, String str, int id, Class<? extends IJavaCompletionProposal> proposalClass, boolean checkResult) throws CoreException {
+ public void checkProposal(IProject project, String fileName, String newFile, String str, int id, Class<? extends IJavaCompletionProposal> proposalClass, boolean checkResult, String problemType) throws CoreException {
IFile file = project.getFile(fileName);
IFile nFile = project.getFile(newFile);
@@ -131,7 +131,7 @@
Assert.assertTrue("String - "+str+" not found", offset > 0);
int length = str.length();
- Annotation annotation = createAnnotation(file, id, offset, length);
+ Annotation annotation = createAnnotation(problemType, file, id, offset, length);
Position position = new Position(offset, length);
IJavaCompletionProposal[] proposals = getCompletionProposals(annotation, position);
@@ -193,7 +193,7 @@
Assert.assertEquals("Wrong result of resolution", fileContent, text);
}
- protected Annotation createAnnotation(IFile file, int quickFixId, int offset, int length){
+ protected Annotation createAnnotation(String problemType, IFile file, int quickFixId, int offset, int length){
if("java".equals(file.getFileExtension())){
ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
@@ -215,7 +215,7 @@
message.setAttribute(TempMarkerManager.MESSAGE_ID_ATTRIBUTE_NAME, quickFixId);
message.setAttribute(TempMarkerManager.PREFERENCE_KEY_ATTRIBUTE_NAME, "preferenceKey");
message.setAttribute(TempMarkerManager.PREFERENCE_PAGE_ID_NAME, "pref_page_id");
- message.setAttribute(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME, JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE);
+ message.setAttribute(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME, problemType);
TempJavaProblem problem = new TempJavaProblem(message, "origin");
@@ -229,7 +229,7 @@
attributes.put(TempMarkerManager.MESSAGE_ID_ATTRIBUTE_NAME, quickFixId);
attributes.put(TempMarkerManager.PREFERENCE_KEY_ATTRIBUTE_NAME, "preferenceKey");
attributes.put(TempMarkerManager.PREFERENCE_PAGE_ID_NAME, "pref_page_id");
- attributes.put(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME, JavaMarkerAnnotation.WARNING_ANNOTATION_TYPE);
+ attributes.put(TempMarkerManager.MESSAGE_TYPE_ATTRIBUTE_NAME, problemType);
annotation.setAttributes(attributes);
return annotation;
More information about the jbosstools-commits
mailing list