Bug #293872. Same test plug-ins listed in two features. Plus API updates and Javadoc.
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java
index 89a82cd..9336212 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationDefinition.java
@@ -21,23 +21,30 @@
import org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer;
/**
- *
+ * An <code>AnnotationDefinition</code> is a representation of the information contributed through the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code>,
+ * <code>org.eclipse.jst.ws.annotations.core.annotationCategory</code> and
+ * <code>org.eclipse.jst.ws.annotations.core.annotationInitializer</code> extension points.
+ * for a <code>java.lang.annotation.Annotation</code> class.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * It supplies the annotation class name, its annotation category, the applicable targets for the annotation
+ * and an <code>IAnnotationAttributeInitializer</code> to initialize the annotations element-value pairs.
+ * </p>
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
-public class AnnotationDefinition {
+public final class AnnotationDefinition {
private static final String ATT_CLASS = "class"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$NON-NLS-1$
private static final String ATT_RESTRICTED_TO = "restrictedTo"; //$NON-NLS-1$
-
+
private static final String RESTRICTED_TO_CLASS_ONLY = "CLASS_ONLY";
private static final String RESTRICTED_TO_INTERFACE_ONLY = "INTERFACE_ONLY";
private static final String RESTRICTED_TO_ENUM_ONLY = "ENUM_ONLY";
-
+
private IConfigurationElement configurationElement;
private String category;
private String annotationClassName;
@@ -49,44 +56,81 @@
private boolean interfaceOnly;
private boolean classOnly;
private boolean enumOnly;
-
+
+ /**
+ * Constructs an <code>AnnotationDefinition</code> using information from the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> extension point and category name.
+ * @param configurationElement the <code>annotation</code> element from the <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> extension point
+ * @param category the category name
+ */
public AnnotationDefinition(IConfigurationElement configurationElement, String category) {
this.configurationElement = configurationElement;
this.category = category;
-
+
this.annotationClassName = AnnotationsManager.getAttributeValue(configurationElement, ATT_CLASS);
this.name = AnnotationsManager.getAttributeValue(configurationElement, ATT_NAME);
- this.restictedTo = AnnotationsManager.getAttributeValue(configurationElement,
+ this.restictedTo = AnnotationsManager.getAttributeValue(configurationElement,
ATT_RESTRICTED_TO);
this.classOnly = restictedTo.equals(RESTRICTED_TO_CLASS_ONLY);
this.interfaceOnly = restictedTo.equals(RESTRICTED_TO_INTERFACE_ONLY);
this.enumOnly = restictedTo.equals(RESTRICTED_TO_ENUM_ONLY);
}
-
+
+ /**
+ * Returns the annotation name.
+ * @return the annotation name.
+ */
public String getName() {
return name;
}
-
+
+ /**
+ * Returns the category the annotation belongs to.
+ * @return the annotation category.
+ */
public String getCategory() {
return category;
}
-
+
+ /**
+ * Returns the fully qualified class name of the annotation.
+ * @return the fully qualified class name of the annotation.
+ */
public String getAnnotationClassName() {
return annotationClassName;
}
-
+
+ /**
+ * Returns whether the annotation is restricted to class types.
+ * @return <code>true</code> if the annotation is restricted to classes only.
+ */
public boolean isClassOnly() {
return classOnly;
}
-
+
+ /**
+ * Returns whether the annotation is restricted to interface types.
+ * @return <code>true</code> if the annotation is restricted to interfaces only.
+ */
public boolean isInterfaceOnly() {
return interfaceOnly;
}
-
+
+ /**
+ * Returns whether the annotation is restricted to enum types.
+ * @return <code>true</code> if the annotation is restricted to enums only.
+ */
public boolean isEnumOnly() {
return enumOnly;
}
-
+
+ /**
+ * Returns the annotation class as specified by the <code>class</code> attribute of the
+ * <code>annotation<annotation> element in the <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code>
+ * extension point.
+ *
+ * @return the annotation class
+ */
@SuppressWarnings("unchecked")
public Class<? extends java.lang.annotation.Annotation> getAnnotationClass() {
if (annotationClass == null) {
@@ -102,32 +146,51 @@
}
return annotationClass;
}
-
+
+ /**
+ * Returns a list of <code>ElementType</code> that specify the Java elements to which the annotation
+ * can be applied.
+ * <p>
+ * The <code>ElementType</code> are retrieved from the annotations
+ * <code>java.lang.annotation.Target</code> meta-annotation type. This list can be filtered using
+ * the <code>targetFilter</code> element on the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> extension point when defining
+ * the annotation.
+ * </p>
+ * @return a list of <code>ElementType</code>
+ */
public List<ElementType> getTargets() {
if (targets == null) {
targets = new LinkedList<ElementType>();
-
+
Class<? extends java.lang.annotation.Annotation> annotation = getAnnotationClass();
if (annotation != null) {
Target target = annotation.getAnnotation(Target.class);
if (target != null) {
targets.addAll(Arrays.asList(target.value()));
-
+
List<ElementType> filteredTargets = AnnotationsManager
.getFilteredTargets(configurationElement);
if (targets.containsAll(filteredTargets) && filteredTargets.size() < targets.size()) {
targets.removeAll(filteredTargets);
}
- }
+ }
}
}
return targets;
}
-
+
+ /**
+ * Returns the annotations attribute initializer as specified in the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationInitializer</code> extension point or null if no
+ * initializer can be found.
+ *
+ * @return the <code>IAnnotationAttributeInitializer</code>
+ */
public IAnnotationAttributeInitializer getAnnotationAttributeInitializer() {
if (annotationInitializer == null) {
try {
- IConfigurationElement configurationElement =
+ IConfigurationElement configurationElement =
AnnotationsManager.getAnnotationInitializerCache().get(getAnnotationClassName());
if (configurationElement != null) {
annotationInitializer = (IAnnotationAttributeInitializer)configurationElement
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java
index 36e7546..c299703 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsCore.java
@@ -34,11 +34,11 @@
import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.TypeLiteral;
/**
- *
+ * Utility class for creating annotations and member value pairs.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
@@ -46,13 +46,20 @@
private AnnotationsCore() {
}
-
- public static NormalAnnotation createNormalAnnotation(AST ast, String annotationName, List<MemberValuePair> memberValuePairs) {
+ /**
+ * Creates a new <code>NormalAnnotation</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the annotation.
+ * @param annotationName the name of the annotation.
+ * @param memberValuePairs a list of <code>MemberValuePair</code> to add to the <code>NormalAnnotation</code>.
+ * @return a normal annotation with the given member value pairs.
+ */
+ public static NormalAnnotation createNormalAnnotation(AST ast, String annotationName, List<MemberValuePair> memberValuePairs) {
NormalAnnotation annotation = ast.newNormalAnnotation();
-
+
Name annotationTypeName = ast.newName(annotationName);
-
+
annotation.setTypeName(annotationTypeName);
if (memberValuePairs != null) {
@@ -64,33 +71,55 @@
}
return annotation;
}
-
+
+ /**
+ * Creates a new <code>SingleMemberAnnotation</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the annotation.
+ * @param annotationName the name of the annotation.
+ * @param value the <code>Expression</code> to set as the <code>SingleMemberAnnotation</code> value.
+ * @return a single member annotation with the given value.
+ */
public static SingleMemberAnnotation createSingleMemberAnnotation(AST ast, String annotationName, Expression value) {
SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
-
+
Name annotationTypeName = ast.newName(annotationName);
-
+
annotation.setTypeName(annotationTypeName);
if (value != null) {
value = (Expression)Expression.copySubtree(ast, value);
annotation.setValue(value);
}
-
+
return annotation;
}
+ /**
+ * Creates a new <code>MarkerAnnotation</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the annotation.
+ * @param annotationName the name of the annotation.
+ * @return a marker annotation.
+ */
public static MarkerAnnotation createMarkerAnnotation(AST ast, String annotationName) {
MarkerAnnotation annotation = ast.newMarkerAnnotation();
-
+
Name annotationTypeName = ast.newName(annotationName);
-
+
annotation.setTypeName(annotationTypeName);
return annotation;
}
-
+ /**
+ * Creates a new <code>MemberValuePair</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param expression the <code>Expression</code> to set as the <code>MemberValuePair</code> value.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
public static MemberValuePair createMemberValuePair(AST ast, String name, Expression expression) {
MemberValuePair memberValuePair = ast.newMemberValuePair();
memberValuePair.setName(ast.newSimpleName(name));
@@ -98,41 +127,96 @@
return memberValuePair;
}
- public static MemberValuePair createStringMemberValuePair(AST ast, String name, Object value) {
+ /**
+ * Creates a new <code>MemberValuePair</code> with a <code>StringLiteral</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param value the <code>String</code> value.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
+ public static MemberValuePair createStringMemberValuePair(AST ast, String name, String value) {
MemberValuePair stringMemberValuePair = AnnotationsCore.createMemberValuePair(ast, name,
AnnotationsCore.createStringLiteral(ast, value.toString()));
return stringMemberValuePair;
}
- public static MemberValuePair createBooleanMemberValuePair(AST ast, String name, Object value) {
+ /**
+ * Creates a new <code>MemberValuePair</code> with a <code>BooleanLiteral</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param value the <code>Boolean</code> value.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
+ public static MemberValuePair createBooleanMemberValuePair(AST ast, String name, Boolean value) {
MemberValuePair booleanValuePair = AnnotationsCore.createMemberValuePair(ast, name, AnnotationsCore
- .createBooleanLiteral(ast, ((Boolean)value).booleanValue()));
+ .createBooleanLiteral(ast, value.booleanValue()));
return booleanValuePair;
}
-
- public static MemberValuePair createNumberMemberValuePair(AST ast, String name, Object value) {
- MemberValuePair primitiveValuePair = AnnotationsCore.createMemberValuePair(ast, name,
+
+ /**
+ * Creates a new <code>MemberValuePair</code> with a <code>NumberLiteral</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param value the <code>String</code> value representing the number.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
+ public static MemberValuePair createNumberMemberValuePair(AST ast, String name, String value) {
+ MemberValuePair primitiveValuePair = AnnotationsCore.createMemberValuePair(ast, name,
AnnotationsCore.createNumberLiteral(ast, value.toString()));
return primitiveValuePair;
}
-
- public static MemberValuePair createEnumMemberValuePair(AST ast, String className, String name,
+
+ /**
+ * Creates a new <code>MemberValuePair</code> with a <code>Name</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param value the enum value.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
+ public static MemberValuePair createEnumMemberValuePair(AST ast, String className, String name,
Object value) {
- return AnnotationsCore.createMemberValuePair(ast, name, createEnumLiteral(ast, className, value));
+ return AnnotationsCore.createMemberValuePair(ast, name, createEnumLiteral(ast, className, value));
}
-
+
+ /**
+ * Creates a new <code>MemberValuePair</code> with a <code>TypeLiteral</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param name the name of the <code>MemberValuePair</code>.
+ * @param value the type value.
+ * @return a new <code>MemberValuePair</code> with the given name and value.
+ */
public static MemberValuePair createTypeMemberValuePair(AST ast, String name, Object value) {
return AnnotationsCore.createMemberValuePair(ast, name,
createTypeLiteral(ast, value));
}
-
+
+ /**
+ * Creates a new <code>MemberValuePair</code> with an <code>ArrayInitializer</code> value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>MemberValuePair</code>.
+ * @param method
+ * @param values an array of <code>Object</code> values.
+ * @return a new <code>MemberValuePair</code> with the given name and array of values.
+ */
public static MemberValuePair createArrayMemberValuePair(AST ast, Method method, Object[] values) {
- return AnnotationsCore.createMemberValuePair(ast, method.getName(), createArrayValueLiteral(ast,
+ return AnnotationsCore.createMemberValuePair(ast, method.getName(), createArrayValueLiteral(ast,
method, values));
- }
-
+ }
+
+ /**
+ * Creates a new <code>ArrayInitializer</code>.
+ * @param ast the <code>AST</code> that will be used to create the <code>ArrayInitializer</code>.
+ * @param method
+ * @param values an array of <code>Object</code> values.
+ * @return a new <code>ArrayInitializer</code>.
+ */
@SuppressWarnings("unchecked")
public static ArrayInitializer createArrayValueLiteral(AST ast, Method method, Object[] values) {
ArrayInitializer arrayInitializer = ast.newArrayInitializer();
@@ -141,7 +225,7 @@
//TODO Handle this situation. Arises when annotations are specified as defaults in array initializers
}
if (value instanceof List) {
- Class<? extends java.lang.annotation.Annotation> annotationClass =
+ Class<? extends java.lang.annotation.Annotation> annotationClass =
(Class<? extends java.lang.annotation.Annotation>) method.getReturnType().getComponentType();
List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
@@ -149,7 +233,7 @@
List<Map<String, Object>> valuesList = (List<Map<String, Object>>) value;
Iterator<Map<String, Object>> valuesIterator = valuesList.iterator();
while (valuesIterator.hasNext()) {
- Map<String, Object> annotationMap = (Map<String, Object>) valuesIterator.next();
+ Map<String, Object> annotationMap = valuesIterator.next();
Set<Entry<String, Object>> entrySet = annotationMap.entrySet();
Iterator<Map.Entry<String, Object>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
@@ -162,11 +246,11 @@
Class<?> returnType = annotationMethod.getReturnType();
if (returnType.equals(String.class)) {
memberValuePairs.add(createStringMemberValuePair(ast, memberName,
- memberValue));
+ memberValue.toString()));
}
if (returnType.equals(Boolean.TYPE)) {
memberValuePairs.add(createBooleanMemberValuePair(ast, memberName,
- memberValue));
+ (Boolean) memberValue));
}
if (returnType.equals(Class.class)) {
String className = memberValue.toString();
@@ -174,13 +258,13 @@
className = className.substring(0, className.lastIndexOf("."));
}
memberValuePairs.add(AnnotationsCore.createMemberValuePair(ast, memberName,
- createTypeLiteral(ast, className)));
+ createTypeLiteral(ast, className)));
}
// if (returnType.isPrimitive()) {
// memberValuePairs.add(getNumberMemberValuePair(ast, memberName, memberValue));
// }
}
-
+
} catch (SecurityException se) {
AnnotationsCorePlugin.log(se);
} catch (NoSuchMethodException nsme) {
@@ -206,7 +290,15 @@
}
return arrayInitializer;
}
-
+
+ /**
+ * Creates a new <code>Name</code> to represent an enum literal value.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>Name</code>.
+ * @param className the fully qualified name of the ENUM class.
+ * @param value the ENUM value.
+ * @return a new <code>Name</code>.
+ */
public static Name createEnumLiteral(AST ast, String className, Object value) {
QualifiedName enumName = null;
SimpleName enumClassName = ast.newSimpleName(value.getClass().getSimpleName());
@@ -229,6 +321,13 @@
return enumName;
}
+ /**
+ * Creates a new <code>TypeLiteral</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>TypeLiteral</code>.
+ * @param value a <code>Class</code> or a <code>String</code> from which to create the <code>TypeLiteral</code>.
+ * @return a new <code>TypeLiteral</code> or null it the value is not of type <code>Class</code> or <code>String</code>.
+ */
public static TypeLiteral createTypeLiteral(AST ast, Object value) {
TypeLiteral typeLiteral = null;
if (value instanceof Class) {
@@ -240,10 +339,17 @@
return typeLiteral;
}
+ /**
+ * Creates a new <code>TypeLiteral</code>
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>TypeLiteral</code>
+ * @param value the class value
+ * @return a new <code>TypeLiteral</code>
+ */
public static TypeLiteral createTypeLiteral(AST ast, Class<?> value) {
TypeLiteral typeLiteral = ast.newTypeLiteral();
- Class<?> aClass = (Class<?>)value;
+ Class<?> aClass = value;
SimpleName className = ast.newSimpleName(aClass.getSimpleName());
if (aClass.isMemberClass()) {
@@ -255,6 +361,13 @@
return createTypeLiteral(ast, value.getCanonicalName());
}
+ /**
+ * Creates a new <code>TypeLiteral</code>
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>TypeLiteral</code>
+ * @param value the name of class
+ * @return a new <code>TypeLiteral</code>
+ */
public static TypeLiteral createTypeLiteral(AST ast, String value) {
TypeLiteral typeLiteral = ast.newTypeLiteral();
@@ -273,17 +386,36 @@
return typeLiteral;
}
+ /**
+ * Creates a new <code>StringLiteral</code>.
+ * @param ast the <code>AST</code> that will be used to create the <code>StringLiteral</code>.
+ * @param literalValue the string value.
+ * @return a new <code>StringLiteral</code>.
+ */
public static StringLiteral createStringLiteral(AST ast, String literalValue) {
StringLiteral stringLiteral = ast.newStringLiteral();
stringLiteral.setLiteralValue(literalValue);
return stringLiteral;
}
+ /**
+ * Creates a new <code>BooleanLiteral</code>.
+ * @param ast the <code>AST</code> that will be used to create the <code>BooleanLiteral</code>.
+ * @param value the boolean value.
+ * @return a new <code>BooleanLiteral</code>.
+ */
public static BooleanLiteral createBooleanLiteral(AST ast, boolean value) {
BooleanLiteral booleanLiteral = ast.newBooleanLiteral(value);
return booleanLiteral;
}
-
+
+ /**
+ * Creates a new <code>NumberLiteral</code>.
+ *
+ * @param ast the <code>AST</code> that will be used to create the <code>NumberLiteral</code>.
+ * @param value the number value.
+ * @return a new <code>NumberLiteral</code>.
+ */
public static NumberLiteral createNumberLiteral(AST ast, String value) {
NumberLiteral primitiveLiteral = ast.newNumberLiteral();
primitiveLiteral.setToken(value);
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java
index 46f112e..e0ca5fc 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/AnnotationsManager.java
@@ -37,20 +37,24 @@
import org.eclipse.jst.ws.annotations.core.initialization.IAnnotationAttributeInitializer;
/**
- *
+ * Manages the annotation categories, definitions, processors and initializers contributed through the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code>,
+ * <code>org.eclipse.jst.ws.annotations.core.annotationCategory</code>,
+ * <code>org.eclipse.jst.ws.annotations.core.annotationInitializer</code> and
+ * <code>org.eclipse.jst.ws.annotations.core.annotationProcessor</code> extension points.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
public final class AnnotationsManager {
- public static final String ANNOTATION_DEFINITION = "annotationDefinition"; //$NON-NLS-1$
- public static final String ANNOTATION_CATEGORY = "annotationCategory"; //$NON-NLS-1$
- public static final String ANNOTATION_INITIALIZER = "annotationInitializer"; //$NON-NLS-1$
- public static final String ANNOTATION_PROCESSOR = "annotationProcessor"; //$NON-NLS-1$
- public static final String ANNOTATION = "annotation"; //$NON-NLS-1$
+ private static final String ANNOTATION_DEFINITION = "annotationDefinition"; //$NON-NLS-1$
+ private static final String ANNOTATION_CATEGORY = "annotationCategory"; //$NON-NLS-1$
+ private static final String ANNOTATION_INITIALIZER = "annotationInitializer"; //$NON-NLS-1$
+ private static final String ANNOTATION_PROCESSOR = "annotationProcessor"; //$NON-NLS-1$
+ private static final String ANNOTATION = "annotation"; //$NON-NLS-1$
private static List<AnnotationDefinition> annotationCache = null;
private static Map<String, String> annotationCategoryCache = null;
@@ -64,17 +68,23 @@
private static final String ATT_ID = "id"; //$NON-NLS-1$
private static final String ATT_NAME = "name"; //$NON-NLS-1$
private static final String ATT_CATEGORY = "category"; //$NON-NLS-1$
-
+
private static final String ELEM_TARGET_FILTER = "targetFilter"; //$NON-NLS-1$
private static final String ATT_TARGET = "target"; //$NON-NLS-1$
private AnnotationsManager() {
}
-
+
+ /**
+ * Returns a list of <code>AnnotationDefinition</code> constructed from contributions to the
+ * <code>org.eclipse.jst.ws.annotations.core.annotationDefinition</code> extension point.
+ *
+ * @return a list of <code>AnnotationDefinition</code>.
+ */
public static synchronized List<AnnotationDefinition> getAnnotations() {
if (annotationCache == null) {
annotationCache = new ArrayList<AnnotationDefinition>();
-
+
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
AnnotationsCorePlugin.PLUGIN_ID, ANNOTATION_DEFINITION);
if (extensionPoint != null) {
@@ -82,7 +92,7 @@
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element = elements[i];
if (element.getName().equals(ANNOTATION)) {
- AnnotationDefinition annotationDefinition = new AnnotationDefinition(element,
+ AnnotationDefinition annotationDefinition = new AnnotationDefinition(element,
getAnnotationCategory(getAttributeValue(element, ATT_CATEGORY)));
annotationCache.add(annotationDefinition);
}
@@ -92,26 +102,37 @@
return annotationCache;
}
- public static Object[] getAnnotations(Object element) {
+ /**
+ * Returns a list of all the contributed <code>java.lang.annotation.Annotation</code> that target the given java element type.
+ *
+ * @param element one of
+ * <li>org.eclipse.jdt.core.IPackageDeclaration</li>
+ * <li>org.eclipse.jdt.core.IType</li>
+ * <li>org.eclipse.jdt.core.IField</li>
+ * <li>org.eclipse.jdt.core.IMethod</li>
+ * <li>org.eclipse.jdt.core.ILocalVariable</li>
+ *
+ * @return a list of <code>java.lang.annotation.Annotation</code>
+ */
+ public static List<Class<? extends Annotation>> getAnnotations(Object element) {
List<Class<? extends Annotation>> annotations = new ArrayList<Class<? extends Annotation>>();
-
+
try {
List<AnnotationDefinition> annotationDefinitions = getAllAnnotationsForElement(element);
-
+
filterAnnotationsList(element, annotationDefinitions);
-
+
for (AnnotationDefinition annotationDefinition : annotationDefinitions) {
annotations.add(annotationDefinition.getAnnotationClass());
}
} catch (JavaModelException jme) {
AnnotationsCorePlugin.log(jme.getStatus());
- }
- return annotations.toArray();
+ }
+ return annotations;
}
-
- private static synchronized Map<String, AnnotationDefinition>
- getAnnotationToClassNameDefinitionMap() {
-
+
+ private static synchronized Map<String, AnnotationDefinition> getAnnotationToClassNameDefinitionMap() {
+
if (annotationClassNameToDefinitionMap == null) {
List<AnnotationDefinition> annotationDefinitions = getAnnotations();
@@ -124,26 +145,26 @@
}
return annotationClassNameToDefinitionMap;
}
-
+
private static synchronized Map<String, AnnotationDefinition> getSimpleNameToDefinitionMap() {
if (annotationSimpleNameToDefinitionMap == null) {
List<AnnotationDefinition> annotationDefinitions = getAnnotations();
annotationSimpleNameToDefinitionMap = new HashMap<String, AnnotationDefinition>();
-
+
for (AnnotationDefinition annotationDefinition : annotationDefinitions) {
annotationSimpleNameToDefinitionMap.put(annotationDefinition.getName(), annotationDefinition);
}
}
return annotationSimpleNameToDefinitionMap;
}
-
+
private static synchronized Map<String, AnnotationDefinition> getQualifiedNameToDefinitionMap() {
if (annotationQualifiedNameToDefinitionMap == null) {
List<AnnotationDefinition> annotationDefinitions = getAnnotations();
-
+
annotationQualifiedNameToDefinitionMap = new HashMap<String, AnnotationDefinition>();
-
+
for (AnnotationDefinition annotationDefinition : annotationDefinitions) {
annotationQualifiedNameToDefinitionMap.put(annotationDefinition.getAnnotationClassName(),
annotationDefinition);
@@ -151,7 +172,12 @@
}
return annotationQualifiedNameToDefinitionMap;
}
-
+
+ /**
+ *
+ * @param element
+ * @return <code></code>
+ */
@SuppressWarnings("unchecked")
public static AnnotationDefinition getAnnotationDefinitionForClass(Object element) {
if (element instanceof Class && ((Class<?>)element).isAnnotation()) {
@@ -160,35 +186,59 @@
}
return null;
}
-
+
+ /**
+ *
+ * @param name
+ * @return <code></code>
+ */
public static IAnnotationAttributeInitializer getAnnotationAttributeInitializerForName(Name name) {
if (name != null) {
if (name.isSimpleName() && getSimpleNameToDefinitionMap().containsKey(((SimpleName) name).getIdentifier())) {
- return getSimpleNameToDefinitionMap().get(((SimpleName) name).getIdentifier()).getAnnotationAttributeInitializer();
+ return getSimpleNameToDefinitionMap().get(((SimpleName) name).getIdentifier()).getAnnotationAttributeInitializer();
} else if (name.isQualifiedName() && getQualifiedNameToDefinitionMap().containsKey(name.getFullyQualifiedName())) {
return getQualifiedNameToDefinitionMap().get(name.getFullyQualifiedName()).getAnnotationAttributeInitializer();
}
}
return null;
}
-
- public static AnnotationDefinition getAnnotationDefinitionForClass(Class<? extends Annotation>
+
+ /**
+ *
+ * @param annotationClass
+ * @return <code></code>
+ */
+ public static AnnotationDefinition getAnnotationDefinitionForClass(Class<? extends Annotation>
annotationClass) {
return getAnnotationToClassNameDefinitionMap().get(annotationClass.getCanonicalName());
}
-
+
+ /**
+ *
+ * @param canonicalName
+ * @return <code></code>
+ */
+ public static AnnotationDefinition getAnnotationDefinitionForClass(String canonicalName) {
+ return getAnnotationToClassNameDefinitionMap().get(canonicalName);
+ }
+
+ /**
+ *
+ * @param categoryName
+ * @return <code></code>
+ */
public static synchronized List<AnnotationDefinition> getAnnotationsByCategory(String categoryName) {
if (annotationsByCategoryMap == null) {
annotationsByCategoryMap = new HashMap<String, List<AnnotationDefinition>>();
for (AnnotationDefinition annotationDefinition : getAnnotations()) {
-
+
List<AnnotationDefinition> annotationDefinitionList = annotationsByCategoryMap.get(
annotationDefinition.getCategory());
-
+
if (annotationDefinitionList == null) {
annotationDefinitionList = new ArrayList<AnnotationDefinition>();
annotationDefinitionList.add(annotationDefinition);
- annotationsByCategoryMap.put(annotationDefinition.getCategory(),
+ annotationsByCategoryMap.put(annotationDefinition.getCategory(),
annotationDefinitionList);
continue;
}
@@ -198,13 +248,17 @@
return annotationsByCategoryMap.get(categoryName);
}
+ /**
+ *
+ * @return <code></code>
+ */
public static List<String> getAnnotationCategories() {
return Arrays.asList(getAnnotationCategoryCache().values().toArray(
new String[getAnnotationCategoryCache().size()]));
}
- public static String getAnnotationCategory(String categoryId) {
- return getAnnotationCategoryCache().get(categoryId);
+ private static String getAnnotationCategory(String categoryId) {
+ return getAnnotationCategoryCache().get(categoryId);
}
private static synchronized Map<String, String> getAnnotationCategoryCache() {
@@ -213,44 +267,52 @@
}
annotationCategoryCache = new HashMap<String, String>();
-
+
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
AnnotationsCorePlugin.PLUGIN_ID, ANNOTATION_CATEGORY);
if (extensionPoint != null) {
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element = elements[i];
- annotationCategoryCache.put(getAttributeValue(element, ATT_ID),
+ annotationCategoryCache.put(getAttributeValue(element, ATT_ID),
getAttributeValue(element, ATT_NAME));
}
}
return annotationCategoryCache;
}
-
+
+ /**
+ *
+ * @return <code></code>
+ */
public static synchronized Map<String, IConfigurationElement> getAnnotationInitializerCache() {
if (annotationInitializerCache != null) {
return annotationInitializerCache;
}
annotationInitializerCache = new HashMap<String, IConfigurationElement>();
-
+
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
AnnotationsCorePlugin.PLUGIN_ID, ANNOTATION_INITIALIZER);
if (extensionPoint != null) {
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
for (int i = 0; i < elements.length; i++) {
IConfigurationElement element = elements[i];
- annotationInitializerCache.put(getAttributeValue(element, ANNOTATION),
+ annotationInitializerCache.put(getAttributeValue(element, ANNOTATION),
element);
}
}
return annotationInitializerCache;
}
-
+
+ /**
+ *
+ * @return <code></code>
+ */
public static synchronized Map<String, List<IConfigurationElement>> getAnnotationProcessorsCache() {
if (annotationProcessorCache == null) {
annotationProcessorCache = new HashMap<String, List<IConfigurationElement>>();
-
+
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(
AnnotationsCorePlugin.PLUGIN_ID, ANNOTATION_PROCESSOR);
if (extensionPoint != null) {
@@ -260,7 +322,7 @@
if (element.getName().equalsIgnoreCase("processor")) {
String annotationKey = getAttributeValue(element, ANNOTATION);
List<IConfigurationElement> configurationElements = annotationProcessorCache.get(
- annotationKey);
+ annotationKey);
if (configurationElements == null) {
configurationElements = new ArrayList<IConfigurationElement>();
configurationElements.add(element);
@@ -275,6 +337,12 @@
return annotationProcessorCache;
}
+ /**
+ *
+ * @param configurationElement
+ * @param attributeName
+ * @return
+ */
public static String getAttributeValue(IConfigurationElement configurationElement, String attributeName) {
String attribute = configurationElement.getAttribute(attributeName);
if (attribute != null) {
@@ -282,7 +350,12 @@
}
return ""; //$NON-NLS-1$
}
-
+
+ /**
+ *
+ * @param configurationElement
+ * @return
+ */
public static List<ElementType> getFilteredTargets(IConfigurationElement configurationElement) {
List<ElementType> targets = new ArrayList<ElementType>(7);
try {
@@ -297,13 +370,13 @@
return targets;
}
- private static List<AnnotationDefinition> getAllAnnotationsForElement(Object element)
+ private static List<AnnotationDefinition> getAllAnnotationsForElement(Object element)
throws JavaModelException {
-
+
if (element instanceof IPackageDeclaration) {
return getAnnotationsForElementType(ElementType.PACKAGE);
}
-
+
if (element instanceof IType) {
IType type = (IType) element;
if (type.isAnnotation()) {
@@ -311,15 +384,15 @@
}
return getAnnotationsForElementType(ElementType.TYPE);
}
-
+
if (element instanceof IField) {
return getAnnotationsForElementType(ElementType.FIELD);
}
-
+
if (element instanceof IMethod) {
return getAnnotationsForElementType(ElementType.METHOD);
}
-
+
if (element instanceof SingleVariableDeclaration) {
return getAnnotationsForElementType(ElementType.PARAMETER);
}
@@ -331,32 +404,32 @@
if (element instanceof IAnnotation) {
return getAnnotationsForElementType(ElementType.ANNOTATION_TYPE);
}
-
+
return Collections.emptyList();
}
-
+
private static List<AnnotationDefinition> getAnnotationsForElementType(ElementType elementType) {
List<AnnotationDefinition> annotationDefinitions = new ArrayList<AnnotationDefinition>();
-
+
if (annotationCache == null) {
getAnnotations();
}
-
+
for (AnnotationDefinition annotationDefinition : annotationCache) {
- if (annotationDefinition.getTargets().contains(elementType) &&
+ if (annotationDefinition.getTargets().contains(elementType) &&
!isDeprecated(annotationDefinition)) {
annotationDefinitions.add(annotationDefinition);
}
}
return annotationDefinitions;
}
-
- private static void filterAnnotationsList(Object element,
+
+ private static void filterAnnotationsList(Object element,
List<AnnotationDefinition> annotationDefinitions) throws JavaModelException {
Iterator<AnnotationDefinition> annotationIter = annotationDefinitions.iterator();
while (annotationIter.hasNext()) {
AnnotationDefinition annotationDefinition = annotationIter.next();
-
+
if (element instanceof IType) {
IType type = (IType) element;
if (isClassRestricted(type, annotationDefinition)
@@ -381,7 +454,7 @@
annotationIter.remove();
}
}
-
+
if (element instanceof IField) {
if(isClassRestricted((IField) element, annotationDefinition)
|| isInterfaceRestricted((IField) element, annotationDefinition)
@@ -391,7 +464,7 @@
}
}
}
-
+
private static boolean isClassRestricted(IJavaElement javaElement,
AnnotationDefinition annotationDefinition) throws JavaModelException {
if (javaElement.getElementType() == IJavaElement.TYPE) {
@@ -407,7 +480,7 @@
}
return false;
}
-
+
private static boolean isInterfaceRestricted(IJavaElement javaElement,
AnnotationDefinition annotationDefinition) throws JavaModelException {
if (javaElement.getElementType() == IJavaElement.TYPE) {
@@ -423,23 +496,23 @@
}
return false;
}
-
+
private static boolean isEnumRestricted(IJavaElement javaElement,
AnnotationDefinition annotationDefinition) throws JavaModelException {
if (javaElement.getElementType() == IJavaElement.TYPE) {
- return !((IType)javaElement).isEnum() && annotationDefinition.isEnumOnly();
+ return !((IType)javaElement).isEnum() && annotationDefinition.isEnumOnly();
}
if (javaElement.getElementType() == IJavaElement.METHOD) {
IType type = (IType)javaElement.getParent();
- return !type.isEnum() && annotationDefinition.isEnumOnly();
+ return !type.isEnum() && annotationDefinition.isEnumOnly();
}
if (javaElement.getElementType() == IJavaElement.FIELD) {
IType type = (IType)javaElement.getParent();
- return !type.isEnum() && annotationDefinition.isEnumOnly();
+ return !type.isEnum() && annotationDefinition.isEnumOnly();
}
return false;
}
-
+
//TODO Move the Deprecated option to preferences
private static boolean isDeprecated(AnnotationDefinition annotationDefinition) {
Class<?> annotationClass = annotationDefinition.getAnnotationClass();
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java
index 79fa98f..dd7f84c 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/AnnotationAttributeInitializer.java
@@ -18,6 +18,7 @@
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.swt.graphics.Image;
@@ -30,17 +31,17 @@
* Provides default implementations for all methods.
* </p>
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under development and
- * expected to change significantly before reaching stability. It is being made available at this early stage
- * to solicit feedback from pioneering adopters on the understanding that any code that uses this API will
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under development and
+ * expected to change significantly before reaching stability. It is being made available at this early stage
+ * to solicit feedback from pioneering adopters on the understanding that any code that uses this API will
* almost certainly be broken (repeatedly) as the API evolves.
* </p>
- *
+ *
*/
public class AnnotationAttributeInitializer implements IAnnotationAttributeInitializer {
protected static final String MISSING_IDENTIFER = "$missing$";
-
+
public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement, AST ast,
Class<? extends Annotation> annotationClass) {
return Collections.emptyList();
@@ -51,12 +52,17 @@
return Collections.emptyList();
}
- protected CompletionProposal createCompletionProposal(String proposal, Expression value) {
+ public List<ICompletionProposal> getCompletionProposalsForSingleMemberAnnotation(IJavaElement javaElement,
+ SingleMemberAnnotation singleMemberAnnotation) {
+ return Collections.emptyList();
+ }
+
+ protected CompletionProposal createCompletionProposal(String proposal, Expression value) {
Image image = PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ISharedImages.IMG_OBJ_FILE);
return createCompletionProposal(proposal, value, image, proposal);
- }
+ }
- protected CompletionProposal createCompletionProposal(String proposal, Expression value, Image image,
+ protected CompletionProposal createCompletionProposal(String proposal, Expression value, Image image,
String displayString) {
int replacementOffset = value.getStartPosition();
int replacementLength = 0;
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java
index 3393729..bb457a7 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/DefaultsAnnotationAttributeInitializer.java
@@ -23,14 +23,14 @@
/**
* Constructs <code>MemberValuePair</code> from the defaults found in the passed in <code>Annotation</code>.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
public class DefaultsAnnotationAttributeInitializer extends AnnotationAttributeInitializer {
-
+
public DefaultsAnnotationAttributeInitializer() {
}
@@ -39,11 +39,11 @@
Class<? extends Annotation> annotationClass) {
return getMemberValuePairs(ast, annotationClass);
}
-
+
private List<MemberValuePair> getMemberValuePairs(AST ast,
Class<? extends Annotation> annotationClass) {
List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
-
+
Method[] declaredMethods = annotationClass.getDeclaredMethods();
for (Method method : declaredMethods) {
String name = method.getName();
@@ -55,34 +55,34 @@
memberValuePairs.add(AnnotationsCore.createStringMemberValuePair(ast,
name, defaultValue.toString()));
}
-
+
if (returnType.equals(Boolean.TYPE)) {
memberValuePairs.add(AnnotationsCore.createBooleanMemberValuePair(ast,
name, Boolean.parseBoolean(defaultValue.toString())));
}
-
- if (returnType.isPrimitive() && (returnType.equals(Byte.TYPE) || returnType.equals(Short.TYPE)
+
+ if (returnType.isPrimitive() && (returnType.equals(Byte.TYPE) || returnType.equals(Short.TYPE)
|| returnType.equals(Integer.TYPE) || returnType.equals(Long.TYPE)
|| returnType.equals(Float.TYPE) || returnType.equals(Double.TYPE))) {
- memberValuePairs.add(AnnotationsCore.createNumberMemberValuePair(ast, name, defaultValue));
+ memberValuePairs.add(AnnotationsCore.createNumberMemberValuePair(ast, name, defaultValue.toString()));
}
-
+
if (returnType.isArray()) {
- memberValuePairs.add(AnnotationsCore.createArrayMemberValuePair(ast, method,
+ memberValuePairs.add(AnnotationsCore.createArrayMemberValuePair(ast, method,
(Object[])defaultValue));
}
-
+
if (returnType.isEnum()) {
- memberValuePairs.add(AnnotationsCore.createEnumMemberValuePair(ast,
+ memberValuePairs.add(AnnotationsCore.createEnumMemberValuePair(ast,
method.getDeclaringClass().getCanonicalName(), name, defaultValue));
}
-
+
if (returnType.equals(Class.class)) {
- memberValuePairs.add(AnnotationsCore.createTypeMemberValuePair(ast, name,
+ memberValuePairs.add(AnnotationsCore.createTypeMemberValuePair(ast, name,
defaultValue));
}
}
- }
+ }
return memberValuePairs;
}
}
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java
index 6e79e91..e8ea259 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/initialization/IAnnotationAttributeInitializer.java
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
/**
@@ -33,5 +34,9 @@
public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement,
MemberValuePair memberValuePair);
+
+ public List<ICompletionProposal> getCompletionProposalsForSingleMemberAnnotation(IJavaElement javaElement,
+ SingleMemberAnnotation singleMemberAnnotation);
+
}
diff --git a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
index 2e4f412..a646835 100644
--- a/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
+++ b/bundles/org.eclipse.jst.ws.annotations.core/src/org/eclipse/jst/ws/annotations/core/utils/AnnotationUtils.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2008 IONA Technologies PLC
+ * Copyright (c) 2008 IONA Technologies PLC, Shane Clarke
* All rights reserved. This program and the accompanying materials
* are 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:
- * IONA Technologies PLC - initial API and implementation
+ * IONA Technologies PLC - initial API and implementation
+ * Shane Clarke - Rewrote API
*******************************************************************************/
package org.eclipse.jst.ws.annotations.core.utils;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -20,12 +20,8 @@
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IAnnotatable;
@@ -46,7 +42,6 @@
import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
import org.eclipse.jdt.core.dom.BodyDeclaration;
import org.eclipse.jdt.core.dom.BooleanLiteral;
import org.eclipse.jdt.core.dom.ChildListPropertyDescriptor;
@@ -71,13 +66,13 @@
import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
import org.eclipse.jdt.ui.CodeStyleConfiguration;
import org.eclipse.jdt.ui.SharedASTProvider;
-import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.ws.annotations.core.AnnotationDefinition;
import org.eclipse.jst.ws.annotations.core.AnnotationsCorePlugin;
+import org.eclipse.jst.ws.annotations.core.AnnotationsManager;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.IUndoManager;
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.TextEdit;
@@ -98,35 +93,120 @@
* </p>
*/
public final class AnnotationUtils {
- private static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR
- = "org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator"; //$NON-NLS-1$
- private static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR
- = "org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator"; //$NON-NLS-1$
- private static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$
-
private AnnotationUtils() {
}
- public static TextEdit createAddImportTextEdit(IJavaElement javaElement,
- Class<? extends java.lang.annotation.Annotation> annotation) throws CoreException {
+ public static void addImport(IJavaElement javaElement, String qualifiedName) throws CoreException {
+ TextFileChange change = new TextFileChange("Add Import", (IFile) javaElement.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createAddImportTextEdit(javaElement, qualifiedName);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+
+ public static void removeImport(IJavaElement javaElement, String qualifiedName) throws CoreException {
+ TextFileChange change = new TextFileChange("Remove Import", (IFile) javaElement.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createRemoveImportTextEdit(javaElement, qualifiedName);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+
+ public static void addAnnotation(IJavaElement javaElement, Annotation annotation) throws CoreException {
+ TextFileChange change = new TextFileChange("Add annotation", (IFile) javaElement.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createAddAnnotationTextEdit(javaElement, annotation);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+
+ public static void removeAnnotation(IJavaElement javaElement, Annotation annotation) throws CoreException {
+ TextFileChange change = new TextFileChange("Remove annotation", (IFile) javaElement.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit textEdit = AnnotationUtils.createRemoveAnnotationTextEdit(javaElement, annotation);
+ change.addEdit(textEdit);
+ applyChange(null, change);
+ }
+
+ public static void addMemberValuePair(NormalAnnotation annotation, MemberValuePair memberValuePair) throws CoreException {
+ if (annotation.getRoot() instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) annotation.getRoot();
+ TextFileChange change = new TextFileChange("Add Member Value Pair", (IFile) compilationUnit.getJavaElement().getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createAddMemberValuePairTextEdit(annotation, memberValuePair);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+ }
+
+ public static void removeMemberValuePair(NormalAnnotation annotation, MemberValuePair memberValuePair) throws CoreException {
+ if (annotation.getRoot() instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) annotation.getRoot();
+ TextFileChange change = new TextFileChange("Remove Member Value Pair", (IFile) compilationUnit.getJavaElement().getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createRemoveMemberValuePairTextEdit(annotation, memberValuePair);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+ }
+
+ public static void updateMemberValuePair(MemberValuePair memberValuePair, ASTNode value) throws CoreException {
+ if (memberValuePair.getRoot() instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) memberValuePair.getRoot();
+ TextFileChange change = new TextFileChange("Update Member Value Pair", (IFile) compilationUnit.getJavaElement().getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createUpdateMemberValuePairTextEdit(memberValuePair, value);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+ }
+
+ public static void updateSingleMemberAnnotation(SingleMemberAnnotation annotation, ASTNode value) throws CoreException {
+ if (annotation.getRoot() instanceof CompilationUnit) {
+ CompilationUnit compilationUnit = (CompilationUnit) annotation.getRoot();
+ TextFileChange change = new TextFileChange("Update Single Member Annotation", (IFile) compilationUnit.getJavaElement().getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
+
+ TextEdit annotationEdit = AnnotationUtils.createUpdateSingleMemberAnnotationTextEdit(annotation, value);
+ change.addEdit(annotationEdit);
+ applyChange(null, change);
+ }
+ }
+
+ public static TextEdit createAddImportTextEdit(IJavaElement javaElement, String qualifiedName) throws CoreException {
CompilationUnit compilationUnit = SharedASTProvider.getAST(getCompilationUnitFromJavaElement(javaElement), SharedASTProvider.WAIT_YES, null);
- String qualifiedName = annotation.getCanonicalName();
ImportRewrite importRewrite = CodeStyleConfiguration.createImportRewrite(compilationUnit, true);
importRewrite.addImport(qualifiedName);
return importRewrite.rewriteImports(null);
}
@SuppressWarnings("unchecked")
- public static TextEdit createRemoveImportTextEdit(IJavaElement javaElement,
- Class<? extends java.lang.annotation.Annotation> annotation) throws CoreException {
+ public static TextEdit createRemoveImportTextEdit(IJavaElement javaElement, String qualifiedName) throws CoreException {
CompilationUnit compilationUnit = SharedASTProvider.getAST(getCompilationUnitFromJavaElement(javaElement), SharedASTProvider.WAIT_YES, null);
- String qualifiedName = annotation.getCanonicalName();
ImportRewrite importRewrite = CodeStyleConfiguration.createImportRewrite(compilationUnit, true);
- final String annotationSimpleName = annotation.getSimpleName();
+ final String annotationSimpleName = qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1);
final List<String> occurences = new ArrayList<String>();
- Target target = annotation.getAnnotation(Target.class);
- List<ElementType> elementTypes = Arrays.asList(target.value());
+ AnnotationDefinition annotationDefinition = AnnotationsManager.getAnnotationDefinitionForClass(qualifiedName);
+ List<ElementType> elementTypes = Collections.emptyList();
+ if (annotationDefinition != null) {
+ elementTypes = annotationDefinition.getTargets();
+ }
for (ElementType elementType : elementTypes) {
if (elementType == ElementType.PACKAGE) {
compilationUnit.accept(new ASTVisitor() {
@@ -236,20 +316,6 @@
}
}
- public static void addAnnotation(IJavaElement javaElement, Annotation annotation) throws CoreException {
- TextChange change = AnnotationUtils.createTextFileChange("Add annotation", (IFile) javaElement.getResource());
- TextEdit annotationEdit = createAddAnnotationTextEdit(javaElement, annotation);
- change.addEdit(annotationEdit);
- applyChange(null, change);
- }
-
- public static void removeAnnotation(IJavaElement javaElement, Annotation annotation) throws CoreException {
- TextEdit textEdit = createRemoveAnnotationTextEdit(javaElement, annotation);
- TextChange change = AnnotationUtils.createTextFileChange("Add annotation", (IFile) javaElement.getResource());
- change.addEdit(textEdit);
- applyChange(null, change);
- }
-
private static void applyChange(IProgressMonitor monitor, Change change) {
if (change == null) {
return;
@@ -281,24 +347,6 @@
}
}
- private static IDocument getDocument(ICompilationUnit source) throws CoreException {
- ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
- IProgressMonitor monitor = new NullProgressMonitor();
-
- IPath path = source.getResource().getFullPath();
- boolean connected = false;
- try {
- bufferManager.connect(path, LocationKind.IFILE, monitor);
- connected = true;
- IDocument document = bufferManager.getTextFileBuffer(path, LocationKind.IFILE).getDocument();
- return document;
- } finally {
- if (connected) {
- bufferManager.disconnect(path, LocationKind.IFILE, monitor);
- }
- }
- }
-
private static TextEdit createAddAnnotationTextEdit(IPackageDeclaration packageDeclaration, Annotation annotation) throws CoreException {
if (packageDeclaration != null && !isAnnotationPresent(packageDeclaration, AnnotationUtils.getAnnotationName(annotation))) {
ICompilationUnit source = getCompilationUnitFromJavaElement(packageDeclaration);
@@ -331,22 +379,17 @@
listRewrite.remove((Annotation) object, null);
}
}
-
return rewriter.rewriteAST();
}
return new MultiTextEdit();
}
private static TextEdit createAddAnnotationTextEdit(IType type, Annotation annotation) throws CoreException {
- ICompilationUnit source = type.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(type);
+ if(typeDeclaration != null && !isAnnotationPresent(type, annotation)) {
+ ASTRewrite rewriter = ASTRewrite.create(typeDeclaration.getAST());
- AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(compilationUnit, type);
- if(typeDeclaration != null && !isAnnotationPresent(typeDeclaration, annotation)) {
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
-
- ListRewrite listRewrite = rewriter.getListRewrite(typeDeclaration,
- getChildListPropertyDescriptorForType(typeDeclaration));
+ ListRewrite listRewrite = rewriter.getListRewrite(typeDeclaration, getChildListPropertyDescriptorForType(typeDeclaration));
listRewrite.insertFirst(annotation, null);
@@ -356,15 +399,11 @@
}
private static TextEdit createRemoveAnnotationTextEdit(IType type, Annotation annotation) throws CoreException {
- ICompilationUnit source = type.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(type);
+ if (typeDeclaration != null && isAnnotationPresent(type, annotation)) {
+ ASTRewrite rewriter = ASTRewrite.create(typeDeclaration.getAST());
- AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(compilationUnit, type);
- if (typeDeclaration != null && isAnnotationPresent(typeDeclaration, annotation)) {
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
-
- ListRewrite listRewrite = rewriter.getListRewrite(typeDeclaration,
- getChildListPropertyDescriptorForType(typeDeclaration));
+ ListRewrite listRewrite = rewriter.getListRewrite(typeDeclaration, getChildListPropertyDescriptorForType(typeDeclaration));
@SuppressWarnings("unchecked")
List originalList = listRewrite.getOriginalList();
@@ -373,22 +412,18 @@
listRewrite.remove((Annotation)object, null);
}
}
-
return rewriter.rewriteAST();
}
return new MultiTextEdit();
}
private static TextEdit createAddAnnotationTextEdit(IMethod method, Annotation annotation) throws CoreException {
- ICompilationUnit source = method.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ MethodDeclaration methodDeclaration = getMethodDeclaration(method);
+ if (methodDeclaration != null && !isAnnotationPresent(method, annotation)) {
+ ASTRewrite rewriter = ASTRewrite.create(methodDeclaration.getAST());
- BodyDeclaration bodyDeclaration = getMethodDeclaration(compilationUnit, method);
- if (bodyDeclaration != null && !isAnnotationPresent(bodyDeclaration, annotation)) {
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
+ ListRewrite listRewrite = rewriter.getListRewrite(methodDeclaration, MethodDeclaration.MODIFIERS2_PROPERTY);
- ListRewrite listRewrite = rewriter.getListRewrite(bodyDeclaration,
- getChildListPropertyDescriptorForMethod(bodyDeclaration));
listRewrite.insertAt(annotation, 0, null);
return rewriter.rewriteAST();
@@ -397,15 +432,11 @@
}
private static TextEdit createRemoveAnnotationTextEdit(IMethod method, Annotation annotation) throws CoreException {
- ICompilationUnit source = method.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ MethodDeclaration methodDeclaration = getMethodDeclaration(method);
+ if (methodDeclaration != null && isAnnotationPresent(method, annotation)) {
+ ASTRewrite rewriter = ASTRewrite.create(methodDeclaration.getAST());
- BodyDeclaration bodyDeclaration = getMethodDeclaration(compilationUnit, method);
- if (bodyDeclaration != null && isAnnotationPresent(bodyDeclaration, annotation)) {
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
-
- ListRewrite listRewrite = rewriter.getListRewrite(bodyDeclaration,
- getChildListPropertyDescriptorForMethod(bodyDeclaration));
+ ListRewrite listRewrite = rewriter.getListRewrite(methodDeclaration, MethodDeclaration.MODIFIERS2_PROPERTY);
@SuppressWarnings("unchecked")
List originalList = listRewrite.getOriginalList();
@@ -416,18 +447,14 @@
}
return rewriter.rewriteAST();
}
-
return new MultiTextEdit();
}
private static TextEdit createAddAnnotationTextEdit(IField field, Annotation annotation) throws CoreException {
- ICompilationUnit source = field.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ FieldDeclaration fieldDeclaration = getFieldDeclaration(field);
+ if (fieldDeclaration != null && !isAnnotationPresent(field, annotation)) {
- FieldDeclaration fieldDeclaration = getFieldDeclaration(compilationUnit, field);
- if (fieldDeclaration != null && !isAnnotationPresent(fieldDeclaration, annotation)) {
-
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
+ ASTRewrite rewriter = ASTRewrite.create(fieldDeclaration.getAST());
ListRewrite listRewrite = rewriter.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
listRewrite.insertAt(annotation, 0, null);
@@ -439,14 +466,9 @@
}
private static TextEdit createRemoveAnnotationTextEdit(IField field, Annotation annotation) throws CoreException {
- ICompilationUnit source = field.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
-
- FieldDeclaration fieldDeclaration = getFieldDeclaration(compilationUnit, field);
-
- if (fieldDeclaration != null && isAnnotationPresent(fieldDeclaration, annotation)) {
-
- ASTRewrite rewriter = ASTRewrite.create(compilationUnit.getAST());
+ FieldDeclaration fieldDeclaration = getFieldDeclaration(field);
+ if (fieldDeclaration != null && isAnnotationPresent(field, annotation)) {
+ ASTRewrite rewriter = ASTRewrite.create(fieldDeclaration.getAST());
ListRewrite listRewrite = rewriter.getListRewrite(fieldDeclaration, FieldDeclaration.MODIFIERS2_PROPERTY);
@@ -457,10 +479,8 @@
listRewrite.remove((Annotation) object, null);
}
}
-
return rewriter.rewriteAST();
}
-
return new MultiTextEdit();
}
@@ -505,14 +525,25 @@
listRewrite.insertLast(memberValuePair, null);
- if (annotation.getRoot() instanceof CompilationUnit) {
- CompilationUnit compilationUnit = (CompilationUnit) annotation.getRoot();
- ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(compilationUnit.getJavaElement());
- IDocument document = getDocument(source);
- return rewriter.rewriteAST(document, getOptions(source));
- } else {
- return rewriter.rewriteAST();
+ return rewriter.rewriteAST();
+ }
+
+ public static TextEdit createRemoveMemberValuePairTextEdit(NormalAnnotation annotation, MemberValuePair memberValuePair) throws CoreException {
+ ASTRewrite rewriter = ASTRewrite.create(annotation.getAST());
+
+ ListRewrite listRewrite = rewriter.getListRewrite(annotation, NormalAnnotation.VALUES_PROPERTY);
+
+ @SuppressWarnings("unchecked")
+ List originalList = listRewrite.getOriginalList();
+ for (Object object : originalList) {
+ if (object instanceof MemberValuePair) {
+ MemberValuePair mvp = (MemberValuePair) object;
+ if (mvp.getName().getIdentifier().equals(memberValuePair.getName().getIdentifier())) {
+ listRewrite.remove(mvp, null);
+ }
+ }
}
+ return rewriter.rewriteAST();
}
public static TextEdit createUpdateMemberValuePairTextEdit(MemberValuePair memberValuePair, ASTNode value) throws CoreException {
@@ -558,7 +589,8 @@
}
@SuppressWarnings("unchecked")
- private static AbstractTypeDeclaration getTypeDeclaration(CompilationUnit compilationUnit, IType type) {
+ public static AbstractTypeDeclaration getTypeDeclaration(IType type) {
+ CompilationUnit compilationUnit = SharedASTProvider.getAST(type.getCompilationUnit(), SharedASTProvider.WAIT_YES, null);
List<TypeDeclaration> types = compilationUnit.types();
for (AbstractTypeDeclaration abstractTypeDeclaration : types) {
if (compareTypeNames(abstractTypeDeclaration, type)) {
@@ -569,19 +601,15 @@
}
@SuppressWarnings("unchecked")
- private static BodyDeclaration getMethodDeclaration(CompilationUnit compilationUnit, IMethod method) {
- AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(compilationUnit, method.getDeclaringType());
+ public static MethodDeclaration getMethodDeclaration(IMethod method) {
+ AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(method.getDeclaringType());
if (typeDeclaration != null) {
List<BodyDeclaration> bodyDeclarations = typeDeclaration.bodyDeclarations();
for (BodyDeclaration bodyDeclaration : bodyDeclarations) {
if (bodyDeclaration instanceof MethodDeclaration) {
- if (compareMethods((MethodDeclaration) bodyDeclaration, method)) {
- return bodyDeclaration;
- }
- }
- if (bodyDeclaration instanceof AnnotationTypeMemberDeclaration) {
- if (compareMethodNames((AnnotationTypeMemberDeclaration)bodyDeclaration, method)) {
- return bodyDeclaration;
+ MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
+ if (compareMethods(methodDeclaration, method)) {
+ return methodDeclaration;
}
}
}
@@ -590,8 +618,8 @@
}
@SuppressWarnings("unchecked")
- private static FieldDeclaration getFieldDeclaration(CompilationUnit compilationUnit, IField field) {
- AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(compilationUnit, field.getDeclaringType());
+ public static FieldDeclaration getFieldDeclaration(IField field) {
+ AbstractTypeDeclaration typeDeclaration = getTypeDeclaration(field.getDeclaringType());
if (typeDeclaration != null) {
List<BodyDeclaration> bodyDeclarations = typeDeclaration.bodyDeclarations();
for (BodyDeclaration bodyDeclaration : bodyDeclarations) {
@@ -606,25 +634,23 @@
return null;
}
- private static BodyDeclaration getFieldDeclaration(List<BodyDeclaration> bodyDeclarations, IField field) {
- for (BodyDeclaration bodyDeclaration : bodyDeclarations) {
- if (bodyDeclaration instanceof FieldDeclaration) {
- if (compareFieldNames((FieldDeclaration)bodyDeclaration, field)) {
- return bodyDeclaration;
+ public static SingleVariableDeclaration getSingleVariableDeclaration(ILocalVariable javaElement) {
+ if (javaElement instanceof ILocalVariable && javaElement.getParent() instanceof IMethod) {
+ ILocalVariable localVariable = javaElement;
+ IMethod method = (IMethod) localVariable.getParent();
+ MethodDeclaration methodDeclaration = getMethodDeclaration(method);
+
+ @SuppressWarnings("unchecked")
+ List<SingleVariableDeclaration> parameters = methodDeclaration.parameters();
+ for (SingleVariableDeclaration singleVariableDeclaration : parameters) {
+ if (singleVariableDeclaration.getName().getIdentifier().equals(localVariable.getElementName())) {
+ return singleVariableDeclaration;
}
}
}
return null;
}
- @SuppressWarnings("unchecked")
- private static Map getOptions(ICompilationUnit source) {
- Map options = source.getJavaProject().getOptions(true);
- options.put(FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, DO_NOT_INSERT);
- options.put(FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, DO_NOT_INSERT);
- return options;
- }
-
private static ChildListPropertyDescriptor getChildListPropertyDescriptorForType(AbstractTypeDeclaration
abstractTypeDeclaration) {
ChildListPropertyDescriptor childListPropertyDescriptor = null;
@@ -640,24 +666,11 @@
return childListPropertyDescriptor;
}
- private static ChildListPropertyDescriptor getChildListPropertyDescriptorForMethod(
- BodyDeclaration bodyDeclaration) {
- if (bodyDeclaration instanceof MethodDeclaration) {
- return MethodDeclaration.MODIFIERS2_PROPERTY;
- }
- if (bodyDeclaration instanceof AnnotationTypeMemberDeclaration) {
- return AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY;
- }
- return null;
- }
-
- public static TextFileChange createTextFileChange(String textFileChangeName, IFile file) {
- TextFileChange textFileChange = new TextFileChange(textFileChangeName, file);
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- textFileChange.setEdit(multiTextEdit);
- return textFileChange;
- }
-
+ /**
+ * Returns the annotations name.
+ * @param annotation
+ * @return the annotation name
+ */
public static String getAnnotationName(Annotation annotation) {
Name annotationTypeName = annotation.getTypeName();
return annotationTypeName.getFullyQualifiedName();
@@ -707,8 +720,7 @@
public static boolean compareMethods(com.sun.mirror.declaration.MethodDeclaration methodOne,
com.sun.mirror.declaration.MethodDeclaration methodTwo) {
- return compareMethodNames(methodOne, methodTwo)
- && compareMethodParameterTypes(methodOne, methodTwo);
+ return compareMethodNames(methodOne, methodTwo) && compareMethodParameterTypes(methodOne, methodTwo);
}
private static boolean compareMethodNames(com.sun.mirror.declaration.MethodDeclaration methodOne,
@@ -730,15 +742,10 @@
}
}
return true;
-
}
return false;
}
- private static boolean compareMethodNames(AnnotationTypeMemberDeclaration memmberDeclaration, IMethod method) {
- return memmberDeclaration.getName().getIdentifier().equals(method.getElementName());
- }
-
@SuppressWarnings("unchecked")
private static boolean compareFieldNames(FieldDeclaration fieldDeclaration, IField field) {
List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
@@ -777,44 +784,17 @@
return isAnnotationPresent(((ICompilationUnit)javaElement).findPrimaryType(), annotationName);
}
- ICompilationUnit source = getCompilationUnitFromJavaElement(javaElement);
-
int elementType = javaElement.getElementType();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
if (elementType == IJavaElement.PACKAGE_DECLARATION
|| elementType == IJavaElement.TYPE
|| elementType == IJavaElement.METHOD
|| elementType == IJavaElement.LOCAL_VARIABLE
|| elementType == IJavaElement.FIELD) {
- return isAnnotationPresent(compilationUnit, javaElement,
- annotationName);
- }
- return false;
- }
- @SuppressWarnings("unchecked")
- private static boolean isAnnotationPresent(BodyDeclaration bodyDeclaration, Annotation annatotationToAdd) {
- boolean exists = false;
- List<IExtendedModifier> modifiers = bodyDeclaration.modifiers();
- for (IExtendedModifier extendedModifier : modifiers) {
- if (extendedModifier instanceof Annotation) {
- Annotation existingAnnotation = (Annotation) extendedModifier;
- if (compareAnnotationNames(annatotationToAdd, existingAnnotation)) {
- return true;
- }
- }
- }
- return exists;
- }
-
- private static boolean isAnnotationPresent(CompilationUnit compilationUnit, IJavaElement javaElement,
- String annotationName) {
- List<IExtendedModifier> modifiers = getExtendedModifiers(compilationUnit, javaElement);
- for (IExtendedModifier extendedModifier : modifiers) {
- if (extendedModifier.isAnnotation()) {
- Annotation existingAnnotation = (Annotation) extendedModifier;
- if (AnnotationUtils.getAnnotationName(existingAnnotation).equals(annotationName)) {
+ List<Annotation> annotations = getAnnotations(javaElement);
+ for (Annotation annotation : annotations) {
+ if (AnnotationUtils.getAnnotationName(annotation).equals(annotationName)) {
return true;
}
}
@@ -823,105 +803,59 @@
}
@SuppressWarnings("unchecked")
- public static List<IExtendedModifier> getExtendedModifiers(CompilationUnit compilationUnit,
- IJavaElement javaElement) {
+ public static List<Annotation> getAnnotations(IJavaElement javaElement) {
+ ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
+ CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION) {
PackageDeclaration packageDeclaration = compilationUnit.getPackage();
return packageDeclaration.annotations();
}
- IType type = compilationUnit.getTypeRoot().findPrimaryType();
- List<AbstractTypeDeclaration> types = compilationUnit.types();
- for (AbstractTypeDeclaration abstractTypeDeclaration : types) {
- if (compareTypeNames(abstractTypeDeclaration, type)) {
- List<BodyDeclaration> bodyDeclarations = getBodyDeclarationsForType(abstractTypeDeclaration);
- BodyDeclaration bodyDeclaration = null;
- if (javaElement.getElementType() == IJavaElement.TYPE) {
- bodyDeclaration = abstractTypeDeclaration;
- }
+ if (javaElement.getElementType() == IJavaElement.TYPE) {
+ IType type = (IType) javaElement;
+ AbstractTypeDeclaration typeDeclaration = AnnotationUtils.getTypeDeclaration(type);
+ return extractAnnotations(typeDeclaration.modifiers());
+ }
- if (javaElement.getElementType() == IJavaElement.METHOD) {
- bodyDeclaration = getMethodDeclaration(bodyDeclarations, (IMethod) javaElement);
- }
+ if (javaElement.getElementType() == IJavaElement.METHOD) {
+ IMethod method = (IMethod) javaElement;
+ MethodDeclaration methodDeclaration = AnnotationUtils.getMethodDeclaration(method);
+ return extractAnnotations(methodDeclaration.modifiers());
+ }
- if (javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
- SingleVariableDeclaration singleVariableDeclaration = getSingleVariableDeclaration((ILocalVariable) javaElement);
- if (singleVariableDeclaration != null) {
- return singleVariableDeclaration.modifiers();
- }
- }
+ if (javaElement.getElementType() == IJavaElement.FIELD) {
+ IField field = (IField) javaElement;
+ FieldDeclaration fieldDeclaration = AnnotationUtils.getFieldDeclaration(field);
+ return extractAnnotations(fieldDeclaration.modifiers());
+ }
- if (javaElement.getElementType() == IJavaElement.FIELD) {
- bodyDeclaration = getFieldDeclaration(bodyDeclarations, (IField) javaElement);
- }
-
- return bodyDeclaration != null ? bodyDeclaration.modifiers() : Collections.emptyList();
+ if (javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
+ SingleVariableDeclaration singleVariableDeclaration = getSingleVariableDeclaration((ILocalVariable) javaElement);
+ if (singleVariableDeclaration != null) {
+ return extractAnnotations(singleVariableDeclaration.modifiers());
}
}
+
return Collections.emptyList();
}
- public static SingleVariableDeclaration getSingleVariableDeclaration(ILocalVariable javaElement) {
- if (javaElement instanceof ILocalVariable && javaElement.getParent() instanceof IMethod) {
- ILocalVariable localVariable = javaElement;
- IMethod method = (IMethod) localVariable.getParent();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(getCompilationUnitFromJavaElement(javaElement), SharedASTProvider.WAIT_YES, null);
-
- MethodDeclaration methodDeclaration = (MethodDeclaration) getMethodDeclaration(compilationUnit, method);
-
- @SuppressWarnings("unchecked")
- List<SingleVariableDeclaration> parameters = methodDeclaration.parameters();
- for (SingleVariableDeclaration singleVariableDeclaration : parameters) {
- if (singleVariableDeclaration.getName().toString().equals(localVariable.getElementName())) {
- return singleVariableDeclaration;
- }
+ private static List<Annotation> extractAnnotations(List<IExtendedModifier> extendedModifiers) {
+ List<Annotation> annotations = new ArrayList<Annotation>();
+ for (IExtendedModifier extendedModifier : extendedModifiers) {
+ if (extendedModifier.isAnnotation()) {
+ annotations.add((Annotation) extendedModifier);
}
}
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private static List<BodyDeclaration> getBodyDeclarationsForType(
- AbstractTypeDeclaration abstractTypeDeclaration) {
- if (abstractTypeDeclaration instanceof TypeDeclaration) {
- TypeDeclaration typeDeclaration = (TypeDeclaration) abstractTypeDeclaration;
- return typeDeclaration.bodyDeclarations();
- }
- if (abstractTypeDeclaration instanceof EnumDeclaration) {
- EnumDeclaration enumDeclaration = (EnumDeclaration) abstractTypeDeclaration;
- return enumDeclaration.bodyDeclarations();
- }
- if (abstractTypeDeclaration instanceof AnnotationTypeDeclaration) {
- AnnotationTypeDeclaration annotationTypeDeclaration =
- (AnnotationTypeDeclaration) abstractTypeDeclaration;
- return annotationTypeDeclaration.bodyDeclarations();
- }
- return Collections.emptyList();
- }
-
- private static MethodDeclaration getMethodDeclaration(List<BodyDeclaration> bodyDeclarations, IMethod method) {
- for (BodyDeclaration bodyDeclaration : bodyDeclarations) {
- if (bodyDeclaration instanceof MethodDeclaration) {
- if (compareMethods((MethodDeclaration)bodyDeclaration, method)) {
- return (MethodDeclaration) bodyDeclaration;
- }
- }
- if (bodyDeclaration instanceof AnnotationTypeMemberDeclaration) {
- if (compareMethodNames((AnnotationTypeMemberDeclaration)bodyDeclaration, method)) {
- return (MethodDeclaration) bodyDeclaration;
- }
- }
- }
- return null;
+ return annotations;
}
@SuppressWarnings("unchecked")
public static List<SingleVariableDeclaration> getSingleVariableDeclarations(final IMethod method) {
ICompilationUnit source = method.getCompilationUnit();
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
- final List<SingleVariableDeclaration> parameters = new ArrayList();
+ final List<SingleVariableDeclaration> parameters = new ArrayList<SingleVariableDeclaration>();
compilationUnit.accept(new ASTVisitor() {
@Override
public boolean visit(MethodDeclaration methodDeclaration) {
@@ -958,32 +892,9 @@
return null;
}
- public static String getStringValue(AnnotationMirror mirror, String attributeName) {
- AnnotationValue annotationValue = getAnnotationValue(mirror, attributeName);
- if (annotationValue != null) {
- return annotationValue.getValue().toString();
- }
- return null;
- }
-
- public static Boolean getBooleanValue(AnnotationMirror mirror, String attributeName) {
- String value = getStringValue(mirror, attributeName);
- if (value != null) {
- return Boolean.valueOf(value);
- }
- return null;
- }
-
- public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String attributeName) {
- Map<AnnotationTypeElementDeclaration, AnnotationValue> values = mirror.getElementValues();
- Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> entrySet = values.entrySet();
- for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : entrySet) {
- AnnotationTypeElementDeclaration element = entry.getKey();
- if (element.getSimpleName().equals(attributeName)) {
- return entry.getValue();
- }
- }
- return null;
+ public static Annotation getAnnotation(IJavaElement javaElement, Class<? extends java.lang.annotation.Annotation> annotation) {
+ List<Annotation> annotations = getAnnotations(javaElement);
+ return getAnnotation(annotations, annotation);
}
public static AnnotationMirror getAnnotation(Declaration declaration,
@@ -1001,31 +912,38 @@
return null;
}
- public static String getStringValue(Annotation annotation, String attributeName) {
- if (annotation instanceof NormalAnnotation) {
- Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
- if (expression != null && expression instanceof StringLiteral) {
- return ((StringLiteral) expression).getLiteralValue();
+ private static Annotation getAnnotation(List<Annotation> annotations,
+ Class<? extends java.lang.annotation.Annotation> annotation) {
+ for (Annotation astAnnotation : annotations) {
+ String typeName = astAnnotation.getTypeName().getFullyQualifiedName();
+ if (typeName.equals(annotation.getCanonicalName())
+ || typeName.equals(annotation.getSimpleName())) {
+ return astAnnotation;
}
}
return null;
}
- public static String getEnumValue(Annotation annotation, String attributeName) {
- if (annotation instanceof NormalAnnotation) {
- Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
- if (expression != null && expression instanceof QualifiedName) {
- return ((QualifiedName) expression).getName().getIdentifier();
+ public static IAnnotation getAnnotation(Class<? extends java.lang.annotation.Annotation> annotation,
+ IAnnotatable annotatable) throws JavaModelException {
+ IAnnotation[] annotations = annotatable.getAnnotations();
+ for (IAnnotation jdtAnnotation : annotations) {
+ String annotationName = jdtAnnotation.getElementName();
+ if (annotationName.equals(annotation.getCanonicalName())
+ || annotationName.equals(annotation.getSimpleName())) {
+ return jdtAnnotation;
}
}
return null;
}
- public static Boolean getBooleanValue(Annotation annotation, String attributeName) {
- if (annotation instanceof NormalAnnotation) {
- Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
- if (expression != null && expression instanceof BooleanLiteral) {
- return Boolean.valueOf(((BooleanLiteral) expression).booleanValue());
+ public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String attributeName) {
+ Map<AnnotationTypeElementDeclaration, AnnotationValue> values = mirror.getElementValues();
+ Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> entrySet = values.entrySet();
+ for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry : entrySet) {
+ AnnotationTypeElementDeclaration element = entry.getKey();
+ if (element.getSimpleName().equals(attributeName)) {
+ return entry.getValue();
}
}
return null;
@@ -1042,37 +960,47 @@
return null;
}
- @SuppressWarnings("unchecked")
- public static Annotation getAnnotation(BodyDeclaration bodyDeclaration,
- Class<? extends java.lang.annotation.Annotation> annotation) {
-
- return getAnnotation(bodyDeclaration.modifiers(), annotation);
- }
-
- @SuppressWarnings("unchecked")
- public static Annotation getAnnotation(SingleVariableDeclaration parameter,
- Class<? extends java.lang.annotation.Annotation> annotation) {
-
- return getAnnotation(parameter.modifiers(), annotation);
- }
-
- private static Annotation getAnnotation(List<IExtendedModifier> modifiers,
- Class<? extends java.lang.annotation.Annotation> annotation) {
- if (modifiers != null) {
- for (IExtendedModifier extendedModifier : modifiers) {
- if (extendedModifier instanceof Annotation) {
- Annotation astAnnotation = (Annotation) extendedModifier;
- String typeName = astAnnotation.getTypeName().getFullyQualifiedName();
- if (typeName.equals(annotation.getCanonicalName())
- || typeName.equals(annotation.getSimpleName())) {
- return astAnnotation;
- }
+ public static Object getAnnotationValue(IAnnotation annotation, String attributeName) throws JavaModelException {
+ IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
+ if (memberValuePairs.length > 0) {
+ for (IMemberValuePair memberValuePair : memberValuePairs) {
+ if (memberValuePair.getMemberName().equals(attributeName)) {
+ return memberValuePair.getValue();
}
}
}
return null;
}
+ @SuppressWarnings("unchecked")
+ public static MemberValuePair getMemberValuePair(NormalAnnotation normalAnnotation, String memberName) {
+ List<MemberValuePair> memberValuesPairs = normalAnnotation.values();
+ for (MemberValuePair memberValuePair : memberValuesPairs) {
+ if (memberValuePair.getName().getIdentifier().equals(memberName)) {
+ return memberValuePair;
+ }
+ }
+ return null;
+ }
+
+ public static String getStringValue(AnnotationMirror mirror, String attributeName) {
+ AnnotationValue annotationValue = getAnnotationValue(mirror, attributeName);
+ if (annotationValue != null) {
+ return annotationValue.getValue().toString();
+ }
+ return null;
+ }
+
+ public static String getStringValue(Annotation annotation, String attributeName) {
+ if (annotation instanceof NormalAnnotation) {
+ Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
+ if (expression != null && expression instanceof StringLiteral) {
+ return ((StringLiteral) expression).getLiteralValue();
+ }
+ }
+ return null;
+ }
+
public static String getStringValue(IAnnotation annotation, String attributeName)
throws JavaModelException {
Object value = AnnotationUtils.getAnnotationValue(annotation, attributeName);
@@ -1082,10 +1010,20 @@
return null;
}
- public static String getEnumValue(IAnnotation annotation, String attributeName) throws JavaModelException {
- String value = AnnotationUtils.getStringValue(annotation, attributeName);
- if (value != null && value.indexOf(".") != -1) {
- return value.substring(value.lastIndexOf(".") + 1);
+ public static Boolean getBooleanValue(AnnotationMirror mirror, String attributeName) {
+ String value = getStringValue(mirror, attributeName);
+ if (value != null) {
+ return Boolean.valueOf(value);
+ }
+ return null;
+ }
+
+ public static Boolean getBooleanValue(Annotation annotation, String attributeName) {
+ if (annotation instanceof NormalAnnotation) {
+ Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
+ if (expression != null && expression instanceof BooleanLiteral) {
+ return Boolean.valueOf(((BooleanLiteral) expression).booleanValue());
+ }
}
return null;
}
@@ -1098,30 +1036,21 @@
return null;
}
- public static Object getAnnotationValue(IAnnotation annotation, String attributeName)
- throws JavaModelException {
- IMemberValuePair[] memberValuePairs = annotation.getMemberValuePairs();
- if (memberValuePairs.length > 0) {
- for (IMemberValuePair memberValuePair : memberValuePairs) {
- if (memberValuePair.getMemberName().equals(attributeName)) {
- return memberValuePair.getValue();
- }
+ public static String getEnumValue(Annotation annotation, String attributeName) {
+ if (annotation instanceof NormalAnnotation) {
+ Expression expression = getAnnotationValue((NormalAnnotation) annotation, attributeName);
+ if (expression != null && expression instanceof QualifiedName) {
+ return ((QualifiedName) expression).getName().getIdentifier();
}
}
return null;
}
- public static IAnnotation getAnnotation(IAnnotatable annotatable,
- Class<? extends java.lang.annotation.Annotation> annotation) throws JavaModelException {
- IAnnotation[] annotations = annotatable.getAnnotations();
- for (IAnnotation jdtAnnotation : annotations) {
- String annotationName = jdtAnnotation.getElementName();
- if (annotationName.equals(annotation.getCanonicalName())
- || annotationName.equals(annotation.getSimpleName())) {
- return jdtAnnotation;
- }
+ public static String getEnumValue(IAnnotation annotation, String attributeName) throws JavaModelException {
+ String value = AnnotationUtils.getStringValue(annotation, attributeName);
+ if (value != null && value.indexOf(".") != -1) {
+ return value.substring(value.lastIndexOf(".") + 1);
}
return null;
}
-
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientCommand.java b/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientCommand.java
index 2dfe265..0b637d7 100644
--- a/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientCommand.java
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jst.ws.internal.cxf.consumption.core.CXFConsumptionCorePlugin;
@@ -35,7 +36,7 @@
/**
* Executes the <code>org.apache.cxf.tools.wsdlto.WSDLToJava</code> command with the arguments
* necessary to generate a client.
- *
+ *
*/
public class WSDL2JavaClientCommand extends AbstractDataModelOperation {
public static final String CXF_TOOL_CLASS_NAME = "org.apache.cxf.tools.wsdlto.WSDLToJava"; //$NON-NLS-1$
@@ -56,7 +57,7 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
- javaResourceChangeListener = new JavaResourceChangeListener(model.getJavaSourceFolder());
+ javaResourceChangeListener = new JavaResourceChangeListener(new Path(model.getJavaSourceFolder()));
ResourcesPlugin.getWorkspace().addResourceChangeListener(javaResourceChangeListener,
IResourceChangeEvent.POST_CHANGE);
diff --git a/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientDefaultingCommand.java b/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientDefaultingCommand.java
index ca7e166..d66e388 100644
--- a/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.consumption.core/src/org/eclipse/jst/ws/internal/cxf/consumption/core/commands/WSDL2JavaClientDefaultingCommand.java
@@ -31,10 +31,10 @@
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
/**
- * Loads the <code>WSDL2JavaDataModel</code> with the persisted defaults
+ * Loads the <code>WSDL2JavaDataModel</code> with the persisted defaults
* from the preferences and with the initial runtime information such as the
* starting point WSDL URL.
- *
+ *
*/
public class WSDL2JavaClientDefaultingCommand extends AbstractDataModelOperation {
private WSDL2JavaDataModel model;
@@ -79,13 +79,13 @@
model.setUseDefaultValues(context.isUseDefaultValues());
model.setNoAddressBinding(context.isNoAddressBinding());
model.setAutoNameResolution(context.isAutoNameResolution());
-
- model.setJavaSourceFolder(JDTUtils.getJavaProjectSourceDirectoryPath(model.getProjectName()));
+
+ model.setJavaSourceFolder(JDTUtils.getJavaProjectSourceDirectoryPath(model.getProjectName()).toOSString());
try {
URL wsdlUrl = new URL(inputURL);
model.setWsdlURL(wsdlUrl);
-
+
Definition definition = WSDLUtils.readWSDL(model.getWsdlURL());
if (definition != null) {
String targetNamespace = definition.getTargetNamespace();
@@ -97,22 +97,22 @@
if (wsdlLocation != null) {
model.setWsdlLocation(wsdlLocation);
}
-
+
model.setWsdlDefinition(definition);
}
} catch (MalformedURLException murle) {
- status = new Status(IStatus.ERROR, CXFConsumptionCorePlugin.PLUGIN_ID,
+ status = new Status(IStatus.ERROR, CXFConsumptionCorePlugin.PLUGIN_ID,
murle.getLocalizedMessage());
CXFConsumptionCorePlugin.log(status);
} catch (IOException ioe) {
- status = new Status(IStatus.ERROR, CXFConsumptionCorePlugin.PLUGIN_ID,
+ status = new Status(IStatus.ERROR, CXFConsumptionCorePlugin.PLUGIN_ID,
ioe.getLocalizedMessage());
CXFConsumptionCorePlugin.log(status);
}
return status;
}
-
+
public WSDL2JavaDataModel getWSDL2JavaDataModel() {
return model;
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.consumption.ui/src/org/eclipse/jst/ws/internal/cxf/consumption/ui/widgets/object/JAXWSSelectionTransformer.java b/bundles/org.eclipse.jst.ws.cxf.consumption.ui/src/org/eclipse/jst/ws/internal/cxf/consumption/ui/widgets/object/JAXWSSelectionTransformer.java
index 0f1bd61..2417e78 100644
--- a/bundles/org.eclipse.jst.ws.cxf.consumption.ui/src/org/eclipse/jst/ws/internal/cxf/consumption/ui/widgets/object/JAXWSSelectionTransformer.java
+++ b/bundles/org.eclipse.jst.ws.cxf.consumption.ui/src/org/eclipse/jst/ws/internal/cxf/consumption/ui/widgets/object/JAXWSSelectionTransformer.java
@@ -16,11 +16,11 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jst.ws.internal.cxf.consumption.ui.CXFConsumptionUIPlugin;
-import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
import org.eclipse.wst.command.internal.env.core.data.Transformer;
@SuppressWarnings("restriction")
@@ -63,7 +63,7 @@
if (path.isAbsolute()) {
try {
IPath javaFolderPath = path.removeLastSegments(1);
- IPackageFragment packageFragment = JDTUtils.getJavaProject(project).findPackageFragment(
+ IPackageFragment packageFragment = JavaCore.create(project).findPackageFragment(
javaFolderPath);
return packageFragment.getElementName() + "." + javaFileName; //$NON-NLS-1$
} catch (JavaModelException jme) {
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/resources/JavaResourceChangeListener.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/resources/JavaResourceChangeListener.java
index 432418e..03c8e99 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/resources/JavaResourceChangeListener.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/resources/JavaResourceChangeListener.java
@@ -23,27 +23,26 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jst.ws.internal.cxf.core.CXFCorePlugin;
/**
* Listens for changes to the <code>IJavaProject</code> src folder.
- *
+ *
*/
public class JavaResourceChangeListener implements IResourceChangeListener {
private List<IResource> changedResources = new ArrayList<IResource>();
- private String sourceDirectoryPath;
-
+ private IPath sourceDirectoryPath;
+
/**
* Constructs a JavaResourceChangeListener instance.
- *
+ *
* @param sourceDirectoryPath
*/
- public JavaResourceChangeListener(String sourceDirectoryPath) {
+ public JavaResourceChangeListener(IPath sourceDirectoryPath) {
this.sourceDirectoryPath = sourceDirectoryPath;
}
-
+
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() != IResourceChangeEvent.POST_CHANGE) {
return;
@@ -51,7 +50,7 @@
IResourceDelta rootDelta = event.getDelta();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IFolder srcFolder = workspaceRoot.getFolder(new Path(sourceDirectoryPath));
+ IFolder srcFolder = workspaceRoot.getFolder(sourceDirectoryPath);
IPath srcFolderPath = srcFolder.getFullPath();
if (!srcFolderPath.hasTrailingSeparator()) {
srcFolderPath = srcFolderPath.addTrailingSeparator();
@@ -79,7 +78,7 @@
CXFCorePlugin.log(ce.getStatus());
}
}
-
+
public List<IResource> getChangedResources() {
return changedResources;
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java
index 9e93bbf..0b245dd 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CXFModelUtils.java
@@ -31,7 +31,6 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MemberValuePair;
@@ -55,7 +54,7 @@
/**
* Provides utility methods for working with the CXF model.
* Also serving as an interim class to aid in refactoring core utilities into jaxws core.
- *
+ *
*/
public final class CXFModelUtils {
private static final Version v_0_0_0 = new Version("0.0.0");
@@ -96,18 +95,18 @@
private CXFModelUtils() {
}
- public static void getWebServiceAnnotationChange(IType type, Java2WSDataModel model,
+ public static void getWebServiceAnnotationChange(IType type, Java2WSDataModel model,
TextFileChange textFileChange) throws CoreException {
ICompilationUnit source = type.getCompilationUnit();
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+ CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
AST ast = compilationUnit.getAST();
-
- NormalAnnotation webServiceAnnotation = getAnnotation(compilationUnit, type, WebService.class);
+
+ NormalAnnotation webServiceAnnotation = getAnnotation(type, WebService.class);
if (webServiceAnnotation != null && model.isUseServiceEndpointInterface() && type.isClass()) {
MemberValuePair endpointInterface = getMemberValuePair(webServiceAnnotation, ENDPOINT_INTERFACE);
if (endpointInterface != null && endpointInterface.getValue() instanceof StringLiteral) {
- StringLiteral stringLiteral = (StringLiteral) endpointInterface.getValue();
+ StringLiteral stringLiteral = (StringLiteral) endpointInterface.getValue();
if (!stringLiteral.getLiteralValue().equals(model.getServiceEndpointInterfaceName())) {
ASTNode newSEIValue = AnnotationsCore.createStringLiteral(ast, model
.getServiceEndpointInterfaceName());
@@ -122,7 +121,7 @@
textFileChange.addEdit(AnnotationUtils.createAddMemberValuePairTextEdit(webServiceAnnotation, endpointInterfacePair));
}
} else {
- IAnnotationAttributeInitializer annotationAttributeInitializer =
+ IAnnotationAttributeInitializer annotationAttributeInitializer =
AnnotationsManager.getAnnotationDefinitionForClass(WebService.class).
getAnnotationAttributeInitializer();
@@ -130,7 +129,7 @@
WebService.class);
if (model.isUseServiceEndpointInterface() && type.isClass()) {
- MemberValuePair endpointInterfaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
+ MemberValuePair endpointInterfaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
ENDPOINT_INTERFACE, model.getServiceEndpointInterfaceName());
memberValuePairs.add(1, endpointInterfaceValuePair);
}
@@ -138,24 +137,17 @@
Annotation annotation = AnnotationsCore.createNormalAnnotation(ast, WebService.class.getSimpleName(), memberValuePairs);
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
- }
+ }
}
- @SuppressWarnings("unchecked")
- private static NormalAnnotation getAnnotation(CompilationUnit compilationUnit, IType type,
- Class<? extends java.lang.annotation.Annotation> annotation) {
- List<AbstractTypeDeclaration> types = compilationUnit.types();
- for (AbstractTypeDeclaration typeDeclaration : types) {
- if (AnnotationUtils.compareTypeNames(typeDeclaration, type)) {
- Annotation jdtAnnotation = AnnotationUtils.getAnnotation(typeDeclaration, annotation);
- if (jdtAnnotation != null && jdtAnnotation instanceof NormalAnnotation) {
- return (NormalAnnotation) jdtAnnotation;
- }
- }
+ private static NormalAnnotation getAnnotation(IType type, Class<? extends java.lang.annotation.Annotation> annotation) {
+ Annotation jdtAnnotation = AnnotationUtils.getAnnotation(type, annotation);
+ if (jdtAnnotation != null && jdtAnnotation instanceof NormalAnnotation) {
+ return (NormalAnnotation) jdtAnnotation;
}
return null;
}
-
+
@SuppressWarnings("unchecked")
private static MemberValuePair getMemberValuePair(NormalAnnotation annotation, String memberName) {
List<MemberValuePair> memberValuePairs = annotation.values();
@@ -167,8 +159,8 @@
return null;
}
- public static void createMethodAnnotationChange(IType type, IMethod method,
- Class<? extends java.lang.annotation.Annotation> annotationClass, TextFileChange textFileChange)
+ public static void createMethodAnnotationChange(IType type, IMethod method,
+ Class<? extends java.lang.annotation.Annotation> annotationClass, TextFileChange textFileChange)
throws CoreException {
ICompilationUnit source = type.getCompilationUnit();
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
@@ -180,7 +172,7 @@
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
}
- public static void getWebMethodAnnotationChange(IType type, IMethod method,
+ public static void getWebMethodAnnotationChange(IType type, IMethod method,
TextFileChange textFileChange) throws CoreException {
ICompilationUnit source = type.getCompilationUnit();
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
@@ -191,8 +183,8 @@
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
}
-
- public static void getRequestWrapperAnnotationChange(IType type, IMethod method,
+
+ public static void getRequestWrapperAnnotationChange(IType type, IMethod method,
TextFileChange textFileChange) throws CoreException {
ICompilationUnit source = type.getCompilationUnit();
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
@@ -215,9 +207,9 @@
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
}
-
- public static void getWebParamAnnotationChange(IType type, final IMethod method,
- ILocalVariable parameter, TextFileChange textFileChange)
+
+ public static void getWebParamAnnotationChange(IType type, final IMethod method,
+ ILocalVariable parameter, TextFileChange textFileChange)
throws CoreException {
ICompilationUnit source = type.getCompilationUnit();
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
@@ -228,27 +220,27 @@
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(parameter, annotation));
}
-
- private static Annotation getAnnotation(IJavaElement javaElement, AST ast,
+
+ private static Annotation getAnnotation(IJavaElement javaElement, AST ast,
Class<? extends java.lang.annotation.Annotation> annotationClass) {
-
+
IAnnotationAttributeInitializer annotationAttributeInitializer = AnnotationsManager.
getAnnotationDefinitionForClass(annotationClass).getAnnotationAttributeInitializer();
-
- List<MemberValuePair> memberValuePairs =
+
+ List<MemberValuePair> memberValuePairs =
annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, annotationClass);
-
+
return AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs);
}
-
- public static void getImportsChange(ICompilationUnit compilationUnit, Java2WSDataModel model,
+
+ public static void getImportsChange(ICompilationUnit compilationUnit, Java2WSDataModel model,
TextFileChange textFileChange, boolean classOnly) {
try {
-
+
ImportRewrite importRewrite = CodeStyleConfiguration.createImportRewrite(compilationUnit, true);
-
+
importRewrite.addImport(ANNOTATION_TYPENAME_MAP.get(WEB_SERVICE));
-
+
if (!classOnly) {
Map<IMethod, Map<String, Boolean>> methodAnnotationMap = model.getMethodMap();
Set<Entry<IMethod, Map<String, Boolean>>> methodAnnotationSet = methodAnnotationMap.entrySet();
@@ -259,7 +251,7 @@
if (ANNOTATION_TYPENAME_MAP.containsKey(method.getKey()) && method.getValue()) {
importRewrite.addImport(ANNOTATION_TYPENAME_MAP.get(method.getKey()));
}
- }
+ }
}
}
if (importRewrite.hasRecordedChanges()) {
@@ -282,7 +274,7 @@
IMethod[] methods = type.getMethods();
for (IMethod method : methods) {
if (type.isInterface()) {
- methodMap.put(method, getAnnotationMap(model));
+ methodMap.put(method, getAnnotationMap(model));
} else if (type.isClass() && JDTUtils.isPublicMethod(method)) {
methodMap.put(method, getAnnotationMap(model));
}
@@ -292,7 +284,7 @@
}
return methodMap;
}
-
+
public static Map<String, Boolean> getAnnotationMap(Java2WSDataModel model) {
Map<String, Boolean> annotationdMap = new HashMap<String, Boolean>();
annotationdMap.put(CXFModelUtils.WEB_METHOD, model.isGenerateWebMethodAnnotation());
@@ -301,11 +293,11 @@
annotationdMap.put(CXFModelUtils.RESPONSE_WRAPPER, model.isGenerateResponseWrapperAnnotation());
return annotationdMap;
}
-
+
/**
* CXF wsdl2java -autoNameResolution is supported in the CXF 2.0 stream from 2.0.7
* and in the CXF 2.1 stream from 2.1.1 up.
- *
+ *
* @param cxfRuntimeVersion
* @return
*/
@@ -326,7 +318,7 @@
}
return false;
}
-
+
public static boolean getDefaultBooleanValue(int classifierID, int featureID) {
Object defaultValue = null;
diff --git a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CommandLineUtils.java b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CommandLineUtils.java
index aed68ba..59750f3 100644
--- a/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CommandLineUtils.java
+++ b/bundles/org.eclipse.jst.ws.cxf.core/src/org/eclipse/jst/ws/internal/cxf/core/utils/CommandLineUtils.java
@@ -82,7 +82,7 @@
private CommandLineUtils() {
}
-
+
public static String[] getJava2WSProgramArguments(Java2WSDataModel model) {
List<String> progArgs = new ArrayList<String>();
@@ -115,7 +115,7 @@
if (model.isGenerateClient()) {
progArgs.add(GEN_CLIENT);
}
-
+
if (model.isGenerateServer()) {
progArgs.add(GEN_SERVER);
}
@@ -127,14 +127,14 @@
progArgs.add(className);
}
- return (String[]) progArgs.toArray(new String[progArgs.size()]);
+ return progArgs.toArray(new String[progArgs.size()]);
}
-
+
private static String[] getStandardJava2WSDLProgramArguments(Java2WSDataModel model) {
String projectName = model.getProjectName();
List<String> progArgs = new ArrayList<String>();
progArgs.add(J2W_CLASSPATH);
- progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName));
+ progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName).toOSString());
progArgs.add(SOURCE_DIR);
progArgs.add(FileUtils.getTmpFolder(projectName) + "/src"); //$NON-NLS-1$
@@ -143,10 +143,10 @@
progArgs.add(FileUtils.getTmpFolder(projectName) + "/wsdl"); //$NON-NLS-1$
progArgs.add(CLASS_DIR);
- progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName));
+ progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName).toOSString());
progArgs.add(OUT_FILE);
- progArgs.add(((Java2WSDataModel) model).getWsdlFileName());
+ progArgs.add(model.getWsdlFileName());
if (model.isSoap12Binding()) {
progArgs.add(INC_SOAP12);
@@ -158,8 +158,8 @@
if (model.isVerbose()) {
progArgs.add(VERBOSE);
}
-
- return (String[]) progArgs.toArray(new String[progArgs.size()]);
+
+ return progArgs.toArray(new String[progArgs.size()]);
}
public static String[] getWSDL2JavaProgramArguments(WSDL2JavaDataModel model) {
@@ -171,17 +171,17 @@
// Add Standard args
progArgs.addAll(Arrays.asList(CommandLineUtils.getStandardWSDL2JavaProgramArguments(model,
projectName)));
-
+
String serviceName = model.getServiceName();
if (serviceName != null && serviceName.length() > 0) {
progArgs.add(W2J_SERVICE_NAME);
progArgs.add(serviceName);
}
-
+
if (model.isUseDefaultValues()) {
progArgs.add(W2J_DEFAULT_VALUES);
}
-
+
if (model.getCxfRuntimeVersion().compareTo(CXFCorePlugin.CXF_VERSION_2_1) >= 0) {
progArgs.add(W2J_FRONTEND);
progArgs.add(model.getFrontend().getLiteral());
@@ -191,7 +191,7 @@
progArgs.add(W2J_WSDL_VERSION);
progArgs.add(model.getWsdlVersion());
-
+
if (model.isNoAddressBinding()) {
progArgs.add(W2J_NO_ADDRESS_BINDING);
}
@@ -199,7 +199,7 @@
progArgs.add(model.getWsdlURL().toExternalForm());
}
- return (String[]) progArgs.toArray(new String[progArgs.size()]);
+ return progArgs.toArray(new String[progArgs.size()]);
}
public static String[] getWSDL2JavaGenerateClientArguments(WSDL2JavaDataModel model) {
@@ -213,16 +213,16 @@
// Add WSLD2Java args
progArgs.addAll(Arrays.asList(CommandLineUtils.getWSDL2JavaProgramArguments(model)));
}
- return (String[]) progArgs.toArray(new String[progArgs.size()]);
+ return progArgs.toArray(new String[progArgs.size()]);
}
-
+
public static String[] getStandardWSDL2JavaProgramArguments(WSDL2JavaDataModel model, String projectName) {
List<String> progArgs = new ArrayList<String>();
progArgs.add(RESOURCE_DIR);
progArgs.add(FileUtils.getTmpFolder(projectName) + "/src"); //$NON-NLS-1$
progArgs.add(CLASS_DIR);
- progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName));
+ progArgs.add(JDTUtils.getJavaProjectOutputDirectoryPath(projectName).toOSString());
Map<String, String> includedNamespaces = model.getIncludedNamespaces();
if (includedNamespaces != null && model.getIncludedNamespaces().size() > 0) {
@@ -242,7 +242,7 @@
progArgs.add(bindingFile);
}
}
-
+
if (model.isGenerateServer()) {
progArgs.add(GEN_SERVER);
}
@@ -254,13 +254,13 @@
if(model.isValidate()) {
progArgs.add(W2J_VALIDATE_WSDL);
}
-
+
progArgs.add(W2J_EXT_SOAP_HEADER);
progArgs.add(Boolean.toString(model.isProcessSOAPHeaders()));
-
+
progArgs.add(W2J_DEFAULT_NAMESPACE);
progArgs.add(Boolean.toString(model.isLoadDefaultNamespacePackageNameMapping()));
-
+
progArgs.add(W2J_DEFAULT_EXCLUDE_NS);
progArgs.add(Boolean.toString(model.isLoadDefaultExcludesNamepsaceMapping()));
@@ -277,11 +277,11 @@
progArgs.add(W2J_WSDL_LOCATION);
progArgs.add(model.getWsdlLocation());
}
-
+
if (model.isVerbose()) {
progArgs.add(VERBOSE);
}
- return (String[]) progArgs.toArray(new String[progArgs.size()]);
+ return progArgs.toArray(new String[progArgs.size()]);
}
private static String getXJCArgs(WSDL2JavaDataModel model) {
@@ -309,11 +309,11 @@
}
String xjcArg = xjcArgs.toString();
- xjcArg = xjcArg.replace('[', ' ');
+ xjcArg = xjcArg.replace('[', ' ');
xjcArg = xjcArg.replace(']', ' ');
-
+
xjcArg = xjcArg.replaceAll("\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
+
return xjcArg.trim();
}
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
index 0502c04..396bb79 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSCommand.java
@@ -25,6 +25,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jst.ws.internal.cxf.core.CXFCorePlugin;
import org.eclipse.jst.ws.internal.cxf.core.context.Java2WSPersistentContext;
import org.eclipse.jst.ws.internal.cxf.core.model.CXFDataModel;
@@ -40,10 +42,10 @@
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
/**
- * Provides a wrapper around the <code>org.apache.cxf.tools.java2ws.JavaToWS</code> or the
+ * Provides a wrapper around the <code>org.apache.cxf.tools.java2ws.JavaToWS</code> or the
* <code>org.apache.cxf.tools.java2wsdl.JavaToWSDL</code> command depending on the version
* of CXF used.
- *
+ *
*/
public class Java2WSCommand extends AbstractDataModelOperation {
private static String JAVA2WSDL_TOOL_CLASS_NAME = "org.apache.cxf.tools.java2wsdl.JavaToWSDL"; //$NON-NLS-1$
@@ -52,10 +54,10 @@
private Java2WSDataModel model;
private String projectName;
-
+
private JavaResourceChangeListener javaResourceChangeListener;
private WebContentChangeListener webContentChangeListener;
-
+
public Java2WSCommand(Java2WSDataModel model) {
this.model = model;
projectName = model.getProjectName();
@@ -64,13 +66,14 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
+ IType startingPoint = JDTUtils.getType(projectName, model.getJavaStartingPoint());
javaResourceChangeListener = new JavaResourceChangeListener(JDTUtils
- .getJavaProjectSourceDirectoryPath(projectName, model.getJavaStartingPoint()));
+ .getJavaProjectSourceDirectoryPath(startingPoint));
webContentChangeListener = new WebContentChangeListener(projectName);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(javaResourceChangeListener,
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(javaResourceChangeListener,
IResourceChangeEvent.POST_CHANGE);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(webContentChangeListener,
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(webContentChangeListener,
IResourceChangeEvent.POST_CHANGE);
if (model.getCxfRuntimeVersion().compareTo(CXFCorePlugin.CXF_VERSION_2_1) >= 0) {
@@ -83,18 +86,18 @@
try {
IProject project = FileUtils.getProject(projectName);
- IJavaProject javaProject = JDTUtils.getJavaProject(project);
+ IJavaProject javaProject = JavaCore.create(project);
LaunchUtils.launch(javaProject, CXF_TOOL_CLASS_NAME, progArgs);
FileUtils.copyJ2WFilesFromTmp(model);
-
+
if (model.isGenerateWSDL()) {
SpringUtils.loadSpringConfigInformationFromWSDL((model));
}
-
+
if (isImplementationSelected() || isGenerateServer()) {
SpringUtils.createJAXWSEndpoint(model);
}
-
+
} catch (CoreException ce) {
status = ce.getStatus();
CXFCreationCorePlugin.log(status);
@@ -111,7 +114,7 @@
}
private boolean isImplementationSelected() {
- return (model.getFullyQualifiedJavaClassName() != null &&
+ return (model.getFullyQualifiedJavaClassName() != null &&
model.getFullyQualifiedJavaClassName().trim().length() > 0);
}
@@ -122,7 +125,7 @@
}
return false;
}
-
+
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
@@ -148,7 +151,7 @@
model.setGenerateXSDImports(context.isGenerateXSDImports());
return status;
}
-
+
public CXFDataModel getCXFDataModel() {
return model;
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
index fb7d497..9a7c2b3 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/Java2WSDefaultingCommand.java
@@ -43,13 +43,13 @@
model.setCxfRuntimeVersion(context.getCxfRuntimeVersion());
model.setCxfRuntimeEdition(context.getCxfRuntimeEdition());
- IType startingPointType = getJavaStartingPointType();
+ IType startingPointType = getJavaStartingPointType();
model.setUseServiceEndpointInterface(startingPointType.isInterface());
model.setExtractInterface(false);
-
+
String packageName = startingPointType.getPackageFragment().getElementName();
model.setTargetNamespace(JDTUtils.getTargetNamespaceFromPackageName(packageName));
-
+
model.setAnnotationProcessingEnabled(context.isAnnotationProcessingEnabled());
model.setGenerateWebMethodAnnotation(context.isGenerateWebMethodAnnotation());
model.setGenerateWebParamAnnotation(context.isGenerateWebParamAnnotation());
@@ -57,7 +57,7 @@
model.setGenerateResponseWrapperAnnotation(context.isGenerateResponseWrapperAnnotation());
model.setAnnotationMap(CXFModelUtils.getAnnotationMap(model));
model.setMethodMap(CXFModelUtils.getMethodMap(startingPointType, model));
-
+
model.setGenerateXSDImports(context.isGenerateXSDImports());
model.setDatabinding(context.getDatabinding());
model.setFrontend(context.getFrontend());
@@ -68,8 +68,8 @@
model.setGenerateWSDL(context.isGenerateWSDL());
model.setUseSpringApplicationContext(context.isUseSpringApplicationContext());
model.setVerbose(context.isVerbose());
-
- String className = JDTUtils.getClassName(model.getProjectName(), model.getJavaStartingPoint());
+
+ String className = getClassName(model.getProjectName(), model.getJavaStartingPoint());
model.setWsdlFileName(className.toLowerCase() + WSDLUtils.WSDL_FILE_EXTENSION);
} catch (JavaModelException jme) {
status = jme.getStatus();
@@ -91,10 +91,15 @@
return startingPointType;
}
+ public String getClassName(String projectName, String fullyQualifiedClassName) {
+ return JDTUtils.getType(JDTUtils.getJavaProject(projectName), fullyQualifiedClassName)
+ .getElementName();
+ }
+
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
-
+
return status;
}
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaCommand.java
index 571b464..38f9da5 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaCommand.java
@@ -22,6 +22,7 @@
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jst.ws.internal.cxf.core.model.CXFDataModel;
@@ -39,12 +40,12 @@
/**
* Provides a wrapper around the <code>org.apache.cxf.tools.wsdlto.WSDLToJava</code> command.
- *
+ *
*/
@SuppressWarnings("restriction")
public class WSDL2JavaCommand extends AbstractDataModelOperation {
public static final String CXF_TOOL_CLASS_NAME = "org.apache.cxf.tools.wsdlto.WSDLToJava"; //$NON-NLS-1$
-
+
private WSDL2JavaDataModel model;
private IWebService ws;
@@ -59,7 +60,7 @@
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
- javaResourceChangeListener = new JavaResourceChangeListener(model.getJavaSourceFolder());
+ javaResourceChangeListener = new JavaResourceChangeListener(new Path(model.getJavaSourceFolder()));
webContentChangeListener = new WebContentChangeListener(model.getProjectName());
ResourcesPlugin.getWorkspace().addResourceChangeListener(javaResourceChangeListener,
@@ -68,7 +69,7 @@
IResourceChangeEvent.POST_CHANGE);
String projectName = model.getProjectName();
-
+
//TODO revisit
ws.getWebServiceInfo().setImplURLs(new String[] {projectName + "/Impl.java"}); //$NON-NLS-1$
@@ -88,7 +89,7 @@
CXFCreationCorePlugin.log(status);
} catch (IOException ioe) {
status = new Status(IStatus.ERROR, CXFCreationCorePlugin.PLUGIN_ID, ioe.getLocalizedMessage());
- CXFCreationCorePlugin.log(status);
+ CXFCreationCorePlugin.log(status);
} finally {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(javaResourceChangeListener);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(webContentChangeListener);
@@ -116,7 +117,7 @@
}
return status;
}
-
+
public CXFDataModel getCXFDataModel() {
return model;
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaDefaultingCommand.java b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaDefaultingCommand.java
index 3aa2ae0..b105e2a 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.core/src/org/eclipse/jst/ws/internal/cxf/creation/core/commands/WSDL2JavaDefaultingCommand.java
@@ -57,9 +57,9 @@
private WSDL2JavaDataModel model;
private String projectName;
private String inputURL;
-
+
private WebContentChangeListener webContentChangeListener;
-
+
public WSDL2JavaDefaultingCommand(WSDL2JavaDataModel model, String projectName, String inputURL) {
this.model = model;
this.projectName = projectName;
@@ -70,11 +70,11 @@
@SuppressWarnings({ "unchecked", "deprecation" })
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
-
+
webContentChangeListener = new WebContentChangeListener(projectName);
ResourcesPlugin.getWorkspace().addResourceChangeListener(webContentChangeListener,
IResourceChangeEvent.POST_CHANGE);
-
+
WSDL2JavaPersistentContext context = CXFCorePlugin.getDefault().getWSDL2JavaContext();
model.setCxfRuntimeVersion(context.getCxfRuntimeVersion());
model.setCxfRuntimeEdition(context.getCxfRuntimeEdition());
@@ -105,7 +105,7 @@
model.setAutoNameResolution(context.isAutoNameResolution());
model.setNoAddressBinding(context.isNoAddressBinding());
model.setUseSpringApplicationContext(context.isUseSpringApplicationContext());
- model.setJavaSourceFolder(JDTUtils.getJavaProjectSourceDirectoryPath(model.getProjectName()));
+ model.setJavaSourceFolder(JDTUtils.getJavaProjectSourceDirectoryPath(model.getProjectName()).toOSString());
try {
Definition definition = null;
@@ -145,7 +145,7 @@
for (Map.Entry serviceEntry : servicesSet) {
Service service = (Service) serviceEntry.getValue();
Map portsMap = service.getPorts();
- Set<Map.Entry> portsSet = portsMap.entrySet();
+ Set<Map.Entry> portsSet = portsMap.entrySet();
for (Map.Entry portEntry : portsSet) {
Port port = (Port) portEntry.getValue();
PortType portType = port.getBinding().getPortType();
@@ -161,22 +161,22 @@
copier.setTargetFolderURI(wsdlFolderPath.toFile().toURI().toString());
copier.setTargetFilename(filename);
workspace.run(copier, monitor);
-
+
File wsdlFile = wsdlFolderPath.addTrailingSeparator().append(filename).toFile();
model.setWsdlURL(wsdlFile.toURI().toURL());
}
- model.setWsdlFileName(WSDLUtils.getWSDLFileNameFromURL(model.getWsdlURL()));
-
+ model.setWsdlFileName(getWSDLFileNameFromURL(model.getWsdlURL()));
+
IPath wsdlLocationPath = new Path(model.getWsdlURL().getPath());
wsdlLocationPath = wsdlLocationPath.removeFirstSegments(WSDLUtils.getWebContentFolder(project)
.getLocation().matchingFirstSegments(wsdlLocationPath));
-
+
if (wsdlLocationPath.getDevice() != null) {
wsdlLocationPath = wsdlLocationPath.setDevice(null);
}
model.setWsdlDefinition(definition);
model.setConfigWsdlLocation(wsdlLocationPath.toString());
-
+
} catch (CoreException ce) {
status = ce.getStatus();
CXFCreationCorePlugin.log(status);
@@ -193,7 +193,12 @@
ResourcesPlugin.getWorkspace().removeResourceChangeListener(webContentChangeListener);
return status;
}
-
+
+ public String getWSDLFileNameFromURL(URL wsdlURL) {
+ IPath wsdlPath = new Path(wsdlURL.toExternalForm());
+ return wsdlPath.lastSegment();
+ }
+
private void setWSDLLocation(Definition definition) throws MalformedURLException {
String wsdlLocation = WSDLUtils.getWSDLLocation(definition);
if (wsdlLocation != null) {
@@ -211,7 +216,7 @@
public WSDL2JavaDataModel getWSDL2JavaDataModel() {
return model;
}
-
+
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
IStatus status = Status.OK_STATUS;
@@ -227,10 +232,10 @@
}
}
}
-
+
model.getBindingFiles().clear();
model.getIncludedNamespaces().clear();
-
+
return status;
}
}
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.jst.ws.cxf.creation.ui/META-INF/MANIFEST.MF
index 88c90f1..48ea797 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/META-INF/MANIFEST.MF
@@ -35,7 +35,8 @@
javax.wsdl;bundle-version="[1.6.2,1.7.0)",
org.eclipse.ui.editors;bundle-version="[3.4.0,4.0.0)",
org.eclipse.wst.common.modulecore;bundle-version="[1.1.0,1.3.0)",
- org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)"
+ org.eclipse.jdt.apt.core;bundle-version="[3.3.100,4.0.0)",
+ org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Bundle-ActivationPolicy: lazy
Ant-Version: Apache Ant 1.7.0
Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.)
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
index 272bd2b..8bce936 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/JAXWSAnnotateJavaWidget.java
@@ -91,23 +91,23 @@
private TreeViewerColumn webParamViewerColumn;
private TreeViewerColumn requestWrapperViewerColumn;
private TreeViewerColumn responceWrapperViewerColumn;
-
+
public JAXWSAnnotateJavaWidget() {
}
public void setJava2WSDataModel(Java2WSDataModel model) {
this.model = model;
}
-
+
@Override
public WidgetDataEvents addControls(Composite parent, Listener statusListener) {
SashForm sashForm = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH);
GridLayout gridLayout = new GridLayout(1, true);
sashForm.setLayout(gridLayout);
-
+
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
sashForm.setLayoutData(gridData);
-
+
Composite javaTreecomposite = new Composite(sashForm, SWT.NONE);
gridLayout = new GridLayout(1, true);
javaTreecomposite.setLayout(gridLayout);
@@ -198,15 +198,15 @@
if (event.getSelection() instanceof ITreeSelection) {
ITreeSelection treeSelection = (TreeSelection) event.getSelection();
Object firstElement = treeSelection.getFirstElement();
-
+
IDocument document = annotationPreviewViewer.getDocument();
- FindReplaceDocumentAdapter findReplaceDocumentAdapter =
+ FindReplaceDocumentAdapter findReplaceDocumentAdapter =
new FindReplaceDocumentAdapter(document);
try {
if (firstElement instanceof IType) {
IType sourceType = (IType) firstElement;
String elementName = sourceType.getElementName();
-
+
StringBuilder regex = new StringBuilder("\\bpublic\\W+(?:\\w+\\W+){1,3}?");
regex.append(elementName);
regex.append("\\b");
@@ -218,22 +218,22 @@
} else if (firstElement instanceof IMethod) {
IMethod sourceMethod = (IMethod) firstElement;
IType sourceType = (IType) sourceMethod.getParent();
-
+
String elementName = sourceMethod.getElementName();
-
+
StringBuilder regex = new StringBuilder();
-
+
if (sourceType.isClass()) {
regex.append("\\bpublic");
}
-
+
regex.append("\\W+(?:\\w+\\W+){1,3}?");
regex.append(elementName);
regex.append("\\s*?\\(\\s*?.*?");
-
+
String[] parameterTypes = sourceMethod.getParameterTypes();
String[] paramterNames = sourceMethod.getParameterNames();
-
+
for (int i = 0; i < parameterTypes.length; i++) {
regex.append("\\s*?");
String typeName = Signature.toString(parameterTypes[i]);
@@ -248,14 +248,14 @@
IRegion region = findReplaceDocumentAdapter.find(0, regex.toString(), true, true,
false, true);
-
+
if (region != null) {
IRegion elementNameRegion = findReplaceDocumentAdapter.find(
region.getOffset(), elementName, true, true, true, false);
if (elementNameRegion != null) {
- annotationPreviewViewer.setSelectedRange(elementNameRegion.getOffset(),
+ annotationPreviewViewer.setSelectedRange(elementNameRegion.getOffset(),
elementNameRegion.getLength());
- annotationPreviewViewer.revealRange(elementNameRegion.getOffset(),
+ annotationPreviewViewer.revealRange(elementNameRegion.getOffset(),
elementNameRegion.getLength());
}
}
@@ -293,9 +293,9 @@
gridData.heightHint = 10;
gridData.widthHint = 200;
annotationPreviewViewer.getControl().setLayoutData(gridData);
-
+
sashForm.setWeights(new int[]{50, 50});
-
+
return this;
}
@@ -319,17 +319,17 @@
type =JDTUtils.getType(JDTUtils.getJavaProject(model.getProjectName()), model
.getFullyQualifiedJavaClassName());
}
-
+
if (type == null) {
type = JDTUtils.getType(JDTUtils.getJavaProject(model.getProjectName()), model
.getJavaStartingPoint());
}
-
+
model.setMethodMap(CXFModelUtils.getMethodMap(type, model));
return type;
}
-
+
private TreeViewerColumn createWebMethodViewerColumn(TreeViewer treeViewer) {
webMethodViewerColumn = new TreeViewerColumn(treeViewer, SWT.CENTER);
TreeColumn webMethodColumn = webMethodViewerColumn.getColumn();
@@ -366,7 +366,7 @@
createRequestWrapperColumn.setMoveable(false);
requestWrapperViewerColumn.setLabelProvider(new AnnotationColumnLabelProvider(model,
CXFModelUtils.REQUEST_WRAPPER, getType()));
- requestWrapperViewerColumn.setEditingSupport(new AnnotationEditingSupport(treeViewer,
+ requestWrapperViewerColumn.setEditingSupport(new AnnotationEditingSupport(treeViewer,
CXFModelUtils.REQUEST_WRAPPER));
return requestWrapperViewerColumn;
}
@@ -383,7 +383,7 @@
CXFModelUtils.RESPONSE_WRAPPER));
return responceWrapperViewerColumn;
}
-
+
private void updateLabelProviders() {
webMethodViewerColumn.setLabelProvider(new AnnotationColumnLabelProvider(model,
CXFModelUtils.WEB_METHOD, getType()));
@@ -394,15 +394,15 @@
responceWrapperViewerColumn.setLabelProvider(new AnnotationColumnLabelProvider(model,
CXFModelUtils.RESPONSE_WRAPPER, getType()));
}
-
+
private void handleAnnotation(IType type) {
try {
annotationPreviewViewer.setRedraw(false);
ICompilationUnit compilationUnit = type.getCompilationUnit();
IProgressMonitor monitor = new NullProgressMonitor();
-
- TextFileChange textFileChange = new TextFileChange("Annotation Changes",
+
+ TextFileChange textFileChange = new TextFileChange("Annotation Changes",
(IFile)compilationUnit.getResource());
MultiTextEdit multiTextEdit = new MultiTextEdit();
textFileChange.setEdit(multiTextEdit);
@@ -426,12 +426,12 @@
if (methodAnnotationMap.get(CXFModelUtils.WEB_PARAM)) {
List<SingleVariableDeclaration> parameters = AnnotationUtils.getSingleVariableDeclarations(method);
for (SingleVariableDeclaration parameter : parameters) {
- CXFModelUtils.getWebParamAnnotationChange(type, method,
+ CXFModelUtils.getWebParamAnnotationChange(type, method,
(ILocalVariable) parameter.resolveBinding().getJavaElement(), textFileChange);
}
- }
+ }
}
-
+
CXFModelUtils.getImportsChange(compilationUnit, model, textFileChange, false);
annotationPreviewViewer.getDocument().set(textFileChange.getPreviewContent(monitor));
@@ -440,7 +440,7 @@
CXFCreationUIPlugin.log(ce.getStatus());
} catch (MalformedTreeException mte) {
CXFCreationUIPlugin.log(mte);
- }
+ }
}
private SourceViewer createAnnotationPreviewer(Composite parent, int styles) {
@@ -459,7 +459,7 @@
annotationPreviewViewer.setEditable(false);
- String source = JDTUtils.getSourceFromType(getType());
+ String source = getSourceFromType(getType());
IDocument document = new Document(source);
JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document,
@@ -469,6 +469,15 @@
return annotationPreviewViewer;
}
+ public String getSourceFromType(IType type) {
+ try {
+ return type.getCompilationUnit().getBuffer().getContents();
+ } catch (JavaModelException jme) {
+ CXFCreationUIPlugin.log(jme.getStatus());
+ }
+ return ""; //$NON-NLS-1$
+ }
+
@Override
public IStatus getStatus() {
return status;
@@ -478,7 +487,7 @@
private CheckboxCellEditor checkboxCellEditor;
private String annotationKey;
-
+
public AnnotationEditingSupport(TreeViewer viewer, String annotationKey) {
super(viewer);
this.annotationKey = annotationKey;
@@ -489,7 +498,7 @@
protected boolean canEdit(Object element) {
if (element instanceof IMethod) {
IMethod method = (IMethod) element;
- return !AnnotationUtils.isAnnotationPresent(type.findMethods(method)[0],
+ return !AnnotationUtils.isAnnotationPresent(type.findMethods(method)[0],
annotationKey);
}
return false;
diff --git a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
index 5a6d7f8..b163bb6 100644
--- a/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
+++ b/bundles/org.eclipse.jst.ws.cxf.creation.ui/src/org/eclipse/jst/ws/internal/cxf/creation/ui/widgets/Java2WSClassConfigWidget.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jst.ws.internal.cxf.creation.ui.widgets;
+import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -17,11 +18,16 @@
import javax.jws.WebService;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
@@ -35,6 +41,8 @@
import org.eclipse.jst.ws.internal.cxf.creation.ui.CXFCreationUIMessages;
import org.eclipse.jst.ws.internal.cxf.creation.ui.CXFCreationUIPlugin;
import org.eclipse.jst.ws.internal.cxf.ui.widgets.Java2WSWidgetFactory;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
+import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCorePlugin;
import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -62,7 +70,7 @@
private IStatus SEI_SELECTION_STATUS = Status.OK_STATUS;
private static final String NAME = "name";
-
+
private int NUMBER_OF_PUBLIC_METHODS;
private int NUMBER_OF_CHECKED_METHODS;
private IMethod[] publicMethods;
@@ -74,7 +82,7 @@
private Combo selectSEICombo;
private Text seiInterfaceNameText;
-
+
private CheckboxTableViewer seiMembersToExtractTableViewer;
private Table seiMembersToExtractTable;
private Button selectAllButton;
@@ -135,7 +143,7 @@
statusListener.handleEvent(null);
if (!useSEI) {
model.setServiceEndpointInterfaceName("");
-
+
selectSEIButton.setSelection(false);
enableSelectSEIControls(false);
@@ -148,7 +156,7 @@
gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
gridData.horizontalSpan = 3;
useSEIButton.setLayoutData(gridData);
-
+
Label paddingLabel = Java2WSWidgetFactory.createPaddingLabel(composite);
gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.horizontalSpan = 3;
@@ -167,7 +175,7 @@
}
}
});
-
+
selectSEIButton.setSelection(false);
selectSEIButton.setEnabled(false);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
@@ -181,7 +189,7 @@
statusListener.handleEvent(null);
}
});
-
+
selectSEICombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
@@ -193,7 +201,7 @@
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.horizontalSpan = 1;
selectSEICombo.setLayoutData(gridData);
-
+
browseSEIButton = Java2WSWidgetFactory.createBrowseButton(composite);
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
@@ -245,7 +253,7 @@
gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
extractSEIButton.setLayoutData(gridData);
-
+
seiInterfaceNameText = Java2WSWidgetFactory.createSEIInterfaceNameText(composite);
seiInterfaceNameText.addModifyListener(new ModifyListener() {
@@ -261,7 +269,7 @@
String compilationUnitName = interfaceName + ".java"; //$NON-NLS-1$
JAVA_TYPE_NAME_STATUS = JDTUtils.validateJavaTypeName(model.getProjectName(), interfaceName);
- JAVA_TYPE_EXISTS_STATUS = JDTUtils.checkTypeExists(startingPointType, compilationUnitName);
+ JAVA_TYPE_EXISTS_STATUS = checkTypeExists(startingPointType, compilationUnitName);
updateSEISelectionStatus();
statusListener.handleEvent(null);
}
@@ -287,7 +295,7 @@
public void checkStateChanged(CheckStateChangedEvent event) {
Object[] checkedMethods = seiMembersToExtractTableViewer.getCheckedElements();
-
+
Map<IMethod, Map<String, Boolean>> methodMap = new HashMap<IMethod, Map<String, Boolean>>();
for (int i = 0; i < checkedMethods.length; i++) {
methodMap.put((IMethod)checkedMethods[i], model.getAnnotationMap());
@@ -387,7 +395,7 @@
return this;
}
-
+
private void validateSEISelection() {
if (!useSEIButton.getSelection()) {
SEI_SELECTION_STATUS = Status.OK_STATUS;
@@ -416,8 +424,8 @@
} else {
SEI_SELECTION_STATUS = new Status(IStatus.ERROR, CXFCreationUIPlugin.PLUGIN_ID,
CXFCreationUIMessages.bind(CXFCreationUIMessages.WEBSERVICE_ENPOINTINTERFACE_NOT_FOUND,
- selectSEICombo.getText()));
- }
+ selectSEICombo.getText()));
+ }
}
private String getImplementsMessage(IType seiType, IMethod seiMethod) {
@@ -440,12 +448,12 @@
private IStatus validateSEIAddition() {
IStatus status = Status.OK_STATUS;
try {
- IAnnotation webService = AnnotationUtils.getAnnotation(startingPointType, WebService.class);
+ IAnnotation webService = AnnotationUtils.getAnnotation(WebService.class, startingPointType);
if (webService != null) {
Object name = AnnotationUtils.getAnnotationValue(webService, NAME);
if (name != null) {
status = new Status(IStatus.ERROR, CXFCreationUIPlugin.PLUGIN_ID,
- CXFCreationUIMessages.JAVA2WS_SELECT_SEI_WEBSERVICE_NAME_ATTRIBUTE_PRESENT);
+ CXFCreationUIMessages.JAVA2WS_SELECT_SEI_WEBSERVICE_NAME_ATTRIBUTE_PRESENT);
}
}
} catch (JavaModelException jme) {
@@ -453,7 +461,7 @@
}
return status;
}
-
+
public void enableSelectSEIControls(boolean enable) {
selectSEICombo.setEnabled(enable);
browseSEIButton.setEnabled(enable);
@@ -526,7 +534,7 @@
if (SEI_SELECTION_STATUS.matches(IStatus.ERROR)) {
return SEI_SELECTION_STATUS;
}
-
+
if (SEI_SELECTION_STATUS.getSeverity() >= JAVA_TYPE_NAME_STATUS.getSeverity()) {
return SEI_SELECTION_STATUS;
}
@@ -538,4 +546,30 @@
return JAVA_TYPE_NAME_STATUS;
}
+ public IStatus checkTypeExists(IType type, String compilationUnitName) {
+ compilationUnitName = compilationUnitName.trim();
+
+ IPackageFragment packageFragment = type.getPackageFragment();
+ ICompilationUnit compilationUnit = packageFragment.getCompilationUnit(compilationUnitName);
+ IResource resource = compilationUnit.getResource();
+
+ if (resource.exists()) {
+ return new Status(IStatus.ERROR, JAXWSCorePlugin.PLUGIN_ID, JAXWSCoreMessages
+ .bind(JAXWSCoreMessages.TYPE_WITH_NAME_ALREADY_EXISTS, new Object[] {
+ compilationUnitName, packageFragment.getElementName() }));
+ }
+ URI location = resource.getLocationURI();
+ if (location != null) {
+ try {
+ IFileStore fileStore = EFS.getStore(location);
+ if (fileStore.fetchInfo().exists()) {
+ return new Status(IStatus.ERROR, JAXWSCorePlugin.PLUGIN_ID,
+ JAXWSCoreMessages.TYPE_NAME_DIFFERENT_CASE_EXISTS);
+ }
+ } catch (CoreException ce) {
+ JAXWSCorePlugin.log(ce.getStatus());
+ }
+ }
+ return Status.OK_STATUS;
+ }
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/JDTUtils.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/JDTUtils.java
index 1e68a5e..40423c4 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/JDTUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/JDTUtils.java
@@ -10,15 +10,12 @@
*******************************************************************************/
package org.eclipse.jst.ws.jaxws.core.utils;
-import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -26,10 +23,9 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragment;
@@ -38,15 +34,14 @@
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCoreMessages;
import org.eclipse.jst.ws.internal.jaxws.core.JAXWSCorePlugin;
/**
* JDT Utility class.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
@@ -55,6 +50,11 @@
private JDTUtils() {
}
+ /**
+ * Add a <code>IClasspathEntry</code> to a <code>IJavaProject</code>
+ * @param javaProject the <code>IJavaProject</code> to add the classpath entry to
+ * @param classpathEntry the <code>IClasspathEntry</code> to add
+ */
public static void addToClasspath(IJavaProject javaProject, IClasspathEntry classpathEntry) {
try {
List<IClasspathEntry> currentEntries = Arrays.asList(javaProject.getRawClasspath());
@@ -70,6 +70,11 @@
}
}
+ /**
+ * Remove a <code>IClasspathEntry</code> from a <code>IJavaProject</code>
+ * @param javaProject the <code>IJavaProject</code> to remove the classpath entry from
+ * @param classpathEntry the <code>IClasspathEntry</code> to remove
+ */
public static void removeFromClasspath(IJavaProject javaProject, IClasspathEntry classpathEntry) {
try {
List<IClasspathEntry> currentEntries = Arrays.asList(javaProject.getRawClasspath());
@@ -84,119 +89,85 @@
JAXWSCorePlugin.log(jme.getStatus());
}
}
-
- public static IStatus checkTypeExists(IType type, String compilationUnitName) {
- compilationUnitName = compilationUnitName.trim();
- IPackageFragment packageFragment = type.getPackageFragment();
- ICompilationUnit compilationUnit = packageFragment.getCompilationUnit(compilationUnitName);
- IResource resource = compilationUnit.getResource();
-
- if (resource.exists()) {
- return new Status(IStatus.ERROR, JAXWSCorePlugin.PLUGIN_ID, JAXWSCoreMessages
- .bind(JAXWSCoreMessages.TYPE_WITH_NAME_ALREADY_EXISTS, new Object[] {
- compilationUnitName, packageFragment.getElementName() }));
- }
- URI location = resource.getLocationURI();
- if (location != null) {
- try {
- IFileStore fileStore = EFS.getStore(location);
- if (fileStore.fetchInfo().exists()) {
- return new Status(IStatus.ERROR, JAXWSCorePlugin.PLUGIN_ID,
- JAXWSCoreMessages.TYPE_NAME_DIFFERENT_CASE_EXISTS);
- }
- } catch (CoreException ce) {
- JAXWSCorePlugin.log(ce.getStatus());
- }
- }
- return Status.OK_STATUS;
- }
-
- public static String getClassName(String projectName, String fullyQualifiedClassName) {
- return JDTUtils.getType(JDTUtils.getJavaProject(projectName), fullyQualifiedClassName)
- .getElementName();
- }
-
- public static IJavaProject getJavaProject(IProject project) {
- IJavaProject javaProject = JavaCore.create(project);
- return javaProject;
- }
-
+ /**
+ * Returns the Java project corresponding to the given project name.
+ * @param projectName the project name
+ * @return the Java project corresponding to the given project name
+ */
public static IJavaProject getJavaProject(String projectName) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- return JDTUtils.getJavaProject(project);
+ return JavaCore.create(project);
}
- public static String getJavaProjectOutputDirectoryPath(IJavaProject javaProject) {
- IPath outputPath;
- String fullPath = ""; //$NON-NLS-1$
+ /**
+ * Returns the absolute path in the local file system of the default output location for the given java project.
+ * @param javaProject the java project
+ * @return the absolute path of the default output folder for the given java project
+ */
+ public static IPath getJavaProjectOutputDirectoryPath(IJavaProject javaProject) {
try {
- outputPath = javaProject.getOutputLocation();
- fullPath = ResourcesPlugin.getWorkspace().getRoot().findMember(outputPath).getLocation()
- .toOSString();
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(javaProject.getOutputLocation()).getLocation();
} catch (JavaModelException jme) {
JAXWSCorePlugin.log(jme.getStatus());
}
- return fullPath;
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(javaProject.getPath()).getLocation();
}
- public static String getJavaProjectOutputDirectoryPath(String projectName) {
+ /**
+ * Returns the absolute path in the local file system of the default output location for the given java project name.
+ * @param projectName the name of the java project
+ * @return the absolute path of the default output folder for the given java project name
+ */
+ public static IPath getJavaProjectOutputDirectoryPath(String projectName) {
return JDTUtils.getJavaProjectOutputDirectoryPath(JDTUtils.getJavaProject(projectName));
}
- public static String getJavaProjectSourceDirectoryPath(IJavaProject javaProject,
- String fullyQualifiedClassName) {
-
- IType type = JDTUtils.getType(javaProject, fullyQualifiedClassName);
+ /**
+ * Returns the full, absolute path relative to the workspace of the source folder that contains the given type.
+ * @param type the <code>IType</code>
+ * @return the absolute path of the given <code>IType</code> source folder
+ */
+ public static IPath getJavaProjectSourceDirectoryPath(IType type) {
IPackageFragment packageFragment = type.getPackageFragment();
- IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot)packageFragment.getParent();
+ IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) packageFragment.getParent();
IResource srcDirectoryResource = packageFragmentRoot.getResource();
- return srcDirectoryResource.getFullPath().toOSString();
+ return srcDirectoryResource.getFullPath();
}
- public static String getJavaProjectSourceDirectoryPath(String projectName,
- String fullyQualifiedClassName) {
- return JDTUtils.getJavaProjectSourceDirectoryPath(JDTUtils.getJavaProject(projectName),
- fullyQualifiedClassName);
- }
-
- public static String getJavaProjectSourceDirectoryPath(String projectName) {
+ /**
+ * Returns the full, absolute path relative to the workspace of the first source folder found in the java project with the given name.
+ * @param projectName the name of the java project
+ * @return the absolute path of the first source folder found in the java project with the given name.
+ */
+ public static IPath getJavaProjectSourceDirectoryPath(String projectName) {
return JDTUtils.getJavaProjectSourceDirectoryPath(JDTUtils.getJavaProject(projectName));
}
- public static String getJavaProjectSourceDirectoryPath(IProject project) {
- return JDTUtils.getJavaProjectSourceDirectoryPath(JDTUtils.getJavaProject(project));
- }
-
- public static String getJavaProjectSourceDirectoryPath(IJavaProject javaProject) {
+ /**
+ * Returns the full, absolute path relative to the workspace of the first source folder found in the given java project.
+ * @param javaProject the <code>IJavaProject</code>
+ * @return the absolute path of the first source folder found in the given java project.
+ */
+ public static IPath getJavaProjectSourceDirectoryPath(IJavaProject javaProject) {
try {
IPackageFragmentRoot[] packageFragmentRoots = javaProject.getAllPackageFragmentRoots();
IPackageFragmentRoot packageFragmentRoot = packageFragmentRoots[0];
IResource srcDirectoryResource = packageFragmentRoot.getResource();
- return srcDirectoryResource.getFullPath().toOSString();
+ return srcDirectoryResource.getFullPath();
} catch (JavaModelException jme) {
JAXWSCorePlugin.log(jme.getStatus());
}
- return ""; //$NON-NLS-1$
+ return new Path("");
}
- public static String getPackageNameFromClass(IJavaProject javaProject, String fullyQualifiedClassName) {
- return JDTUtils.getType(javaProject, fullyQualifiedClassName).getPackageFragment().getElementName();
- }
-
- public static String getPackageNameFromClass(String projectName, String fullyQualifiedClassName) {
- return JDTUtils
- .getPackageNameFromClass(JDTUtils.getJavaProject(projectName), fullyQualifiedClassName);
- }
-
-
/**
* If the given <code>IType</code> is an interface all methods declared in that interface are returned.
* <p>
- * Alternatively if the given given <code>IType</code> is a class only methods that are explicitly marked
+ * Alternatively if the given given <code>IType</code> is a class, only methods that are explicitly marked
* public are returned.
- *
- * @param type the type
+ *
+ * @param type the <code>IType</code>
* @return the public methods declared in this type
*/
public static IMethod[] getPublicMethods(IType type) {
@@ -217,16 +188,16 @@
}
return publicMethods.toArray(new IMethod[publicMethods.size()]);
}
-
- public static String getSourceFromType(IType type) {
- try {
- return type.getCompilationUnit().getBuffer().getContents();
- } catch (JavaModelException jme) {
- JAXWSCorePlugin.log(jme.getStatus());
- }
- return ""; //$NON-NLS-1$
- }
+ /**
+ * Constructs a target namespace string from the given package name by splitting the dot '.' separated
+ * package name, reversing the order of the package name segments followed by prefixing the string with
+ * 'http://' and appending a forward slash '/' to the end.
+ * <p>E.g., the Java package Òcom.example.wsÓ would return the target namespace Òhttp://ws.example.com/Ó.</p>
+ * <p>If the package name is null or is of zero length "http://default_package/" is returned.</p>
+ * @param packageName the package name
+ * @return the derived target namespace
+ */
public static String getTargetNamespaceFromPackageName(String packageName) {
if (packageName == null || packageName.length() == 0) {
return "http://default_package/"; //$NON-NLS-1$
@@ -249,6 +220,12 @@
return targetNamespace;
}
+ /**
+ * Returns the first type found following the given java project's classpath with the given fully qualified name or null if none is found.
+ * @param javaProject the given <code>IJavaProject</code>
+ * @param fullyQualifiedClassName the given fully qualified name
+ * @return the first type found following the java project's classpath with the given fully qualified name or null if none is found
+ */
public static IType getType(IJavaProject javaProject, String fullyQualifiedClassName) {
try {
return javaProject.findType(fullyQualifiedClassName);
@@ -258,14 +235,22 @@
return null;
}
- public static IType getType(IProject project, String fullyQualifiedClassName) {
- return JDTUtils.getType(JDTUtils.getJavaProject(project), fullyQualifiedClassName);
- }
-
+ /**
+ * Returns the first type found with the given fully qualified name following the classpath of the java project with
+ * the give project name or null if none is found.
+ * @param projectName the name of the java project
+ * @param fullyQualifiedClassName the given fully qualified name
+ * @return the first type found following the java project's classpath with the given fully qualified name or null if none is found
+ */
public static IType getType(String projectName, String fullyQualifiedClassName) {
return JDTUtils.getType(JDTUtils.getJavaProject(projectName), fullyQualifiedClassName);
}
+ /**
+ * Returns whether the given project has the java nature.
+ * @param project the given project
+ * @return <code>true</code> if the project has the java nature
+ */
public static boolean isJavaProject(IProject project) {
try {
return project.hasNature(JavaCore.NATURE_ID);
@@ -274,7 +259,12 @@
}
return false;
}
-
+
+ /**
+ * Returns true if the given method isn't a main method or constructor and if it has the public modifier.
+ * @param method the given method
+ * @return <code>true</code> if the given method is public
+ */
public static boolean isPublicMethod(IMethod method) {
try {
return Flags.isPublic(method.getFlags()) && !method.isConstructor() && !method.isMainMethod();
@@ -284,19 +274,39 @@
return false;
}
- public static IStatus validateJavaTypeName(String compilationUnitName) {
+ /**
+ * Validates the given Java type name, either simple or qualified, using the workspace source and compliance levels.
+ * @param name the name of a type
+ * @return a status object with code IStatus.OK if the given name is valid as a Java type name, a status with
+ * code IStatus.WARNING indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name
+ */
+ public static IStatus validateJavaTypeName(String name) {
String sourceLevel = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
String complianceLevel = JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE);
- return JavaConventions.validateJavaTypeName(compilationUnitName, sourceLevel, complianceLevel);
+ return JavaConventions.validateJavaTypeName(name, sourceLevel, complianceLevel);
}
- public static IStatus validateJavaTypeName(String projectName, String compilationUnitName) {
+ /**
+ * Validates the given Java type name, either simple or qualified, using the given projects source and compliance levels.
+ * @param projectName the name of the java project
+ * @param name the name of a type
+ * @return a status object with code IStatus.OK if the given name is valid as a Java type name, a status with
+ * code IStatus.WARNING indicating why the given name is discouraged, otherwise a status object indicating what is wrong with the name
+ */
+ public static IStatus validateJavaTypeName(String projectName, String name) {
IJavaProject javaProject = JDTUtils.getJavaProject(projectName);
String sourceLevel = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
String complianceLevel = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
- return JavaConventions.validateJavaTypeName(compilationUnitName, sourceLevel, complianceLevel);
+ return JavaConventions.validateJavaTypeName(name, sourceLevel, complianceLevel);
}
+ /**
+ * Validate the given package name using the given projects source and compliance levels.
+ * @param projectName the name of the java project
+ * @param packageName the name of a package
+ * @return a status object with code IStatus.OK if the given name is valid as a package name, otherwise a status
+ * object indicating what is wrong with the name
+ */
public static IStatus validatePackageName(String projectName, String packageName) {
IJavaProject javaProject = JDTUtils.getJavaProject(projectName);
String sourceLevel = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
@@ -304,6 +314,12 @@
return JavaConventions.validatePackageName(packageName, sourceLevel, complianceLevel);
}
+ /**
+ * Validates the given Java identifier with the workspace source and compliance levels.
+ * @param id the Java identifier
+ * @return a status object with code IStatus.OK if the given identifier is a valid Java identifier, otherwise
+ * a status object indicating what is wrong with the identifier
+ */
public static IStatus validateIdentifier(String id) {
String sourceLevel = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
String complianceLevel = JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE);
diff --git a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/WSDLUtils.java b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/WSDLUtils.java
index 82c4c82..53154f0 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/WSDLUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.core/src/org/eclipse/jst/ws/jaxws/core/utils/WSDLUtils.java
@@ -56,9 +56,9 @@
/**
* WSDL Utility class.
* <p>
- * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability. It is being made available at
- * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
+ * <strong>Provisional API:</strong> This class/interface is part of an interim API that is still under
+ * development and expected to change significantly before reaching stability. It is being made available at
+ * this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses
* this API will almost certainly be broken (repeatedly) as the API evolves.
* </p>
*/
@@ -70,10 +70,17 @@
private static final int TIMEOUT = 30000;
public static final String WSDL_FILE_EXTENSION = ".wsdl"; //$NON-NLS-1$
-
+
private WSDLUtils() {
}
-
+
+ /**
+ * Returns a <code>javax.wsdl.Definition</code> by reading the WSDL document at the given URL or null if none can be found
+ * or if the connection times out.
+ * @param wsdlURL the url of the wsdl document to read.
+ * @return the definition described in the wsdl document pointed to by the given URL.
+ * @throws IOException if an I/O exception occurs.
+ */
public static Definition readWSDL(URL wsdlURL) throws IOException {
URLConnection urlConnection = wsdlURL.openConnection();
urlConnection.setConnectTimeout(TIMEOUT);
@@ -95,7 +102,14 @@
}
return null;
}
-
+
+ /**
+ * Writes the given <code>javax.wsdl.Definition</code> to the wsdl document at the given URL.
+ * @param wsdlURL the url of the wsdl document to write to.
+ * @param definition the WSDL definition to be written.
+ * @throws IOException if an I/O exception occurs.
+ * @throws CoreException if an exception occurs refreshing the file in the workspace if it exists.
+ */
public static void writeWSDL(URL wsdlURL, Definition definition) throws IOException, CoreException {
URI wsdlURI = null;
OutputStream wsdlOutputStream = null;
@@ -121,28 +135,47 @@
}
}
}
-
+
+ /**
+ * Returns <code>true</code> if the given file name contains Alphanumeric characters, underscore '_',
+ * dashes '-' and ends with the '.wsdl' extension. Otherwise returns <code>false</code>.
+ * @param wsdlFileName the wsdl file name
+ * @return <code>true</code> if valid, code>false</code> otherwise.
+ */
public static boolean isValidWSDLFileName(String wsdlFileName) {
- return wsdlFileName != null && wsdlFileName.matches(WSDL_FILE_NAME_PATTERN);
+ return wsdlFileName != null && wsdlFileName.matches(WSDL_FILE_NAME_PATTERN);
}
-
- public static IProject getProject(String projectName) {
+
+ private static IProject getProject(String projectName) {
return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
-
- public static IFolder getWebContentFolder(String projectName) {
- return WSDLUtils.getWebContentFolder(WSDLUtils.getProject(projectName));
- }
-
+
+ /**
+ * Returns the Web Content folder of the given project. The returned resource may not exist.
+ * @param project the name of the web project
+ * @return the web content folder
+ */
public static IFolder getWebContentFolder(IProject project) {
return ResourcesPlugin.getWorkspace().getRoot().getFolder(
WSDLUtils.getWebContentPath(project));
}
+ /**
+ * Returns the WSDL folder of the project with the given name. The WSDL folder path is the projects web content folder
+ * path appended with the 'WSDL' directory. The returned resource may not exist.
+ * @param projectName the name of the web project
+ * @return the wsdl folder
+ */
public static IFolder getWSDLFolder(String projectName) {
return WSDLUtils.getWSDLFolder(WSDLUtils.getProject(projectName));
}
+ /**
+ * Returns the WSDL folder of the given project. The WSDL folder path is the projects web content folder
+ * path appended with the 'WSDL' directory. The returned resource may not exist.
+ * @param projectName the name of the web project
+ * @return the wsdl folder
+ */
public static IFolder getWSDLFolder(IProject project) {
IPath wsdlFolderPath = WSDLUtils.getWebContentPath(project).append(WSDLUtils.WSDL_FOLDER_PATH);
IFolder wsdlFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(wsdlFolderPath);
@@ -155,18 +188,16 @@
}
return wsdlFolder;
}
-
- public static IPath getWebContentPath(IProject project) {
+
+ private static IPath getWebContentPath(IProject project) {
return J2EEUtils.getWebContentPath(project).addTrailingSeparator();
}
- public static String getWSDLFileNameFromURL(URL wsdlURL) {
- IPath wsdlPath = new Path(wsdlURL.toExternalForm());
- return wsdlPath.lastSegment();
- }
-
/**
- * will return one of:
+ * Returns the first <code>SOAPAddress</code> or <code>SOAP12Address</code> found in the given
+ * <code>Definition</code> or null if none is found.
+ * @param definition the given definition.
+ * @return return one of:
* <li>SOAPAddress<li>SOAP12Address<li>null if it can not find a soap address
*/
@SuppressWarnings("unchecked")
@@ -183,7 +214,7 @@
List extensibilityElements = port.getExtensibilityElements();
for (Object object : extensibilityElements) {
if (object instanceof SOAPAddress || object instanceof SOAP12Address) {
- return (ExtensibilityElement) object;
+ return (ExtensibilityElement) object;
}
}
}
@@ -192,6 +223,14 @@
return null;
}
+ /**
+ * Returns the location URI from the first <code>SOAPAddress</code> or <code>SOAP12Address</code> found
+ * in the given <code>Definition</code> or null if none is found. The returned location URI is appended with
+ * the '?wsdl' query if the query was not present in the <code>SOAPAddress</code> or <code>SOAP12Address</code> location URI.
+ * @param definition the given defintion.
+ * @return the location URI or the first <code>SOAPAddress</code> or <code>SOAP12Address</code> found in the given definition.
+ * @throws MalformedURLException if an error occurs testing the location URI for a query part.
+ */
public static String getWSDLLocation(Definition definition) throws MalformedURLException {
ExtensibilityElement extensibilityElement = WSDLUtils.getEndpointAddress(definition);
if (extensibilityElement != null) {
@@ -206,7 +245,7 @@
}
return null;
}
-
+
private static String getLocationURI(ExtensibilityElement extensibilityElement) {
if (extensibilityElement instanceof SOAPAddress) {
return ((SOAPAddress) extensibilityElement).getLocationURI();
@@ -216,7 +255,14 @@
}
return ""; //$NON-NLS-1$
}
-
+
+ /**
+ * Constructs a dot separated package name from a given namespace.
+ * <p>E.g., the namespace Òhttp://ws.example.com/Ó would return the Java package name Òcom.example.wsÓ.</p>
+ * <p>N.B. This method does not preserve 'www' in the returned package name if it exists in the given namespace.</p>
+ * @param namespace the given name.
+ * @return a package name.
+ */
public static String getPackageNameFromNamespace(String namespace) {
String packageName = ""; //$NON-NLS-1$
try {
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/contentassist/AnnotationCompletionProposalComputer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/contentassist/AnnotationCompletionProposalComputer.java
index 929e04c..fd43d5a 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/contentassist/AnnotationCompletionProposalComputer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/contentassist/AnnotationCompletionProposalComputer.java
@@ -20,12 +20,11 @@
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.ui.SharedASTProvider;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer;
import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext;
@@ -37,71 +36,72 @@
public class AnnotationCompletionProposalComputer implements IJavaCompletionProposalComputer {
- public AnnotationCompletionProposalComputer() {
- super();
- }
+ public AnnotationCompletionProposalComputer() {
+ super();
+ }
- @SuppressWarnings("unchecked")
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- if (context instanceof JavaContentAssistInvocationContext) {
- return computeCompletionProposals((JavaContentAssistInvocationContext) context);
- }
- return Collections.emptyList();
- }
+ @SuppressWarnings("unchecked")
+ public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ if (context instanceof JavaContentAssistInvocationContext) {
+ return computeCompletionProposals((JavaContentAssistInvocationContext) context);
+ }
+ return Collections.emptyList();
+ }
- private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context) {
+ private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context) {
CompletionContext completionContext = context.getCoreContext();
int tokenStart = completionContext.getOffset();
-
- ICompilationUnit source = context.getCompilationUnit();
- try {
- IJavaElement javaElement = source.getElementAt(tokenStart);
- if (javaElement != null) {
-
- CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
-
- switch(javaElement.getElementType()) {
- case IJavaElement.PACKAGE_DECLARATION:
- case IJavaElement.TYPE:
- case IJavaElement.FIELD:
- return getCompletionProposalsForJavaElement(AnnotationUtils.getExtendedModifiers(
- compilationUnit, javaElement), javaElement, tokenStart);
- case IJavaElement.METHOD:
- ILocalVariable localVariable = AnnotationUtils.getLocalVariable((IMethod) javaElement, tokenStart);
- if (localVariable != null) {
- return getCompletionProposalsForJavaElement(AnnotationUtils.getExtendedModifiers(
- compilationUnit, localVariable), localVariable, tokenStart);
- } else {
- return getCompletionProposalsForJavaElement(AnnotationUtils.getExtendedModifiers(
- compilationUnit, javaElement), javaElement, tokenStart);
+
+ ICompilationUnit source = context.getCompilationUnit();
+ try {
+ IJavaElement javaElement = source.getElementAt(tokenStart);
+ if (javaElement != null) {
+ switch(javaElement.getElementType()) {
+ case IJavaElement.PACKAGE_DECLARATION:
+ case IJavaElement.TYPE:
+ case IJavaElement.FIELD:
+ return getCompletionProposalsForJavaElement(AnnotationUtils.getAnnotations(
+ javaElement), javaElement, tokenStart);
+ case IJavaElement.METHOD:
+ ILocalVariable localVariable = AnnotationUtils.getLocalVariable((IMethod) javaElement, tokenStart);
+ if (localVariable != null) {
+ return getCompletionProposalsForJavaElement(AnnotationUtils.getAnnotations(
+ localVariable), localVariable, tokenStart);
+ } else {
+ return getCompletionProposalsForJavaElement(AnnotationUtils.getAnnotations(
+ javaElement), javaElement, tokenStart);
}
- }
- }
- } catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
- }
- return Collections.emptyList();
- }
-
- private List<ICompletionProposal> getCompletionProposalsForJavaElement(List<IExtendedModifier> modifiers,
- IJavaElement javaElement, int offset) {
- for (IExtendedModifier extendedModifier : modifiers) {
- if (extendedModifier.isAnnotation() && extendedModifier instanceof NormalAnnotation) {
- NormalAnnotation normalAnnotation = (NormalAnnotation) extendedModifier;
+ }
+ }
+ } catch (JavaModelException jme) {
+ JAXWSUIPlugin.log(jme.getStatus());
+ }
+ return Collections.emptyList();
+ }
+
+ private List<ICompletionProposal> getCompletionProposalsForJavaElement(List<Annotation> annotations,
+ IJavaElement javaElement, int offset) {
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof NormalAnnotation) {
+ NormalAnnotation normalAnnotation = (NormalAnnotation) annotation;
MemberValuePair memberValuePair = getMemberValuePairForPosition(normalAnnotation, offset);
if (memberValuePair != null) {
- return getCompletionProposalsForJavaElement(normalAnnotation, memberValuePair,
+ return getCompletionProposalsForJavaElement(normalAnnotation, memberValuePair,
javaElement);
}
}
+ if (annotation instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation;
+ return getCompletionProposalsForJavaElement(singleMemberAnnotation, javaElement);
+ }
}
return Collections.emptyList();
}
-
- private List<ICompletionProposal> getCompletionProposalsForJavaElement(NormalAnnotation normalAnnotation,
- MemberValuePair memberValuePair, IJavaElement javaElement) {
+
+ private List<ICompletionProposal> getCompletionProposalsForJavaElement(NormalAnnotation annotation,
+ MemberValuePair memberValuePair, IJavaElement javaElement) {
IAnnotationAttributeInitializer annotationAttributeInitializer = AnnotationsManager
- .getAnnotationAttributeInitializerForName(normalAnnotation.getTypeName());
+ .getAnnotationAttributeInitializerForName(annotation.getTypeName());
if (annotationAttributeInitializer != null) {
return annotationAttributeInitializer.getCompletionProposalsForMemberValuePair(javaElement,
memberValuePair);
@@ -109,8 +109,20 @@
return Collections.emptyList();
}
- @SuppressWarnings("unchecked")
- private MemberValuePair getMemberValuePairForPosition(NormalAnnotation normalAnnotation, int offset) {
+ private List<ICompletionProposal> getCompletionProposalsForJavaElement(SingleMemberAnnotation annotation,
+ IJavaElement javaElement) {
+ IAnnotationAttributeInitializer annotationAttributeInitializer = AnnotationsManager
+ .getAnnotationAttributeInitializerForName(annotation.getTypeName());
+ if (annotationAttributeInitializer != null) {
+ return annotationAttributeInitializer.getCompletionProposalsForSingleMemberAnnotation(javaElement,
+ annotation);
+ }
+ return Collections.emptyList();
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private MemberValuePair getMemberValuePairForPosition(NormalAnnotation normalAnnotation, int offset) {
List<MemberValuePair> memberValuePairs = normalAnnotation.values();
for (MemberValuePair memberValuePair : memberValuePairs) {
Expression value = memberValuePair.getValue();
@@ -122,21 +134,20 @@
}
}
return null;
- }
-
- @SuppressWarnings("unchecked")
- public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- return Collections.emptyList();
- }
+ }
- public String getErrorMessage() {
- return null;
- }
+ @SuppressWarnings("unchecked")
+ public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ return Collections.emptyList();
+ }
- public void sessionEnded() {
- }
+ public String getErrorMessage() {
+ return null;
+ }
- public void sessionStarted() {
- }
+ public void sessionEnded() {
+ }
+ public void sessionStarted() {
+ }
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/JAXWSQuickFixProcessor.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/JAXWSQuickFixProcessor.java
index 03e7038..41c7301 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/JAXWSQuickFixProcessor.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/JAXWSQuickFixProcessor.java
@@ -84,13 +84,13 @@
}
}
}
-
- return (IJavaCompletionProposal[]) proposals.toArray(new IJavaCompletionProposal[proposals.size()]);
+
+ return proposals.toArray(new IJavaCompletionProposal[proposals.size()]);
}
- private void process(IInvocationContext context, IProblemLocation problemLocation,
+ private void process(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals) throws CoreException {
-
+
String problem = problemLocation.getProblemArguments()[1];
if (problem.equals(JAXWSCoreMessages.WEBSERVICE_ENPOINTINTERFACE_MUST_IMPLEMENT)) {
@@ -108,7 +108,7 @@
|| problem.equals(JAXWSCoreMessages.WEBMETHOD_EXCLUDE_NOT_ALLOWED_ON_SEI)) {
addRemoveMemberValuePairProposal(context, problemLocation, proposals, false);
}
-
+
if (problem.equals(JAXWSCoreMessages.WEBMETHOD_EXCLUDE_SPECIFIED_NO_OTHER_ATTRIBUTES_ALLOWED)) {
addRemoveMemberValuePairProposal(context, problemLocation, proposals, true);
}
@@ -145,7 +145,7 @@
if (problem.equals(JAXWSCoreMessages.WEBSERVICE_WEBSERVICEPROVIDER_COMBINATION)) {
addRemoveAnnotationProposal(context, problemLocation, proposals, WebServiceProvider.class);
}
-
+
if (problem.equals(JAXWSCoreMessages.HANDLER_CHAIN_SOAP_MESSAGE_HANDLERS)) {
addRemoveAnnotationProposal(context, problemLocation, proposals, SOAPMessageHandlers.class);
}
@@ -153,7 +153,7 @@
if (problem.equals(JAXWSCoreMessages.WEBSERVICE_OVERRIDE_FINALIZE)) {
addRemoveMethodProposal(context, problemLocation, proposals);
}
-
+
if (problem.equals(JAXWSCoreMessages.WEBMETHOD_ONLY_ON_PUBLIC_METHODS)
|| problem.equals(JAXWSCoreMessages.WEBMETHOD_NO_STATIC_MODIFIER_ALLOWED)
|| problem.equals(JAXWSCoreMessages.WEBMETHOD_NO_FINAL_MODIFIER_ALLOWED)) {
@@ -166,25 +166,25 @@
}
if (problem.equals(JAXWSCoreMessages.WEBSERVICE_ENPOINTINTERFACE_INCOMPATIBLE_RETURN_TYPE)) {
- addChangeReturnTypeProposal(context, problemLocation, proposals);
+ addChangeReturnTypeProposal(context, problemLocation, proposals);
}
}
- private void addAnnotationToTypeProposal(IInvocationContext context, List<IJavaCompletionProposal> proposals,
+ private void addAnnotationToTypeProposal(IInvocationContext context, List<IJavaCompletionProposal> proposals,
Class<? extends java.lang.annotation.Annotation> annotationClass) {
-
+
String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.ADD_ANNOTATION, annotationClass.getSimpleName());
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
proposals.add(new AddAnnotationToTypeCorrectionProposal(context, annotationClass, displayString, 5, image));
}
-
+
private void addRemoveMethodProposal(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals) {
-
+
ASTNode selectedNode = problemLocation.getCoveringNode(context.getASTRoot());
if (selectedNode.getParent() instanceof NormalAnnotation) {
- NormalAnnotation normalAnnotation = (NormalAnnotation) selectedNode.getParent();
+ NormalAnnotation normalAnnotation = (NormalAnnotation) selectedNode.getParent();
ASTNode parentNode = normalAnnotation.getParent();
if (parentNode instanceof MethodDeclaration) {
selectedNode = ((MethodDeclaration) parentNode).getName();
@@ -194,7 +194,7 @@
selectedNode = ((MethodDeclaration) singleVariableDeclaration.getParent()).getName();
}
}
-
+
if (selectedNode instanceof SimpleName) {
SimpleName methodName = (SimpleName) selectedNode;
String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_METHOD, methodName.getIdentifier());
@@ -204,23 +204,23 @@
}
}
- private void addRemoveAnnotationProposal(IInvocationContext context, IProblemLocation problemLocation,
+ private void addRemoveAnnotationProposal(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals, Class<? extends java.lang.annotation.Annotation> annotation) {
-
+
ASTNode coveringNode = problemLocation.getCoveringNode(context.getASTRoot());
ASTNode parentNode = coveringNode.getParent();
-
- String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_ANNOTATION, annotation.getSimpleName());
+
+ String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_ANNOTATION, annotation.getSimpleName());
Image image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
proposals.add(new RemoveAnnotationCorrectionProposal(context, annotation, parentNode, displayString, 5, image));
}
- private void addRemoveMemberValuePairProposal(IInvocationContext context, IProblemLocation problemLocation,
- List<IJavaCompletionProposal> proposals, boolean removeAllOtherMVPs) {
-
- ASTNode coveringNode = problemLocation.getCoveringNode(context.getASTRoot());
-
- if (coveringNode.getParent() instanceof MemberValuePair) {
+ private void addRemoveMemberValuePairProposal(IInvocationContext context, IProblemLocation problemLocation,
+ List<IJavaCompletionProposal> proposals, boolean removeAllOtherMVPs) {
+
+ ASTNode coveringNode = problemLocation.getCoveringNode(context.getASTRoot());
+
+ if (coveringNode.getParent() instanceof MemberValuePair) {
MemberValuePair memberValuePair = (MemberValuePair) coveringNode.getParent();
String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_MEMBERVALUEPAIR, memberValuePair
.toString());
@@ -231,8 +231,8 @@
Image image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE);
proposals.add(new RemoveMemberValuePairCorrectionProposal(context, memberValuePair,
removeAllOtherMVPs, displayString, 5, image));
- }
- }
+ }
+ }
private void addUnimplementedMethodsProposal(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals) {
@@ -244,61 +244,61 @@
ASTNode typeDeclaration = webServiceAnnotation.getParent();
String endpointInterface = ((StringLiteral) endpointInterfaceValue).getLiteralValue();
-
+
Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
proposals.add(new AddUnimplementedMethodCorrectionProposal(context, typeDeclaration, endpointInterface,
JAXWSUIMessages.ADD_UNIMPLEMENTED_METHODS, 5, image));
}
}
-
- private void addChangeModifierProposal(IInvocationContext context, IProblemLocation problemLocation,
- List<IJavaCompletionProposal> proposals, int relevance) {
-
+
+ private void addChangeModifierProposal(IInvocationContext context, IProblemLocation problemLocation,
+ List<IJavaCompletionProposal> proposals, int relevance) {
+
CompilationUnit astRoot = context.getASTRoot();
ASTNode selectedNode = problemLocation.getCoveringNode(astRoot);
- if (!(selectedNode instanceof SimpleName)) {
- return;
- }
+ if (!(selectedNode instanceof SimpleName)) {
+ return;
+ }
- IBinding binding = ((SimpleName) selectedNode).resolveBinding();
- if (binding != null) {
- String bindingName = binding.getName();
- String displayString = "";
-
- int excludedModifiers = 0;
- int includedModifiers = 0;
-
- String problem = problemLocation.getProblemArguments()[1];
+ IBinding binding = ((SimpleName) selectedNode).resolveBinding();
+ if (binding != null) {
+ String bindingName = binding.getName();
+ String displayString = "";
+
+ int excludedModifiers = 0;
+ int includedModifiers = 0;
+
+ String problem = problemLocation.getProblemArguments()[1];
if(problem.equals(JAXWSCoreMessages.WEBMETHOD_ONLY_ON_PUBLIC_METHODS)
- || problem.equals(JAXWSCoreMessages.WEBSERVICE_ENPOINTINTERFACE_REDUCED_VISIBILITY)) {
- excludedModifiers = ~(Modifier.PUBLIC);
- includedModifiers = Modifier.PUBLIC ;
- displayString = JAXWSUIMessages.bind(JAXWSUIMessages.CHANGE_METHOD_VISIBILITY, "public"); //$NON-NLS-1$
+ || problem.equals(JAXWSCoreMessages.WEBSERVICE_ENPOINTINTERFACE_REDUCED_VISIBILITY)) {
+ excludedModifiers = ~(Modifier.PUBLIC);
+ includedModifiers = Modifier.PUBLIC ;
+ displayString = JAXWSUIMessages.bind(JAXWSUIMessages.CHANGE_METHOD_VISIBILITY, "public"); //$NON-NLS-1$
}
if(problem.equals(JAXWSCoreMessages.WEBMETHOD_NO_FINAL_MODIFIER_ALLOWED)) {
- excludedModifiers = Modifier.FINAL;
- displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_FINAL_MODIFIER, bindingName);
+ excludedModifiers = Modifier.FINAL;
+ displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_FINAL_MODIFIER, bindingName);
}
if(problem.equals(JAXWSCoreMessages.WEBMETHOD_NO_STATIC_MODIFIER_ALLOWED)) {
- excludedModifiers = Modifier.STATIC;
- displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_STATIC_MODIFIER, bindingName);
- }
-
- if (problem.equals(JAXWSCoreMessages.WEBSERVICE_PUBLIC_ABSTRACT_FINAL)) {
- excludedModifiers = Modifier.ABSTRACT | Modifier.FINAL;
- displayString = JAXWSUIMessages.REMOVE_ILLEGAL_MODIFIER;
+ excludedModifiers = Modifier.STATIC;
+ displayString = JAXWSUIMessages.bind(JAXWSUIMessages.REMOVE_STATIC_MODIFIER, bindingName);
}
- Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
- proposals.add(new ChangeModifierCorrectionProposal(context, binding, includedModifiers,
- excludedModifiers, displayString, 5, image));
- }
- }
-
+ if (problem.equals(JAXWSCoreMessages.WEBSERVICE_PUBLIC_ABSTRACT_FINAL)) {
+ excludedModifiers = Modifier.ABSTRACT | Modifier.FINAL;
+ displayString = JAXWSUIMessages.REMOVE_ILLEGAL_MODIFIER;
+ }
+
+ Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ proposals.add(new ChangeModifierCorrectionProposal(context, binding, includedModifiers,
+ excludedModifiers, displayString, 5, image));
+ }
+ }
+
private void addConstructorProposal(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals, int relevance) {
@@ -309,7 +309,7 @@
if (typeBinding != null && typeBinding.isFromSource()) {
String displayString = JAXWSUIMessages.bind(JAXWSUIMessages.CREATE_CONSTRUCTOR,
typeBinding.getTypeDeclaration().getName());
-
+
Image image = JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC,
JavaElementImageDescriptor.CONSTRUCTOR, JavaElementImageProvider.SMALL_SIZE);
@@ -317,24 +317,26 @@
image));
}
}
-
+
private void addChangeReturnTypeProposal(IInvocationContext context, IProblemLocation problemLocation,
List<IJavaCompletionProposal> proposals) {
- CompilationUnit astRoot = context.getASTRoot();
+ CompilationUnit astRoot = context.getASTRoot();
ASTNode selectedNode = problemLocation.getCoveringNode(astRoot);
- if (!(selectedNode instanceof SimpleName)) {
- return;
- }
-
- MethodDeclaration implMethodDeclaration = (MethodDeclaration)((SimpleName) selectedNode).getParent();
- TypeDeclaration implTypeDeclaration = (TypeDeclaration)implMethodDeclaration.getParent();
- Annotation annotation = AnnotationUtils.getAnnotation(implTypeDeclaration, WebService.class);
- String endpointInterface = AnnotationUtils.getStringValue(annotation, "endpointInterface"); //$NON-NLS-1$
- String displayString = JAXWSUIMessages.CHANGE_METHOD_RETURN_TYPE;
- Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
- proposals.add(new ChangeReturnTypeCorrectionProposal(context, implTypeDeclaration,
- implMethodDeclaration, endpointInterface, displayString, 5, image));
+ if (!(selectedNode instanceof SimpleName)) {
+ return;
+ }
+
+ MethodDeclaration implMethodDeclaration = (MethodDeclaration)((SimpleName) selectedNode).getParent();
+ TypeDeclaration implTypeDeclaration = (TypeDeclaration)implMethodDeclaration.getParent();
+
+ Annotation annotation = AnnotationUtils.getAnnotation(implTypeDeclaration.resolveBinding().getJavaElement(), WebService.class);
+
+ String endpointInterface = AnnotationUtils.getStringValue(annotation, "endpointInterface"); //$NON-NLS-1$
+ String displayString = JAXWSUIMessages.CHANGE_METHOD_RETURN_TYPE;
+ Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
+ proposals.add(new ChangeReturnTypeCorrectionProposal(context, implTypeDeclaration,
+ implMethodDeclaration, endpointInterface, displayString, 5, image));
}
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/RemoveAnnotationCorrectionProposal.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/RemoveAnnotationCorrectionProposal.java
index 3c0a09a..97162e8 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/RemoveAnnotationCorrectionProposal.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/RemoveAnnotationCorrectionProposal.java
@@ -22,11 +22,11 @@
import org.eclipse.swt.graphics.Image;
public class RemoveAnnotationCorrectionProposal extends AbstractJavaCorrectionPropsoal {
-
+
private Class<? extends java.lang.annotation.Annotation> annotation;
private ASTNode parentNode;
-
- public RemoveAnnotationCorrectionProposal(IInvocationContext invocationContext,
+
+ public RemoveAnnotationCorrectionProposal(IInvocationContext invocationContext,
Class<? extends java.lang.annotation.Annotation> annotation, ASTNode parentNode, String displayString,
int relevance, Image image) {
super(invocationContext, displayString, relevance, image);
@@ -42,23 +42,23 @@
Annotation jdtDomAnnotation = (Annotation) parentNode;
rewriter.remove(jdtDomAnnotation, null);
}
-
+
if (parentNode instanceof MethodDeclaration) {
MethodDeclaration methodDeclaration = (MethodDeclaration) parentNode;
- Annotation jdtDomAnnotation = AnnotationUtils.getAnnotation(methodDeclaration, annotation);
+ Annotation jdtDomAnnotation = AnnotationUtils.getAnnotation(methodDeclaration.resolveBinding().getJavaElement(), annotation);
if (jdtDomAnnotation != null) {
rewriter.remove(jdtDomAnnotation, null);
}
}
-
+
if (parentNode.getParent() instanceof TypeDeclaration) {
TypeDeclaration typeDeclaration = (TypeDeclaration) parentNode.getParent();
- Annotation jdtDomAnnotation = AnnotationUtils.getAnnotation(typeDeclaration, annotation);
+ Annotation jdtDomAnnotation = AnnotationUtils.getAnnotation(typeDeclaration.resolveBinding().getJavaElement(), annotation);
if (jdtDomAnnotation != null) {
rewriter.remove(jdtDomAnnotation, null);
}
}
-
+
textChange.addEdit(rewriter.rewriteAST());
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java
index ec079dd..cc5a1f2 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/BindingTypeAttributeInitializer.java
@@ -22,7 +22,9 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
@@ -42,10 +44,10 @@
private static final String HTTP_BINDING = "javax.xml.ws.http.HTTPBinding"; //$NON-NLS-1$
public BindingTypeAttributeInitializer() {
- JAXWSUIPlugin.getDefault().getImageRegistry().put(SOAP_BINDING,
- JAXWSUIPlugin.getImageDescriptor("icons/obj16/soapbinding_obj.gif").createImage()); //$NON-NLS-1$
- JAXWSUIPlugin.getDefault().getImageRegistry().put(HTTP_BINDING,
- JAXWSUIPlugin.getImageDescriptor("icons/obj16/httpbinding_obj.gif").createImage()); //$NON-NLS-1$
+ JAXWSUIPlugin.getDefault().getImageRegistry().put(SOAP_BINDING,
+ JAXWSUIPlugin.getImageDescriptor("icons/obj16/soapbinding_obj.gif").createImage()); //$NON-NLS-1$
+ JAXWSUIPlugin.getDefault().getImageRegistry().put(HTTP_BINDING,
+ JAXWSUIPlugin.getImageDescriptor("icons/obj16/httpbinding_obj.gif").createImage()); //$NON-NLS-1$
}
@Override
@@ -59,11 +61,25 @@
return memberValuePairs;
}
+ @Override
+ public List<ICompletionProposal> getCompletionProposalsForSingleMemberAnnotation(IJavaElement javaElement,
+ SingleMemberAnnotation singleMemberAnnotation) {
+ List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
+ if (javaElement.getElementType() == IJavaElement.TYPE) {
+ Expression expression = singleMemberAnnotation.getValue();
+ if (expression != null) {
+ addQualifiedNameBindingsCompletionProposals(completionProposals, expression);
+ }
+ }
+ return completionProposals;
+ }
+
+ @Override
public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement,
MemberValuePair memberValuePair) {
List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
if (javaElement.getElementType() == IJavaElement.TYPE) {
- IType type = (IType) javaElement;
+ IType type = (IType) javaElement;
String memberValuePairName = memberValuePair.getName().getIdentifier();
if (memberValuePairName.equals(VALUE)) { //$NON-NLS-1$
String value = memberValuePair.getValue().toString();
@@ -82,21 +98,24 @@
fullyQualifiedTypeName));
}
} else {
- Map<String, String> bindings = getQualifiedNameBindingsMap();
- Iterator<Map.Entry<String, String>> bindingsIter = bindings.entrySet().iterator();
- while (bindingsIter.hasNext()) {
- Map.Entry<String, String> bindingEntry = bindingsIter.next();
- String proposal = bindingEntry.getKey();
- Image image = JAXWSUIPlugin.getDefault().getImageRegistry().get(bindingEntry.getValue());
- completionProposals.add(createCompletionProposal(proposal, memberValuePair.getValue(),
- image, getDisplayString(proposal)));
- }
+ addQualifiedNameBindingsCompletionProposals(completionProposals, memberValuePair.getValue());
}
}
}
return completionProposals;
}
+ private void addQualifiedNameBindingsCompletionProposals(List<ICompletionProposal> completionProposals, Expression value) {
+ Map<String, String> bindings = getQualifiedNameBindingsMap();
+ Iterator<Map.Entry<String, String>> bindingsIter = bindings.entrySet().iterator();
+ while (bindingsIter.hasNext()) {
+ Map.Entry<String, String> bindingEntry = bindingsIter.next();
+ String proposal = bindingEntry.getKey();
+ Image image = JAXWSUIPlugin.getDefault().getImageRegistry().get(bindingEntry.getValue());
+ completionProposals.add(createCompletionProposal(proposal, value, image, getDisplayString(proposal)));
+ }
+ }
+
public String getDefault() {
return SOAPBinding.SOAP11HTTP_BINDING;
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java
index 0d1b808..6506b06 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/RequestWrapperAttributeInitializer.java
@@ -113,7 +113,7 @@
protected String getLocalName(IType type, IMethod method) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(method, WebMethod.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebMethod.class, method);
if (annotation != null) {
String operationName = AnnotationUtils.getStringValue(annotation, OPERATION_NAME);
if (operationName != null) {
@@ -122,14 +122,14 @@
}
return method.getElementName() + AnnotationUtils.accountForOverloadedMethods(type, method);
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return ""; //$NON-NLS-1$
}
protected String getTargetNamespace(IType type) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(type, WebService.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebService.class, type);
if (annotation != null) {
String targetNamespace = AnnotationUtils.getStringValue(annotation, TARGET_NAMESPACE);
if (targetNamespace != null && targetNamespace.length() > 0) {
@@ -138,7 +138,7 @@
}
return JDTUtils.getTargetNamespaceFromPackageName(type.getPackageFragment().getElementName());
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return ""; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/ResponseWrapperAttributeInitializer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/ResponseWrapperAttributeInitializer.java
index f651516..8eeac21 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/ResponseWrapperAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/ResponseWrapperAttributeInitializer.java
@@ -31,7 +31,7 @@
return getPackageName(type) + methodName.substring(0, 1).toUpperCase()
+ methodName.substring(1) + AnnotationUtils.accountForOverloadedMethods(type, method);
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return ""; //$NON-NLS-1$
}
@@ -39,7 +39,7 @@
@Override
protected String getLocalName(IType type, IMethod method) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(method, WebMethod.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebMethod.class, method);
if (annotation != null) {
String operationName = AnnotationUtils.getStringValue(annotation, OPERATION_NAME);
if (operationName != null) {
@@ -49,7 +49,7 @@
return method.getElementName() + RESPONSE_SUFFIX
+ AnnotationUtils.accountForOverloadedMethods(type, method);
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return ""; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java
index 2fa1a09..c6916bc 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebParamAttributeInitializer.java
@@ -19,6 +19,7 @@
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import javax.jws.WebMethod;
@@ -28,76 +29,79 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
import org.eclipse.jst.ws.annotations.core.initialization.AnnotationAttributeInitializer;
import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.jst.ws.internal.jaxws.core.utils.JAXWSUtils;
+import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin;
import org.eclipse.jst.ws.jaxws.core.utils.JDTUtils;
public class WebParamAttributeInitializer extends AnnotationAttributeInitializer {
@Override
- public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement,
- AST ast, Class<? extends Annotation> annotationClass) {
+ public List<MemberValuePair> getMemberValuePairs(IJavaElement javaElement,
+ AST ast, Class<? extends Annotation> annotationClass) {
- List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
-
+ List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
+
if (javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
- SingleVariableDeclaration parameter = AnnotationUtils.getSingleVariableDeclaration((ILocalVariable) javaElement);
- MemberValuePair nameValuePair = AnnotationsCore.createStringMemberValuePair(ast, NAME, getName(parameter));
+ ILocalVariable parameter = (ILocalVariable) javaElement;
+ MemberValuePair nameValuePair = AnnotationsCore.createStringMemberValuePair(ast, NAME, getName(parameter));
memberValuePairs.add(nameValuePair);
}
return memberValuePairs;
- }
+ }
- public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement,
+ @Override
+ public List<ICompletionProposal> getCompletionProposalsForMemberValuePair(IJavaElement javaElement,
MemberValuePair memberValuePair) {
-
+
List<ICompletionProposal> completionProposals = new ArrayList<ICompletionProposal>();
if (javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
- SingleVariableDeclaration parameter = AnnotationUtils.getSingleVariableDeclaration((ILocalVariable) javaElement);
-
+ ILocalVariable parameter = (ILocalVariable) javaElement;
+
String memberValuePairName = memberValuePair.getName().getIdentifier();
-
+
if (memberValuePairName.equals(NAME)) {
completionProposals.add(createCompletionProposal(getName(parameter),
- memberValuePair.getValue()));
+ memberValuePair.getValue()));
}
-
+
if (memberValuePairName.equals(PART_NAME)) {
completionProposals.add(createCompletionProposal(getPartName(parameter),
memberValuePair.getValue()));
}
-
+
if (memberValuePairName.equals(TARGET_NAMESPACE)) {
completionProposals.add(createCompletionProposal(getTargetNamespace(parameter),
memberValuePair.getValue()));
}
-
+
}
return completionProposals;
}
- private String getName(SingleVariableDeclaration parameter) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) parameter.getParent();
- if (hasDocumentBareSOAPBinding(methodDeclaration)) {
- return getWebMethodOperationName(methodDeclaration);
+ private String getName(ILocalVariable parameter) {
+ IMethod method = (IMethod) parameter.getParent();
+ if (hasDocumentBareSOAPBinding(method)) {
+ return getWebMethodOperationName(method);
}
-
- List<?> siblings = (List<?>) methodDeclaration.getStructuralProperty(parameter.getLocationInParent());
- return ARG + siblings.indexOf(parameter);
+ try {
+ List<String> methodNames = Arrays.asList(method.getParameterNames());
+ return ARG + methodNames.indexOf(parameter.getElementName());
+ } catch (JavaModelException jme) {
+ JAXWSUIPlugin.log(jme.getStatus());
+ }
+ return parameter.getElementName();
}
-
- private String getPartName(SingleVariableDeclaration parameter) {
+
+ private String getPartName(ILocalVariable parameter) {
org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(parameter,
WebParam.class);
if (annotation != null) {
@@ -108,19 +112,18 @@
}
return getName(parameter);
}
-
- private String getTargetNamespace(SingleVariableDeclaration parameter) {
+
+ private String getTargetNamespace(ILocalVariable parameter) {
if (hasDocumentWrappedSOAPBinding(parameter) && !isHeader(parameter)) {
return ""; //$NON-NLS-1$
}
return getDefaultTargetNamespace(parameter);
}
- private String getDefaultTargetNamespace(SingleVariableDeclaration parameter) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) parameter.getParent();
- TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent();
-
- org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(typeDeclaration,
+ private String getDefaultTargetNamespace(ILocalVariable parameter) {
+ IMethod method = (IMethod) parameter.getParent();
+ IType type = method.getDeclaringType();
+ org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(type,
WebService.class);
if (annotation != null) {
String targetNamespace = AnnotationUtils.getStringValue(annotation, TARGET_NAMESPACE);
@@ -128,20 +131,10 @@
return targetNamespace;
}
}
- return JDTUtils.getTargetNamespaceFromPackageName(getPackageName(typeDeclaration));
+ return JDTUtils.getTargetNamespaceFromPackageName(type.getPackageFragment().getElementName());
}
- private String getPackageName(TypeDeclaration typeDeclaration) {
- if (typeDeclaration.isPackageMemberTypeDeclaration()) {
- PackageDeclaration packageDeclaration = ((CompilationUnit) typeDeclaration.getParent()).getPackage();
- if (packageDeclaration != null) {
- return packageDeclaration.getName().getFullyQualifiedName();
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- private boolean isHeader(SingleVariableDeclaration parameter) {
+ private boolean isHeader(ILocalVariable parameter) {
org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(parameter, WebParam.class);
if (annotation != null) {
Boolean header = AnnotationUtils.getBooleanValue(annotation, HEADER);
@@ -152,18 +145,16 @@
return false;
}
- private boolean hasDocumentWrappedSOAPBinding(SingleVariableDeclaration parameter) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) parameter.getParent();
+ private boolean hasDocumentWrappedSOAPBinding(ILocalVariable parameter) {
+ IMethod method = (IMethod) parameter.getParent();
- org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(methodDeclaration,
+ org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(method,
SOAPBinding.class);
if (annotation != null) {
return JAXWSUtils.isDocumentWrapped(annotation);
}
-
- TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent();
-
- org.eclipse.jdt.core.dom.Annotation typeAnnotation = AnnotationUtils.getAnnotation(typeDeclaration,
+
+ org.eclipse.jdt.core.dom.Annotation typeAnnotation = AnnotationUtils.getAnnotation(method.getDeclaringType(),
SOAPBinding.class);
if (typeAnnotation != null) {
return JAXWSUtils.isDocumentWrapped(typeAnnotation);
@@ -171,22 +162,22 @@
return true;
}
- private boolean hasDocumentBareSOAPBinding(BodyDeclaration bodyDeclaration) {
- org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(bodyDeclaration,
+ private boolean hasDocumentBareSOAPBinding(IJavaElement javaElement) {
+ org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(javaElement,
SOAPBinding.class);
if (annotation != null) {
return JAXWSUtils.isDocumentBare(annotation);
}
- if (bodyDeclaration instanceof MethodDeclaration) {
- MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
- return hasDocumentBareSOAPBinding((TypeDeclaration) methodDeclaration.getParent());
+ if (javaElement.getElementType() == IJavaElement.METHOD) {
+ IMethod method = (IMethod) javaElement;
+ return hasDocumentBareSOAPBinding(method.getDeclaringType());
}
return false;
}
- private String getWebMethodOperationName(MethodDeclaration methodDeclaration) {
- org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(methodDeclaration,
+ private String getWebMethodOperationName(IMethod method) {
+ org.eclipse.jdt.core.dom.Annotation annotation = AnnotationUtils.getAnnotation(method,
WebMethod.class);
if (annotation != null) {
String operationName = AnnotationUtils.getStringValue(annotation, OPERATION_NAME);
@@ -194,7 +185,7 @@
return operationName;
}
}
- return methodDeclaration.getName().getIdentifier();
+ return method.getElementName();
}
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java
index 54dd7fa..bdf5964 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/initialization/WebResultAttributeInitializer.java
@@ -99,7 +99,7 @@
private String getOperationName(IMethod method) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(method, WebMethod.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebMethod.class, method);
if (annotation != null) {
String operationName = AnnotationUtils.getStringValue(annotation, OPERATION_NAME);
if (operationName != null) {
@@ -107,14 +107,14 @@
}
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return method.getElementName();
}
private boolean hasDocumentBareSOAPBinding(IAnnotatable annotatable) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(annotatable, SOAPBinding.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(SOAPBinding.class, annotatable);
if (annotation != null) {
return JAXWSUtils.isDocumentBare(annotation);
}
@@ -123,14 +123,14 @@
return hasDocumentBareSOAPBinding((IType) method.getParent());
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return false;
}
private String getPartName(IMethod method) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(method, WebResult.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebResult.class, method);
if (annotation != null) {
String name = AnnotationUtils.getStringValue(annotation, NAME);
if (name != null) {
@@ -138,7 +138,7 @@
}
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return getName(method);
}
@@ -152,7 +152,7 @@
private boolean hasDocumentWrappedSOAPBinding(IAnnotatable annotatable) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(annotatable, SOAPBinding.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(SOAPBinding.class, annotatable);
if (annotation != null) {
return JAXWSUtils.isDocumentWrapped(annotation);
}
@@ -161,14 +161,14 @@
return hasDocumentWrappedSOAPBinding((IType) method.getParent());
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return true;
}
private boolean isHeader(IMethod method) {
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(method, WebResult.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebResult.class, method);
if (annotation != null) {
Boolean header = AnnotationUtils.getBooleanValue(annotation, HEADER);
if (header != null) {
@@ -176,7 +176,7 @@
}
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return false;
}
@@ -184,7 +184,7 @@
private String getDefaultTargetNamespace(IMethod method) {
IType type = method.getDeclaringType();
try {
- IAnnotation annotation = AnnotationUtils.getAnnotation(type, WebService.class);
+ IAnnotation annotation = AnnotationUtils.getAnnotation(WebService.class, type);
if (annotation != null) {
String targetNamespace = AnnotationUtils.getStringValue(annotation, TARGET_NAMESPACE);
if (targetNamespace != null) {
@@ -192,7 +192,7 @@
}
}
} catch (JavaModelException jme) {
- JAXWSUIPlugin.log(jme.getStatus());
+ JAXWSUIPlugin.log(jme.getStatus());
}
return JDTUtils.getTargetNamespaceFromPackageName(getPackageName(type));
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java
index 4711a52..15027d3 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsValuesEditingSupport.java
@@ -29,7 +29,6 @@
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
@@ -52,11 +51,12 @@
import org.eclipse.ltk.core.refactoring.RefactoringCore;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.MultiTextEdit;
public class AnnotationsValuesEditingSupport extends EditingSupport {
private AnnotationsView annotationsView;
private TreeViewer treeViewer;
-
+
private TextCellEditor textCellEditor;
private CheckboxCellEditor checkboxCellEditor;
private ComboBoxCellEditor comboBoxCellEditor;
@@ -103,11 +103,11 @@
if (returnType.equals(Boolean.TYPE)) {
return checkboxCellEditor;
}
-
+
if (returnType.equals(Class.class)) {
return classDialogCellEditor;
}
-
+
if (returnType.isArray()) {
annotationArrayCellEditor.setMethod(method);
return annotationArrayCellEditor;
@@ -135,7 +135,7 @@
Double.parseDouble((String) value);
}
} catch (NumberFormatException nfe) {
- return JAXWSUIMessages.ANNOTATION_EDITING_SUPPORT_NOT_VALID_MESSAGE_PREFIX
+ return JAXWSUIMessages.ANNOTATION_EDITING_SUPPORT_NOT_VALID_MESSAGE_PREFIX
+ returnType.getSimpleName();
}
return null;
@@ -147,7 +147,7 @@
}
return checkboxCellEditor;
}
-
+
@Override
protected Object getValue(Object element) {
if (element instanceof Class) {
@@ -158,14 +158,14 @@
}
return null;
}
-
+
private Object getValueForClass(Class<?> aClass) {
if (treeViewer.getInput() instanceof IAnnotatable) {
return getValueForClass(aClass, (IAnnotatable) treeViewer.getInput());
}
return Boolean.FALSE;
}
-
+
private Object getValueForClass(Class<?> aClass, IAnnotatable annotatedElement) {
try {
IAnnotation[] annotations = annotatedElement.getAnnotations();
@@ -179,10 +179,10 @@
}
} catch (JavaModelException jme) {
JAXWSUIPlugin.log(jme.getStatus());
- }
+ }
return Boolean.FALSE;
}
-
+
private Object getValueForMethod(Method method) {
Object value = null;
try {
@@ -194,7 +194,7 @@
}
return value;
}
-
+
private Object getValueForMethod(Method method, IAnnotatable annotatedElement) throws JavaModelException {
Class<?> returnType = method.getReturnType();
IAnnotation[] annotations = annotatedElement.getAnnotations();
@@ -224,7 +224,7 @@
if (returnType.equals(Class.class)) {
return memberValuePair.getValue();
}
-
+
if (returnType.equals(Boolean.TYPE)) {
return memberValuePair.getValue();
}
@@ -250,7 +250,7 @@
}
return null;
}
-
+
private Object getDefaultValueForMethod(Class<?> returnType) {
if (returnType.equals(String.class)) {
return ""; //$NON-NLS-1$
@@ -269,7 +269,7 @@
}
return null;
}
-
+
@Override
protected void setValue(Object element, Object value) {
if (value == null) {
@@ -278,9 +278,9 @@
try {
if (element instanceof Class) {
- Class<? extends java.lang.annotation.Annotation> annotationClass =
+ Class<? extends java.lang.annotation.Annotation> annotationClass =
AnnotationsManager.getAnnotationDefinitionForClass(element).getAnnotationClass();
-
+
if (annotationClass != null) {
setValueForClass(annotationClass, (Boolean) value);
}
@@ -290,50 +290,50 @@
}
} catch (CoreException ce) {
JAXWSUIPlugin.log(ce.getStatus());
- }
+ }
}
-
- private void setValueForClass(Class<? extends java.lang.annotation.Annotation> annotationClass,
+
+ private void setValueForClass(Class<? extends java.lang.annotation.Annotation> annotationClass,
Boolean annotate) throws CoreException {
Object viewerInput = treeViewer.getInput();
- IAnnotationAttributeInitializer annotationAttributeInitializer =
+ IAnnotationAttributeInitializer annotationAttributeInitializer =
AnnotationsManager.getAnnotationDefinitionForClass(annotationClass).getAnnotationAttributeInitializer();
if (viewerInput instanceof IJavaElement) {
setValueForClass(annotationClass, annotate, (IJavaElement) viewerInput, annotationAttributeInitializer);
}
}
-
+
private Annotation getAnnotation(AST ast, Class<? extends java.lang.annotation.Annotation> annotationClass,
- List<MemberValuePair> memberValuePairs) {
-
- Annotation annotation = null;
- int numberOfDeclaredMethods = annotationClass.getDeclaredMethods().length;
- if (numberOfDeclaredMethods == 0) {
- annotation = AnnotationsCore.createMarkerAnnotation(ast, annotationClass.getSimpleName());
- } else if (numberOfDeclaredMethods == 1) {
- Expression value = null;
- if (memberValuePairs != null && memberValuePairs.size() == 1) {
- MemberValuePair memberValuePair = memberValuePairs.get(0);
- if (memberValuePair != null) {
- value = memberValuePair.getValue();
- }
- }
- if (value != null) {
- annotation = AnnotationsCore.createSingleMemberAnnotation(ast, annotationClass.getSimpleName(), value);
- } else {
- annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs);
- }
- } else if (numberOfDeclaredMethods > 1) {
- annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs);
- }
-
- return annotation;
- }
+ List<MemberValuePair> memberValuePairs) {
+
+ Annotation annotation = null;
+ int numberOfDeclaredMethods = annotationClass.getDeclaredMethods().length;
+ if (numberOfDeclaredMethods == 0) {
+ annotation = AnnotationsCore.createMarkerAnnotation(ast, annotationClass.getSimpleName());
+ } else if (numberOfDeclaredMethods == 1) {
+ Expression value = null;
+ if (memberValuePairs != null && memberValuePairs.size() == 1) {
+ MemberValuePair memberValuePair = memberValuePairs.get(0);
+ if (memberValuePair != null) {
+ value = memberValuePair.getValue();
+ }
+ }
+ if (value != null) {
+ annotation = AnnotationsCore.createSingleMemberAnnotation(ast, annotationClass.getSimpleName(), value);
+ } else {
+ annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs);
+ }
+ } else if (numberOfDeclaredMethods > 1) {
+ annotation = AnnotationsCore.createNormalAnnotation(ast, annotationClass.getSimpleName(), memberValuePairs);
+ }
+
+ return annotation;
+ }
private void setValueForClass(Class<? extends java.lang.annotation.Annotation> annotationClass,
- Boolean annotate, IJavaElement javaElement, IAnnotationAttributeInitializer annotationAttributeInitializer)
+ Boolean annotate, IJavaElement javaElement, IAnnotationAttributeInitializer annotationAttributeInitializer)
throws CoreException {
ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
@@ -344,32 +344,34 @@
Annotation annotation = getAnnotation(ast, annotationClass, memberValuePairs);
- TextFileChange textFileChange = AnnotationUtils.createTextFileChange("AC", (IFile) source.getResource()); //$NON-NLS-1$
+ TextFileChange change = new TextFileChange("Add/Remove Annotation", (IFile) source.getResource()); //$NON-NLS-1$
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
if (annotate) {
- if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION
- || javaElement.getElementType() == IJavaElement.TYPE
- || javaElement.getElementType() == IJavaElement.FIELD
- || javaElement.getElementType() == IJavaElement.METHOD
- || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
- textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(javaElement, annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(javaElement, annotationClass));
- }
+ if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION
+ || javaElement.getElementType() == IJavaElement.TYPE
+ || javaElement.getElementType() == IJavaElement.FIELD
+ || javaElement.getElementType() == IJavaElement.METHOD
+ || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
+ change.addEdit(AnnotationUtils.createAddAnnotationTextEdit(javaElement, annotation));
+ change.addEdit(AnnotationUtils.createAddImportTextEdit(javaElement, annotationClass.getCanonicalName()));
+ }
} else {
- if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION
- || javaElement.getElementType() == IJavaElement.TYPE
- || javaElement.getElementType() == IJavaElement.FIELD
- || javaElement.getElementType() == IJavaElement.METHOD
- || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
- textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(javaElement, annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(javaElement, annotationClass));
- }
+ if (javaElement.getElementType() == IJavaElement.PACKAGE_DECLARATION
+ || javaElement.getElementType() == IJavaElement.TYPE
+ || javaElement.getElementType() == IJavaElement.FIELD
+ || javaElement.getElementType() == IJavaElement.METHOD
+ || javaElement.getElementType() == IJavaElement.LOCAL_VARIABLE) {
+ change.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(javaElement, annotation));
+ change.addEdit(AnnotationUtils.createRemoveImportTextEdit(javaElement, annotationClass.getCanonicalName()));
+ }
}
- executeChange(new NullProgressMonitor(), textFileChange);
+ executeChange(new NullProgressMonitor(), change);
}
-
+
private List<MemberValuePair> getMemberValuePairs(
- IAnnotationAttributeInitializer annotationAttributeInitializer, IJavaElement javaElement, AST ast,
+ IAnnotationAttributeInitializer annotationAttributeInitializer, IJavaElement javaElement, AST ast,
Class<?extends java.lang.annotation.Annotation> annotationClass) {
if (annotationAttributeInitializer != null) {
return annotationAttributeInitializer.getMemberValuePairs(javaElement, ast, annotationClass);
@@ -383,62 +385,65 @@
Object viewerInput = treeViewer.getInput();
if (viewerInput instanceof IAnnotatable) {
setValueForMethod(method, value, (IJavaElement) viewerInput);
- }
+ }
}
}
-
+
private void setValueForMethod(Method method, Object value, IJavaElement javaElement) throws CoreException {
- ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
+ ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
AST ast = compilationUnit.getAST();
- TextFileChange textFileChange = AnnotationUtils.createTextFileChange("AC", (IFile) source.getResource()); //$NON-NLS-1$
+ TextFileChange change = new TextFileChange("Add/Update Annotation Value", (IFile) source.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ change.setEdit(multiTextEdit);
- List<IExtendedModifier> extendedModifiers = AnnotationUtils.getExtendedModifiers(compilationUnit, javaElement);
- for (IExtendedModifier extendedModifier : extendedModifiers) {
- if (extendedModifier instanceof NormalAnnotation) {
- NormalAnnotation normalAnnotation = (NormalAnnotation) extendedModifier;
- Class<?> declaringClass = method.getDeclaringClass();
- String annotationName = normalAnnotation.getTypeName().getFullyQualifiedName();
- if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) {
- @SuppressWarnings("unchecked")
- List<MemberValuePair> memberValuePairs = normalAnnotation.values();
- boolean hasMemberValuePair = false;
- for (MemberValuePair memberValuePair : memberValuePairs) {
- if (memberValuePair.getName().getIdentifier().equals(method.getName())) {
- ASTNode memberValue = getMemberValuePairValue(ast, method, value);
- if (memberValue != null) {
- textFileChange.addEdit(AnnotationUtils.createUpdateMemberValuePairTextEdit(memberValuePair, memberValue));
- hasMemberValuePair = true;
- break;
- }
- }
- }
- if (!hasMemberValuePair) {
- MemberValuePair memberValuePair = getMemberValuePair(ast, method, value);
- if (memberValuePair != null) {
- textFileChange.addEdit(AnnotationUtils.createAddMemberValuePairTextEdit(normalAnnotation, memberValuePair));
- break;
- }
- }
- }
- } else if (extendedModifier instanceof SingleMemberAnnotation) {
- SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) extendedModifier;
- Class<?> declaringClass = method.getDeclaringClass();
- String annotationName = singleMemberAnnotation.getTypeName().getFullyQualifiedName();
- if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) {
- MemberValuePair memberValuePair = getMemberValuePair(ast, method, value);
- if (memberValuePair != null) {
- textFileChange.addEdit(AnnotationUtils.createUpdateSingleMemberAnnotationTextEdit(singleMemberAnnotation, memberValuePair.getValue()));
- break;
- }
- }
-
- }
- }
- executeChange(new NullProgressMonitor(), textFileChange);
+ List<Annotation> annotations = AnnotationUtils.getAnnotations(javaElement);
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof NormalAnnotation) {
+ NormalAnnotation normalAnnotation = (NormalAnnotation) annotation;
+ Class<?> declaringClass = method.getDeclaringClass();
+ String annotationName = normalAnnotation.getTypeName().getFullyQualifiedName();
+ if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) {
+ @SuppressWarnings("unchecked")
+ List<MemberValuePair> memberValuePairs = normalAnnotation.values();
+ boolean hasMemberValuePair = false;
+ for (MemberValuePair memberValuePair : memberValuePairs) {
+ if (memberValuePair.getName().getIdentifier().equals(method.getName())) {
+ ASTNode memberValue = getMemberValuePairValue(ast, method, value);
+ if (memberValue != null) {
+ change.addEdit(AnnotationUtils.createUpdateMemberValuePairTextEdit(memberValuePair, memberValue));
+ hasMemberValuePair = true;
+ break;
+ }
+ }
+ }
+ if (!hasMemberValuePair) {
+ MemberValuePair memberValuePair = getMemberValuePair(ast, method, value);
+ if (memberValuePair != null) {
+ change.addEdit(AnnotationUtils.createAddMemberValuePairTextEdit(normalAnnotation, memberValuePair));
+ break;
+ }
+ }
+ }
+ } else if (annotation instanceof SingleMemberAnnotation) {
+ SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation;
+ Class<?> declaringClass = method.getDeclaringClass();
+ String annotationName = singleMemberAnnotation.getTypeName().getFullyQualifiedName();
+ if (annotationName.equals(declaringClass.getSimpleName()) || annotationName.equals(declaringClass.getCanonicalName())) {
+ MemberValuePair memberValuePair = getMemberValuePair(ast, method, value);
+ if (memberValuePair != null) {
+ change.addEdit(AnnotationUtils.createUpdateSingleMemberAnnotationTextEdit(singleMemberAnnotation, memberValuePair.getValue()));
+ break;
+ }
+ }
+
+ }
+ }
+
+ executeChange(new NullProgressMonitor(), change);
}
-
+
private ASTNode getMemberValuePairValue(AST ast, Method method, Object value) {
Class<?> returnType = method.getReturnType();
if (returnType.equals(String.class)) {
@@ -456,11 +461,11 @@
if (returnType.isArray()) {
return AnnotationsCore.createArrayValueLiteral(ast, method, (Object[]) value);
}
-
+
if (returnType.equals(Class.class)) {
return AnnotationsCore.createTypeLiteral(ast, value.toString());
}
-
+
if (returnType.isEnum()) {
int selected = ((Integer) value).intValue();
if (selected != -1) {
@@ -474,10 +479,10 @@
private MemberValuePair getMemberValuePair(AST ast, Method method, Object value) {
Class<?> returnType = method.getReturnType();
if (returnType.equals(String.class)) {
- return AnnotationsCore.createStringMemberValuePair(ast, method.getName(), value);
+ return AnnotationsCore.createStringMemberValuePair(ast, method.getName(), (String) value);
}
if (returnType.equals(Boolean.TYPE)) {
- return AnnotationsCore.createBooleanMemberValuePair(ast, method.getName(), value);
+ return AnnotationsCore.createBooleanMemberValuePair(ast, method.getName(), (Boolean) value);
}
if (returnType.isPrimitive()
&& (returnType.equals(Byte.TYPE) || returnType.equals(Short.TYPE)
@@ -488,7 +493,7 @@
if (returnType.isArray()) {
return AnnotationsCore.createArrayMemberValuePair(ast, method, (Object[]) value);
}
-
+
if (returnType.equals(Class.class)) {
return AnnotationsCore.createTypeMemberValuePair(ast, method.getName(), value.toString());
}
@@ -496,7 +501,7 @@
if (returnType.isEnum()) {
int selected = ((Integer) value).intValue();
if (selected != -1) {
- return AnnotationsCore.createEnumMemberValuePair(ast,
+ return AnnotationsCore.createEnumMemberValuePair(ast,
method.getDeclaringClass().getCanonicalName(), method.getName(), method.getReturnType()
.getEnumConstants()[selected]);
}
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java
index 89e2f1f..4e23056 100755
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/views/AnnotationsViewContentProvider.java
@@ -36,11 +36,11 @@
public Object[] getElements(Object inputElement) {
if (inputElement != null) {
- return AnnotationsManager.getAnnotations(inputElement);
+ return AnnotationsManager.getAnnotations(inputElement).toArray();
}
return new Object[] {};
}
-
+
public void dispose() {
}
diff --git a/features/org.eclipse.jst.ws.cxf_tests.feature/feature.xml b/features/org.eclipse.jst.ws.cxf_tests.feature/feature.xml
index 27d446c..b774d61 100644
--- a/features/org.eclipse.jst.ws.cxf_tests.feature/feature.xml
+++ b/features/org.eclipse.jst.ws.cxf_tests.feature/feature.xml
@@ -28,17 +28,4 @@
install-size="0"
version="0.0.0"/>
- <plugin
- id="org.eclipse.jst.ws.jaxws.core.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jst.ws.jaxb.core.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
</feature>
diff --git a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AbstractAnnotationTest.java b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AbstractAnnotationTest.java
index f8fc9a9..a08e66f 100644
--- a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AbstractAnnotationTest.java
+++ b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AbstractAnnotationTest.java
@@ -19,10 +19,10 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.ui.SharedASTProvider;
-import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.MultiTextEdit;
public abstract class AbstractAnnotationTest extends TestCase {
protected TestJavaProject testJavaProject;
@@ -45,7 +45,9 @@
ast = compilationUnit.getAST();
rewriter = ASTRewrite.create(ast);
annotation = getAnnotation();
- textFileChange = AnnotationUtils.createTextFileChange("AC", (IFile) source.getResource());
+ textFileChange = new TextFileChange("Add annotation", (IFile) source.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ textFileChange.setEdit(multiTextEdit);
}
protected boolean isAutoBuildingEnabled() {
diff --git a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AddAnnotationToPackageTest.java b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AddAnnotationToPackageTest.java
index 6805f5e..016d91d 100644
--- a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AddAnnotationToPackageTest.java
+++ b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/AddAnnotationToPackageTest.java
@@ -49,10 +49,10 @@
MemberValuePair namespaceVP = AnnotationsCore.createStringMemberValuePair(ast,
"namespace", "uri:testNS");
-
+
memberValuePairs.add(locationVP);
memberValuePairs.add(namespaceVP);
-
+
return AnnotationsCore.createNormalAnnotation(ast, XmlSchema.class.getSimpleName(), memberValuePairs);
}
@@ -62,10 +62,10 @@
assertEquals(XmlSchema.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
IPackageDeclaration myPackage = source.getPackageDeclaration(getPackageName());
assertNotNull(myPackage);
-
+
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(myPackage, annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(myPackage, XmlSchema.class));
-
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(myPackage, XmlSchema.class.getCanonicalName()));
+
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
assertTrue(AnnotationUtils.isAnnotationPresent(myPackage, AnnotationUtils.getAnnotationName(annotation)));
@@ -74,5 +74,5 @@
fail(ce.getLocalizedMessage());
}
}
-
+
}
diff --git a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/RemoveAnnotationFromPackageTest.java b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/RemoveAnnotationFromPackageTest.java
index 8d9b9c6..fdaad71 100644
--- a/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/RemoveAnnotationFromPackageTest.java
+++ b/tests/org.eclipse.jst.ws.jaxb.core.tests/src/org/eclipse/jst/ws/jaxb/core/tests/RemoveAnnotationFromPackageTest.java
@@ -52,10 +52,10 @@
.getAnnotationName(annotation)));
textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(myPackage, annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(myPackage, XmlSchema.class));
+ textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(myPackage, XmlSchema.class.getCanonicalName()));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
-
+
assertFalse(AnnotationUtils.isAnnotationPresent(myPackage, AnnotationUtils.getAnnotationName(annotation)));
assertFalse(source.getImport(XmlSchema.class.getCanonicalName()).exists());
} catch (CoreException ce) {
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java
index 5f2a169..19de308 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractOnewayValidationTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.Oneway;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -40,11 +39,11 @@
public String getPackageName() {
return "com.example";
}
-
+
public abstract String getErrorMessage();
-
+
public abstract IMethod getMethodToTest();
-
+
public void testOnewayRule() {
try {
assertNotNull(annotation);
@@ -53,7 +52,7 @@
IMethod method = getMethodToTest();
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, Oneway.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, Oneway.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -61,7 +60,8 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
-
+ assertTrue(source.getImport(Oneway.class.getCanonicalName()).exists());
+
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebMethodPublicStaticFinalRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebMethodPublicStaticFinalRuleTest.java
index 82063d2..51ae8c1 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebMethodPublicStaticFinalRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebMethodPublicStaticFinalRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.WebMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -55,7 +54,7 @@
protected String getPackageName() {
return "com.example";
}
-
+
public abstract IMethod getMethodToTeset();
public abstract String getErrorMessage();
@@ -67,7 +66,7 @@
IMethod method = getMethodToTeset();
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -75,6 +74,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebServicePublicAbstractFinalRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebServicePublicAbstractFinalRuleTest.java
index ee05646..85b6197 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebServicePublicAbstractFinalRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/AbstractWebServicePublicAbstractFinalRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -68,7 +67,7 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -76,6 +75,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java
index bf92f98..5bf6422 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareNonVoidNoOutParametersRuleTest.java
@@ -42,23 +42,24 @@
IMethod method = source.findPrimaryType().getMethod("noOut", new String[] { "QString;",
"QString; "});
-
+
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
-
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
+
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java
index 5e1890a..05b8458 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareOneNonHeaderINParameterRuleTest.java
@@ -62,7 +62,7 @@
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
@@ -84,12 +84,12 @@
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- IMethod method = source.findPrimaryType().getMethod("onlyOneIN", new String[] { "QString;",
+ IMethod method = source.findPrimaryType().getMethod("onlyOneIN", new String[] { "QString;",
"QString;" });
-
+
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -102,7 +102,7 @@
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
@@ -118,18 +118,18 @@
fail(ie.getLocalizedMessage());
}
}
-
+
public void testOnlyOneNonHeaderINParameterWithWebParamsRule() {
try {
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- IMethod method = source.findPrimaryType().getMethod("oneMore", new String[] { "QString;",
+ IMethod method = source.findPrimaryType().getMethod("oneMore", new String[] { "QString;",
"QString;" });
-
+
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -137,12 +137,13 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java
index ff16112..b565123 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/DocBareVoidOneINOneOutParameterRuleTest.java
@@ -46,10 +46,10 @@
IMethod method = source.findPrimaryType().getMethod("oneIn", new String[] { "QHolder<QString;>;",
"QString;"});
-
+
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -62,7 +62,7 @@
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
@@ -86,10 +86,10 @@
IMethod method = source.findPrimaryType().getMethod("oneOut", new String[] { "QHolder<QString;>;",
"QHolder<QString;>;"});
-
+
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -97,12 +97,13 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/HolderTypeParameterRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/HolderTypeParameterRuleTest.java
index 927287d..1f7d515 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/HolderTypeParameterRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/HolderTypeParameterRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -55,8 +54,8 @@
try {
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -64,6 +63,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingDocumentEncodedRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingDocumentEncodedRuleTest.java
index ae2e64c..def8420 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingDocumentEncodedRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingDocumentEncodedRuleTest.java
@@ -58,11 +58,11 @@
try {
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
+
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -70,6 +70,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMixedBindingsRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMixedBindingsRuleTest.java
index fac618a..58900ce 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMixedBindingsRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingMixedBindingsRuleTest.java
@@ -53,7 +53,7 @@
return AnnotationsCore.createNormalAnnotation(ast, SOAPBinding.class.getSimpleName(), memberValuePairs);
}
-
+
@Override
protected String getClassContents() {
StringBuilder classContents = new StringBuilder("package com.example;\n\n");
@@ -64,16 +64,16 @@
classContents.append("\n\t\treturn \"txt\";\n\t}\n\n}");
return classContents.toString();
}
-
+
public void testSOAPBindingMixedBindingsRule() {
try {
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
+
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -81,6 +81,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRCPBareRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRCPBareRuleTest.java
index dd74a51..9862694 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRCPBareRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRCPBareRuleTest.java
@@ -52,13 +52,13 @@
return AnnotationsCore.createNormalAnnotation(ast, SOAPBinding.class.getSimpleName(), memberValuePairs);
}
-
+
public void testSOAPBindingRPCBareRule() {
try {
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class));
+
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -66,6 +66,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCEncodedRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCEncodedRuleTest.java
index fbb4f6e..01b0a27 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCEncodedRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCEncodedRuleTest.java
@@ -57,8 +57,8 @@
try {
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class));
+
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -66,6 +66,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCStyleOnMethodRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCStyleOnMethodRuleTest.java
index d54c3e5..49424a0 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCStyleOnMethodRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/SOAPBindingRPCStyleOnMethodRuleTest.java
@@ -62,7 +62,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -70,6 +70,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodCheckForWebServiceRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodCheckForWebServiceRuleTest.java
index 8105086..0440c4d 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodCheckForWebServiceRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodCheckForWebServiceRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -73,7 +72,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[0]);
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -81,6 +80,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnImplTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnImplTest.java
index 508c36e..70e88ba 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnImplTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnImplTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -79,7 +78,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[0]);
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -87,6 +86,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnSEITest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnSEITest.java
index d79bf21..1b80249 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnSEITest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebMethodExcludeRuleOnSEITest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -70,7 +69,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[0]);
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -78,6 +77,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java
index 64ff571..a423f02 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebParamModeHolderTypeRuleTest.java
@@ -15,7 +15,6 @@
import javax.jws.WebParam;
import javax.jws.WebParam.Mode;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -41,7 +40,7 @@
WebParam.class.getCanonicalName(), "mode", Mode.OUT);
memberValuePairs.add(modeValuePair);
-
+
return AnnotationsCore.createNormalAnnotation(ast, WebParam.class.getSimpleName(), memberValuePairs);
}
@@ -69,20 +68,21 @@
try {
assertNotNull(annotation);
assertEquals(WebParam.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
-
+
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
ILocalVariable localVariable = AnnotationUtils.getLocalVariable(method, "param");
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(localVariable, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
assertTrue(AnnotationUtils.isAnnotationPresent(localVariable, annotation));
-
+ assertTrue(source.getImport(WebParam.class.getCanonicalName()).exists());
+
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceDefaultPublicConstructorRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceDefaultPublicConstructorRuleTest.java
index 291b5ae..7fa8fdf 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceDefaultPublicConstructorRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceDefaultPublicConstructorRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -75,7 +74,7 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -84,6 +83,8 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
+
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceNoFinalizeMethodRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceNoFinalizeMethodRuleTest.java
index 9df5a96..d84c431 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceNoFinalizeMethodRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceNoFinalizeMethodRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -75,7 +74,7 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -83,6 +82,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoEndpointInterfaceRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoEndpointInterfaceRuleTest.java
index 41d5a7c..230de1e 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoEndpointInterfaceRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoEndpointInterfaceRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -39,7 +38,7 @@
MemberValuePair endpointInterfaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
"endpointInterface", "MyInterface");
- MemberValuePair targetNamespaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
+ MemberValuePair targetNamespaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
"targetNamespace", "http://example.com/");
memberValuePairs.add(nameValuePair);
@@ -65,13 +64,13 @@
protected String getPackageName() {
return "com.example";
}
-
+
public void testWebServiceSEINoEndpointInterfaceRule() {
try {
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -79,6 +78,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoOnewayRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoOnewayRuleTest.java
index 489a1fe..d0c7f37 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoOnewayRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoOnewayRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.Oneway;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -40,7 +39,7 @@
IMethod method = source.findPrimaryType().getMethod("methodOne", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, Oneway.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, Oneway.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -48,6 +47,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(Oneway.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoPortNameRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoPortNameRuleTest.java
index e58d689..4f9f045 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoPortNameRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoPortNameRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -36,10 +35,10 @@
MemberValuePair nameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "name", "MyClass");
- MemberValuePair targetNamespaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
+ MemberValuePair targetNamespaceValuePair = AnnotationsCore.createStringMemberValuePair(ast,
"targetNamespace", "http://example.com/");
- MemberValuePair portNameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "portName",
+ MemberValuePair portNameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "portName",
"MyClassPort");
memberValuePairs.add(nameValuePair);
@@ -65,13 +64,13 @@
protected String getPackageName() {
return "com.example";
}
-
+
public void testWebServiceSEINoPortNameRule() {
try {
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -79,6 +78,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoSOAPBindingRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoSOAPBindingRuleTest.java
index bc29682..cad1b99 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoSOAPBindingRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoSOAPBindingRuleTest.java
@@ -40,7 +40,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -48,6 +48,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(SOAPBinding.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
@@ -75,7 +76,7 @@
assertNotNull(annotation);
assertEquals(SOAPBinding.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), SOAPBinding.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -105,7 +106,7 @@
}
}
-
-
+
+
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoServiceNameRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoServiceNameRuleTest.java
index 5037aca..86335fb 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoServiceNameRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoServiceNameRuleTest.java
@@ -14,7 +14,6 @@
import java.util.List;
import javax.jws.WebService;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -71,7 +70,7 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
@@ -79,6 +78,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebMethodRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebMethodRuleTest.java
index fa4d25e..ae49209 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebMethodRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebMethodRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.WebMethod;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -40,7 +39,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -48,6 +47,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebParamRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebParamRuleTest.java
index 89b763b..58b94c9 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebParamRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebParamRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.WebParam;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -43,14 +42,15 @@
ILocalVariable localVariable = AnnotationUtils.getLocalVariable(method, "in");
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(localVariable, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
assertTrue(AnnotationUtils.isAnnotationPresent(localVariable, annotation));
-
+ assertTrue(source.getImport(WebParam.class.getCanonicalName()).exists());
+
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebResultRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebResultRuleTest.java
index 2af9c06..4b0f28b 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebResultRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceSEINoWebResultRuleTest.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.ws.jaxws.core.annotation.validation.tests;
import javax.jws.WebResult;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -40,7 +39,7 @@
IMethod method = source.findPrimaryType().getMethod("myMethod", new String[] { "QString;" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebResult.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebResult.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
@@ -48,6 +47,7 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebResult.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceWebServiceProviderCoExistRuleTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceWebServiceProviderCoExistRuleTest.java
index 03b5586..150d340 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceWebServiceProviderCoExistRuleTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/annotation/validation/tests/WebServiceWebServiceProviderCoExistRuleTest.java
@@ -58,20 +58,20 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
- assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils
- .getAnnotationName(annotation)));
+ assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils.getAnnotationName(annotation)));
+ assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
IMarker[] allmarkers = source.getResource().findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
-
+
assertEquals(1, allmarkers.length);
IMarker annotationProblemMarker = allmarkers[0];
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AbstractAnnotationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AbstractAnnotationTest.java
index e1ff225..bac3649 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AbstractAnnotationTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AbstractAnnotationTest.java
@@ -21,10 +21,10 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
import org.eclipse.jdt.ui.SharedASTProvider;
-import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.MultiTextEdit;
public abstract class AbstractAnnotationTest extends TestCase {
protected TestJavaProject testJavaProject;
@@ -47,7 +47,9 @@
ast = compilationUnit.getAST();
rewriter = ASTRewrite.create(ast);
annotation = getAnnotation();
- textFileChange = AnnotationUtils.createTextFileChange("AC", (IFile) source.getResource());
+ textFileChange = new TextFileChange("Add annotation", (IFile) source.getResource());
+ MultiTextEdit multiTextEdit = new MultiTextEdit();
+ textFileChange.setEdit(multiTextEdit);
}
protected boolean isAutoBuildingEnabled() {
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToFieldTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToFieldTest.java
index 40e55bb..bac692e 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToFieldTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToFieldTest.java
@@ -60,7 +60,7 @@
IField field = source.findPrimaryType().getField("service");
assertNotNull(field);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(field, WebServiceRef.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(field, WebServiceRef.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(field, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
@@ -71,5 +71,5 @@
fail(ce.getLocalizedMessage());
}
}
-
+
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodParameterTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodParameterTest.java
index bd1c67c..a12295b 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodParameterTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodParameterTest.java
@@ -64,8 +64,8 @@
assertNotNull(method);
ILocalVariable localVariable = AnnotationUtils.getLocalVariable(method, "i");
-
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class));
+
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(localVariable, WebParam.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(localVariable, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodTest.java
index 9b1f553..1efe61d 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToMethodTest.java
@@ -63,11 +63,11 @@
IMethod method = source.findPrimaryType().getMethod("add", new String[] { "I", "I" });
assertNotNull(method);
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(method, WebMethod.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(method, annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
-
+
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils.getAnnotationName(annotation)));
assertTrue(source.getImport(WebMethod.class.getCanonicalName()).exists());
} catch (CoreException ce) {
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToTypeTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToTypeTest.java
index 6f59948..044fad3 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToTypeTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddAnnotationToTypeTest.java
@@ -72,11 +72,11 @@
assertNotNull(annotation);
assertEquals(WebService.class.getSimpleName(), AnnotationUtils.getAnnotationName(annotation));
- textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createAddImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
textFileChange.addEdit(AnnotationUtils.createAddAnnotationTextEdit(source.findPrimaryType(), annotation));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
-
+
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils.getAnnotationName(annotation)));
assertTrue(source.getImport(WebService.class.getCanonicalName()).exists());
} catch (CoreException ce) {
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddMemberValuePairToAnnotationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddMemberValuePairToAnnotationTest.java
new file mode 100644
index 0000000..56ff519
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/AddMemberValuePairToAnnotationTest.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.tests;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceRef;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+
+public class AddMemberValuePairToAnnotationTest extends AbstractAnnotationTest {
+
+ @Override
+ protected Annotation getAnnotation() {
+ return null;
+ }
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebService;\n");
+ classContents.append("import javax.jws.WebMethod;\n");
+ classContents.append("import javax.jws.WebParam;\n");
+ classContents.append("import javax.xml.ws.WebServiceRef;\n\n");
+ classContents.append("@WebService()\n");
+ classContents.append("public class Calculator {\n\n");
+ classContents.append("\t@WebServiceRef()\n");
+ classContents.append("\tpublic String myField;\n\n");
+ classContents.append("\t@WebMethod()\n");
+ classContents.append("\tpublic int add(@WebParam() int i, int k) {");
+ classContents.append("\n\t\treturn i + k;\n\t}\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ protected String getClassName() {
+ return "Calculator.java";
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "com.example";
+ }
+
+ public void testAddMemberValuePairToAnnotation() {
+ try {
+ //@WebService
+ IType type = source.findPrimaryType();
+ assertTrue(AnnotationUtils.isAnnotationPresent(source, "WebService"));
+ Annotation webService = AnnotationUtils.getAnnotation(type, WebService.class);
+ assertNotNull(webService);
+ assertTrue(webService instanceof NormalAnnotation);
+
+ NormalAnnotation webServiceAnnotation = (NormalAnnotation) webService;
+ assertTrue(webServiceAnnotation.values().size() == 0);
+
+ MemberValuePair nameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "name", "Calculator");
+
+ AnnotationUtils.addMemberValuePair(webServiceAnnotation, nameValuePair);
+ webServiceAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(type, WebService.class);
+ assertTrue(webServiceAnnotation.values().size() == 1);
+
+ //@WebServiceRef
+ IField field = type.getField("myField");
+ assertTrue(AnnotationUtils.isAnnotationPresent(field, "WebServiceRef"));
+ Annotation webServiceRef = AnnotationUtils.getAnnotation(field, WebServiceRef.class);
+ assertNotNull(webServiceRef);
+ assertTrue(webServiceRef instanceof NormalAnnotation);
+
+ NormalAnnotation webServiceRefAnnotation = (NormalAnnotation) webServiceRef;
+ assertTrue(webServiceRefAnnotation.values().size() == 0);
+
+ MemberValuePair mappedNameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "mappedName", "myField");
+
+ AnnotationUtils.addMemberValuePair(webServiceRefAnnotation, mappedNameValuePair);
+ webServiceRefAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(field, WebServiceRef.class);
+ assertTrue(webServiceRefAnnotation.values().size() == 1);
+
+ //@WebMethod
+ IMethod method = type.getMethod("add", new String[] { "I", "I" });
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, "WebMethod"));
+ Annotation webMethod = AnnotationUtils.getAnnotation(method, WebMethod.class);
+ assertNotNull(webMethod);
+ assertTrue(webMethod instanceof NormalAnnotation);
+
+ NormalAnnotation webMethodAnnotation = (NormalAnnotation) webMethod;
+ assertTrue(webMethodAnnotation.values().size() == 0);
+
+ MemberValuePair operationNameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "operationName", "add");
+
+ AnnotationUtils.addMemberValuePair(webMethodAnnotation, operationNameValuePair);
+ webMethodAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(method, WebMethod.class);
+ assertTrue(webMethodAnnotation.values().size() == 1);
+
+ //@WebParam
+ ILocalVariable localVariable = AnnotationUtils.getLocalVariable(method, "i");
+ assertTrue(AnnotationUtils.isAnnotationPresent(localVariable, "WebParam"));
+ Annotation webParam = AnnotationUtils.getAnnotation(localVariable, WebParam.class);
+ assertNotNull(webParam);
+ assertTrue(webParam instanceof NormalAnnotation);
+
+ NormalAnnotation webParamAnnotation = (NormalAnnotation) webParam;
+ assertTrue(webParamAnnotation.values().size() == 0);
+
+ MemberValuePair partNameValuePair = AnnotationsCore.createStringMemberValuePair(ast, "partName", "i");
+
+ AnnotationUtils.addMemberValuePair(webParamAnnotation, partNameValuePair);
+ webParamAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(localVariable, WebParam.class);
+ assertTrue(webParamAnnotation.values().size() == 1);
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ }
+ }
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/JAXWSCoreTestSuite.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/JAXWSCoreTestSuite.java
index ff0a0b5..8bebf15 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/JAXWSCoreTestSuite.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/JAXWSCoreTestSuite.java
@@ -18,7 +18,7 @@
public static Test suite() {
return new JAXWSCoreTestSuite();
}
-
+
public JAXWSCoreTestSuite() {
super("JAX-WS Core Tests");
addTestSuite(AddAnnotationToTypeTest.class);
@@ -28,7 +28,11 @@
addTestSuite(AddAnnotationToMethodTest.class);
addTestSuite(RemoveAnnotationFromMethodTest.class);
addTestSuite(AddAnnotationToMethodParameterTest.class);
- addTestSuite(RemoveAnnotationFromMethodParameterTest.class);
+ addTestSuite(RemoveAnnotationFromMethodParameterTest.class);
+ addTestSuite(AddMemberValuePairToAnnotationTest.class);
+ addTestSuite(RemoveMemberValuePairTest.class);
+ addTestSuite(UpdateMemberValuePairTest.class);
+ addTestSuite(UpdateSingleMemberAnnotationTest.class);
}
-
+
}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromFieldTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromFieldTest.java
index 9b1f393..4abfdf7 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromFieldTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromFieldTest.java
@@ -54,12 +54,12 @@
assertTrue(AnnotationUtils.isAnnotationPresent(field, AnnotationUtils
.getAnnotationName(annotation)));
-
+
assertNotNull(source.getImport(WebServiceRef.class.getCanonicalName()));
-
+
textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(field, annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(field, WebServiceRef.class));
-
+ textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(field, WebServiceRef.class.getCanonicalName()));
+
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
assertFalse(AnnotationUtils.isAnnotationPresent(field, AnnotationUtils.getAnnotationName(annotation)));
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodParameterTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodParameterTest.java
index 83b7d35..9070b14 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodParameterTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodParameterTest.java
@@ -58,12 +58,12 @@
assertTrue(AnnotationUtils.isAnnotationPresent(localVariable, annotation));
assertNotNull(source.getImport(WebParam.class.getCanonicalName()));
-
+
textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(localVariable, annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(localVariable, WebParam.class));
-
+ textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(localVariable, WebParam.class.getCanonicalName()));
+
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
-
+
assertFalse(AnnotationUtils.isAnnotationPresent(localVariable, annotation));
assertFalse(source.getImport(WebParam.class.getCanonicalName()).exists());
} catch (CoreException ce) {
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodTest.java
index 8dca6e7..b92a1a4 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromMethodTest.java
@@ -56,9 +56,9 @@
assertTrue(AnnotationUtils.isAnnotationPresent(method, AnnotationUtils
.getAnnotationName(annotation)));
assertNotNull(source.getImport(WebMethod.class.getCanonicalName()));
-
+
textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(method, annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(method, WebMethod.class));
+ textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(method, WebMethod.class.getCanonicalName()));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromTypeTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromTypeTest.java
index b9c938a..69337d6 100644
--- a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromTypeTest.java
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveAnnotationFromTypeTest.java
@@ -54,9 +54,9 @@
assertTrue(AnnotationUtils.isAnnotationPresent(source, AnnotationUtils.getAnnotationName(annotation)));
assertNotNull(source.getImport(WebService.class.getCanonicalName()));
-
+
textFileChange.addEdit(AnnotationUtils.createRemoveAnnotationTextEdit(source.findPrimaryType(), annotation));
- textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(source.findPrimaryType(), WebService.class));
+ textFileChange.addEdit(AnnotationUtils.createRemoveImportTextEdit(source.findPrimaryType(), WebService.class.getCanonicalName()));
assertTrue(executeChange(new NullProgressMonitor(), textFileChange));
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveMemberValuePairTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveMemberValuePairTest.java
new file mode 100644
index 0000000..84032f4
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/RemoveMemberValuePairTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.tests;
+
+import javax.jws.WebService;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+
+public class RemoveMemberValuePairTest extends AbstractAnnotationTest {
+
+ @Override
+ protected Annotation getAnnotation() {
+ return null;
+ }
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebService;\n\n");
+ classContents.append("@WebService(name=\"Calculator\")\n");
+ classContents.append("public class Calculator {\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ protected String getClassName() {
+ return "Calculator.java";
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "com.example";
+ }
+
+ public void testRemoveMemberValuePairFromAnnotation() {
+ try {
+ IType type = source.findPrimaryType();
+ assertTrue(AnnotationUtils.isAnnotationPresent(source, "WebService"));
+ Annotation webService = AnnotationUtils.getAnnotation(type, WebService.class);
+ assertNotNull(webService);
+ assertTrue(webService instanceof NormalAnnotation);
+
+ NormalAnnotation webServiceAnnotation = (NormalAnnotation) webService;
+ assertTrue(webServiceAnnotation.values().size() == 1);
+
+ MemberValuePair nameValuePair = AnnotationUtils.getMemberValuePair(webServiceAnnotation, "name");
+
+ AnnotationUtils.removeMemberValuePair(webServiceAnnotation, nameValuePair);
+ webServiceAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(type, WebService.class);
+ assertTrue(webServiceAnnotation.values().size() == 0);
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateMemberValuePairTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateMemberValuePairTest.java
new file mode 100644
index 0000000..29daf1a
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateMemberValuePairTest.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.tests;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceRef;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+
+public class UpdateMemberValuePairTest extends AbstractAnnotationTest {
+
+ @Override
+ protected Annotation getAnnotation() {
+ return null;
+ }
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.jws.WebService;\n");
+ classContents.append("import javax.jws.WebMethod;\n");
+ classContents.append("import javax.jws.WebParam;\n");
+ classContents.append("import javax.xml.ws.WebServiceRef;\n\n");
+ classContents.append("@WebService(name=\"Calculator\")\n");
+ classContents.append("public class Calculator {\n\n");
+ classContents.append("\t@WebServiceRef(mappedName=\"myField\")\n");
+ classContents.append("\tpublic String myField;\n\n");
+ classContents.append("\t@WebMethod(operationName=\"add\")\n");
+ classContents.append("\tpublic int add(@WebParam(partName=\"i\") int i, int k) {");
+ classContents.append("\n\t\treturn i + k;\n\t}\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ protected String getClassName() {
+ return "Calculator.java";
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "com.example";
+ }
+
+ public void testUpdateMemberValuePair() {
+ try {
+ //@WebService
+ IType type = source.findPrimaryType();
+ assertTrue(AnnotationUtils.isAnnotationPresent(source, "WebService"));
+ Annotation webService = AnnotationUtils.getAnnotation(type, WebService.class);
+ assertNotNull(webService);
+ assertTrue(webService instanceof NormalAnnotation);
+
+ NormalAnnotation webServiceAnnotation = (NormalAnnotation) webService;
+ assertTrue(webServiceAnnotation.values().size() == 1);
+
+ MemberValuePair nameValuePair = AnnotationUtils.getMemberValuePair(webServiceAnnotation, "name");
+ assertNotNull(nameValuePair);
+ StringLiteral nameValue = (StringLiteral) nameValuePair.getValue();
+ assertTrue(nameValue.getLiteralValue().equals("Calculator"));
+
+ AnnotationUtils.updateMemberValuePair(nameValuePair, AnnotationsCore.createStringLiteral(ast, "ScientificCalculator"));
+ webServiceAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(type, WebService.class);
+ nameValuePair = AnnotationUtils.getMemberValuePair(webServiceAnnotation, "name");
+ nameValue = (StringLiteral) nameValuePair.getValue();
+ assertTrue(nameValue.getLiteralValue().equals("ScientificCalculator"));
+
+ //@WebServiceRef
+ IField field = type.getField("myField");
+ assertTrue(AnnotationUtils.isAnnotationPresent(field, "WebServiceRef"));
+ Annotation webServiceRef = AnnotationUtils.getAnnotation(field, WebServiceRef.class);
+ assertNotNull(webServiceRef);
+ assertTrue(webServiceRef instanceof NormalAnnotation);
+
+ NormalAnnotation webServiceRefAnnotation = (NormalAnnotation) webServiceRef;
+ assertTrue(webServiceRefAnnotation.values().size() == 1);
+
+ MemberValuePair mappedNameValuePair = AnnotationUtils.getMemberValuePair(webServiceRefAnnotation, "mappedName");
+ assertNotNull(mappedNameValuePair);
+ StringLiteral mappedNameValue = (StringLiteral) mappedNameValuePair.getValue();
+ assertTrue(mappedNameValue.getLiteralValue().equals("myField"));
+
+ AnnotationUtils.updateMemberValuePair(mappedNameValuePair, AnnotationsCore.createStringLiteral(ast, "anotherField"));
+ webServiceRefAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(field, WebServiceRef.class);
+ mappedNameValuePair = AnnotationUtils.getMemberValuePair(webServiceRefAnnotation, "mappedName");
+ mappedNameValue = (StringLiteral) mappedNameValuePair.getValue();
+ assertTrue(mappedNameValue.getLiteralValue().equals("anotherField"));
+
+ //@WebMethod
+ IMethod method = type.getMethod("add", new String[] { "I", "I" });
+ assertTrue(AnnotationUtils.isAnnotationPresent(method, "WebMethod"));
+ Annotation webMethod = AnnotationUtils.getAnnotation(method, WebMethod.class);
+ assertNotNull(webMethod);
+ assertTrue(webMethod instanceof NormalAnnotation);
+
+ NormalAnnotation webMethodAnnotation = (NormalAnnotation) webMethod;
+ assertTrue(webMethodAnnotation.values().size() == 1);
+
+ MemberValuePair operationNameValuePair = AnnotationUtils.getMemberValuePair(webMethodAnnotation, "operationName");
+ assertNotNull(operationNameValuePair);
+ StringLiteral operationNameValue = (StringLiteral) operationNameValuePair.getValue();
+ assertTrue(operationNameValue.getLiteralValue().equals("add"));
+
+ AnnotationUtils.updateMemberValuePair(operationNameValuePair, AnnotationsCore.createStringLiteral(ast, "multiply"));
+ webMethodAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(method, WebMethod.class);
+ operationNameValuePair = AnnotationUtils.getMemberValuePair(webMethodAnnotation, "operationName");
+ operationNameValue = (StringLiteral) operationNameValuePair.getValue();
+ assertTrue(operationNameValue.getLiteralValue().equals("multiply"));
+
+ //@WebParam
+ ILocalVariable localVariable = AnnotationUtils.getLocalVariable(method, "i");
+ assertTrue(AnnotationUtils.isAnnotationPresent(localVariable, "WebParam"));
+ Annotation webParam = AnnotationUtils.getAnnotation(localVariable, WebParam.class);
+ assertNotNull(webParam);
+ assertTrue(webParam instanceof NormalAnnotation);
+
+ NormalAnnotation webParamAnnotation = (NormalAnnotation) webParam;
+ assertTrue(webParamAnnotation.values().size() == 1);
+
+ MemberValuePair partNameValuePair = AnnotationUtils.getMemberValuePair(webParamAnnotation, "partName");
+ assertNotNull(partNameValuePair);
+ StringLiteral partNameValue = (StringLiteral) partNameValuePair.getValue();
+ assertTrue(partNameValue.getLiteralValue().equals("i"));
+
+ AnnotationUtils.updateMemberValuePair(partNameValuePair, AnnotationsCore.createStringLiteral(ast, "iii"));
+ webParamAnnotation = (NormalAnnotation) AnnotationUtils.getAnnotation(localVariable, WebParam.class);
+ partNameValuePair = AnnotationUtils.getMemberValuePair(webParamAnnotation, "partName");
+ partNameValue = (StringLiteral) partNameValuePair.getValue();
+ assertTrue(partNameValue.getLiteralValue().equals("iii"));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ }
+ }
+
+}
diff --git a/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateSingleMemberAnnotationTest.java b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateSingleMemberAnnotationTest.java
new file mode 100644
index 0000000..29da147
--- /dev/null
+++ b/tests/org.eclipse.jst.ws.jaxws.core.tests/src/org/eclipse/jst/ws/jaxws/core/tests/UpdateSingleMemberAnnotationTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Shane Clarke.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Shane Clarke - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.ws.jaxws.core.tests;
+
+import javax.xml.ws.BindingType;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.eclipse.jdt.core.dom.StringLiteral;
+import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
+import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
+
+public class UpdateSingleMemberAnnotationTest extends AbstractAnnotationTest {
+
+ @Override
+ protected Annotation getAnnotation() {
+ return null;
+ }
+
+ @Override
+ protected String getClassContents() {
+ StringBuilder classContents = new StringBuilder("package com.example;\n\n");
+ classContents.append("import javax.xml.ws.BindingType;\n\n");
+ classContents.append("@BindingType(\"http://schemas.xmlsoap.org/wsdl/soap/http\")\n");
+ classContents.append("public class Calculator {\n\n}");
+ return classContents.toString();
+ }
+
+ @Override
+ protected String getClassName() {
+ return "Calculator.java";
+ }
+
+ @Override
+ protected String getPackageName() {
+ return "com.example";
+ }
+
+ public void testUpdateSingleMemberAnnotation() {
+ try {
+ IType type = source.findPrimaryType();
+ assertTrue(AnnotationUtils.isAnnotationPresent(source, "BindingType"));
+ Annotation bindingType = AnnotationUtils.getAnnotation(type, BindingType.class);
+ assertNotNull(bindingType);
+ assertTrue(bindingType instanceof SingleMemberAnnotation);
+
+ SingleMemberAnnotation bindingTypeAnnotation = (SingleMemberAnnotation) bindingType;
+ StringLiteral bindingTypeValue = (StringLiteral) bindingTypeAnnotation.getValue();
+ assertTrue(bindingTypeValue.getLiteralValue().equals("http://schemas.xmlsoap.org/wsdl/soap/http"));
+
+ AnnotationUtils.updateSingleMemberAnnotation(bindingTypeAnnotation, AnnotationsCore.createStringLiteral(ast, "http://www.w3.org/2003/05/soap/bindings/HTTP/"));
+ bindingTypeAnnotation = (SingleMemberAnnotation) AnnotationUtils.getAnnotation(type, BindingType.class);
+ bindingTypeValue = (StringLiteral) bindingTypeAnnotation.getValue();
+ assertTrue(bindingTypeValue.getLiteralValue().equals("http://www.w3.org/2003/05/soap/bindings/HTTP/"));
+ } catch (CoreException ce) {
+ fail(ce.getLocalizedMessage());
+ }
+ }
+
+}