TPTP 4.6.0 Platform Project
Internal API Specification

org.eclipse.hyades.probekit.internal
Class Compiler

java.lang.Object
  extended by org.eclipse.hyades.probekit.internal.Compiler
All Implemented Interfaces:
org.eclipse.hyades.probekit.IProbeCompiler

public class Compiler
extends java.lang.Object
implements org.eclipse.hyades.probekit.IProbeCompiler

This is the default implementation of IProbeCompiler. CompilerFactory will return an instance of this class if nobody uses the extension point to tell it to return a different one.


Nested Class Summary
static class Compiler.ProbeDetails
          Holds the computed details about a probe, like its unique name, the signatures of the fragment functions, and convenience flags and attributes.
 
Field Summary
 
Fields inherited from interface org.eclipse.hyades.probekit.IProbeCompiler
PROBEKIT_PROBLEM_MARKER
 
Constructor Summary
Compiler()
          The default constructor.
Compiler(Probekit probekit)
          Deprecated.  
Compiler(java.lang.String file)
          Deprecated.  
 
Method Summary
 void addFile(java.lang.String file)
          Deprecated.  
 java.lang.String addIFile(org.eclipse.core.resources.IFile file)
           
 void addProbekit(Probekit probekit)
          Deprecated.  
 void addResource(org.eclipse.emf.ecore.resource.Resource res)
          Deprecated. Use addResource(Resource,IResource) instead, because it can report errors against the proper Workspace resource.
 java.lang.String addResource(org.eclipse.emf.ecore.resource.Resource res, org.eclipse.core.resources.IResource ires)
          Add probekits that appear at the top level of an EMF resource to the probekits this compiler will compile.
 java.lang.String getClassSuffix()
          API function to return the suffix string that is added to the string from setClassPrefix() to form the class name.
 java.lang.String getEngineScript()
          Get the script that describes this probe set to the BCI engine.
 java.lang.String getGeneratedSource()
          Get the generated source.
 java.lang.String makeValidJavaIdentifier(java.lang.String arg)
          See the interface definition for an explanation.
 void setClassPrefix(java.lang.String prefix)
          Sets the class prefix to use for generated probe classes.
 void setPackageName(java.lang.String pkg)
          Sets the package name to use.
 void verify()
          Tests a probe set for correctness and consistency.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler()
The default constructor. The factory uses this.


Compiler

public Compiler(Probekit probekit)
Deprecated. 

Constructor which takes a Probekit object.

Parameters:
probekit -

Compiler

public Compiler(java.lang.String file)
         throws org.eclipse.hyades.probekit.ProbekitException
Deprecated. 

Constructor which takes a file name, opens it as a resource, and adds probes found inside to the compiler. Since no IResource is available to report errors against, errors are reported using marker objects at the top level of the workspace.

Parameters:
file - the name of the file to load.
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors (not just syntax errors in the probe source)
Method Detail

addProbekit

public void addProbekit(Probekit probekit)
                 throws org.eclipse.hyades.probekit.ProbekitException
Deprecated. 

Add a probekit object to the list of probekits this compiler will compile. Since no IResource is available to report errors against, errors are reported using marker objects at the top level of the workspace.

Specified by:
addProbekit in interface org.eclipse.hyades.probekit.IProbeCompiler
Parameters:
probekit - the Probekit to add
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors (not just syntax errors in the probe source)

addFile

public void addFile(java.lang.String file)
             throws org.eclipse.hyades.probekit.ProbekitException
Deprecated. 

Load the named file as a resource and add probekit objects found at the top level to this Compiler. Since no IResource is available to report errors against, errors are reported using marker objects at the top level of the workspace.

Specified by:
addFile in interface org.eclipse.hyades.probekit.IProbeCompiler
Parameters:
file - the name of the file to load.
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors (not just syntax errors in the probe source)

addResource

public void addResource(org.eclipse.emf.ecore.resource.Resource res)
                 throws org.eclipse.hyades.probekit.ProbekitException
Deprecated. Use addResource(Resource,IResource) instead, because it can report errors against the proper Workspace resource.

Add probekits that appear at the top level of an EMF resource to the probekits this compiler will compile.

Since no IResource is available to report errors against, errors are reported using marker objects at the top level of the workspace.

See addResource(Resource,IResource) regarding LocationAdapters being put on the EObjects of the Resource.

Specified by:
addResource in interface org.eclipse.hyades.probekit.IProbeCompiler
Parameters:
res - the Resource to scan for probekits.
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors

addResource

public java.lang.String addResource(org.eclipse.emf.ecore.resource.Resource res,
                                    org.eclipse.core.resources.IResource ires)
                             throws org.eclipse.hyades.probekit.ProbekitException
Add probekits that appear at the top level of an EMF resource to the probekits this compiler will compile. This method takes an IResource argument for error reporting: errors are reported using Markers on that resource. (The IResource isn't used for anything else.)

The Resource you pass in will have LocationAdapter instances attached to its EObjects using the EMF eAdapters system. The LocationAdapter tells which lines in the generated Java source came from each EObject in the Resource.

Specified by:
addResource in interface org.eclipse.hyades.probekit.IProbeCompiler
Parameters:
res - the EMF Resource to scan for probekits.
ires - the Eclipse IResource to use for reporting errors
Returns:
the "id" of the probe in the file
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors (not just syntax errors in the probe source)

addIFile

public java.lang.String addIFile(org.eclipse.core.resources.IFile file)
                          throws org.eclipse.hyades.probekit.ProbekitException
Specified by:
addIFile in interface org.eclipse.hyades.probekit.IProbeCompiler
Throws:
org.eclipse.hyades.probekit.ProbekitException

setClassPrefix

public void setClassPrefix(java.lang.String prefix)
                    throws org.eclipse.hyades.probekit.ProbekitException
Sets the class prefix to use for generated probe classes. They will be in a package determined by the probe compiler, but here the caller can set the class name prefix. You'll get classes called classPrefix_probe.

Specified by:
setClassPrefix in interface org.eclipse.hyades.probekit.IProbeCompiler
Throws:
org.eclipse.hyades.probekit.ProbekitException - if you pass a class prefix that's not valid Java syntax

setPackageName

public void setPackageName(java.lang.String pkg)
                    throws org.eclipse.hyades.probekit.ProbekitException
Sets the package name to use. If this is never called, generated classes will appear in the default package.

Specified by:
setPackageName in interface org.eclipse.hyades.probekit.IProbeCompiler
Parameters:
pkg -
Throws:
org.eclipse.hyades.probekit.ProbekitException

getClassSuffix

public java.lang.String getClassSuffix()
API function to return the suffix string that is added to the string from setClassPrefix() to form the class name. Callers have to know this so they can form the Java source file name.

Don't change the value of this string ("_probe") because it's something users of the static instrumentation system are likely to write into their automation scripts.

Specified by:
getClassSuffix in interface org.eclipse.hyades.probekit.IProbeCompiler
Returns:
the class name suffix

makeValidJavaIdentifier

public java.lang.String makeValidJavaIdentifier(java.lang.String arg)
See the interface definition for an explanation. Utility function for callers to convert file name parts into class prefixes consistently.

Specified by:
makeValidJavaIdentifier in interface org.eclipse.hyades.probekit.IProbeCompiler

verify

public void verify()
            throws org.eclipse.hyades.probekit.ProbekitException
Tests a probe set for correctness and consistency. Throws an exception if the probe set fails any tests. The tests tend to be for things that aren't already forbidden by the modeling. This verification step permits the core implementation to have less internal consistency checking logic.

Reports errors as Problem markers on the original resource.

Specified by:
verify in interface org.eclipse.hyades.probekit.IProbeCompiler
Throws:
org.eclipse.hyades.probekit.ProbekitException - for serious errors (not just syntax errors)
org.eclipse.hyades.probekit.ProbekitCompileProblemException - for problems that have been reported as markers.

getGeneratedSource

public java.lang.String getGeneratedSource()
                                    throws org.eclipse.hyades.probekit.ProbekitException
Get the generated source. If the source hasn't been generated yet, it will be. Internally calls verify() and can throw ProbekitException if there is a problem.

Specified by:
getGeneratedSource in interface org.eclipse.hyades.probekit.IProbeCompiler
Returns:
the generated source as a string.
Throws:
org.eclipse.hyades.probekit.ProbekitException

getEngineScript

public java.lang.String getEngineScript()
                                 throws org.eclipse.hyades.probekit.ProbekitException
Get the script that describes this probe set to the BCI engine.

Specified by:
getEngineScript in interface org.eclipse.hyades.probekit.IProbeCompiler
Returns:
the string form of the description data
Throws:
org.eclipse.hyades.probekit.ProbekitException

TPTP 4.6.0 Platform Project
Internal API Specification