[jbosstools-commits] JBoss Tools SVN: r35451 - in trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui: marker and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Oct 6 20:13:14 EDT 2011


Author: dazarov
Date: 2011-10-06 20:13:14 -0400 (Thu, 06 Oct 2011)
New Revision: 35451

Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
Log:
Quick fixes for problem markers in beans.xml https://issues.jboss.org/browse/JBIDE-9833

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties	2011-10-07 00:12:43 UTC (rev 35450)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/CDIUIMessages.properties	2011-10-07 00:13:14 UTC (rev 35451)
@@ -92,10 +92,10 @@
 ADD_ANNOTATION_MARKER_RESOLUTION_TITLE=Add @{0} annotation to ''{1}'' {2}
 DELETE_ANNOTATION_MARKER_RESOLUTION_TITLE=Delete @{0} annotation from ''{1}'' {2}
 CHANGE_ANNOTATION_MARKER_RESOLUTION_TITLE=Change ''{0}'' annotation to {1}
-CREATE_BEAN_CLASS_TITLE=Create ''{0}'' Bean Class
-CREATE_STEREOTYPE_TITLE=Create ''{0}'' Stereotype
-CREATE_INTERCEPTOR_TITLE=Create ''{0}'' Interceptor
-CREATE_DECORATOR_TITLE=Create ''{0}'' Decorator
+CREATE_BEAN_CLASS_TITLE=Create ''{0}'' CDI Bean Class
+CREATE_STEREOTYPE_TITLE=Create ''{0}'' CDI Stereotype
+CREATE_INTERCEPTOR_TITLE=Create ''{0}'' CDI Interceptor
+CREATE_DECORATOR_TITLE=Create ''{0}'' CDI Decorator
 
 QUESTION=Question
 DECREASING_FIELD_VISIBILITY_MAY_CAUSE_COMPILATION_PROBLEMS=Decreasing field visibility may cause compilation problems. Do you want to continue?

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java	2011-10-07 00:12:43 UTC (rev 35450)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java	2011-10-07 00:13:14 UTC (rev 35451)
@@ -17,7 +17,6 @@
 import org.eclipse.jdt.core.IField;
 import org.eclipse.jdt.core.IJavaElement;
 import org.eclipse.jdt.core.ILocalVariable;
-import org.eclipse.jdt.core.IMember;
 import org.eclipse.jdt.core.IMethod;
 import org.eclipse.jdt.core.IType;
 import org.eclipse.osgi.util.NLS;
@@ -51,11 +50,6 @@
 		label = NLS.bind(CDIUIMessages.ADD_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
 	}
 	
-	public AddAnnotationMarkerResolution(String classQualifiedName, String annotationQualifiedName){
-		this.qualifiedName = annotationQualifiedName;
-		
-	}
-
 	public String getLabel() {
 		return label;
 	}

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java	2011-10-07 00:12:43 UTC (rev 35450)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java	2011-10-07 00:13:14 UTC (rev 35451)
@@ -17,6 +17,7 @@
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jdt.core.Flags;
 import org.eclipse.jdt.core.IAnnotatable;
@@ -24,6 +25,7 @@
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IField;
 import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.ILocalVariable;
 import org.eclipse.jdt.core.IMember;
 import org.eclipse.jdt.core.IMethod;
@@ -52,7 +54,6 @@
 import org.jboss.tools.common.java.IAnnotationDeclaration;
 import org.jboss.tools.common.model.util.EclipseJavaUtil;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.ui.WebUiPlugin;
 
 /**
  * @author Daniel Azarov
@@ -506,13 +507,19 @@
 					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_STEREOTYPE)
 				};
 			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_BEAN_CLASS_ID){
-				return new IMarkerResolution[] {
-					new AddAnnotationMarkerResolution(text, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
-				};
+				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
+				if(element != null){
+					return new IMarkerResolution[] {
+						new AddAnnotationMarkerResolution(element, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
+					};
+				}
 			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_ANNOTATION_ID){
-				return new IMarkerResolution[] {
-					new AddAnnotationMarkerResolution(text, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
-				};
+				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
+				if(element != null){
+					return new IMarkerResolution[] {
+						new AddAnnotationMarkerResolution(element, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
+					};
+				}
 			}else if(messageId == CDIValidationErrorManager.UNKNOWN_DECORATOR_BEAN_CLASS_NAME_ID){
 				return new IMarkerResolution[] {
 					new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_DECORATOR)
@@ -526,6 +533,17 @@
 		return new IMarkerResolution[] {};
 	}
 	
+	private IJavaElement findJavaElementByQualifiedName(IProject project, String qualifiedName){
+		IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+		try {
+			return javaProject.findType(qualifiedName);
+		} catch (JavaModelException ex) {
+			CDIUIPlugin.getDefault().logError(ex);
+		}
+		
+		return null;
+	}
+	
 	private IType findNamedDeclarationType(ICDIProject cdiProject, IType type, boolean isItDecorator){
 		IType declarationType = null;
 		IBean bean = null;



More information about the jbosstools-commits mailing list