org.netbeans.modules.parsing.api/1 1.55.0 6

org.netbeans.modules.parsing.api
Class ParserManager

java.lang.Object
  extended by org.netbeans.modules.parsing.api.ParserManager

public final class ParserManager
extends Object

ParserManager allows to start priority parsing request for one or more sources.


Method Summary
static void parse(Collection<Source> sources, UserTask userTask)
          Priority request for parsing of list of Sources.
static void parse(String mimeType, UserTask userTask)
          Runs given task in parser thread.
static Future<Void> parseWhenScanFinished(Collection<Source> sources, UserTask userTask)
          Performs the given task when the scan finished.
static Future<Void> parseWhenScanFinished(String mimeType, UserTask userTask)
          Performs the given task when the scan finished.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static void parse(@NonNull
                         Collection<Source> sources,
                         @NonNull
                         UserTask userTask)
                  throws ParseException
Priority request for parsing of list of Sources. Implementator of this task have full control over the process of parsing of embedded languages. You can scan tree of embedded sources and start parsing for all of them, or for some of them only. This method is blocking. It means that only one parsing request per time is allowed. But you can call another parsing request from your Task. This secondary parsing request is called immediately in the same thread (current thread).

This method is typically called as a response on some user request - during code completion for example.

Parameters:
sources - A list of sources that should be parsed.
userTask - A task that will be started when parsing is done.
Throws:
ParseException - encapsulating the user exception

parseWhenScanFinished

@NonNull
public static Future<Void> parseWhenScanFinished(@NonNull
                                                         Collection<Source> sources,
                                                         @NonNull
                                                         UserTask userTask)
                                          throws ParseException
Performs the given task when the scan finished. When the background scan is active the task is enqueued and the method returns, the task is performed when the background scan completes by the thread doing the background scan. When no background scan is running the method behaves exactly like the {#link ParserManager#parse}, it performs the given task synchronously (in caller thread). If there is an another UserTask running this method waits until it's completed.

Parameters:
sources - A list of sources that should be parsed.
userTask - A task started when parsing is done.
Returns:
Future which can be used to find out the state of the task Future.isDone() or Future.isCancelled(). The caller may cancel the task using Future.cancel(boolean) or wait until the task is performed Future.get().
Throws:
ParseException - encapsulating the user exception.

parse

public static void parse(@NonNull
                         String mimeType,
                         @NonNull
                         UserTask userTask)
                  throws ParseException
Runs given task in parser thread.

Parameters:
mimetype - specifying the parser
userTask - a user task
Throws:
ParseException - encapsulating the user exception

parseWhenScanFinished

@NonNull
public static Future<Void> parseWhenScanFinished(@NonNull
                                                         String mimeType,
                                                         @NonNull
                                                         UserTask userTask)
                                          throws ParseException
Performs the given task when the scan finished. When the background scan is active the task is enqueued and the method returns, the task is performed when the background scan completes by the thread doing the background scan. When no background scan is running the method behaves exactly like the {#link ParserManager#parse}, it performs the given task synchronously (in caller thread). If there is an another UserTask running this method waits until it's completed.

Parameters:
mimetype - A mimetype specifying the parser.
userTask - A task started when parsing is done.
Returns:
Future which can be used to find out the state of the task Future.isDone() or Future.isCancelled(). The caller may cancel the task using Future.cancel(boolean) or wait until the task is performed Future.get().
Throws:
ParseException - encapsulating the user exception.

org.netbeans.modules.parsing.api/1 1.55.0 6

Built on May 24 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.