[jbosstools-commits] JBoss Tools SVN: r42583 - in trunk: cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker and 7 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri Jul 13 18:39:31 EDT 2012
Author: dazarov
Date: 2012-07-13 18:39:30 -0400 (Fri, 13 Jul 2012)
New Revision: 42583
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFix.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/marker/CDIMarkerResolutionGeneratorExtension.java
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/AddLocalBeanMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
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/ChangeAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllOtherAnnotationsFromParametersMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ICDIMarkerResolutionGeneratorExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java
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/MakeFieldStaticMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/TempJavaProblem.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFixGenerator.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/QuickFixManager.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.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.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/marker/CDIMarkerResolutionGeneratorExtension.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/marker/CDIMarkerResolutionGeneratorExtension.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.ui/src/org/jboss/tools/cdi/seam/config/ui/marker/CDIMarkerResolutionGeneratorExtension.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -13,11 +13,11 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.ui.IMarkerResolution;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.internal.core.validation.CDIValidationErrorManager;
import org.jboss.tools.cdi.seam.solder.core.generic.IGenericBean;
import org.jboss.tools.cdi.ui.marker.ICDIMarkerResolutionGeneratorExtension;
+import org.jboss.tools.common.quickfix.IQuickFix;
public class CDIMarkerResolutionGeneratorExtension implements
ICDIMarkerResolutionGeneratorExtension {
@@ -29,7 +29,7 @@
}
@Override
- public List<IMarkerResolution> getResolutions(int id, IBean bean) {
+ public List<IQuickFix> getResolutions(int id, IBean bean) {
return Collections.emptyList();
}
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 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddAnnotationMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -32,6 +32,7 @@
private String qualifiedName;
public AddAnnotationMarkerResolution(IJavaElement element, String qualifiedName){
+ super(CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit());
this.element = element;
this.qualifiedName = qualifiedName;
String shortName = CDIMarkerResolutionUtils.getShortName(qualifiedName);
@@ -62,11 +63,6 @@
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddLocalBeanMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,7 +12,6 @@
import java.text.MessageFormat;
-import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -26,9 +25,9 @@
import org.eclipse.text.edits.ReplaceEdit;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDIImages;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.refactoring.BaseMarkerResolution;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
@@ -42,19 +41,14 @@
private static final String SPACE = " "; //$NON-NLS-1$
private IMethod method;
- private IFile file;
- public AddLocalBeanMarkerResolution(IMethod method, IFile file){
+ public AddLocalBeanMarkerResolution(IMethod method){
+ super(CDIMarkerResolutionUtils.getJavaMember(method).getCompilationUnit());
this.label = MessageFormat.format(CDIUIMessages.ADD_LOCAL_BEAN_MARKER_RESOLUTION_TITLE, new Object[]{method.getDeclaringType().getElementName()});
this.method = method;
- this.file = file;
init();
}
- @Override
- protected ICompilationUnit getCompilationUnit(){
- return EclipseUtil.getCompilationUnit(file);
- }
@Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddRetentionAnnotationMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -28,17 +28,13 @@
private IType type;
public AddRetentionAnnotationMarkerResolution(IType type){
+ super(type.getCompilationUnit());
this.type = type;
label = NLS.bind(CDIUIMessages.ADD_RETENTION_MARKER_RESOLUTION_TITLE, type.getElementName());
init();
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return type.getCompilationUnit();
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddSerializableInterfaceMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,7 +12,6 @@
import java.text.MessageFormat;
-import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -23,7 +22,6 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.refactoring.BaseMarkerResolution;
/**
@@ -33,21 +31,15 @@
public static final String SERIALIZABLE = "java.io.Serializable"; //$NON-NLS-1$
private IType type;
- private IFile file;
- public AddSerializableInterfaceMarkerResolution(IType type, IFile file){
+ public AddSerializableInterfaceMarkerResolution(IType type){
+ super(type.getCompilationUnit());
this.label = MessageFormat.format(CDIUIMessages.ADD_SERIALIZABLE_INTERFACE_MARKER_RESOLUTION_TITLE, new Object[]{type.getElementName()});
this.type = type;
- this.file = file;
init();
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return EclipseUtil.getCompilationUnit(file);
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/AddTargetAnnotationMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -31,6 +31,7 @@
private String totalList;
public AddTargetAnnotationMarkerResolution(IType type, String[] typeNames){
+ super(type.getCompilationUnit());
this.qualifiedNames = typeNames;
this.type = type;
shortNames = CDIMarkerResolutionUtils.getShortNames(qualifiedNames);
@@ -40,11 +41,6 @@
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return type.getCompilationUnit();
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
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-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/CDIProblemMarkerResolutionGenerator.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -31,13 +31,16 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaConventionsUtil;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.Annotation;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator2;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.DocumentProviderRegistry;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDIUtil;
@@ -57,12 +60,16 @@
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.common.quickfix.IQuickFix;
+import org.jboss.tools.common.quickfix.IQuickFixGenerator;
+import org.jboss.tools.common.validation.java.TempJavaProblem;
+import org.jboss.tools.common.validation.java.TempJavaProblemAnnotation;
/**
* @author Daniel Azarov
*/
public class CDIProblemMarkerResolutionGenerator implements
- IMarkerResolutionGenerator2 {
+ IMarkerResolutionGenerator2, IQuickFixGenerator {
private static final String JAVA_EXTENSION = "java"; //$NON-NLS-1$
private static final String XML_EXTENSION = "xml"; //$NON-NLS-1$
private static final int MARKER_RESULUTION_NUMBER_LIMIT = 7;
@@ -89,420 +96,428 @@
return -1;
}
-
- private IMarkerResolution[] findResolutions(IMarker marker)
- throws CoreException {
-
- int messageId = getMessageID(marker);
- if (messageId == -1)
- 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)
- return new IMarkerResolution[] {};
- final int start = attribute.intValue();
-
- attribute = ((Integer) marker.getAttribute(IMarker.CHAR_END));
- if (attribute == null)
- return new IMarkerResolution[] {};
- final int end = attribute.intValue();
-
- ICDIMarkerResolutionGeneratorExtension[] extensions = CDIQuickFixExtensionManager.getInstances();
-
- if (JAVA_EXTENSION.equals(file.getFileExtension())) {
- if (messageId == CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID) {
- IField field = findNonStaticField(file, start);
- if(field != null){
- return new IMarkerResolution[] {
- new MakeFieldStaticMarkerResolution(field, file)
+
+ private IQuickFix[] findResolutions(ICompilationUnit compilationUnit, int problemId, int offset, ICDIMarkerResolutionGeneratorExtension[] extensions) throws JavaModelException{
+ if (problemId == CDIValidationErrorManager.ILLEGAL_PRODUCER_FIELD_IN_SESSION_BEAN_ID) {
+ IField field = findNonStaticField(compilationUnit, offset);
+ if(field != null){
+ return new IQuickFix[] {
+ new MakeFieldStaticMarkerResolution(field)
+ };
+ }
+ }else if (problemId == CDIValidationErrorManager.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN_ID ||
+ problemId == CDIValidationErrorManager.ILLEGAL_DISPOSER_IN_SESSION_BEAN_ID ||
+ problemId == CDIValidationErrorManager.ILLEGAL_OBSERVER_IN_SESSION_BEAN_ID) {
+ IMethod method = findMethod(compilationUnit, offset);
+ if(method != null){
+ List<IType> types = findLocalAnnotattedInterfaces(method);
+ if(types.size() == 0 && !Flags.isPublic(method.getFlags())){
+ return new IQuickFix[] {
+ new MakeMethodPublicMarkerResolution(method)
};
- }
- }else if (messageId == CDIValidationErrorManager.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN_ID ||
- messageId == CDIValidationErrorManager.ILLEGAL_DISPOSER_IN_SESSION_BEAN_ID ||
- messageId == CDIValidationErrorManager.ILLEGAL_OBSERVER_IN_SESSION_BEAN_ID) {
- IMethod method = findMethod(file, start);
- if(method != null){
- List<IType> types = findLocalAnnotattedInterfaces(method);
- if(types.size() == 0 && !Flags.isPublic(method.getFlags())){
- return new IMarkerResolution[] {
- new MakeMethodPublicMarkerResolution(method, file)
- };
- }else{
- IMarkerResolution[] resolutions = new IMarkerResolution[types.size()+1];
- for(int i = 0; i < types.size(); i++){
- resolutions[i] = new MakeMethodBusinessMarkerResolution(method, types.get(i), file);
- }
- resolutions[types.size()] = new AddLocalBeanMarkerResolution(method, file);
- return resolutions;
+ }else{
+ IQuickFix[] resolutions = new IQuickFix[types.size()+1];
+ for(int i = 0; i < types.size(); i++){
+ resolutions[i] = new MakeMethodBusinessMarkerResolution(method, types.get(i));
}
+ resolutions[types.size()] = new AddLocalBeanMarkerResolution(method);
+ return resolutions;
}
- }else if (messageId == CDIValidationErrorManager.MULTIPLE_DISPOSERS_FOR_PRODUCER_ID) {
- IMethod method = findMethod(file, start);
- if(method != null){
- return new IMarkerResolution[] {
- new DeleteAllDisposerDuplicantMarkerResolution(method, file)
- };
+ }
+ }else if (problemId == CDIValidationErrorManager.MULTIPLE_DISPOSERS_FOR_PRODUCER_ID) {
+ IMethod method = findMethod(compilationUnit, offset);
+ if(method != null){
+ return new IQuickFix[] {
+ new DeleteAllDisposerDuplicantMarkerResolution(method)
+ };
+ }
+ }else if (problemId == CDIValidationErrorManager.MULTIPLE_INJECTION_CONSTRUCTORS_ID) {
+ IMethod method = findMethod(compilationUnit, offset);
+ if(method != null){
+ return new IQuickFix[] {
+ new DeleteAllInjectedConstructorsMarkerResolution(method)
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.AMBIGUOUS_INJECTION_POINTS_ID ||
+ problemId == CDIValidationErrorManager.UNSATISFIED_INJECTION_POINTS_ID){
+
+ List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
+
+ IInjectionPoint injectionPoint = findInjectionPoint(compilationUnit, offset);
+ if(injectionPoint != null){
+ List<IBean> beans;
+ if(problemId == CDIValidationErrorManager.AMBIGUOUS_INJECTION_POINTS_ID){
+ beans = findBeans(injectionPoint);
+ }else{
+ beans = findLegalBeans(injectionPoint);
}
- }else if (messageId == CDIValidationErrorManager.MULTIPLE_INJECTION_CONSTRUCTORS_ID) {
- IMethod method = findMethod(file, start);
- if(method != null){
- return new IMarkerResolution[] {
- new DeleteAllInjectedConstructorsMarkerResolution(method, file)
- };
- }
- }else if(messageId == CDIValidationErrorManager.AMBIGUOUS_INJECTION_POINTS_ID ||
- messageId == CDIValidationErrorManager.UNSATISFIED_INJECTION_POINTS_ID){
- List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
-
- IInjectionPoint injectionPoint = findInjectionPoint(file, start);
- if(injectionPoint != null){
- List<IBean> beans;
- if(messageId == CDIValidationErrorManager.AMBIGUOUS_INJECTION_POINTS_ID){
- beans = findBeans(injectionPoint);
- }else{
- beans = findLegalBeans(injectionPoint);
- }
-
- for(int i = beans.size()-1; i >= 0; i--){
- IBean bean = beans.get(i);
- for(ICDIMarkerResolutionGeneratorExtension extension : extensions){
- if(extension.shouldBeExtended(messageId, bean)){
- List<IMarkerResolution> addings = extension.getResolutions(messageId, bean);
- resolutions.addAll(addings);
- beans.remove(bean);
- break;
- }
+ for(int i = beans.size()-1; i >= 0; i--){
+ IBean bean = beans.get(i);
+ for(ICDIMarkerResolutionGeneratorExtension extension : extensions){
+ if(extension.shouldBeExtended(problemId, bean)){
+ List<IQuickFix> addings = extension.getResolutions(problemId, bean);
+ resolutions.addAll(addings);
+ beans.remove(bean);
+ break;
}
}
-
- if(beans.size() < MARKER_RESULUTION_NUMBER_LIMIT){
- for(int i = 0; i < beans.size(); i++){
- resolutions.add(new MakeInjectedPointUnambiguousMarkerResolution(injectionPoint, beans, i));
- }
- }else{
- resolutions.add(new SelectBeanMarkerResolution(injectionPoint, beans));
- }
}
- return resolutions.toArray(new IMarkerResolution[]{});
- }else if(messageId == CDIValidationErrorManager.NOT_PASSIVATION_CAPABLE_BEAN_ID){
- IType type = findTypeWithNoSerializable(file, start);
- if(type != null){
- return new IMarkerResolution[] {
- new AddSerializableInterfaceMarkerResolution(type, file)
- };
- }
- }else if(messageId == CDIValidationErrorManager.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD_ID){
- IField field = findPublicField(file, start);
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
- if(cdiNature != null){
- ICDIProject cdiProject = cdiNature.getDelegate();
-
- if(cdiProject != null){
- Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
- Iterator<IBean> iter = beans.iterator();
- if(iter.hasNext()){
- IBean bean = iter.next();
- if(field != null){
- return new IMarkerResolution[] {
- new MakeFieldProtectedMarkerResolution(field, file),
- new MakeBeanScopedDependentMarkerResolution(bean, file)
- };
- }
- }
+ if(beans.size() < MARKER_RESULUTION_NUMBER_LIMIT){
+ for(int i = 0; i < beans.size(); i++){
+ resolutions.add(new MakeInjectedPointUnambiguousMarkerResolution(injectionPoint, beans, i));
}
+ }else{
+ resolutions.add(new SelectBeanMarkerResolution(injectionPoint, beans));
}
- }else if(messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID ||
- messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID ||
- messageId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
+ }
+ return resolutions.toArray(new IQuickFix[]{});
+ }else if(problemId == CDIValidationErrorManager.NOT_PASSIVATION_CAPABLE_BEAN_ID){
+ IType type = findTypeWithNoSerializable(compilationUnit, offset);
+
+ if(type != null){
+ return new IQuickFix[] {
+ new AddSerializableInterfaceMarkerResolution(type)
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD_ID){
+ IField field = findPublicField(compilationUnit, offset);
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(field.getUnderlyingResource().getProject());
+ if(cdiNature != null){
+ ICDIProject cdiProject = cdiNature.getDelegate();
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
- if(ta != null){
- if(ta.annotation == null){
- return new IMarkerResolution[] {
- new AddRetentionAnnotationMarkerResolution(ta.type)
- };
- }else{
- return new IMarkerResolution[] {
- new ChangeAnnotationMarkerResolution(ta.annotation, CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME)
- };
-
+ if(cdiProject != null){
+ Set<IBean> beans = cdiProject.getBeans(field.getUnderlyingResource().getFullPath());
+ Iterator<IBean> iter = beans.iterator();
+ if(iter.hasNext()){
+ IBean bean = iter.next();
+ if(field != null){
+ return new IQuickFix[] {
+ new MakeFieldProtectedMarkerResolution(field),
+ new MakeBeanScopedDependentMarkerResolution(compilationUnit, bean)
+ };
+ }
}
}
- }else if(messageId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
- if(ta != null){
- if(ta.annotation == null){
- return new IMarkerResolution[] {
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME}),
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME})
- };
- }else{
- return new IMarkerResolution[] {
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME}),
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME})
- };
-
- }
- }
- }else if(messageId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
- if(ta != null){
- if(ta.annotation == null){
- return new IMarkerResolution[] {
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME}),
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME}),
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ }
+ }else if(problemId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_QUALIFIER_TYPE_ID ||
+ problemId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE_ID ||
+ problemId == CDIValidationErrorManager.MISSING_RETENTION_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
+
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IQuickFix[] {
+ new AddRetentionAnnotationMarkerResolution(ta.type)
};
- }else{
- return new IMarkerResolution[] {
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME}),
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME}),
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ }else{
+ return new IQuickFix[] {
+ new ChangeAnnotationMarkerResolution(ta.annotation, CDIConstants.RETENTION_POLICY_RUNTIME_TYPE_NAME)
};
- }
}
- }else if(messageId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
- if(ta != null){
- if(ta.annotation == null){
- return new IMarkerResolution[] {
- new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ }
+ }else if(problemId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IQuickFix[] {
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME}),
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME})
};
- }else{
- return new IMarkerResolution[] {
- new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ }else{
+ return new IQuickFix[] {
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME}),
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME, CDIConstants.ELEMENT_TYPE_PARAMETER_NAME})
};
- }
}
- }else if(messageId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER_ID ||
- messageId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID ||
- messageId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER_ID ||
- messageId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IAnnotation annotation = getAnnotation(element, CDIConstants.NON_BINDING_ANNOTATION_TYPE_NAME);
- if(element instanceof IMember && annotation == null){
- return new IMarkerResolution[] {
- new AddAnnotationMarkerResolution((IMember)element, CDIConstants.NON_BINDING_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_STEREOTYPE_TYPE_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IQuickFix[] {
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME}),
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME}),
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ };
+ }else{
+ return new IQuickFix[] {
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME}),
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME}),
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_METHOD_NAME}),
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ };
+
}
- }else if(messageId == CDIValidationErrorManager.DISPOSER_ANNOTATED_INJECT_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- IJavaElement disposesElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- if(injectElement != null && disposesElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(disposesElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.MISSING_TARGET_ANNOTATION_IN_SCOPE_TYPE_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
+ if(ta != null){
+ if(ta.annotation == null){
+ return new IQuickFix[] {
+ new AddTargetAnnotationMarkerResolution(ta.type, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ };
+ }else{
+ return new IQuickFix[] {
+ new ChangeAnnotationMarkerResolution(ta.annotation, new String[]{CDIConstants.ELEMENT_TYPE_TYPE_NAME, CDIConstants.ELEMENT_TYPE_METHOD_NAME, CDIConstants.ELEMENT_TYPE_FIELD_NAME})
+ };
+
}
- }else if(messageId == CDIValidationErrorManager.PRODUCER_ANNOTATED_INJECT_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- IJavaElement produsesElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
- if(injectElement != null && produsesElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(produsesElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER_ID ||
+ problemId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ANNOTATION_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID ||
+ problemId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_INTERCEPTOR_BINDING_TYPE_MEMBER_ID ||
+ problemId == CDIValidationErrorManager.MISSING_NONBINDING_FOR_ARRAY_VALUE_IN_QUALIFIER_TYPE_MEMBER_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IAnnotation annotation = getAnnotation(element, CDIConstants.NON_BINDING_ANNOTATION_TYPE_NAME);
+ if(element instanceof IMember && annotation == null){
+ return new IQuickFix[] {
+ new AddAnnotationMarkerResolution((IMember)element, CDIConstants.NON_BINDING_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.OBSERVER_ANNOTATED_INJECT_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(injectElement != null && observerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.DISPOSER_ANNOTATED_INJECT_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ IJavaElement disposesElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ if(injectElement != null && disposesElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(disposesElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(observerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.PRODUCER_ANNOTATED_INJECT_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ IJavaElement produsesElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
+ if(injectElement != null && produsesElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(produsesElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.DISPOSER_IN_INTERCEPTOR_ID ||
- messageId == CDIValidationErrorManager.DISPOSER_IN_DECORATOR_ID ||
- messageId == CDIValidationErrorManager.CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- if(disposerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.OBSERVER_ANNOTATED_INJECT_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement injectElement = findJavaElementByAnnotation(element, CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if(injectElement != null && observerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(injectElement, CDIConstants.INJECT_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.PRODUCER_IN_INTERCEPTOR_ID ||
- messageId == CDIValidationErrorManager.PRODUCER_IN_DECORATOR_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
- if(producerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.CONSTRUCTOR_PARAMETER_ANNOTATED_OBSERVES_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if(observerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.STEREOTYPE_DECLARES_NON_EMPTY_NAME_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
- if(ta != null && ta.annotation != null && ta.type != null){
- return new IMarkerResolution[] {
- new ChangeAnnotationMarkerResolution(ta.annotation),
- new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.NAMED_QUALIFIER_TYPE_NAME)
+ }
+ }else if(problemId == CDIValidationErrorManager.DISPOSER_IN_INTERCEPTOR_ID ||
+ problemId == CDIValidationErrorManager.DISPOSER_IN_DECORATOR_ID ||
+ problemId == CDIValidationErrorManager.CONSTRUCTOR_PARAMETER_ANNOTATED_DISPOSES_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ if(disposerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
};
}
- }else if(messageId == CDIValidationErrorManager.INTERCEPTOR_HAS_NAME_ID ||
- messageId == CDIValidationErrorManager.DECORATOR_HAS_NAME_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
- if(ta != null && ta.type != null){
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
- if(cdiNature != null){
- ICDIProject cdiProject = cdiNature.getDelegate();
- IType declarationType = findNamedDeclarationType(cdiProject, ta.type, messageId == CDIValidationErrorManager.DECORATOR_HAS_NAME_ID);
- ArrayList<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
- if(declarationType != null){
- IAnnotation annotation = getAnnotation(declarationType, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ }
+ }else if(problemId == CDIValidationErrorManager.PRODUCER_IN_INTERCEPTOR_ID ||
+ problemId == CDIValidationErrorManager.PRODUCER_IN_DECORATOR_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
+ if(producerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME)
+ };
+ }
+ }
+ }else if(problemId == CDIValidationErrorManager.STEREOTYPE_DECLARES_NON_EMPTY_NAME_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ if(ta != null && ta.annotation != null && ta.type != null){
+ return new IQuickFix[] {
+ new ChangeAnnotationMarkerResolution(ta.annotation),
+ new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.NAMED_QUALIFIER_TYPE_NAME)
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.INTERCEPTOR_HAS_NAME_ID ||
+ problemId == CDIValidationErrorManager.DECORATOR_HAS_NAME_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ if(ta != null && ta.type != null){
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(ta.type.getUnderlyingResource().getProject());
+ if(cdiNature != null){
+ ICDIProject cdiProject = cdiNature.getDelegate();
+ IType declarationType = findNamedDeclarationType(cdiProject, ta.type, problemId == CDIValidationErrorManager.DECORATOR_HAS_NAME_ID);
+ ArrayList<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
+ if(declarationType != null){
+ IAnnotation annotation = getAnnotation(declarationType, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ if(annotation != null){
+ resolutions.add(new DeleteAnnotationMarkerResolution(declarationType, CDIConstants.NAMED_QUALIFIER_TYPE_NAME));
+ }
+
+ if(!declarationType.equals(ta.type)){
+ annotation = getAnnotation(ta.type, declarationType.getFullyQualifiedName());
if(annotation != null){
- resolutions.add(new DeleteAnnotationMarkerResolution(declarationType, CDIConstants.NAMED_QUALIFIER_TYPE_NAME));
+ resolutions.add(new DeleteAnnotationMarkerResolution(ta.type, declarationType.getFullyQualifiedName()));
}
-
- if(!declarationType.equals(ta.type)){
- annotation = getAnnotation(ta.type, declarationType.getFullyQualifiedName());
- if(annotation != null){
- resolutions.add(new DeleteAnnotationMarkerResolution(ta.type, declarationType.getFullyQualifiedName()));
- }
- }
}
- if(!resolutions.isEmpty()){
- return resolutions.toArray(new IMarkerResolution[]{});
- }
}
+ if(!resolutions.isEmpty()){
+ return resolutions.toArray(new IQuickFix[]{});
+ }
}
- }else if(messageId == CDIValidationErrorManager.STEREOTYPE_IS_ANNOTATED_TYPED_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.TYPED_ANNOTATION_TYPE_NAME);
- if(ta != null && ta.annotation != null && ta.type != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.TYPED_ANNOTATION_TYPE_NAME)
+ }
+ }else if(problemId == CDIValidationErrorManager.STEREOTYPE_IS_ANNOTATED_TYPED_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.TYPED_ANNOTATION_TYPE_NAME);
+ if(ta != null && ta.annotation != null && ta.type != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.TYPED_ANNOTATION_TYPE_NAME)
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.INTERCEPTOR_ANNOTATED_SPECIALIZES_ID ||
+ problemId == CDIValidationErrorManager.DECORATOR_ANNOTATED_SPECIALIZES_ID){
+ TypeAndAnnotation ta = findTypeAndAnnotation(compilationUnit, offset, CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME);
+ if(ta != null && ta.annotation != null && ta.type != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME)
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
+ IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ if(producerElement != null && disposerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
};
}
- }else if(messageId == CDIValidationErrorManager.INTERCEPTOR_ANNOTATED_SPECIALIZES_ID ||
- messageId == CDIValidationErrorManager.DECORATOR_ANNOTATED_SPECIALIZES_ID){
- TypeAndAnnotation ta = findTypeAndAnnotation(file, start, CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME);
- if(ta != null && ta.annotation != null && ta.type != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(ta.type, CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME)
+ }
+ }else if(problemId == CDIValidationErrorManager.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
+ IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if(producerElement != null && observerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
};
}
- }else if(messageId == CDIValidationErrorManager.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
- IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- if(producerElement != null && disposerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if(disposerElement != null && observerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME),
+ new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement producerElement = findJavaElementByAnnotation(element, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
- IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(producerElement != null && observerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(producerElement, CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
- };
- }
+ }
+ }else if(problemId == CDIValidationErrorManager.OBSERVER_IN_DECORATOR_ID ||
+ problemId == CDIValidationErrorManager.OBSERVER_IN_INTERCEPTOR_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ if(observerElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
+ };
}
- }else if(messageId == CDIValidationErrorManager.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement disposerElement = findJavaElementByAnnotation(element, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(disposerElement != null && observerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(disposerElement, CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME),
- new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
- };
- }
- }
- }else if(messageId == CDIValidationErrorManager.OBSERVER_IN_DECORATOR_ID ||
- messageId == CDIValidationErrorManager.OBSERVER_IN_INTERCEPTOR_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement observerElement = findJavaElementByAnnotation(element, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(observerElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(observerElement, CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME)
- };
- }
- }
- }else if(messageId == CDIValidationErrorManager.SESSION_BEAN_ANNOTATED_INTERCEPTOR_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement interceptorElement = findJavaElementByAnnotation(element, CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
- if(interceptorElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(interceptorElement, CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME)
- };
- }
- }
- }else if(messageId == CDIValidationErrorManager.SESSION_BEAN_ANNOTATED_DECORATOR_ID){
- IJavaElement element = findJavaElement(file, start);
- if(element != null){
- IJavaElement decoratorElement = findJavaElementByAnnotation(element, CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
- if(decoratorElement != null){
- return new IMarkerResolution[] {
- new DeleteAnnotationMarkerResolution(decoratorElement, CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME)
- };
- }
- }
- }else if(messageId == CDIValidationErrorManager.PARAM_INJECTION_DECLARES_EMPTY_NAME_ID){
- List<IMarkerResolution> resolutions = getAddNameResolutions(file, start);
- return resolutions.toArray(new IMarkerResolution[]{});
- }else if(messageId == CDIValidationErrorManager.MULTIPLE_DISPOSING_PARAMETERS_ID){
- ILocalVariable parameter = findParameter(file, start);
- if(parameter != null){
- return new IMarkerResolution[] {
- new DeleteAllOtherAnnotationsFromParametersMarkerResolution(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME, parameter, file)
+ }
+ }else if(problemId == CDIValidationErrorManager.SESSION_BEAN_ANNOTATED_INTERCEPTOR_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement interceptorElement = findJavaElementByAnnotation(element, CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
+ if(interceptorElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(interceptorElement, CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME)
};
}
- }else if(messageId == CDIValidationErrorManager.MULTIPLE_OBSERVING_PARAMETERS_ID){
- ILocalVariable parameter = findParameter(file, start);
- if(parameter != null){
- return new IMarkerResolution[] {
- new DeleteAllOtherAnnotationsFromParametersMarkerResolution(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME, parameter, file)
+ }
+ }else if(problemId == CDIValidationErrorManager.SESSION_BEAN_ANNOTATED_DECORATOR_ID){
+ IJavaElement element = findJavaElement(compilationUnit, offset);
+ if(element != null){
+ IJavaElement decoratorElement = findJavaElementByAnnotation(element, CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
+ if(decoratorElement != null){
+ return new IQuickFix[] {
+ new DeleteAnnotationMarkerResolution(decoratorElement, CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME)
};
}
}
+ }else if(problemId == CDIValidationErrorManager.PARAM_INJECTION_DECLARES_EMPTY_NAME_ID){
+ List<IMarkerResolution> resolutions = getAddNameResolutions(compilationUnit, offset);
+ return resolutions.toArray(new IQuickFix[]{});
+ }else if(problemId == CDIValidationErrorManager.MULTIPLE_DISPOSING_PARAMETERS_ID){
+ ILocalVariable parameter = findParameter(compilationUnit, offset);
+ if(parameter != null){
+ return new IQuickFix[] {
+ new DeleteAllOtherAnnotationsFromParametersMarkerResolution(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME, parameter, (IFile)parameter.getUnderlyingResource())
+ };
+ }
+ }else if(problemId == CDIValidationErrorManager.MULTIPLE_OBSERVING_PARAMETERS_ID){
+ ILocalVariable parameter = findParameter(compilationUnit, offset);
+ if(parameter != null){
+ return new IQuickFix[] {
+ new DeleteAllOtherAnnotationsFromParametersMarkerResolution(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME, parameter, (IFile)parameter.getUnderlyingResource())
+ };
+ }
+ }
+ return new IQuickFix[] {};
+ }
+
+ private IMarkerResolution[] findResolutions(IMarker marker)
+ throws CoreException {
+
+ int messageId = getMessageID(marker);
+ if (messageId == -1)
+ 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)
+ return new IMarkerResolution[] {};
+ final int start = attribute.intValue();
+
+ attribute = ((Integer) marker.getAttribute(IMarker.CHAR_END));
+ if (attribute == null)
+ return new IMarkerResolution[] {};
+ final int end = attribute.intValue();
+
+ ICDIMarkerResolutionGeneratorExtension[] extensions = CDIQuickFixExtensionManager.getInstances();
+
+ if (JAVA_EXTENSION.equals(file.getFileExtension())) {
+ ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
+
+ return findResolutions(compilationUnit, messageId, start, extensions);
+
}else if (XML_EXTENSION.equals(file.getFileExtension())){
FileEditorInput input = new FileEditorInput(file);
IDocumentProvider provider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
@@ -572,13 +587,13 @@
return new IMarkerResolution[] {};
}
- private List<IMarkerResolution> getAddNameResolutions(IFile file, int start){
+ private List<IMarkerResolution> getAddNameResolutions(ICompilationUnit compilationUnit, int start) throws JavaModelException{
List<IMarkerResolution> resolutions = new ArrayList<IMarkerResolution>();
- ILocalVariable parameter = findParameter(file, start);
+ ILocalVariable parameter = findParameter(compilationUnit, start);
if(parameter != null){
IAnnotation namedAnnotation = getAnnotation(parameter, CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if(namedAnnotation != null){
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(compilationUnit.getUnderlyingResource().getProject());
if(cdiNature == null)
return resolutions;
@@ -588,7 +603,7 @@
return resolutions;
}
- Set<IBean> allBeans = CDIUtil.getFilteredBeans(cdiProject, file.getFullPath());
+ Set<IBean> allBeans = CDIUtil.getFilteredBeans(cdiProject, compilationUnit.getUnderlyingResource().getFullPath());
IInjectionPoint ip = CDIUtil.findInjectionPoint(allBeans, parameter, start);
if(ip != null){
@@ -756,12 +771,12 @@
}
- private IInjectionPoint findInjectionPoint(IFile file, int start){
- IJavaElement element = findJavaElement(file, start);
+ private IInjectionPoint findInjectionPoint(ICompilationUnit compilationUnit, int start) throws JavaModelException{
+ IJavaElement element = findJavaElement(compilationUnit, start);
if(element == null)
return null;
- CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(file.getProject());
+ CDICoreNature cdiNature = CDIUtil.getCDINatureWithProgress(compilationUnit.getUnderlyingResource().getProject());
if(cdiNature == null)
return null;
@@ -771,7 +786,7 @@
return null;
}
- Set<IBean> allBeans = CDIUtil.getFilteredBeans(cdiProject, file.getFullPath());
+ Set<IBean> allBeans = CDIUtil.getFilteredBeans(cdiProject, compilationUnit.getUnderlyingResource().getFullPath());
IInjectionPoint ip = CDIUtil.findInjectionPoint(allBeans, element, start);
@@ -789,8 +804,8 @@
return beans;
}
- private IMethod findMethod(IFile file, int start){
- IJavaElement javaElement = findJavaElement(file, start);
+ private IMethod findMethod(ICompilationUnit compilationUnit, int start){
+ IJavaElement javaElement = findJavaElement(compilationUnit, start);
if(javaElement instanceof IMethod){
IMethod method = (IMethod)javaElement;
if(!method.isBinary())
@@ -799,8 +814,8 @@
return null;
}
- private IType findTypeWithNoSerializable(IFile file, int start) throws JavaModelException{
- IJavaElement javaElement = findJavaElement(file, start);
+ private IType findTypeWithNoSerializable(ICompilationUnit compilationUnit, int start) throws JavaModelException{
+ IJavaElement javaElement = findJavaElement(compilationUnit, start);
if(javaElement instanceof IType){
IType type = (IType)javaElement;
if(!type.isBinary()){
@@ -830,8 +845,8 @@
}
}
- private TypeAndAnnotation findTypeAndAnnotation(IFile file, int start, String annotationQualifiedName) throws JavaModelException{
- IJavaElement javaElement = findJavaElement(file, start);
+ private TypeAndAnnotation findTypeAndAnnotation(ICompilationUnit compilationUnit, int start, String annotationQualifiedName) throws JavaModelException{
+ IJavaElement javaElement = findJavaElement(compilationUnit, start);
if(javaElement instanceof IType){
IType type = (IType)javaElement;
if(!type.isBinary()){
@@ -845,20 +860,18 @@
return null;
}
- private IJavaElement findJavaElement(IFile file, int start){
+ private IJavaElement findJavaElement(ICompilationUnit compilationUnit, int start){
try{
- ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
-
return compilationUnit == null ? null : compilationUnit.getElementAt(start);
- }catch(CoreException ex){
+ }catch(JavaModelException ex){
CDIUIPlugin.getDefault().logError(ex);
}
return null;
}
- private ILocalVariable findParameter(IFile file, int start){
- IJavaElement element = findJavaElement(file, start);
+ private ILocalVariable findParameter(ICompilationUnit compilationUnit, int start){
+ IJavaElement element = findJavaElement(compilationUnit, start);
if(element instanceof IMethod){
try {
for(ILocalVariable parameter : ((IMethod) element).getParameters()){
@@ -905,9 +918,9 @@
return false;
}
- private IField findNonStaticField(IFile file, int start){
+ private IField findNonStaticField(ICompilationUnit compilationUnit, int start){
try{
- IJavaElement javaElement = findJavaElement(file, start);
+ IJavaElement javaElement = findJavaElement(compilationUnit, start);
if(javaElement instanceof IField){
IField field = (IField)javaElement;
@@ -920,9 +933,9 @@
return null;
}
- private IField findPublicField(IFile file, int start){
+ private IField findPublicField(ICompilationUnit compilationUnit, int start){
try{
- IJavaElement javaElement = findJavaElement(file, start);
+ IJavaElement javaElement = findJavaElement(compilationUnit, start);
if(javaElement instanceof IField){
IField field = (IField)javaElement;
@@ -1010,4 +1023,30 @@
return null;
}
+ @Override
+ public boolean hasProposals(Annotation annotation) {
+ if(annotation instanceof TempJavaProblemAnnotation || annotation instanceof TemporaryAnnotation){
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public IJavaCompletionProposal[] getProposals(Annotation annotation) {
+ if(annotation instanceof TempJavaProblemAnnotation){
+ int messageId = ((TempJavaProblemAnnotation) annotation).getId() - TempJavaProblem.TEMP_PROBLEM_ID;
+ ICompilationUnit compilationUnit = ((TempJavaProblemAnnotation) annotation).getCompilationUnit();
+ int start = ((TempJavaProblemAnnotation) annotation).getPosition();
+
+ ICDIMarkerResolutionGeneratorExtension[] extensions = CDIQuickFixExtensionManager.getInstances();
+
+ try {
+ return findResolutions(compilationUnit, messageId, start, extensions);
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
+ }
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ChangeAnnotationMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -35,6 +35,7 @@
private String[] qualifiedNames = new String[0];
public ChangeAnnotationMarkerResolution(IAnnotation annotation){
+ super(CDIMarkerResolutionUtils.getJavaMember(annotation).getCompilationUnit());
this.annotation = annotation;
changeString += annotation.getElementName();
@@ -105,11 +106,6 @@
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return CDIMarkerResolutionUtils.getJavaMember(annotation).getCompilationUnit();
- }
-
- @Override
public Image getImage() {
return CDIImages.QUICKFIX_CHANGE;
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllDisposerDuplicantMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -18,33 +18,41 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.internal.core.refactoring.DeleteAllDisposerAnnotationsProcessor;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.cdi.ui.wizard.DeletePreviewWizard;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.common.refactoring.TestableResolutionWithRefactoringProcessor;
/**
* @author Daniel Azarov
*/
-public class DeleteAllDisposerDuplicantMarkerResolution implements IMarkerResolution2, TestableResolutionWithRefactoringProcessor {
+public class DeleteAllDisposerDuplicantMarkerResolution implements IQuickFix, TestableResolutionWithRefactoringProcessor {
private String label;
private IMethod method;
private IFile file;
private String description;
- public DeleteAllDisposerDuplicantMarkerResolution(IMethod method, IFile file){
+ public DeleteAllDisposerDuplicantMarkerResolution(IMethod method){
this.label = MessageFormat.format(CDIUIMessages.DELETE_ALL_DISPOSER_DUPLICANT_MARKER_RESOLUTION_TITLE, new Object[]{method.getElementName()});
this.method = method;
- this.file = file;
+ try {
+ this.file = (IFile) method.getUnderlyingResource();
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
description = getPreview();
}
@@ -53,16 +61,20 @@
return label;
}
-
- @Override
- public void run(IMarker marker) {
+ private void internal_run(){
DeleteAllDisposerAnnotationsProcessor processor = new DeleteAllDisposerAnnotationsProcessor(file, method, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
DeletePreviewWizard wizard = new DeletePreviewWizard(refactoring);
wizard.showWizard();
}
+
@Override
+ public void run(IMarker marker) {
+ internal_run();
+ }
+
+ @Override
public RefactoringProcessor getRefactoringProcessor(){
return new DeleteAllDisposerAnnotationsProcessor(file, method, label);
}
@@ -105,4 +117,34 @@
return CDIImages.QUICKFIX_REMOVE;
}
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run();
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return description;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllInjectedConstructorsMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -18,31 +18,35 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.internal.core.refactoring.DeleteAllInjectedConstructorsProcessor;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.cdi.ui.wizard.DeletePreviewWizard;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.common.refactoring.TestableResolutionWithRefactoringProcessor;
/**
* @author Daniel Azarov
*/
-public class DeleteAllInjectedConstructorsMarkerResolution implements IMarkerResolution2, TestableResolutionWithRefactoringProcessor {
+public class DeleteAllInjectedConstructorsMarkerResolution implements IQuickFix, TestableResolutionWithRefactoringProcessor {
private String label;
private IMethod method;
private IFile file;
private String description;
- public DeleteAllInjectedConstructorsMarkerResolution(IMethod method, IFile file){
+ public DeleteAllInjectedConstructorsMarkerResolution(IMethod method){
StringBuffer buffer = new StringBuffer();
buffer.append(method.getElementName()+"(");
String[] types = method.getParameterTypes();
@@ -54,7 +58,11 @@
buffer.append(")");
this.label = MessageFormat.format(CDIUIMessages.DELETE_ALL_INJECTED_CONSTRUCTORS_MARKER_RESOLUTION_TITLE, new Object[]{buffer.toString()});
this.method = method;
- this.file = file;
+ try {
+ this.file = (IFile) method.getUnderlyingResource();
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
description = getPreview();
}
@@ -91,8 +99,7 @@
return label;
}
- @Override
- public void run(IMarker marker) {
+ private void internal_run(){
DeleteAllInjectedConstructorsProcessor processor = new DeleteAllInjectedConstructorsProcessor(file, method, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
DeletePreviewWizard wizard = new DeletePreviewWizard(refactoring);
@@ -100,6 +107,11 @@
}
@Override
+ public void run(IMarker marker) {
+ internal_run();
+ }
+
+ @Override
public RefactoringProcessor getRefactoringProcessor(){
return new DeleteAllInjectedConstructorsProcessor(file, method, label);
}
@@ -114,4 +126,34 @@
return CDIImages.QUICKFIX_REMOVE;
}
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run();
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return description;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllOtherAnnotationsFromParametersMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllOtherAnnotationsFromParametersMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAllOtherAnnotationsFromParametersMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -18,25 +18,28 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.internal.core.refactoring.DeleteOtherAnnotationsFromParametersProcessor;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.cdi.ui.wizard.DeletePreviewWizard;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.common.refactoring.TestableResolutionWithRefactoringProcessor;
/**
* @author Daniel Azarov
*/
-public class DeleteAllOtherAnnotationsFromParametersMarkerResolution implements IMarkerResolution2, TestableResolutionWithRefactoringProcessor {
+public class DeleteAllOtherAnnotationsFromParametersMarkerResolution implements IQuickFix, TestableResolutionWithRefactoringProcessor {
private String label;
private String annotationName;
private ILocalVariable parameter;
@@ -85,8 +88,7 @@
return label;
}
- @Override
- public void run(IMarker marker) {
+ private void internal_run(){
DeleteOtherAnnotationsFromParametersProcessor processor = new DeleteOtherAnnotationsFromParametersProcessor(file, annotationName, parameter, label);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
DeletePreviewWizard wizard = new DeletePreviewWizard(refactoring);
@@ -94,6 +96,11 @@
}
@Override
+ public void run(IMarker marker) {
+ internal_run();
+ }
+
+ @Override
public RefactoringProcessor getRefactoringProcessor(){
return new DeleteOtherAnnotationsFromParametersProcessor(file, annotationName, parameter, label);
}
@@ -108,4 +115,34 @@
return CDIImages.QUICKFIX_REMOVE;
}
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run();
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return description;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/DeleteAnnotationMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -32,6 +32,7 @@
private String qualifiedName;
public DeleteAnnotationMarkerResolution(IJavaElement element, String qualifiedName){
+ super(CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit());
this.element = element;
this.qualifiedName = qualifiedName;
String shortName = CDIMarkerResolutionUtils.getShortName(qualifiedName);
@@ -60,11 +61,6 @@
label = NLS.bind(CDIUIMessages.DELETE_ANNOTATION_MARKER_RESOLUTION_TITLE, new String[]{shortName, element.getElementName(), type});
init();
}
-
- @Override
- protected ICompilationUnit getCompilationUnit(){
- return CDIMarkerResolutionUtils.getJavaMember(element).getCompilationUnit();
- }
@Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ICDIMarkerResolutionGeneratorExtension.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ICDIMarkerResolutionGeneratorExtension.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/ICDIMarkerResolutionGeneratorExtension.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,11 +12,11 @@
import java.util.List;
-import org.eclipse.ui.IMarkerResolution;
import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.common.quickfix.IQuickFix;
public interface ICDIMarkerResolutionGeneratorExtension{
public boolean shouldBeExtended(int id, IBean bean);
- public List<IMarkerResolution> getResolutions(int id, IBean bean);
+ public List<IQuickFix> getResolutions(int id, IBean bean);
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeBeanScopedDependentMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -14,7 +14,6 @@
import java.util.Iterator;
import java.util.Set;
-import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -32,7 +31,6 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.refactoring.BaseMarkerResolution;
/**
@@ -40,23 +38,17 @@
*/
public class MakeBeanScopedDependentMarkerResolution extends BaseMarkerResolution {
private IBean bean;
- private IFile file;
private IAnnotation annotation;
- public MakeBeanScopedDependentMarkerResolution(IBean bean, IFile file){
+ public MakeBeanScopedDependentMarkerResolution(ICompilationUnit compilationUnit, IBean bean){
+ super(compilationUnit);
this.label = MessageFormat.format(CDIUIMessages.MAKE_BEAN_SCOPED_DEPENDENT_MARKER_RESOLUTION_TITLE, new Object[]{bean.getElementName()});
this.bean = bean;
- this.file = file;
annotation = getScopeAnnotation();
init();
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return EclipseUtil.getCompilationUnit(file);
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
if(annotation != null){
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-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldProtectedMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,7 +12,6 @@
import java.text.MessageFormat;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -23,18 +22,22 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.refactoring.CompilationUnitChange;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
-import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.cdi.core.CDIImages;
+import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.MarkerResolutionUtils;
import org.jboss.tools.common.refactoring.TestableResolutionWithDialog;
import org.jboss.tools.common.ui.CommonUIPlugin;
@@ -42,19 +45,19 @@
/**
* @author Daniel Azarov
*/
-public class MakeFieldProtectedMarkerResolution implements IMarkerResolution2, TestableResolutionWithDialog{
+public class MakeFieldProtectedMarkerResolution implements IQuickFix, TestableResolutionWithDialog{
private static final String PUBLIC = "public"; //$NON-NLS-1$
private static final String PROTECTED = "protected"; //$NON-NLS-1$
private String label;
private IField field;
- private IFile file;
private String description;
+ private ICompilationUnit cUnit;
- public MakeFieldProtectedMarkerResolution(IField field, IFile file){
+ public MakeFieldProtectedMarkerResolution(IField field){
+ cUnit = CDIMarkerResolutionUtils.getJavaMember(field).getCompilationUnit();
this.label = MessageFormat.format(CDIUIMessages.MAKE_FIELD_PROTECTED_MARKER_RESOLUTION_TITLE, new Object[]{field.getElementName()});
this.field = field;
- this.file = file;
description = getPreview();
}
@@ -65,15 +68,15 @@
@Override
public void run(IMarker marker) {
- internal_run(marker, false);
+ internal_run(false);
}
@Override
public void runForTest(IMarker marker) {
- internal_run(marker, true);
+ internal_run(true);
}
- private void internal_run(IMarker marker, boolean test){
+ private void internal_run(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);
@@ -81,17 +84,16 @@
return;
}
try{
- ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
- if(original == null) {
+ if(cUnit == null) {
return;
}
- ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+ ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
CompilationUnitChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
change.perform(new NullProgressMonitor());
- original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
compilationUnit.discardWorkingCopy();
}catch(CoreException ex){
@@ -122,12 +124,18 @@
}
private CompilationUnitChange getPreviewChange(){
- try{
- ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
+ if(cUnit != null){
+ try {
+ ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
+
+ CompilationUnitChange change = getChange(compilationUnit);
+
+ compilationUnit.discardWorkingCopy();
+ return change;
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
- return getChange(original);
- }catch(CoreException ex){
- CDIUIPlugin.getDefault().logError(ex);
}
return null;
}
@@ -152,4 +160,34 @@
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
+
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run(false);
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return description;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeFieldStaticMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,7 +12,6 @@
import java.text.MessageFormat;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IBuffer;
@@ -27,7 +26,6 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.refactoring.BaseMarkerResolution;
/**
@@ -35,19 +33,14 @@
*/
public class MakeFieldStaticMarkerResolution extends BaseMarkerResolution {
private IField field;
- private IFile file;
- public MakeFieldStaticMarkerResolution(IField field, IFile file){
+ public MakeFieldStaticMarkerResolution(IField field){
+ super(CDIMarkerResolutionUtils.getJavaMember(field).getCompilationUnit());
this.label = MessageFormat.format(CDIUIMessages.MAKE_FIELD_STATIC_MARKER_RESOLUTION_TITLE, new Object[]{field.getElementName()});
this.field = field;
- this.file = file;
init();
}
- @Override
- protected ICompilationUnit getCompilationUnit(){
- return EclipseUtil.getCompilationUnit(file);
- }
@Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeInjectedPointUnambiguousMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -14,21 +14,24 @@
import java.util.List;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.internal.core.refactoring.AddQualifiersToBeanProcessor;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.wizard.AddQualifiersToBeanWizard;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.TestableResolutionWithDialog;
/**
* @author Daniel Azarov
*/
-public class MakeInjectedPointUnambiguousMarkerResolution implements IMarkerResolution2, TestableResolutionWithDialog {
+public class MakeInjectedPointUnambiguousMarkerResolution implements IQuickFix, TestableResolutionWithDialog {
private String label;
private IInjectionPoint injectionPoint;
private List<IBean> beans;
@@ -48,37 +51,21 @@
@Override
public void runForTest(IMarker marker){
- internal_run(marker, true);
+ internal_run(true);
}
@Override
public void run(IMarker marker) {
- internal_run(marker, false);
+ internal_run(false);
}
- private void internal_run(IMarker marker, boolean test) {
+ private void internal_run(boolean test) {
AddQualifiersToBeanProcessor processor = new AddQualifiersToBeanProcessor(label, injectionPoint, beans, selectedBean);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
AddQualifiersToBeanWizard wizard = new AddQualifiersToBeanWizard(refactoring);
wizard.showWizard();
}
-// private boolean checkBeans(){
-// Set<IQualifier> qualifiers = selectedBean.getQualifiers();
-// if(qualifiers.size() == 0)
-// return true;
-//
-// for(IBean bean: beans){
-// if(bean.equals(selectedBean))
-// continue;
-// if(MarkerResolutionUtils.checkBeanQualifiers(selectedBean, bean, qualifiers))
-// return true;
-//
-// }
-// return false;
-// }
-
-
@Override
public String getDescription() {
return label;
@@ -89,4 +76,34 @@
return CDIImages.QUICKFIX_EDIT;
}
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run(false);
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return label;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodBusinessMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -23,44 +23,54 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.quickfix.IQuickFix;
/**
* @author Daniel Azarov
*/
-public class MakeMethodBusinessMarkerResolution implements IMarkerResolution2 {
+public class MakeMethodBusinessMarkerResolution implements IQuickFix {
private static final String PUBLIC = "public"; //$NON-NLS-1$
private static final String PRIVATE = "private"; //$NON-NLS-1$
private static final String PROTECTED = "protected"; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
-
private String label;
private IMethod method;
private IType localInterface;
private IFile file;
- public MakeMethodBusinessMarkerResolution(IMethod method, IType localInterface, IFile file){
+ public MakeMethodBusinessMarkerResolution(IMethod method, IType localInterface){
this.label = MessageFormat.format(CDIUIMessages.MAKE_METHOD_BUSINESS_MARKER_RESOLUTION_TITLE, new Object[]{method.getElementName(), localInterface.getElementName()});
this.method = method;
this.localInterface = localInterface;
- this.file = file;
+ try {
+ this.file = (IFile) method.getUnderlyingResource();
+ } catch (JavaModelException e) {
+ CDIUIPlugin.getDefault().logError(e);
+ }
}
@Override
public String getLabel() {
return label;
}
-
+
@Override
public void run(IMarker marker) {
+ internal_run();
+ }
+
+ private void internal_run() {
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
if(original == null) {
@@ -156,4 +166,34 @@
return CDIImages.QUICKFIX_ADD;
}
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run();
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return label;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MakeMethodPublicMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,7 +12,6 @@
import java.text.MessageFormat;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IBuffer;
@@ -28,7 +27,6 @@
import org.jboss.tools.cdi.internal.core.refactoring.CDIMarkerResolutionUtils;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
-import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.refactoring.BaseMarkerResolution;
/**
@@ -36,21 +34,15 @@
*/
public class MakeMethodPublicMarkerResolution extends BaseMarkerResolution {
private IMethod method;
- private IFile file;
- public MakeMethodPublicMarkerResolution(IMethod method, IFile file){
+ public MakeMethodPublicMarkerResolution(IMethod method){
+ super(CDIMarkerResolutionUtils.getJavaMember(method).getCompilationUnit());
this.label = MessageFormat.format(CDIUIMessages.MAKE_METHOD_PUBLIC_MARKER_RESOLUTION_TITLE, new Object[]{method.getElementName()});
this.method = method;
- this.file = file;
init();
}
@Override
- protected ICompilationUnit getCompilationUnit(){
- return EclipseUtil.getCompilationUnit(file);
- }
-
- @Override
protected CompilationUnitChange getChange(ICompilationUnit compilationUnit){
CompilationUnitChange change = new CompilationUnitChange("", compilationUnit);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/SelectBeanMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -13,21 +13,24 @@
import java.util.List;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.cdi.core.CDIImages;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.internal.core.refactoring.AddQualifiersToBeanProcessor;
import org.jboss.tools.cdi.ui.CDIUIMessages;
import org.jboss.tools.cdi.ui.wizard.SelectBeanWizard;
+import org.jboss.tools.common.quickfix.IQuickFix;
import org.jboss.tools.common.refactoring.TestableResolutionWithDialog;
/**
* @author Daniel Azarov
*/
-public class SelectBeanMarkerResolution implements IMarkerResolution2, TestableResolutionWithDialog {
+public class SelectBeanMarkerResolution implements IQuickFix, TestableResolutionWithDialog {
private String label;
private IInjectionPoint injectionPoint;
private List<IBean> beans;
@@ -45,80 +48,19 @@
@Override
public void runForTest(IMarker marker){
- internal_run(marker, true);
+ internal_run(true);
}
@Override
public void run(IMarker marker) {
- internal_run(marker, false);
+ internal_run(false);
}
- private void internal_run(IMarker marker, boolean test) {
- //CompositeChange rootChange = new CompositeChange(label);
-
+ private void internal_run(boolean test) {
AddQualifiersToBeanProcessor processor = new AddQualifiersToBeanProcessor(label, injectionPoint, beans, null);
ProcessorBasedRefactoring refactoring = new ProcessorBasedRefactoring(processor);
SelectBeanWizard wizard = new SelectBeanWizard(refactoring);
- //RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
wizard.showWizard();
-
-
-// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-// SelectBeanWizard wizard = new SelectBeanWizard(injectionPoint, beans);
-// WizardDialog dialog = new WizardDialog(shell, wizard);
-
-// IBean selectedBean = null;
-// List<ValuedQualifier> deployed;
-//
-// if(test){
-// if(beans.isEmpty())
-// return;
-//
-// dialog.setBlockOnOpen(false);
-// dialog.open();
-//
-// selectedBean = beans.get(0);
-//
-// wizard.init(selectedBean);
-//
-// List<IQualifier> qualifiers = new ArrayList<IQualifier>();
-// qualifiers.addAll(wizard.getAvailableQualifiers());
-// if(qualifiers.isEmpty())
-// return;
-// for(IQualifier qualifier : qualifiers){
-// if(wizard.checkBeans())
-// break;
-// wizard.deploy(new ValuedQualifier(qualifier));
-// }
-// deployed = wizard.getDeployedQualifiers();
-// wizard.performCancel();
-// dialog.close();
-// }else{
-// int status = dialog.open();
-//
-// if(status != WizardDialog.OK)
-// return;
-//
-// selectedBean = wizard.getBean();
-// deployed = wizard.getDeployedQualifiers();
-// }
-//
-// MarkerResolutionUtils.addQualifiersToBean(deployed, selectedBean, rootChange);
-// try {
-// Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
-// } catch (InterruptedException e) {
-// // do nothing
-// }
-// // reload selectedBean
-// ICDIProject cdiProject = selectedBean.getCDIProject();
-// IBean[] beans = cdiProject.getBeans();
-// for(IBean bean : beans){
-// if(bean.getBeanClass().getFullyQualifiedName().equals(selectedBean.getBeanClass().getFullyQualifiedName()) && bean.getElementName().equals(selectedBean.getElementName())){
-// selectedBean = bean;
-// break;
-// }
-// }
-// MarkerResolutionUtils.addQualifiersToInjectionPoint(injectionPoint, selectedBean, rootChange);
}
@Override
@@ -130,4 +72,34 @@
public Image getImage() {
return CDIImages.QUICKFIX_EDIT;
}
+
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
+
+ @Override
+ public void apply(IDocument document) {
+ internal_run(false);
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return label;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
}
Added: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFix.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFix.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFix.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.quickfix;
+
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.ui.IMarkerResolution2;
+
+public interface IQuickFix extends IMarkerResolution2, IJavaCompletionProposal{
+
+}
Property changes on: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFix.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFixGenerator.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFixGenerator.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/IQuickFixGenerator.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.common.quickfix;
-import java.util.List;
-
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.source.Annotation;
@@ -27,11 +25,11 @@
public boolean hasProposals(Annotation annotation);
/**
- * Returns list of proposals for the given annotation (may
+ * Returns array of proposals for the given annotation (may
* be empty).
*
* @param annotation the annotation
* @return list of proposals for the given annotation
*/
- public List<IJavaCompletionProposal> getProposals(Annotation annotation);
+ public IJavaCompletionProposal[] getProposals(Annotation annotation);
}
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/QuickFixManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/QuickFixManager.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/quickfix/QuickFixManager.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -15,7 +15,6 @@
import java.util.List;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.source.Annotation;
public class QuickFixManager {
@@ -62,8 +61,10 @@
public List<IJavaCompletionProposal> getProposals(Annotation annotation){
ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
for(IQuickFixGenerator generator : generators.values()){
- List<IJavaCompletionProposal> pp = generator.getProposals(annotation);
- proposals.addAll(pp);
+ IJavaCompletionProposal[] pp = generator.getProposals(annotation);
+ for(IJavaCompletionProposal p : pp){
+ proposals.add(p);
+ }
}
return proposals;
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-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/refactoring/BaseMarkerResolution.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -15,14 +15,22 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ltk.core.refactoring.TextChange;
-import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.quickfix.IQuickFix;
-abstract public class BaseMarkerResolution implements IMarkerResolution2 {
+abstract public class BaseMarkerResolution implements IQuickFix {
protected String label;
protected String description;
+ protected ICompilationUnit cUnit;
+ public BaseMarkerResolution(ICompilationUnit compilationUnit){
+ this.cUnit = compilationUnit;
+ }
+
protected final void init(){
description = getPreview();
}
@@ -31,19 +39,17 @@
public final String getLabel() {
return label;
}
-
- @Override
- public final void run(IMarker marker) {
+
+ protected void run_internal(){
try{
- ICompilationUnit original = getCompilationUnit();
- if(original != null){
- ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+ if(cUnit != null){
+ ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
TextChange change = getChange(compilationUnit);
if(change.getEdit().hasChildren()){
change.perform(new NullProgressMonitor());
- original.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
+ cUnit.reconcile(ICompilationUnit.NO_AST, false, null, new NullProgressMonitor());
}
compilationUnit.discardWorkingCopy();
}
@@ -53,15 +59,19 @@
}
@Override
+ public final void run(IMarker marker) {
+ run_internal();
+ }
+
+ @Override
public final String getDescription() {
return description;
}
private TextChange getPreviewChange(){
- ICompilationUnit original = getCompilationUnit();
- if(original != null){
+ if(cUnit != null){
try {
- ICompilationUnit compilationUnit = original.getWorkingCopy(new NullProgressMonitor());
+ ICompilationUnit compilationUnit = cUnit.getWorkingCopy(new NullProgressMonitor());
TextChange change = getChange(compilationUnit);
@@ -87,8 +97,35 @@
return label;
}
- abstract protected ICompilationUnit getCompilationUnit();
+ @Override
+ public void apply(IDocument document) {
+ run_internal();
+ }
+
+ @Override
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ @Override
+ public String getAdditionalProposalInfo() {
+ return description;
+ }
+
+ @Override
+ public String getDisplayString() {
+ return label;
+ }
+
+ @Override
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ @Override
+ public int getRelevance() {
+ return 100;
+ }
abstract protected TextChange getChange(ICompilationUnit compilationUnit);
-
}
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-07-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/marker/ConfigureProblemSeverityResolutionGenerator.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -11,9 +11,6 @@
package org.jboss.tools.common.ui.marker;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -165,7 +162,7 @@
}
@Override
- public List<IJavaCompletionProposal> getProposals(Annotation annotation) {
+ public IJavaCompletionProposal[] getProposals(Annotation annotation) {
ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
String preferenceKey = getPreferenceKey(annotation);
String preferencePageId = getPreferencePageId(annotation);
@@ -193,7 +190,7 @@
}
proposals.add(new ConfigureProblemSeverityMarkerResolution(preferencePageId, preferenceKey));
}
- return proposals;
+ return proposals.toArray(new IJavaCompletionProposal[]{});
}
private int getPosition(TempJavaProblemAnnotation annotation){
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -79,7 +79,7 @@
public void addProblem(String message, String preferenceKey, ITextSourceReference location, IResource target) {
if(asYouTypeValidation) {
- addMesssage(target, location, preferenceKey, message);
+ addMessage(target, location, preferenceKey, message);
} else {
addError(message, preferenceKey, location, target);
}
@@ -87,7 +87,7 @@
public void addProblem(String message, String preferenceKey, String[] messageArguments, ITextSourceReference location, IResource target) {
if(asYouTypeValidation) {
- addMesssage(target, location, preferenceKey, message, messageArguments);
+ addMessage(target, location, preferenceKey, message, messageArguments);
} else {
addError(message, preferenceKey, messageArguments, location, target);
}
@@ -95,7 +95,7 @@
public void addProblem(String message, String preferenceKey, ITextSourceReference location, IResource target, Integer quickFixId) {
if(asYouTypeValidation) {
- addMesssage(target, location, preferenceKey, message, quickFixId);
+ addMessage(target, location, preferenceKey, message, quickFixId);
} else {
addError(message, preferenceKey, location, target, quickFixId);
}
@@ -103,7 +103,7 @@
public IMarker addProblem(String message, String preferenceKey, String[] messageArguments, int length, int offset, IResource target, Integer quickFixId) {
if(asYouTypeValidation) {
- addMesssage(target, offset, length, preferenceKey, message, messageArguments, quickFixId);
+ addMessage(target, offset, length, preferenceKey, message, messageArguments, quickFixId);
return null;
} else {
return addError(message, preferenceKey, messageArguments, length, offset, target, quickFixId);
@@ -112,30 +112,30 @@
public IMarker addProblem(String message, String preferenceKey, String[] messageArguments, int length, int offset, IResource target) {
if(asYouTypeValidation) {
- addMesssage(target, offset, length, preferenceKey, message, messageArguments);
+ addMessage(target, offset, length, preferenceKey, message, messageArguments);
return null;
} else {
return addError(message, preferenceKey, messageArguments, length, offset, target);
}
}
- public IMessage addMesssage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage) {
- return addMesssage(target, -1, location, preferenceKey, textMessage, null);
+ public IMessage addMessage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage) {
+ return addMessage(target, -1, location, preferenceKey, textMessage, null);
}
- public IMessage addMesssage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage, String[] messageArguments) {
- return addMesssage(target, -1, location, preferenceKey, textMessage, messageArguments);
+ public IMessage addMessage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage, String[] messageArguments) {
+ return addMessage(target, -1, location, preferenceKey, textMessage, messageArguments);
}
- public IMessage addMesssage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage, Integer quickFixId) {
- IMessage message = addMesssage(target, -1, location, preferenceKey, textMessage, null);
- if(message!=null) {
+ public IMessage addMessage(IResource target, ITextSourceReference location, String preferenceKey, String textMessage, Integer quickFixId) {
+ IMessage message = addMessage(target, -1, location, preferenceKey, textMessage, null);
+ if(message!=null && quickFixId != -1) {
message.setAttribute(MESSAGE_ID_ATTRIBUTE_NAME, quickFixId);
}
return message;
}
- public IMessage addMesssage(IResource target, int lineNumber, ITextSourceReference location, String preferenceKey, String textMessage, String[] messageArguments) {
+ public IMessage addMessage(IResource target, int lineNumber, ITextSourceReference location, String preferenceKey, String textMessage, String[] messageArguments) {
int severity = getSeverity(preferenceKey, target);
IMessage message = null;
try {
@@ -148,23 +148,19 @@
return message;
}
- public IMessage addMesssage(IResource target, int offset, int length, String preferenceKey, String messageText, String[] messageArguments, int quickFixId) {
- IMessage message = addMesssage(target, -1, offset, length, preferenceKey, messageText, messageArguments);
- if(message!=null) {
- message.setAttribute(MESSAGE_ID_ATTRIBUTE_NAME, quickFixId);
- }
- return message;
+ public IMessage addMessage(IResource target, int offset, int length, String preferenceKey, String messageText, String[] messageArguments, int quickFixId) {
+ return addMessage(target, -1, offset, length, preferenceKey, messageText, messageArguments, quickFixId);
}
- public IMessage addMesssage(IResource target, int offset, int length, String preferenceKey, String message, String[] messageArguments) {
- return addMesssage(target, -1, offset, length, preferenceKey, message, messageArguments);
+ public IMessage addMessage(IResource target, int offset, int length, String preferenceKey, String message, String[] messageArguments) {
+ return addMessage(target, -1, offset, length, preferenceKey, message, messageArguments, -1);
}
- public IMessage addMesssage(IResource target, int lineNumber, int offset, int length, String preferenceKey, String message, String[] messageArguments) {
+ public IMessage addMessage(IResource target, int lineNumber, int offset, int length, String preferenceKey, String message, String[] messageArguments, int quickFixId) {
int severity = getSeverity(preferenceKey, target);
return severity!=-1?addMesssage(target, lineNumber, offset, length, severity, preferenceKey, message, messageArguments):null;
}
-
+
private IMessage addMesssage(IResource target, int lineNumber, int offset, int length, int severity, String preferenceKey, String textMessage, String[] messageArguments) {
IMessage message = null;
if(messageCounter<=getMaxNumberOfMarkersPerFile(target.getProject())) {
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/TempJavaProblem.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/TempJavaProblem.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/TempJavaProblem.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -14,6 +14,7 @@
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.jboss.tools.common.validation.ValidationErrorManager;
import org.jboss.tools.common.validation.ValidationMessage;
/**
@@ -40,6 +41,8 @@
private String fOrigin;
private ValidationMessage vMessage;
+
+ private int id = TEMP_PROBLEM_ID;
public static final int TEMP_PROBLEM_ID= 0x88000000;
@@ -59,6 +62,10 @@
fOrigin= origin;
fIsError = (IMessage.NORMAL_SEVERITY != message.getSeverity());
vMessage = message;
+ Integer messageId = (Integer) message.getAttribute(ValidationErrorManager.MESSAGE_ID_ATTRIBUTE_NAME);
+ if(messageId != null){
+ id = TEMP_PROBLEM_ID+messageId;
+ }
}
/*
@@ -72,7 +79,7 @@
* @see org.eclipse.jdt.core.compiler.IProblem#getID()
*/
public int getID() {
- return TEMP_PROBLEM_ID;
+ return id;
}
/*
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -299,13 +299,13 @@
IJavaSourceReference reference = getJavaReference(el.getResource(), el.getStartPosition() + error.getPosition(), 1);
if(reference == null) {
if(asYouType) {
- addMesssage(el.getResource(), el.getStartPosition() + error.getPosition(), 1, ELSeverityPreferences.EL_SYNTAX_ERROR, ELValidationMessages.EL_SYNTAX_ERROR, new String[]{error.getProblem()});
+ addMessage(el.getResource(), el.getStartPosition() + error.getPosition(), 1, ELSeverityPreferences.EL_SYNTAX_ERROR, ELValidationMessages.EL_SYNTAX_ERROR, new String[]{error.getProblem()});
} else {
addError(ELValidationMessages.EL_SYNTAX_ERROR, ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()}, el.getLineNumber(), 1, el.getStartPosition() + error.getPosition(), context.getResource());
}
} else {
if(asYouType) {
- addMesssage(el.getResource(), reference, ELSeverityPreferences.EL_SYNTAX_ERROR, ELValidationMessages.EL_SYNTAX_ERROR, new String[]{error.getProblem()});
+ addMessage(el.getResource(), reference, ELSeverityPreferences.EL_SYNTAX_ERROR, ELValidationMessages.EL_SYNTAX_ERROR, new String[]{error.getProblem()});
} else {
addError(ELValidationMessages.EL_SYNTAX_ERROR, ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()}, reference, context.getResource());
}
@@ -425,14 +425,14 @@
IMarker marker = null;
if(reference != null) {
if(asYouType) {
- addMesssage(file, reference, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName});
+ addMessage(file, reference, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName});
} else {
marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName}, reference, file);
elReference.addMarker(marker);
}
} else {
if(asYouType) {
- addMesssage(file, startPosition, length, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName});
+ addMessage(file, startPosition, length, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName});
} else {
marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName, existedMethodName, missingMethodName}, elReference.getLineNumber(), length, startPosition, file);
elReference.addMarker(marker);
@@ -485,13 +485,13 @@
}
if(javaReference == null) {
if(asYouType) {
- addMesssage(file, offsetOfVarName, lengthOfVarName, preference, message, new String[]{varName});
+ addMessage(file, offsetOfVarName, lengthOfVarName, preference, message, new String[]{varName});
} else {
marker = addError(message, preference, new String[]{varName}, elReference.getLineNumber(), lengthOfVarName, offsetOfVarName, file);
}
} else {
if(asYouType) {
- addMesssage(file, javaReference, preference, message, new String[]{varName});
+ addMessage(file, javaReference, preference, message, new String[]{varName});
} else {
marker = addError(message, preference, new String[]{varName}, javaReference, file);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-13 22:20:02 UTC (rev 42582)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/JSPProblemMarkerResolutionGenerator.java 2012-07-13 22:39:30 UTC (rev 42583)
@@ -12,10 +12,7 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Properties;
-import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -23,7 +20,6 @@
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -242,12 +238,12 @@
}
@Override
- public List<IJavaCompletionProposal> getProposals(Annotation annotation) {
+ public IJavaCompletionProposal[] getProposals(Annotation annotation) {
ArrayList<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();
IJavaCompletionProposal proposal = isOurCase(annotation);
if(proposal != null){
proposals.add(proposal);
}
- return proposals;
+ return proposals.toArray(new IJavaCompletionProposal[]{});
}
}
\ No newline at end of file
More information about the jbosstools-commits
mailing list