public static void getMissingJavadocTagProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    if (node == null) {
      return;
    }
    node = ASTNodes.getNormalizedNode(node);

    BodyDeclaration bodyDeclaration = ASTResolving.findParentBodyDeclaration(node);
    if (bodyDeclaration == null) {
      return;
    }
    Javadoc javadoc = bodyDeclaration.getJavadoc();
    if (javadoc == null) {
      return;
    }

    String label;
    StructuralPropertyDescriptor location = node.getLocationInParent();
    if (location == SingleVariableDeclaration.NAME_PROPERTY) {
      label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description;
      if (node.getParent().getLocationInParent() != MethodDeclaration.PARAMETERS_PROPERTY) {
        return; // paranoia checks
      }
    } else if (location == TypeParameter.NAME_PROPERTY) {
      label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_paramtag_description;
      StructuralPropertyDescriptor parentLocation = node.getParent().getLocationInParent();
      if (parentLocation != MethodDeclaration.TYPE_PARAMETERS_PROPERTY
          && parentLocation != TypeDeclaration.TYPE_PARAMETERS_PROPERTY) {
        return; // paranoia checks
      }
    } else if (location == MethodDeclaration.RETURN_TYPE2_PROPERTY) {
      label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_returntag_description;
    } else if (location == MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY) {
      label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_throwstag_description;
    } else {
      return;
    }
    ASTRewriteCorrectionProposal proposal =
        new AddMissingJavadocTagProposal(
            label,
            context.getCompilationUnit(),
            bodyDeclaration,
            node,
            IProposalRelevance.ADD_MISSING_TAG);
    proposals.add(proposal);

    String label2 = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_allmissing_description;
    ASTRewriteCorrectionProposal addAllMissing =
        new AddAllMissingJavadocTagsProposal(
            label2,
            context.getCompilationUnit(),
            bodyDeclaration,
            IProposalRelevance.ADD_ALL_MISSING_TAGS);
    proposals.add(addAllMissing);
  }
  public static void getUnusedAndUndocumentedParameterOrExceptionProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    ICompilationUnit cu = context.getCompilationUnit();
    IJavaProject project = cu.getJavaProject();

    if (!JavaCore.ENABLED.equals(project.getOption(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, true))) {
      return;
    }

    int problemId = problem.getProblemId();
    boolean isUnusedTypeParam = problemId == IProblem.UnusedTypeParameter;
    boolean isUnusedParam = problemId == IProblem.ArgumentIsNeverUsed || isUnusedTypeParam;
    String key =
        isUnusedParam
            ? JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE
            : JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_INCLUDE_DOC_COMMENT_REFERENCE;

    if (!JavaCore.ENABLED.equals(project.getOption(key, true))) {
      return;
    }

    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    if (node == null) {
      return;
    }

    BodyDeclaration bodyDecl = ASTResolving.findParentBodyDeclaration(node);
    if (bodyDecl == null || ASTResolving.getParentMethodOrTypeBinding(bodyDecl) == null) {
      return;
    }

    String label;
    if (isUnusedTypeParam) {
      label = CorrectionMessages.JavadocTagsSubProcessor_document_type_parameter_description;
    } else if (isUnusedParam) {
      label = CorrectionMessages.JavadocTagsSubProcessor_document_parameter_description;
    } else {
      node = ASTNodes.getNormalizedNode(node);
      label = CorrectionMessages.JavadocTagsSubProcessor_document_exception_description;
    }
    ASTRewriteCorrectionProposal proposal =
        new AddMissingJavadocTagProposal(
            label,
            context.getCompilationUnit(),
            bodyDecl,
            node,
            IProposalRelevance.DOCUMENT_UNUSED_ITEM);
    proposals.add(proposal);
  }
  public static void getInvalidQualificationProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    if (!(node instanceof Name)) {
      return;
    }
    Name name = (Name) node;
    IBinding binding = name.resolveBinding();
    if (!(binding instanceof ITypeBinding)) {
      return;
    }
    ITypeBinding typeBinding = (ITypeBinding) binding;

    AST ast = node.getAST();
    ASTRewrite rewrite = ASTRewrite.create(ast);
    rewrite.replace(name, ast.newName(typeBinding.getQualifiedName()), null);

    String label = CorrectionMessages.JavadocTagsSubProcessor_qualifylinktoinner_description;
    Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
    ASTRewriteCorrectionProposal proposal =
        new ASTRewriteCorrectionProposal(
            label,
            context.getCompilationUnit(),
            rewrite,
            IProposalRelevance.QUALIFY_INNER_TYPE_NAME,
            image);

    proposals.add(proposal);
  }
Пример #4
0
    @Override
    public JavaContentAssistInvocationContext apply(IInvocationContext context) {
      ICompilationUnit cu = context.getCompilationUnit();
      int offset = context.getSelectionOffset();
      try {
        cu.codeComplete(
            offset,
            new CompletionRequestor() {
              @Override
              public void acceptContext(CompletionContext context) {
                internalContext = context;
              }

              @Override
              public boolean isExtendedContextRequired() {
                return true;
              }

              @Override
              public void accept(CompletionProposal proposal) {}
            });
      } catch (JavaModelException e) {
        propagate(e);
      }

      JavaEditor editor = cast(EditorUtility.isOpenInEditor(cu));
      ISourceViewer viewer = editor.getViewer();
      return new JavaContentAssistInvocationContext(viewer, offset, editor) {

        @Override
        public CompletionContext getCoreContext() {
          return internalContext;
        }
      };
    }
 public boolean hasAssists(IInvocationContext context) throws CoreException {
   IProblem[] problems = context.getASTRoot().getProblems();
   for (int i = 0; i < problems.length; i++) {
     if (hasCorrections(context.getCompilationUnit(), problems[i].getID())) {
       return true;
     }
   }
   return false;
 }
 public FixCorrectionProposal(
     IProposableFix fix,
     ICleanUp cleanUp,
     int relevance,
     Image image,
     IInvocationContext context) {
   super(fix.getDisplayString(), context.getCompilationUnit(), null, relevance, image);
   fFix = fix;
   fCleanUp = cleanUp;
   fCompilationUnit = context.getASTRoot();
 }
  public static void getRemoveJavadocTagProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    while (node != null && !(node instanceof TagElement)) {
      node = node.getParent();
    }
    if (node == null) {
      return;
    }
    ASTRewrite rewrite = ASTRewrite.create(node.getAST());
    rewrite.remove(node, null);

    String label = CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
    Image image =
        JavaPlugin.getDefault()
            .getWorkbench()
            .getSharedImages()
            .getImage(ISharedImages.IMG_TOOL_DELETE);
    proposals.add(
        new ASTRewriteCorrectionProposal(
            label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_TAG, image));
  }
  /**
   * This method inserts our proposal - jar library - into classpath.
   *
   * @param document see super method.
   * @see
   *     org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
   */
  public void apply(final IDocument document) {
    final IJavaProject project = context.getCompilationUnit().getJavaProject();
    final Shell shell = PerclipseActivator.getActivePage().getWorkbenchWindow().getShell();
    try {
      IClasspathEntry entry = null;
      if (isPerfidix) {
        entry = BuildPathSupport.getPerfidixClasspathEntry();
      }
      if (entry != null) {
        addToClasspath(shell, project, entry, new BusyIndicatorRunnableContext());
      }
      final int offset = context.getSelectionOffset();
      final int length = context.getSelectionLength();
      String str;
      str = document.get(offset, length);

      document.replace(offset, length, str);

    } catch (BadLocationException e) {
      PerclipseActivator.log(e);
    } catch (JavaModelException e) {
      PerclipseActivator.log(e);
    }
  }
  public static void getMissingJavadocCommentProposals(
      IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals)
      throws CoreException {
    ASTNode node = problem.getCoveringNode(context.getASTRoot());
    if (node == null) {
      return;
    }
    BodyDeclaration declaration = ASTResolving.findParentBodyDeclaration(node);
    if (declaration == null) {
      return;
    }
    ICompilationUnit cu = context.getCompilationUnit();
    ITypeBinding binding = Bindings.getBindingOfParentType(declaration);
    if (binding == null) {
      return;
    }

    if (declaration instanceof MethodDeclaration) {
      MethodDeclaration methodDecl = (MethodDeclaration) declaration;
      IMethodBinding methodBinding = methodDecl.resolveBinding();
      IMethodBinding overridden = null;
      if (methodBinding != null) {
        overridden = Bindings.findOverriddenMethod(methodBinding, true);
      }

      String string =
          CodeGeneration.getMethodComment(
              cu, binding.getName(), methodDecl, overridden, String.valueOf('\n'));
      if (string != null) {
        String label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_method_description;
        proposals.add(
            new AddJavadocCommentProposal(
                label,
                cu,
                IProposalRelevance.ADD_JAVADOC_METHOD,
                declaration.getStartPosition(),
                string));
      }
    } else if (declaration instanceof AbstractTypeDeclaration) {
      String typeQualifiedName = Bindings.getTypeQualifiedName(binding);
      String[] typeParamNames;
      if (declaration instanceof TypeDeclaration) {
        List<TypeParameter> typeParams = ((TypeDeclaration) declaration).typeParameters();
        typeParamNames = new String[typeParams.size()];
        for (int i = 0; i < typeParamNames.length; i++) {
          typeParamNames[i] = (typeParams.get(i)).getName().getIdentifier();
        }
      } else {
        typeParamNames = new String[0];
      }
      String string =
          CodeGeneration.getTypeComment(
              cu, typeQualifiedName, typeParamNames, String.valueOf('\n'));
      if (string != null) {
        String label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_type_description;
        proposals.add(
            new AddJavadocCommentProposal(
                label,
                cu,
                IProposalRelevance.ADD_JAVADOC_TYPE,
                declaration.getStartPosition(),
                string));
      }
    } else if (declaration instanceof FieldDeclaration) {
      String comment = "/**\n *\n */\n"; // $NON-NLS-1$
      List<VariableDeclarationFragment> fragments = ((FieldDeclaration) declaration).fragments();
      if (fragments != null && fragments.size() > 0) {
        VariableDeclaration decl = fragments.get(0);
        String fieldName = decl.getName().getIdentifier();
        String typeName = binding.getName();
        comment = CodeGeneration.getFieldComment(cu, typeName, fieldName, String.valueOf('\n'));
      }
      if (comment != null) {
        String label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_field_description;
        proposals.add(
            new AddJavadocCommentProposal(
                label,
                cu,
                IProposalRelevance.ADD_JAVADOC_FIELD,
                declaration.getStartPosition(),
                comment));
      }
    } else if (declaration instanceof EnumConstantDeclaration) {
      EnumConstantDeclaration enumDecl = (EnumConstantDeclaration) declaration;
      String id = enumDecl.getName().getIdentifier();
      String comment =
          CodeGeneration.getFieldComment(cu, binding.getName(), id, String.valueOf('\n'));
      String label = CorrectionMessages.JavadocTagsSubProcessor_addjavadoc_enumconst_description;
      proposals.add(
          new AddJavadocCommentProposal(
              label,
              cu,
              IProposalRelevance.ADD_JAVADOC_ENUM,
              declaration.getStartPosition(),
              comment));
    }
  }
 private void process(
     IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals)
     throws CoreException {
   int id = problem.getProblemId();
   if (id == 0) { // no proposals for none-problem locations
     return;
   }
   switch (id) {
     case IProblem.UnterminatedString:
       String quoteLabel = CorrectionMessages.JavaCorrectionProcessor_addquote_description;
       int pos =
           moveBack(
               problem.getOffset() + problem.getLength(),
               problem.getOffset(),
               "\n\r",
               context.getCompilationUnit()); // $NON-NLS-1$
       proposals.add(
           new ReplaceCorrectionProposal(
               quoteLabel, context.getCompilationUnit(), pos, 0, "\"", 0)); // $NON-NLS-1$
       break;
     case IProblem.UnusedImport:
     case IProblem.DuplicateImport:
     case IProblem.CannotImportPackage:
     case IProblem.ConflictingImport:
       ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals);
       break;
     case IProblem.ImportNotFound:
       ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals);
       ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals);
       break;
     case IProblem.UndefinedMethod:
       UnresolvedElementsSubProcessor.getMethodProposals(context, problem, false, proposals);
       break;
     case IProblem.UndefinedConstructor:
       UnresolvedElementsSubProcessor.getConstructorProposals(context, problem, proposals);
       break;
     case IProblem.UndefinedAnnotationMember:
       UnresolvedElementsSubProcessor.getAnnotationMemberProposals(context, problem, proposals);
       break;
     case IProblem.ParameterMismatch:
       UnresolvedElementsSubProcessor.getMethodProposals(context, problem, true, proposals);
       break;
     case IProblem.MethodButWithConstructorName:
       ReturnTypeSubProcessor.addMethodWithConstrNameProposals(context, problem, proposals);
       break;
     case IProblem.UndefinedField:
     case IProblem.UndefinedName:
       UnresolvedElementsSubProcessor.getVariableProposals(context, problem, null, proposals);
       break;
     case IProblem.AmbiguousType:
     case IProblem.JavadocAmbiguousType:
       UnresolvedElementsSubProcessor.getAmbiguosTypeReferenceProposals(
           context, problem, proposals);
       break;
     case IProblem.PublicClassMustMatchFileName:
       ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals);
       break;
     case IProblem.PackageIsNotExpectedPackage:
       ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals);
       break;
     case IProblem.UndefinedType:
     case IProblem.JavadocUndefinedType:
       UnresolvedElementsSubProcessor.getTypeProposals(context, problem, proposals);
       break;
     case IProblem.TypeMismatch:
       // AspectJ Change
       if (problem.getProblemArguments() != null) { // Bug 265052
         TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals);
       }
       break;
     case IProblem.IncompatibleReturnType:
       TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals);
       break;
     case IProblem.IncompatibleExceptionInThrowsClause:
       TypeMismatchSubProcessor.addIncompatibleThrowsProposals(context, problem, proposals);
       break;
     case IProblem.UnhandledException:
       LocalCorrectionsSubProcessor.addUncaughtExceptionProposals(context, problem, proposals);
       break;
     case IProblem.UnreachableCatch:
     case IProblem.InvalidCatchBlockSequence:
       LocalCorrectionsSubProcessor.addUnreachableCatchProposals(context, problem, proposals);
       break;
     case IProblem.VoidMethodReturnsValue:
       ReturnTypeSubProcessor.addVoidMethodReturnsProposals(context, problem, proposals);
       break;
     case IProblem.MethodReturnsVoid:
       ReturnTypeSubProcessor.addMethodRetunsVoidProposals(context, problem, proposals);
       break;
     case IProblem.MissingReturnType:
       ReturnTypeSubProcessor.addMissingReturnTypeProposals(context, problem, proposals);
       break;
     case IProblem.ShouldReturnValue:
       ReturnTypeSubProcessor.addMissingReturnStatementProposals(context, problem, proposals);
       break;
     case IProblem.NonExternalizedStringLiteral:
       LocalCorrectionsSubProcessor.addNLSProposals(context, problem, proposals);
       break;
     case IProblem.UnnecessaryNLSTag:
       LocalCorrectionsSubProcessor.getUnnecessaryNLSTagProposals(context, problem, proposals);
       break;
     case IProblem.NonStaticAccessToStaticField:
     case IProblem.NonStaticAccessToStaticMethod:
     case IProblem.IndirectAccessToStaticField:
     case IProblem.IndirectAccessToStaticMethod:
       LocalCorrectionsSubProcessor.addCorrectAccessToStaticProposals(context, problem, proposals);
       break;
     case IProblem.StaticMethodRequested:
     case IProblem.NonStaticFieldFromStaticInvocation:
     case IProblem.InstanceMethodDuringConstructorInvocation:
     case IProblem.InstanceFieldDuringConstructorInvocation:
       ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_STATIC, 5);
       break;
     case IProblem.NonBlankFinalLocalAssignment:
     case IProblem.DuplicateFinalLocalInitialization:
     case IProblem.FinalFieldAssignment:
     case IProblem.DuplicateBlankFinalFieldInitialization:
     case IProblem.AnonymousClassCannotExtendFinalClass:
     case IProblem.ClassExtendFinalClass:
       ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_FINAL, 9);
       break;
     case IProblem.InheritedMethodReducesVisibility:
     case IProblem.MethodReducesVisibility:
     case IProblem.OverridingNonVisibleMethod:
       ModifierCorrectionSubProcessor.addChangeOverriddenModifierProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_VISIBLE);
       break;
     case IProblem.FinalMethodCannotBeOverridden:
       ModifierCorrectionSubProcessor.addChangeOverriddenModifierProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_FINAL);
       break;
     case IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod:
       ModifierCorrectionSubProcessor.addChangeOverriddenModifierProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_STATIC);
       break;
     case IProblem.CannotHideAnInstanceMethodWithAStaticMethod:
     case IProblem.IllegalModifierForInterfaceMethod:
     case IProblem.IllegalModifierForInterface:
     case IProblem.IllegalModifierForClass:
     case IProblem.IllegalModifierForInterfaceField:
     case IProblem.IllegalModifierForMemberInterface:
     case IProblem.IllegalModifierForMemberClass:
     case IProblem.IllegalModifierForLocalClass:
     case IProblem.IllegalModifierForArgument:
     case IProblem.IllegalModifierForField:
     case IProblem.IllegalModifierForMethod:
     case IProblem.IllegalModifierForVariable:
     case IProblem.IllegalVisibilityModifierForInterfaceMemberType:
     case IProblem.UnexpectedStaticModifierForMethod:
       ModifierCorrectionSubProcessor.addRemoveInvalidModifiersProposal(
           context, problem, proposals, 5);
       break;
     case IProblem.NotVisibleMethod:
     case IProblem.NotVisibleConstructor:
     case IProblem.NotVisibleType:
     case IProblem.NotVisibleField:
     case IProblem.JavadocNotVisibleType:
       ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_VISIBLE, 10);
       break;
     case IProblem.BodyForAbstractMethod:
     case IProblem.AbstractMethodInAbstractClass:
       ModifierCorrectionSubProcessor.addAbstractMethodProposals(context, problem, proposals);
       break;
     case IProblem.AbstractMethodMustBeImplemented:
       LocalCorrectionsSubProcessor.addUnimplementedMethodsProposals(context, problem, proposals);
       break;
     case IProblem.MissingValueForAnnotationMember:
       LocalCorrectionsSubProcessor.addValueForAnnotationProposals(context, problem, proposals);
       break;
     case IProblem.BodyForNativeMethod:
       ModifierCorrectionSubProcessor.addNativeMethodProposals(context, problem, proposals);
       break;
     case IProblem.MethodRequiresBody:
       ModifierCorrectionSubProcessor.addMethodRequiresBodyProposals(context, problem, proposals);
       break;
     case IProblem.OuterLocalMustBeFinal:
       ModifierCorrectionSubProcessor.addNonFinalLocalProposal(context, problem, proposals);
       break;
     case IProblem.UninitializedLocalVariable:
       LocalCorrectionsSubProcessor.addUninitializedLocalVariableProposal(
           context, problem, proposals);
       break;
     case IProblem.UnhandledExceptionInDefaultConstructor:
     case IProblem.UndefinedConstructorInDefaultConstructor:
     case IProblem.NotVisibleConstructorInDefaultConstructor:
       LocalCorrectionsSubProcessor.addConstructorFromSuperclassProposal(
           context, problem, proposals);
       break;
     case IProblem.UnusedPrivateMethod:
     case IProblem.UnusedPrivateConstructor:
     case IProblem.UnusedPrivateField:
     case IProblem.UnusedPrivateType:
     case IProblem.LocalVariableIsNeverUsed:
     case IProblem.ArgumentIsNeverUsed:
       LocalCorrectionsSubProcessor.addUnusedMemberProposal(context, problem, proposals);
       break;
     case IProblem.NeedToEmulateFieldReadAccess:
     case IProblem.NeedToEmulateFieldWriteAccess:
     case IProblem.NeedToEmulateMethodAccess:
     case IProblem.NeedToEmulateConstructorAccess:
       ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(
           context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_PRIVATE, 5);
       break;
     case IProblem.SuperfluousSemicolon:
       LocalCorrectionsSubProcessor.addSuperfluousSemicolonProposal(context, problem, proposals);
       break;
     case IProblem.UnnecessaryCast:
       LocalCorrectionsSubProcessor.addUnnecessaryCastProposal(context, problem, proposals);
       break;
     case IProblem.UnnecessaryInstanceof:
       LocalCorrectionsSubProcessor.addUnnecessaryInstanceofProposal(context, problem, proposals);
       break;
     case IProblem.UnusedMethodDeclaredThrownException:
     case IProblem.UnusedConstructorDeclaredThrownException:
       LocalCorrectionsSubProcessor.addUnnecessaryThrownExceptionProposal(
           context, problem, proposals);
       break;
     case IProblem.UnqualifiedFieldAccess:
       LocalCorrectionsSubProcessor.addUnqualifiedFieldAccessProposal(context, problem, proposals);
       break;
     case IProblem.Task:
       proposals.add(new TaskMarkerProposal(context.getCompilationUnit(), problem, 10));
       break;
     case IProblem.JavadocMissing:
       JavadocTagsSubProcessor.getMissingJavadocCommentProposals(context, problem, proposals);
       break;
     case IProblem.JavadocMissingParamTag:
     case IProblem.JavadocMissingReturnTag:
     case IProblem.JavadocMissingThrowsTag:
       JavadocTagsSubProcessor.getMissingJavadocTagProposals(context, problem, proposals);
       break;
     case IProblem.JavadocInvalidThrowsClassName:
     case IProblem.JavadocDuplicateThrowsClassName:
     case IProblem.JavadocDuplicateReturnTag:
     case IProblem.JavadocDuplicateParamName:
     case IProblem.JavadocInvalidParamName:
     case IProblem.JavadocUnexpectedTag:
     case IProblem.JavadocInvalidTag:
       JavadocTagsSubProcessor.getRemoveJavadocTagProposals(context, problem, proposals);
       break;
     case IProblem.LocalVariableHidingLocalVariable:
     case IProblem.LocalVariableHidingField:
     case IProblem.FieldHidingLocalVariable:
     case IProblem.FieldHidingField:
     case IProblem.ArgumentHidingLocalVariable:
     case IProblem.ArgumentHidingField:
     case IProblem.UseAssertAsAnIdentifier:
     case IProblem.UseEnumAsAnIdentifier:
     case IProblem.RedefinedLocal:
     case IProblem.RedefinedArgument:
       LocalCorrectionsSubProcessor.addInvalidVariableNameProposals(context, problem, proposals);
       break;
     case IProblem.NoMessageSendOnArrayType:
       UnresolvedElementsSubProcessor.getArrayAccessProposals(context, problem, proposals);
       break;
     case IProblem.InvalidOperator:
       LocalCorrectionsSubProcessor.getInvalidOperatorProposals(context, problem, proposals);
       break;
     case IProblem.MissingSerialVersion:
       SerialVersionSubProcessor.getSerialVersionProposals(context, problem, proposals);
       break;
     case IProblem.UnnecessaryElse:
       LocalCorrectionsSubProcessor.getUnnecessaryElseProposals(context, problem, proposals);
       break;
     case IProblem.SuperclassMustBeAClass:
       LocalCorrectionsSubProcessor.getInterfaceExtendsClassProposals(context, problem, proposals);
       break;
     case IProblem.CodeCannotBeReached:
       LocalCorrectionsSubProcessor.getUnreachableCodeProposals(context, problem, proposals);
       break;
     case IProblem.InvalidUsageOfTypeParameters:
     case IProblem.InvalidUsageOfStaticImports:
     case IProblem.InvalidUsageOfForeachStatements:
     case IProblem.InvalidUsageOfTypeArguments:
     case IProblem.InvalidUsageOfEnumDeclarations:
     case IProblem.InvalidUsageOfVarargs:
     case IProblem.InvalidUsageOfAnnotations:
     case IProblem.InvalidUsageOfAnnotationDeclarations:
       // FICXADE  Need reflection here!
       // ECLIPSE 3.8
       //                ReorgCorrectionsSubProcessor.getNeedHigherComplianceProposals(context,
       // problem, proposals, JavaCore.VERSION_1_5);
       // ORIG
       //                ReorgCorrectionsSubProcessor.getNeed50ComplianceProposals(context,
       // problem, proposals);
       break;
     case IProblem.NonGenericType:
       TypeArgumentMismatchSubProcessor.removeMismatchedArguments(context, problem, proposals);
       break;
     case IProblem.MissingOverrideAnnotation:
       ModifierCorrectionSubProcessor.addOverrideAnnotationProposal(context, problem, proposals);
       break;
     case IProblem.FieldMissingDeprecatedAnnotation:
     case IProblem.MethodMissingDeprecatedAnnotation:
     case IProblem.TypeMissingDeprecatedAnnotation:
       ModifierCorrectionSubProcessor.addDeprecatedAnnotationProposal(context, problem, proposals);
       break;
     case IProblem.IsClassPathCorrect:
       ReorgCorrectionsSubProcessor.getIncorrectBuildPathProposals(context, problem, proposals);
       break;
     case IProblem.ForbiddenReference:
     case IProblem.DiscouragedReference:
       ReorgCorrectionsSubProcessor.getAccessRulesProposals(context, problem, proposals);
       break;
     case IProblem.AssignmentHasNoEffect:
       LocalCorrectionsSubProcessor.getAssignmentHasNoEffectProposals(context, problem, proposals);
       break;
     case IProblem.UnsafeTypeConversion:
     case IProblem.RawTypeReference:
     case IProblem.UnsafeRawMethodInvocation:
       LocalCorrectionsSubProcessor.addTypePrametersToRawTypeReference(
           context, problem, proposals);
       break;
     case IProblem.FallthroughCase:
       LocalCorrectionsSubProcessor.addFallThroughProposals(context, problem, proposals);
       break;
     case IProblem.UnhandledWarningToken:
       SuppressWarningsSubProcessor.addUnknownSuppressWarningProposals(
           context, problem, proposals);
       break;
     default:
   }
   if (JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
     SuppressWarningsSubProcessor.addSuppressWarningsProposals(context, problem, proposals);
   }
 }
  @Override
  public IJavaCompletionProposal[] getAssists(
      IInvocationContext context, IProblemLocation[] locations) throws CoreException {
    ICompilationUnit compilationUnit = context.getCompilationUnit();
    IType primaryType = compilationUnit.findPrimaryType();
    if (primaryType == null || !primaryType.isInterface()) ; // return null;

    IJavaElement[] elements =
        compilationUnit.codeSelect(context.getSelectionOffset(), context.getSelectionLength());
    for (IJavaElement element : elements) {
      if (element.getElementType() == IJavaElement.METHOD) {
        IMethod method = (IMethod) element;
        if (!method.getDeclaringType().isInterface()) return null;

        final String statementAnnotation = getStatementAnnotation(method);
        if (method.getParameters().length == 0 && statementAnnotation == null) return null;

        CompilationUnit astNode = getAstNode(compilationUnit);
        astNode.recordModifications();
        final MapperMethod mapperMethod = getMapperMethod(astNode, method);
        if (mapperMethod == null) return null;

        List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>();

        if (method.getParameters().length > 0) {
          proposals.add(
              new QuickAssistCompletionProposal("Add @Param to parameters") {
                private CompilationUnit astNode;

                private MapperMethod method;

                @SuppressWarnings("unchecked")
                @Override
                public void apply(IDocument document) {
                  List<SingleVariableDeclaration> params = method.parameters();
                  for (SingleVariableDeclaration param : params) {
                    List<IExtendedModifier> modifiers = param.modifiers();
                    if (!hasParamAnnotation(modifiers)) {
                      if (JavaMapperUtil.TYPE_ROW_BOUNDS.equals(
                          param.resolveBinding().getType().getQualifiedName())) continue;
                      AST ast = param.getAST();
                      SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
                      annotation.setTypeName(ast.newName("Param"));
                      StringLiteral paramValue = ast.newStringLiteral();
                      paramValue.setLiteralValue(param.getName().getFullyQualifiedName());
                      annotation.setValue(paramValue);
                      param.modifiers().add(annotation);
                    }
                  }
                  TextEdit textEdit = astNode.rewrite(document, null);
                  try {
                    textEdit.apply(document);
                  } catch (MalformedTreeException e) {
                    Activator.log(Status.ERROR, e.getMessage(), e);
                  } catch (BadLocationException e) {
                    Activator.log(Status.ERROR, e.getMessage(), e);
                  }
                }

                private boolean hasParamAnnotation(List<IExtendedModifier> modifiers) {
                  for (IExtendedModifier modifier : modifiers) {
                    if (modifier.isAnnotation()
                        && "Param"
                            .equals(
                                ((Annotation) modifier).getTypeName().getFullyQualifiedName())) {
                      return true;
                    }
                  }
                  return false;
                }

                private QuickAssistCompletionProposal init(
                    CompilationUnit astNode, MapperMethod method) {
                  this.astNode = astNode;
                  this.method = method;
                  return this;
                }
              }.init(astNode, mapperMethod));
        }

        if (mapperMethod.getStatement() != null) {
          proposals.add(
              new QuickAssistCompletionProposal(
                  "Copy @" + statementAnnotation + " statement to clipboard") {
                @Override
                public void apply(IDocument document) {
                  Clipboard clipboard = new Clipboard(Display.getCurrent());
                  clipboard.setContents(
                      new Object[] {mapperMethod.getStatement()},
                      new Transfer[] {TextTransfer.getInstance()});
                }
              });
        }

        return proposals.toArray(new IJavaCompletionProposal[proposals.size()]);
      }
    }
    return null;
  }