PTP
Release 7.0

org.eclipse.ptp.pldt.common.actions
Class RunAnalyseHandlerBase

java.lang.Object
  extended by AbstractHandler
      extended by org.eclipse.ptp.pldt.common.actions.RunAnalyseHandler
          extended by org.eclipse.ptp.pldt.common.actions.RunAnalyseHandlerBase

public abstract class RunAnalyseHandlerBase
extends RunAnalyseHandler

RunAnalyseBase - run analysis to create generic artifact markers.
The analysis is done in the doArtifactAnalysis() method


Field Summary
protected  boolean cancelledByUser
           
protected  int cumulativeArtifacts
           
protected  boolean forceEcho
           
protected  String markerID
           
protected  String name
          the type of artifact e.g.
protected  Shell shell
           
protected static boolean traceOn
          This is NOT final because constructor may change this dynamically if tracing is enabled by user -- see CommonPlugin.getTraceOn();
protected  ArtifactMarkingVisitor visitor
           
protected  IWorkbenchWindow window
           
 
Fields inherited from class org.eclipse.ptp.pldt.common.actions.RunAnalyseHandler
selection
 
Constructor Summary
RunAnalyseHandlerBase(String name, ArtifactMarkingVisitor visitor, String markerID)
          Constructor for the "Run Analysis" action
 
Method Summary
protected abstract  void activateArtifactView()
           
protected  void activateProblemsView()
          If the analysis has an additional view to bring up, override this
 ScanReturn analyse(IProgressMonitor monitor, ITranslationUnit tu, List<String> includes)
           
 boolean areIncludePathsNeeded()
          returns true if include paths must be set for this implementation.
 void dispose()
          We can use this method to dispose of any system resources we previously allocated.
abstract  ScanReturn doArtifactAnalysis(ITranslationUnit tu, List<String> includes)
          Returns artifact analysis for file.
 Object execute(ExecutionEvent event)
          Implemented for Handler; this replaces run() which is for actions.
protected abstract  List<String> getIncludePath()
          Get the include path.
 String getPrefacedName(Object obj)
          Provide a human-readable version of what will be analyzed.
 void init(IWorkbenchWindow window)
          Cache the window object to be able to provide parent shell for the message dialog.
protected  boolean isCPPproject(ICElement ce)
          Determine if the project is a C++ project
protected  void processResults(ScanReturn results, IResource resource)
           
protected  void readPreferences()
          Read preferences
 void run()
          Do the "Run Analysis" on a resource (project, folder, or file).
protected  ScanReturn runArtifactAnalysisFromExtensionPoint(String extensionPointID, ITranslationUnit tu, List<String> includes, boolean allowPrefixOnlyMatch)
          Runs an artifact analysis for the given file by searching the given extension point for an IArtifactAnalysis that matches its language ID.
 boolean runResource(IProgressMonitor monitor, ICElement ce, int indent, List<String> includes)
          Run analysis on a resource (e.g.
protected  boolean runResources(IProgressMonitor monitor, int indent, List<String> includes)
          Run the analysis on the current selection (file, container, or multiple-selection)
 void setActivePart(IAction action, IWorkbenchPart targetPart)
           
protected  boolean validForAnalysis(String filename, boolean isCPP)
          Default determination of if a given filename is valid for our artifact analysis
 
Methods inherited from class org.eclipse.ptp.pldt.common.actions.RunAnalyseHandler
countFiles, countFiles, countFilesSelected, countFilesSelected, getSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

traceOn

protected static boolean traceOn
This is NOT final because constructor may change this dynamically if tracing is enabled by user -- see CommonPlugin.getTraceOn();


forceEcho

protected boolean forceEcho

window

protected IWorkbenchWindow window

cancelledByUser

protected boolean cancelledByUser

cumulativeArtifacts

protected int cumulativeArtifacts

name

protected String name
the type of artifact e.g. "MPI" or "OpenMP"


visitor

protected ArtifactMarkingVisitor visitor

markerID

protected String markerID

shell

protected Shell shell
Constructor Detail

RunAnalyseHandlerBase

public RunAnalyseHandlerBase(String name,
                             ArtifactMarkingVisitor visitor,
                             String markerID)
Constructor for the "Run Analysis" action

Parameters:
name - the type of artifact e.g. "MPI" or "OpenMP"
visitor - the visitor that will put the markers on the source files
markerID - marker ID
Method Detail

analyse

public ScanReturn analyse(IProgressMonitor monitor,
                          ITranslationUnit tu,
                          List<String> includes)

areIncludePathsNeeded

public boolean areIncludePathsNeeded()
returns true if include paths must be set for this implementation. For example, C needs include paths, but Fortran doesn't.


dispose

public void dispose()
We can use this method to dispose of any system resources we previously allocated.

See Also:
implemented for toolbar enablement of this action

doArtifactAnalysis

public abstract ScanReturn doArtifactAnalysis(ITranslationUnit tu,
                                              List<String> includes)
Returns artifact analysis for file.
Derived class should override this method.

Parameters:
tu -
includes - header files include paths
Returns:

runArtifactAnalysisFromExtensionPoint

protected ScanReturn runArtifactAnalysisFromExtensionPoint(String extensionPointID,
                                                           ITranslationUnit tu,
                                                           List<String> includes,
                                                           boolean allowPrefixOnlyMatch)
Runs an artifact analysis for the given file by searching the given extension point for an IArtifactAnalysis that matches its language ID.

This is a utility method generally invoked from doArtifactAnalysis(ITranslationUnit, List).

It is assumed that only one extension will be contributed per language ID. If multiple extensions are found, it is unspecified which one will be run.

Parameters:
extensionPointID -
tu -
includes -
allowPrefixOnlyMatch -
Returns:
ScanReturn
Since:
6.0

execute

public Object execute(ExecutionEvent event)
               throws ExecutionException
Implemented for Handler; this replaces run() which is for actions.

Throws:
ExecutionException

getPrefacedName

public String getPrefacedName(Object obj)
Provide a human-readable version of what will be analyzed.

Parameters:
obj - the file, folder, or project
Returns:
a string indicating what it is

init

public void init(IWorkbenchWindow window)
Cache the window object to be able to provide parent shell for the message dialog.

See Also:
implemented for toolbar enablement of this action NOTE: window object will thus be null for context menu use!! so...we are not using this, using Display.getCurrent() and Display.getCurrent().getActiveShell();

run

public void run()
Do the "Run Analysis" on a resource (project, folder, or file). Descends to all child nodes, collecting artifacts on each.


runResource

public boolean runResource(IProgressMonitor monitor,
                           ICElement ce,
                           int indent,
                           List<String> includes)
                    throws InterruptedException
Run analysis on a resource (e.g. File or Folder) Will descend to members of folder

Parameters:
atu - the resource
indent - number of levels of nesting/recursion for prettyprinting
includes - contains header files include paths from the Preference page
Returns:
true if an error was encountered
Throws:
InterruptedException

setActivePart

public void setActivePart(IAction action,
                          IWorkbenchPart targetPart)

activateArtifactView

protected abstract void activateArtifactView()

activateProblemsView

protected void activateProblemsView()
If the analysis has an additional view to bring up, override this


getIncludePath

protected abstract List<String> getIncludePath()
Get the include path. Subclass should override this method.

Returns:

isCPPproject

protected boolean isCPPproject(ICElement ce)
Determine if the project is a C++ project

Parameters:
ce - the ICElement representing a file
Returns:

processResults

protected void processResults(ScanReturn results,
                              IResource resource)

readPreferences

protected void readPreferences()
Read preferences


runResources

protected boolean runResources(IProgressMonitor monitor,
                               int indent,
                               List<String> includes)
                        throws InterruptedException
Run the analysis on the current selection (file, container, or multiple-selection)

Parameters:
monitor - progress monitor on which to report progress.
indent - indent amount, in number of spaces, used only for debug printing.
includes -
Returns:
true if any errors were found.
Throws:
InterruptedException

validForAnalysis

protected boolean validForAnalysis(String filename,
                                   boolean isCPP)
Default determination of if a given filename is valid for our artifact analysis

Parameters:
filename -
isCPP - is the project a C++ project or not
Returns:

PTP
Release 7.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.