Author: dazarov
Date: 2012-01-11 20:31:34 -0500 (Wed, 11 Jan 2012)
New Revision: 37779
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java
Log:
Quick fix for "Injection point other than injected field must not declare a @Named
annotation that does not specify the value member [JSR-299 ?\194?\1673.11]" error
marker
https://issues.jboss.org/browse/JBIDE-7638
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-01-11
20:59:14 UTC (rev 37778)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2012-01-12
01:31:34 UTC (rev 37779)
@@ -484,15 +484,8 @@
}
}
}else if(messageId ==
CDIValidationErrorManager.PARAM_INJECTION_DECLARES_EMPTY_NAME_ID){
- ILocalVariable parameter = findParameter(file, start);
- if(parameter != null){
- IAnnotation namedAnnotation = getAnnotation(parameter,
CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
- if(namedAnnotation != null){
- return new IMarkerResolution[] {
- new AddNameMarkerResolution(namedAnnotation, parameter.getElementName())
- };
- }
- }
+ List<IMarkerResolution> resolutions = getAddNameResolutions(file, start);
+ return resolutions.toArray(new IMarkerResolution[]{});
}
}else if (XML_EXTENSION.equals(file.getFileExtension())){
FileEditorInput input = new FileEditorInput(file);
@@ -561,6 +554,47 @@
return new IMarkerResolution[] {};
}
+ private List<IMarkerResolution> getAddNameResolutions(IFile file, int start){
+ List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
+ ILocalVariable parameter = findParameter(file, start);
+ if(parameter != null){
+ IAnnotation namedAnnotation = getAnnotation(parameter,
CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ if(namedAnnotation != null){
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+ if(cdiNature == null)
+ return resolutions;
+
+ ICDIProject cdiProject = cdiNature.getDelegate();
+
+ if(cdiProject == null){
+ return resolutions;
+ }
+
+ Set<IBean> allBeans = CDIUtil.getFilteredBeans(cdiProject,
file.getFullPath());
+
+ IInjectionPoint ip = CDIUtil.findInjectionPoint(allBeans, parameter, start);
+ if(ip != null){
+ List<IBean> beans;
+ beans = findLegalBeans(ip);
+ if(beans.size() == 0){
+ beans = findBeans(ip);
+ }
+ if(beans.size() < MARKER_RESULUTION_NUMBER_LIMIT){
+ for(IBean bean : beans){
+ if(bean.getName() != null && !bean.getName().isEmpty()){
+ resolutions.add(new AddNameMarkerResolution(namedAnnotation, bean.getName()));
+ }
+ }
+ }
+ }
+ }
+ if(resolutions.size() == 0){
+ resolutions.add(new AddNameMarkerResolution(namedAnnotation,
parameter.getElementName()));
+ }
+ }
+ return resolutions;
+ }
+
private IType getTypeToAddAlternativeToBean(IProject project, String qualifiedName){
IJavaProject javaProject = EclipseUtil.getJavaProject(project);
IType type = null;