[jbosstools-commits] JBoss Tools SVN: r39234 - trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Mar 1 16:39:32 EST 2012


Author: dazarov
Date: 2012-03-01 16:39:31 -0500 (Thu, 01 Mar 2012)
New Revision: 39234

Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
Log:
Wrong quick fix for empty tag <class> in beans.xml https://issues.jboss.org/browse/JBIDE-11136

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	2012-03-01 19:05:08 UTC (rev 39233)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java	2012-03-01 21:39:31 UTC (rev 39234)
@@ -17,7 +17,6 @@
 
 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;
@@ -31,6 +30,7 @@
 import org.eclipse.jdt.core.IMethod;
 import org.eclipse.jdt.core.IType;
 import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.corext.util.JavaConventionsUtil;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.ui.IMarkerResolution;
@@ -98,6 +98,8 @@
 			return new IMarkerResolution[] {};
 
 		final IFile file = (IFile) marker.getResource();
+		
+		IJavaProject javaProject = EclipseUtil.getJavaProject(file.getProject());
 
 		Integer attribute = ((Integer) marker.getAttribute(IMarker.CHAR_START));
 		if (attribute == null)
@@ -521,44 +523,46 @@
 				provider.disconnect(input);
 			}
 			
+			boolean correctTypeName = JavaConventionsUtil.validatePackageName(text, javaProject).isOK();
+			
 			if(messageId == CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME_ID){
-				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
-				if(element == null){
+				IJavaElement element = findJavaElementByQualifiedName(javaProject, text);
+				if(element == null && correctTypeName){
 					return new IMarkerResolution[] {
 						new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_BEAN_CLASS)
 					};
 				}
 			}else if(messageId == CDIValidationErrorManager.UNKNOWN_ALTERNATIVE_ANNOTATION_NAME_ID){
-				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
-				if(element == null){
+				IJavaElement element = findJavaElementByQualifiedName(javaProject, text);
+				if(element == null && correctTypeName){
 					return new IMarkerResolution[] {
 						new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_STEREOTYPE)
 					};
 				}
 			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_BEAN_CLASS_ID){
-				IJavaElement element = getTypeToAddAlternativeToBean(file.getProject(), text);
+				IJavaElement element = getTypeToAddAlternativeToBean(javaProject, text);
 				if(element != null){
 					return new IMarkerResolution[] {
 						new AddAnnotationMarkerResolution(element, CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME)
 					};
 				}
 			}else if(messageId == CDIValidationErrorManager.ILLEGAL_ALTERNATIVE_ANNOTATION_ID){
-				IJavaElement element = getTypeToAddAlternativeToStereotype(file.getProject(), text);
+				IJavaElement element = getTypeToAddAlternativeToStereotype(javaProject, 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){
-				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
-				if(element == null){
+				IJavaElement element = findJavaElementByQualifiedName(javaProject, text);
+				if(element == null && correctTypeName){
 					return new IMarkerResolution[] {
 						new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_DECORATOR)
 					};
 				}
 			}else if(messageId == CDIValidationErrorManager.UNKNOWN_INTERCEPTOR_CLASS_NAME_ID){
-				IJavaElement element = findJavaElementByQualifiedName(file.getProject(), text);
-				if(element == null){
+				IJavaElement element = findJavaElementByQualifiedName(javaProject, text);
+				if(element == null && correctTypeName){
 					return new IMarkerResolution[] {
 						new CreateCDIElementMarkerResolution(file.getProject(), text, CreateCDIElementMarkerResolution.CREATE_INTERCEPTOR)
 					};
@@ -609,8 +613,7 @@
 		return resolutions;
 	}
 	
-	private IType getTypeToAddAlternativeToBean(IProject project, String qualifiedName){
-		IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+	private IType getTypeToAddAlternativeToBean(IJavaProject javaProject, String qualifiedName){
 		IType type = null;
 		try {
 			type =  javaProject.findType(qualifiedName);
@@ -619,7 +622,7 @@
 		}
 		
 		if(type != null){
-			CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
+			CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(javaProject.getProject());
 			if(cdiNature != null){
 				ICDIProject cdiProject = cdiNature.getDelegate();
 				
@@ -634,8 +637,7 @@
 		return null;
 	}
 
-	private IType getTypeToAddAlternativeToStereotype(IProject project, String qualifiedName){
-		IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+	private IType getTypeToAddAlternativeToStereotype(IJavaProject javaProject, String qualifiedName){
 		IType type = null;
 		try {
 			type =  javaProject.findType(qualifiedName);
@@ -644,7 +646,7 @@
 		}
 		
 		if(type != null){
-			CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(project);
+			CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(javaProject.getProject());
 			if(cdiNature != null){
 				ICDIProject cdiProject = cdiNature.getDelegate();
 				
@@ -659,8 +661,7 @@
 		return null;
 	}
 	
-	private IJavaElement findJavaElementByQualifiedName(IProject project, String qualifiedName){
-		IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+	private IJavaElement findJavaElementByQualifiedName(IJavaProject javaProject, String qualifiedName){
 		try {
 			return javaProject.findType(qualifiedName);
 		} catch (JavaModelException ex) {



More information about the jbosstools-commits mailing list