[377350] Error when annotating implementation class in wizard
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 48df4e7..2abe90d 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
@@ -14,8 +14,8 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
@@ -33,6 +33,7 @@
 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.ASTParser;
 import org.eclipse.jdt.core.dom.Annotation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.MemberValuePair;
@@ -40,7 +41,6 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
 import org.eclipse.jdt.ui.CodeStyleConfiguration;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.jst.ws.annotations.core.AnnotationDefinition;
 import org.eclipse.jst.ws.annotations.core.AnnotationsCore;
 import org.eclipse.jst.ws.annotations.core.AnnotationsManager;
@@ -102,27 +102,29 @@
     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 = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
-        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();
-                if (!stringLiteral.getLiteralValue().equals(model.getServiceEndpointInterfaceName())) {
-                    ASTNode newSEIValue = AnnotationsCore.createStringLiteral(ast, model
-                            .getServiceEndpointInterfaceName());
+        Annotation webServiceAnnotation = getAnnotation(type, WebService.class);
+        if (webServiceAnnotation != null) {
+            if (type.isClass() && model.isUseServiceEndpointInterface() && webServiceAnnotation.isNormalAnnotation()) {
+                MemberValuePair endpointInterface = getMemberValuePair((NormalAnnotation) webServiceAnnotation, ENDPOINT_INTERFACE);
+                if (endpointInterface != null && endpointInterface.getValue() instanceof StringLiteral) {
+                    StringLiteral stringLiteral = (StringLiteral) endpointInterface.getValue();
+                    if (!stringLiteral.getLiteralValue().equals(model.getServiceEndpointInterfaceName())) {
+                        ASTNode newSEIValue = AnnotationsCore.createStringLiteral(ast, model
+                                    .getServiceEndpointInterfaceName());
 
-                    textFileChange.addEdit(AnnotationUtils.createUpdateMemberValuePairTextEdit(endpointInterface, newSEIValue));
+                        textFileChange.addEdit(AnnotationUtils.createUpdateMemberValuePairTextEdit(endpointInterface, newSEIValue));
+                    }
+                } else {
+                    MemberValuePair endpointInterfacePair = AnnotationsCore.createMemberValuePair(ast,
+                            ENDPOINT_INTERFACE, AnnotationsCore.createStringLiteral(ast, model
+                                        .getServiceEndpointInterfaceName()));
+
+                    textFileChange.addEdit(AnnotationUtils.createAddMemberValuePairTextEdit((NormalAnnotation) webServiceAnnotation, endpointInterfacePair));
                 }
-            } else {
-                MemberValuePair endpointInterfacePair = AnnotationsCore.createMemberValuePair(ast,
-                        ENDPOINT_INTERFACE, AnnotationsCore.createStringLiteral(ast, model
-                                .getServiceEndpointInterfaceName()));
-
-                textFileChange.addEdit(AnnotationUtils.createAddMemberValuePairTextEdit(webServiceAnnotation, endpointInterfacePair));
             }
         } else {
             List<MemberValuePair> memberValuePairs = new ArrayList<MemberValuePair>();
@@ -147,12 +149,8 @@
         }
     }
 
-    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;
+    private static Annotation getAnnotation(IType type, Class<? extends java.lang.annotation.Annotation> annotation) {
+        return AnnotationUtils.getAnnotation(type, annotation);
     }
 
     @SuppressWarnings("unchecked")
@@ -169,7 +167,7 @@
     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);
+        CompilationUnit compilationUnit = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
@@ -181,7 +179,7 @@
     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);
+        CompilationUnit compilationUnit = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
@@ -193,7 +191,7 @@
     public static void getResponseWrapperAnnotationChange(IType type, IMethod method,
             TextFileChange textFileChange) throws CoreException {
         ICompilationUnit source = type.getCompilationUnit();
-        CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        CompilationUnit compilationUnit = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
@@ -205,7 +203,7 @@
     public static void getWebResultAnnotationChange(IType type, IMethod method,
             TextFileChange textFileChange) throws CoreException {
         ICompilationUnit source = type.getCompilationUnit();
-        CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        CompilationUnit compilationUnit = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
@@ -218,7 +216,7 @@
             ILocalVariable parameter, TextFileChange textFileChange)
     throws CoreException {
         ICompilationUnit source = type.getCompilationUnit();
-        CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        CompilationUnit compilationUnit = getAST(source);
 
         AST ast = compilationUnit.getAST();
 
@@ -464,5 +462,11 @@
 
         return false;
     }
+    
+    private static CompilationUnit getAST(ICompilationUnit source) {
+        final ASTParser parser = ASTParser.newParser(AST.JLS3);
+        parser.setSource(source);
+        return (CompilationUnit) parser.createAST(null);
+    }
 
 }
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AbstractJavaCorrectionPropsoal.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AbstractJavaCorrectionPropsoal.java
index 816238a..11e928a 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AbstractJavaCorrectionPropsoal.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AbstractJavaCorrectionPropsoal.java
@@ -15,6 +15,9 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.ui.text.java.IInvocationContext;
 import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
 import org.eclipse.jface.text.IDocument;
@@ -109,5 +112,12 @@
     public Point getSelection(IDocument document) {
         return null;
     }
+    
+    protected CompilationUnit getAST(ICompilationUnit source) {
+        final ASTParser parser = ASTParser.newParser(AST.JLS3);
+        parser.setResolveBindings(true);
+        parser.setSource(source);
+        return (CompilationUnit) parser.createAST(null);
+    }
 
 }
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AddUnimplementedMethodCorrectionProposal.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AddUnimplementedMethodCorrectionProposal.java
index 1a72a01..761391d 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AddUnimplementedMethodCorrectionProposal.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/AddUnimplementedMethodCorrectionProposal.java
@@ -31,7 +31,6 @@
 import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
 import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility2;
 import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.jdt.ui.text.java.IInvocationContext;
 import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
 import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin;
@@ -102,7 +101,7 @@
                     
                     if (seiType != null) {
                         ICompilationUnit sei = seiType.getCompilationUnit();
-                        CompilationUnit seiCompilationUnit = SharedASTProvider.getAST(sei, SharedASTProvider.WAIT_YES, null);
+                        CompilationUnit seiCompilationUnit = getAST(sei);
                         
                         List<MethodDeclaration> implementationMethods = getMethodDeclarations(
                                 implementationCompilationUnit);
diff --git a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/ChangeReturnTypeCorrectionProposal.java b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/ChangeReturnTypeCorrectionProposal.java
index a96f555..0651a21 100644
--- a/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/ChangeReturnTypeCorrectionProposal.java
+++ b/bundles/org.eclipse.jst.ws.jaxws.ui/src/org/eclipse/jst/ws/internal/jaxws/ui/annotations/correction/ChangeReturnTypeCorrectionProposal.java
@@ -28,7 +28,6 @@
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;
 import org.eclipse.jdt.ui.CodeStyleConfiguration;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.jdt.ui.text.java.IInvocationContext;
 import org.eclipse.jst.ws.annotations.core.utils.AnnotationUtils;
 import org.eclipse.jst.ws.internal.jaxws.ui.JAXWSUIPlugin;
@@ -85,7 +84,7 @@
                     
                     if (seiType != null) {
                         ICompilationUnit seiCompilationUnit = seiType.getCompilationUnit();
-                        CompilationUnit seiASTRoot = SharedASTProvider.getAST(seiCompilationUnit, SharedASTProvider.WAIT_YES, null);
+                        CompilationUnit seiASTRoot = getAST(seiCompilationUnit);
 
                         List<MethodDeclaration> seiMethodDeclarations = getMethodDeclarations(seiASTRoot);
                         for (MethodDeclaration seiMethodDeclaration : seiMethodDeclarations) {
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 21e27c4..a5d9476 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
@@ -35,6 +35,7 @@
 import org.eclipse.jdt.core.Signature;
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.core.dom.Annotation;
 import org.eclipse.jdt.core.dom.ArrayInitializer;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -42,7 +43,6 @@
 import org.eclipse.jdt.core.dom.MemberValuePair;
 import org.eclipse.jdt.core.dom.NormalAnnotation;
 import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.CheckboxCellEditor;
 import org.eclipse.jface.viewers.ComboBoxCellEditor;
@@ -375,7 +375,7 @@
     private void setValueForClass(IType type, Boolean annotate, IJavaElement javaElement,
             IAnnotationAttributeInitializer annotationAttributeInitializer) throws CoreException {
         ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
-        CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        CompilationUnit compilationUnit = getAST(source);
         AST ast = compilationUnit.getAST();
 
         List<MemberValuePair> memberValuePairs = getMemberValuePairs(annotationAttributeInitializer, javaElement,
@@ -442,7 +442,7 @@
 
     private void setValueForMethod(IMethod method, Object value, IJavaElement javaElement) throws CoreException {
         ICompilationUnit source = AnnotationUtils.getCompilationUnitFromJavaElement(javaElement);
-        CompilationUnit compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        CompilationUnit compilationUnit = getAST(source);
         AST ast = compilationUnit.getAST();
 
         TextFileChange change = new TextFileChange("Add/Update Annotation Value", (IFile) source.getResource());
@@ -703,4 +703,10 @@
         return arrayInitializer;
     }
 
+    private CompilationUnit getAST(ICompilationUnit source) {
+        final ASTParser parser = ASTParser.newParser(AST.JLS3);
+        parser.setSource(source);
+        return (CompilationUnit) parser.createAST(null);
+    }
+
 }
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 3848156..096e03d 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
@@ -17,10 +17,10 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.core.dom.Annotation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.ltk.core.refactoring.Change;
 import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
 import org.eclipse.ltk.core.refactoring.TextFileChange;
@@ -43,7 +43,7 @@
 
         source = testJavaProject.createCompilationUnit(getPackageName(), getClassName(), getClassContents());
         
-        compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        compilationUnit = getAST(source);
         ast = compilationUnit.getAST();
         rewriter = ASTRewrite.create(ast);
         annotation = getAnnotation();
@@ -103,5 +103,11 @@
     		}
     	}
     }
+    
+    private CompilationUnit getAST(ICompilationUnit source) {
+        final ASTParser parser = ASTParser.newParser(AST.JLS3);
+        parser.setSource(source);
+        return (CompilationUnit) parser.createAST(null);
+    }
 
 }
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 b4fb378..caa8110 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
@@ -19,10 +19,10 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.core.dom.Annotation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
-import org.eclipse.jdt.ui.SharedASTProvider;
 import org.eclipse.ltk.core.refactoring.Change;
 import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
 import org.eclipse.ltk.core.refactoring.TextFileChange;
@@ -45,7 +45,7 @@
 
         source = testJavaProject.createCompilationUnit(getPackageName(), getClassName(), getClassContents());
 
-        compilationUnit = SharedASTProvider.getAST(source, SharedASTProvider.WAIT_YES, null);
+        compilationUnit = getAST(source);
         ast = compilationUnit.getAST();
         rewriter = ASTRewrite.create(ast);
         annotation = getAnnotation();
@@ -104,4 +104,10 @@
     		}
     	}
     }
+    
+    private CompilationUnit getAST(ICompilationUnit source) {
+        final ASTParser parser = ASTParser.newParser(AST.JLS3);
+        parser.setSource(source);
+        return (CompilationUnit) parser.createAST(null);
+    }
 }