FeaturesPluginsDocs & SupportCommunityPartners

org.netbeans.modules.jackpot/2 2 1

org.netbeans.api.jackpot
Class TreePathQuery<R,P>

java.lang.Object
  extended by com.sun.source.util.TreeScanner<R,P>
      extended by com.sun.source.util.TreePathScanner<R,P>
          extended by org.netbeans.api.java.source.support.CancellableTreePathScanner<R,P>
              extended by org.netbeans.api.jackpot.TreePathQuery<R,P>
All Implemented Interfaces:
TreeVisitor<R,P>, Query
Direct Known Subclasses:
TreePathTransformer

public abstract class TreePathQuery<R,P>
extends org.netbeans.api.java.source.support.CancellableTreePathScanner<R,P>
implements Query

An abstract Query which extends TreePathScanner to visit the project's AST nodes using the visitor pattern.

See Also:
TreePath, TreePathScanner, CancellableTreePathScanner

Constructor Summary
TreePathQuery()
           
 
Method Summary
 void addResult()
          Adds a result using the scanner's current TreePath, without any comment.
 void addResult(String note)
          Adds a result using the scanner's current TreePath.
 void addResult(TreePath path, String note)
          Forward a result (query match) to the query's context.
 void attach(org.netbeans.api.java.source.CompilationInfo info)
          Attach this Query instance to the specified CompilationInfo prior to processing one or more source files.
 void destroy()
          Release any instance data shared by invocations, including all references to the JavaSource instanced passed to init().
 org.netbeans.api.java.source.CompilationInfo getCompilationInfo()
          Returns the CompilationInfo attached to this query.
 QueryContext getContext()
          Returns the context the query is executing within.
 org.netbeans.api.java.source.JavaSource getJavaSource()
          Returns the JavaSource this query was initialized with.
 void init(QueryContext context, org.netbeans.api.java.source.JavaSource source)
          Initialize any data that is shared across source file processing invocations.
 void release()
          Release any instance data created by attach() or the processing of a set of source files.
 void run()
          Execute the query for the set of source files.
 
Methods inherited from class org.netbeans.api.java.source.support.CancellableTreePathScanner
cancel, isCanceled, scan, scan
 
Methods inherited from class com.sun.source.util.TreePathScanner
getCurrentPath, scan
 
Methods inherited from class com.sun.source.util.TreeScanner
reduce, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitLabeledStatement, visitLiteral, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitNewArray, visitNewClass, visitOther, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, visitWhileLoop, visitWildcard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.netbeans.api.jackpot.Query
cancel
 

Constructor Detail

TreePathQuery

public TreePathQuery()
Method Detail

init

public void init(QueryContext context,
                 org.netbeans.api.java.source.JavaSource source)
Description copied from interface: Query
Initialize any data that is shared across source file processing invocations.

Specified by:
init in interface Query
Parameters:
context - the application environment the query executes within.
source - the JavaSource instance which this query is invoked with.

attach

public void attach(org.netbeans.api.java.source.CompilationInfo info)
Description copied from interface: Query
Attach this Query instance to the specified CompilationInfo prior to processing one or more source files.

Specified by:
attach in interface Query
Parameters:
info - the CompilationInfo associated with this set of source files.

run

public void run()
Description copied from interface: Query
Execute the query for the set of source files.

Specified by:
run in interface Query

release

public void release()
Description copied from interface: Query
Release any instance data created by attach() or the processing of a set of source files. All references to the attached CompilationInfo and its source files must be released.

Specified by:
release in interface Query

destroy

public void destroy()
Description copied from interface: Query
Release any instance data shared by invocations, including all references to the JavaSource instanced passed to init().

Specified by:
destroy in interface Query

getJavaSource

public final org.netbeans.api.java.source.JavaSource getJavaSource()
Description copied from interface: Query
Returns the JavaSource this query was initialized with.

Specified by:
getJavaSource in interface Query
Returns:
the JavaSource, or null if not initialized.

getCompilationInfo

public final org.netbeans.api.java.source.CompilationInfo getCompilationInfo()
Description copied from interface: Query
Returns the CompilationInfo attached to this query.

Specified by:
getCompilationInfo in interface Query
Returns:
the CompilationInfo, or null if not attached.

getContext

public final QueryContext getContext()
Returns the context the query is executing within.

Returns:
the query's context

addResult

public final void addResult()
Adds a result using the scanner's current TreePath, without any comment. This method is normally called only from queries that match on a single condition, such as FindUnusedVariables where a variable is only added if it is unused. Queries which match on multiple possible conditions should include a comment giving the user a reason for the specific result.


addResult

public final void addResult(String note)
Adds a result using the scanner's current TreePath.

Parameters:
note - optional information about the match, or null if there is no note.

addResult

public final void addResult(TreePath path,
                            String note)
Forward a result (query match) to the query's context.

Parameters:
path - the path of the tree that matched the query
note - optional information about the match, or null if there is no note.

org.netbeans.modules.jackpot/2 2 1

Built on April 6 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by