Author: dazarov
Date: 2010-09-07 11:36:15 -0400 (Tue, 07 Sep 2010)
New Revision: 24771
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotationMarkerResolution.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotationMarkerResolution.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/RenameAnnotationMarkerResolution.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent2.java
Removed:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotaionMarkerResolution.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotaionMarkerResolution.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/marker/SeamMarkerResolutionTest.java
Log:
https://jira.jboss.org/browse/JBIDE-6869
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -374,6 +374,8 @@
public static String ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE;
+ public static String RENAME_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AbstractSeamMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -56,7 +56,7 @@
this.end = end;
}
- protected void deleteAnnotation(String annotationTypeName){
+ protected void deleteAnnotation(){
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
@@ -65,7 +65,7 @@
IType type = compilationUnit.findPrimaryType();
if(javaElement != null && type != null){
if(javaElement instanceof IAnnotatable){
- IAnnotation annotation = findAnnotation(type, (IAnnotatable)javaElement,
annotationTypeName);
+ IAnnotation annotation = findAnnotation(type, (IAnnotatable)javaElement);
if(annotation != null){
IBuffer buffer = compilationUnit.getBuffer();
@@ -73,12 +73,12 @@
buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), "");
// check and delete import
- IImportDeclaration importDeclaration =
compilationUnit.getImport(annotationTypeName);
+ IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
IImportContainer importContainer = compilationUnit.getImportContainer();
if(importDeclaration != null && importContainer != null){
int importSize =
importContainer.getSourceRange().getOffset()+importContainer.getSourceRange().getLength();
String text = buffer.getText(importSize, buffer.getLength()-importSize);
- if(checkImport(text, annotationTypeName))
+ if(checkImport(text, qualifiedName))
importDeclaration.delete(false, new NullProgressMonitor());
}
compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
@@ -145,7 +145,7 @@
return name;
}
- protected void addAnnotation(String annotationTypeName, String annotationString, boolean
insertName){
+ protected void addAnnotation(String annotationString, boolean insertName){
try{
ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
@@ -153,9 +153,9 @@
IJavaElement javaElement = compilationUnit.getElementAt(start);
IType type = getType(javaElement);
if(type != null){
- IImportDeclaration importDeclaration = compilationUnit.getImport(annotationTypeName);
+ IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
if(importDeclaration == null || !importDeclaration.exists())
- compilationUnit.createImport(annotationTypeName, null, new NullProgressMonitor());
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
IBuffer buffer = compilationUnit.getBuffer();
@@ -172,24 +172,51 @@
}
}
+ protected void renameAnnotation(String annotationString){
+ try{
+ ICompilationUnit original = EclipseUtil.getCompilationUnit(file);
+ ICompilationUnit compilationUnit = original.getWorkingCopy(new
NullProgressMonitor());
+
+ IJavaElement javaElement = compilationUnit.getElementAt(start);
+ IType type = getType(javaElement);
+ if(type != null){
+ IAnnotation annotation = findAnnotation(type, type);
+ if(annotation != null){
+ IImportDeclaration importDeclaration = compilationUnit.getImport(qualifiedName);
+ if(importDeclaration == null || !importDeclaration.exists())
+ compilationUnit.createImport(qualifiedName, null, new NullProgressMonitor());
+
+ IBuffer buffer = compilationUnit.getBuffer();
+
+ String name=
"(\""+generateComponentName(compilationUnit.findPrimaryType().getElementName())+"\")";
+
+ buffer.replace(annotation.getSourceRange().getOffset(),
annotation.getSourceRange().getLength(), annotationString+name);
+ compilationUnit.commitWorkingCopy(false, new NullProgressMonitor());
+ }
+ }
+ }catch(CoreException ex){
+ SeamGuiPlugin.getPluginLog().logError(ex);
+ }
+ }
- private IAnnotation findAnnotation(IType sourceType, IAnnotatable member, String
annotationTypeName) {
+
+ private IAnnotation findAnnotation(IType sourceType, IAnnotatable member) {
try {
IAnnotation[] annotations = member.getAnnotations();
- String simpleAnnotationTypeName = annotationTypeName;
- int lastDot = annotationTypeName.lastIndexOf('.');
+ String simpleAnnotationTypeName = qualifiedName;
+ int lastDot = qualifiedName.lastIndexOf('.');
if(lastDot>-1) {
simpleAnnotationTypeName = simpleAnnotationTypeName.substring(lastDot + 1);
}
for (IAnnotation annotation : annotations) {
- if(annotationTypeName.equals(annotation.getElementName())) {
+ if(qualifiedName.equals(annotation.getElementName())) {
return annotation;
}
if(simpleAnnotationTypeName.equals(annotation.getElementName())) {
String fullAnnotationclassName = EclipseJavaUtil.resolveType(sourceType,
simpleAnnotationTypeName);
if(fullAnnotationclassName!=null) {
IType annotationType =
sourceType.getJavaProject().findType(fullAnnotationclassName);
- if(annotationType!=null &&
annotationType.getFullyQualifiedName().equals(annotationTypeName)) {
+ if(annotationType!=null &&
annotationType.getFullyQualifiedName().equals(qualifiedName)) {
return annotation;
}
}
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotaionMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotaionMarkerResolution.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotaionMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.seam.ui.marker;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-
-/**
- * @author Daniel Azarov
- */
-public class AddAnnotaionMarkerResolution extends
- AbstractSeamMarkerResolution {
- boolean insertName;
-
- public AddAnnotaionMarkerResolution(String label, String qualifiedName, IFile file, int
start, int end, boolean insertName){
- super(label, qualifiedName, file, start, end);
- this.insertName = insertName;
- }
-
- public void run(IMarker marker) {
- addAnnotation(qualifiedName,"@"+getShortName(qualifiedName), insertName);
//$NON-NLS-1$
- }
-
-}
Copied:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotationMarkerResolution.java
(from rev 24756,
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotaionMarkerResolution.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotationMarkerResolution.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotationMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.seam.ui.marker;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+
+/**
+ * @author Daniel Azarov
+ */
+public class AddAnnotationMarkerResolution extends
+ AbstractSeamMarkerResolution {
+ boolean insertName;
+
+ public AddAnnotationMarkerResolution(String label, String qualifiedName, IFile file, int
start, int end, boolean insertName){
+ super(label, qualifiedName, file, start, end);
+ this.insertName = insertName;
+ }
+
+ public void run(IMarker marker) {
+ addAnnotation("@"+getShortName(qualifiedName), insertName); //$NON-NLS-1$
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/AddAnnotationMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotaionMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotaionMarkerResolution.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotaionMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.seam.ui.marker;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-
-/**
- * @author Daniel Azarov
- */
-public class DeleteAnnotaionMarkerResolution extends
- AbstractSeamMarkerResolution {
-
- public DeleteAnnotaionMarkerResolution(String label, String qualifiedName, IFile file,
int start, int end){
- super(label, qualifiedName, file, start, end);
- }
-
- public String getLabel() {
- return label;
- }
-
- public void run(IMarker marker) {
- deleteAnnotation(qualifiedName);
- }
-}
Copied:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotationMarkerResolution.java
(from rev 24756,
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotaionMarkerResolution.java)
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotationMarkerResolution.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotationMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.seam.ui.marker;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+
+/**
+ * @author Daniel Azarov
+ */
+public class DeleteAnnotationMarkerResolution extends
+ AbstractSeamMarkerResolution {
+
+ public DeleteAnnotationMarkerResolution(String label, String qualifiedName, IFile file,
int start, int end){
+ super(label, qualifiedName, file, start, end);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void run(IMarker marker) {
+ deleteAnnotation();
+ }
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/DeleteAnnotationMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/RenameAnnotationMarkerResolution.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/RenameAnnotationMarkerResolution.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/RenameAnnotationMarkerResolution.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.seam.ui.marker;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+
+/**
+ * @author Daniel Azarov
+ */
+public class RenameAnnotationMarkerResolution extends
+ AbstractSeamMarkerResolution {
+
+ public RenameAnnotationMarkerResolution(String label, String qualifiedName,
+ IFile file, int start, int end) {
+ super(label, qualifiedName, file, start, end);
+ }
+
+ public void run(IMarker marker) {
+ renameAnnotation("@"+getShortName(qualifiedName)); //$NON-NLS-1$
+ }
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/RenameAnnotationMarkerResolution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/marker/SeamProblemMarkerResolutionGenerator.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -23,6 +23,7 @@
* @author Daniel Azarov
*/
public class SeamProblemMarkerResolutionGenerator implements IMarkerResolutionGenerator2
{
+ private static final String JAVA_EXTENSION = "java"; //$NON-NLS-1$
public IMarkerResolution[] getResolutions(IMarker marker) {
try{
@@ -42,6 +43,9 @@
IFile file = (IFile)marker.getResource();
+ if(!JAVA_EXTENSION.equals(file.getFileExtension()))
+ return new IMarkerResolution[]{};
+
attribute = ((Integer)marker.getAttribute(IMarker.CHAR_START));
if(attribute == null)
return new IMarkerResolution[]{};
@@ -52,32 +56,35 @@
return new IMarkerResolution[]{};
int end = attribute.intValue();
- if(messageId == SeamCoreValidator.NONUNIQUE_COMPONENT_NAME_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name",file, start, end)};
- else if(messageId == SeamCoreValidator.DUPLICATE_REMOVE_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_REMOVE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"javax.ejb.Remove", file, start, end)};
+ if(messageId == SeamCoreValidator.NONUNIQUE_COMPONENT_NAME_MESSAGE_ID){
+ return new IMarkerResolution[]{
+ new
RenameAnnotationMarkerResolution(SeamUIMessages.RENAME_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end),
+ new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name",file, start, end)
+ };
+ } else if(messageId == SeamCoreValidator.DUPLICATE_REMOVE_MESSAGE_ID)
+ return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_REMOVE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"javax.ejb.Remove", file, start, end)};
else if(messageId == SeamCoreValidator.DUPLICATE_DESTROY_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
+ return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
else if(messageId == SeamCoreValidator.DUPLICATE_CREATE_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)};
+ return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)};
else if(messageId == SeamCoreValidator.DUPLICATE_UNWRAP_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)};
+ return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)};
else if(messageId ==
SeamCoreValidator.DESTROY_METHOD_BELONGS_TO_STATELESS_SESSION_BEAN_MESSAGE_ID)
- return new IMarkerResolution[]{new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
+ return new IMarkerResolution[]{new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_DESTROY_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Destroy", file, start, end)};
else if(messageId == SeamCoreValidator.CREATE_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
return new IMarkerResolution[]{
- new
AddAnnotaionMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)
+ new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
+ new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_CREATE_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Create", file, start, end)
};
else if(messageId == SeamCoreValidator.UNWRAP_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
return new IMarkerResolution[]{
- new
AddAnnotaionMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)
+ new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
+ new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Unwrap", file, start, end)
};
else if(messageId == SeamCoreValidator.OBSERVER_DOESNT_BELONG_TO_COMPONENT_MESSAGE_ID)
return new IMarkerResolution[]{
- new
AddAnnotaionMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
- new
DeleteAnnotaionMarkerResolution(SeamUIMessages.DELETE_OBSERVER_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Observer", file, start, end)
+ new
AddAnnotationMarkerResolution(SeamUIMessages.ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Name", file, start, end, true),
+ new
DeleteAnnotationMarkerResolution(SeamUIMessages.DELETE_OBSERVER_ANNOTATION_MARKER_RESOLUTION_TITLE,
"org.jboss.seam.annotations.Observer", file, start, end)
};
return new IMarkerResolution[]{};
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2010-09-07
15:36:15 UTC (rev 24771)
@@ -195,3 +195,4 @@
DELETE_UNWRAP_ANNOTATION_MARKER_RESOLUTION_TITLE=Delete @Unwrap annotation
DELETE_OBSERVER_ANNOTATION_MARKER_RESOLUTION_TITLE=Delete @Oserver annotation
ADD_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE=Add @Name annotation
+RENAME_NAME_ANNOTATION_MARKER_RESOLUTION_TITLE=Rename @Name annotation
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.session;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("duplicateComponentName")
+public class DuplicateComponent1 {
+}
\ No newline at end of file
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent2.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent2.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent2.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -0,0 +1,7 @@
+package org.domain.SeamWebWarTestProject.session;
+
+import org.jboss.seam.annotations.Name;
+
+@Name("duplicateComponentName")
+public class DuplicateComponent2 {
+}
\ No newline at end of file
Property changes on:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent2.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/marker/SeamMarkerResolutionTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/marker/SeamMarkerResolutionTest.java 2010-09-07
15:24:48 UTC (rev 24770)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/marker/SeamMarkerResolutionTest.java 2010-09-07
15:36:15 UTC (rev 24771)
@@ -21,8 +21,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.ide.IDE;
-import org.jboss.tools.seam.ui.marker.AddAnnotaionMarkerResolution;
-import org.jboss.tools.seam.ui.marker.DeleteAnnotaionMarkerResolution;
+import org.jboss.tools.seam.ui.marker.AddAnnotationMarkerResolution;
+import org.jboss.tools.seam.ui.marker.DeleteAnnotationMarkerResolution;
+import org.jboss.tools.seam.ui.marker.RenameAnnotationMarkerResolution;
import org.jboss.tools.test.util.JobUtils;
/**
@@ -60,8 +61,8 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("javax.ejb.Remove",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("javax.ejb.Remove",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
found = true;
break;
}
@@ -88,8 +89,8 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Destroy",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Destroy",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
found = true;
break;
}
@@ -116,8 +117,8 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Destroy",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Destroy",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
found = true;
break;
}
@@ -144,8 +145,8 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Create",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Create",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
found = true;
break;
}
@@ -172,8 +173,8 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Unwrap",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Unwrap",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
found = true;
break;
}
@@ -201,12 +202,12 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Create",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Create",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
dFound = true;
}
- if (resolution instanceof AddAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof AddAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotationMarkerResolution)resolution).getQualifiedName());
cFound = true;
}
}
@@ -234,12 +235,12 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Unwrap",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Unwrap",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
dFound = true;
}
- if (resolution instanceof AddAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof AddAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotationMarkerResolution)resolution).getQualifiedName());
cFound = true;
}
}
@@ -267,12 +268,12 @@
.getResolutions(marker);
for (int j = 0; j < resolutions.length; j++) {
IMarkerResolution resolution = resolutions[j];
- if (resolution instanceof DeleteAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Observer",
((DeleteAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Observer",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
dFound = true;
}
- if (resolution instanceof AddAnnotaionMarkerResolution) {
- assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotaionMarkerResolution)resolution).getQualifiedName());
+ if (resolution instanceof AddAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Name",
((AddAnnotationMarkerResolution)resolution).getQualifiedName());
cFound = true;
}
}
@@ -283,5 +284,39 @@
assertTrue("The quickfix \"Delete @Observer annotation\" doesn't
exist.", dFound);
assertTrue("The quickfix \"Add @Name annotation\" doesn't
exist.", cFound);
}
+
+ public void testDuplicateComponentNameResolution() throws CoreException {
+ String TARGET_FILE_NAME =
"src/action/org/domain/SeamWebWarTestProject/session/DuplicateComponent1.java";
+ IFile file = project.getFile(TARGET_FILE_NAME);
+
+ assertTrue("File - "+TARGET_FILE_NAME+" must be
exists",file.exists());
+
+ IMarker[] markers = file.findMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
+
+ boolean dFound = false;
+ boolean cFound = false;
+ for (int i = 0; i < markers.length; i++) {
+ IMarker marker = markers[i];
+ IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry()
+ .getResolutions(marker);
+ for (int j = 0; j < resolutions.length; j++) {
+ IMarkerResolution resolution = resolutions[j];
+ if (resolution instanceof DeleteAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Name",
((DeleteAnnotationMarkerResolution)resolution).getQualifiedName());
+ dFound = true;
+ }
+ if (resolution instanceof RenameAnnotationMarkerResolution) {
+ assertEquals("org.jboss.seam.annotations.Name",
((RenameAnnotationMarkerResolution)resolution).getQualifiedName());
+ cFound = true;
+ }
+ }
+ if (dFound && cFound) {
+ break;
+ }
+ }
+ assertTrue("The quickfix \"Delete @Name annotation\" doesn't
exist.", dFound);
+ assertTrue("The quickfix \"Rename @Name annotation\" doesn't
exist.", cFound);
+ }
+
}