Documentation for Violation Resolutions

CodePro AnalytiX (Audit & Test), includes over 1000 audit rules and metrics, JUnit test generation & editing, code coverage, and duplicate code analysis

Moderators: gnebling, jwren, Eric Clayberg, Dan Rubel, Brian Wilkerson, dcarew

Documentation for Violation Resolutions

Postby ralf.zahn » Wed Jan 19, 2011 11:28 pm

Hi,

is there any documentation how to write custom violation resolutions? I can implement simple AbstractAuditViolationResolution subclasses that use the TextualResourceEditor instance to modify text.
But I need to implement a resolution that uses some of the JDT's actions like org.eclipse.jdt.ui.actions.AddJavaDocStubAction.
ralf.zahn
 
Posts: 6
Joined: Sun Dec 19, 2010 11:19 pm

Re: Documentation for Violation Resolutions

Postby ralf.zahn » Wed Jan 19, 2011 11:30 pm

In addition, here's my implementation of this violation that does not work correctly, if there are multiple resolutions within a single Java source file, because the editor does not recognize changes made by the resolution.

Code: Select all
  public void resolve(final AuditViolation violation,
      final TextualResourceEditor editor, final IProgressMonitor monitor)
      throws ResolutionException {
    try {
      final IWorkbenchPartSite site =
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
              .getActivePart().getSite();
      final AddJavaDocStubAction action = new AddJavaDocStubAction(site);
      final IJavaElement element =
          violation.getCompilationUnit().getElementAt(
              violation.getHighlightStart());
      if( element instanceof IMember ) {
        final IMember member = (IMember) element;
        action.run(new StructuredSelection(member));
      }
      super.resolve(violation, editor, monitor);
    } catch( final JavaModelException e ) {
      throw new ResolutionException(e);
    } finally {
      editor.doneEditing();
    }
  }
ralf.zahn
 
Posts: 6
Joined: Sun Dec 19, 2010 11:19 pm

Re: Documentation for Violation Resolutions

Postby gnebling » Tue Apr 19, 2011 8:08 am

No, there isn't any documentation.

I'm not sure how someone could do that. If you were guaranteed that no other resolutions would be applied at the same time, then you could ignore the editor and simply invoke the action. But if multiple edits might be getting made then there's a possibility for confusion because the text editor won't have the result of any changes that the action might make.

I would try to just run the action in the resolution and see whether there are any problems.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am


Return to CodePro AnalytiX & PlusPak. EclipsePro Audit & Test

Who is online

Users browsing this forum: No registered users and 1 guest

cron