public class IncludeHandler extends Object
IncludeHandler
.
IncludeHandler
responsibilities:
IFileSpecification
from an include statement.Modifier and Type | Class and Description |
---|---|
protected static class |
IncludeHandler.Tree
Tree node type for storing include relationships.
|
Constructor and Description |
---|
IncludeHandler(IFileSpecificationGetter fileSpecGetter)
Create an
IncludeHandler . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Reset the state of the include handler by clearing the include chain and
collection of included files.
|
static IncludeHandler |
creatDefaultIncludeHandler()
Create an
IncludeHandler that does not interception of requests
to open included files. |
static IncludeHandler |
create(IFileSpecificationGetter fileSpecGetter,
int startAbsoluteOffset)
Create an
IncludeHandler with a given starting absolute offset. |
static IncludeHandler |
createForASTBuilding(IFileSpecificationGetter fileSpecGetter,
String sourcePath,
int localOffset,
int absoluteOffset)
Create an
IncludeHandler with a given starting absolute offset. |
void |
enterFile(String filename)
Enter an included file.
|
protected int |
getAbsoluteOffset() |
protected IFileSpecification |
getFileSpecificationForInclude(String includer,
String includeString)
Given an the canonical path of a file that contains an include directive
with the specified string, return an
IFileSpecification for the
file the include directive references. |
com.google.common.collect.ImmutableSet<String> |
getIncludedFiles() |
protected String |
getIncludeStackTop()
Get the file on top of the include chain stack.
|
protected IncludeHandler.Tree |
getIncludeTree()
Get a tree of include relationship.
|
long |
getLastModified()
This timestamp will be the latest modification time of all the root
source and all included files
|
com.google.common.collect.ImmutableList<OffsetCue> |
getOffsetCueList()
Get all the
OffsetCue 's. |
void |
handleFileNotFound(IFileSpecification fileSpec)
When a client catches a file not found, they should call us back and let
us know.
|
protected boolean |
isCyclicInclude(String filename)
Check if the file is already on the include chain.
|
void |
leaveFile()
Leave the included file.
|
void |
leaveFile(int endOffset)
Extend the end offset of the current file and leave the file.
|
void |
onNextMXMLUnitData(IMXMLUnitData unitData)
Update the
IncludeHandler 's current offset counter with the next
IMXMLUnitData |
protected void |
onNextToken(ASToken token)
Set the absolute offset on an
ASToken . |
void |
propagateLastModified(IncludeHandler childIncludeHandler)
propagates the lastModified timestamp from a
IncludeHandler from a
child node to this one. |
void |
setProjectAndCompilationUnit(IASProject project,
ICompilationUnit compilationUnit)
Set project reference.
|
String |
toString() |
public IncludeHandler(IFileSpecificationGetter fileSpecGetter)
IncludeHandler
. The workspace
is used to find a
file specification from the workspace file specification pool. If the
workspace is null,
getFileSpecificationForInclude(String, String)
will always
create a new IFileSpecification
result.fileSpecGetter
- IFileSpecificationGetter
that should be
used by the include hander to open included files.public static IncludeHandler create(IFileSpecificationGetter fileSpecGetter, int startAbsoluteOffset)
IncludeHandler
with a given starting absolute offset.
This is useful for creating MXML AST nodes, because MXML node
construction routine doesn't track absolute offsets. Instead, it uses the
OffsetLookup
created by MXMLScopeBuilder
to recover the
absolute offset, and create a "one-time" IncludeHandler
in order
to get the nodes with the same absolute offsets and the definitions.fileSpecGetter
- IFileSpecificationGetter
that should be
used by the include hander to open included files.startAbsoluteOffset
- starting absolute offsetpublic static IncludeHandler creatDefaultIncludeHandler()
IncludeHandler
that does not interception of requests
to open included files.IncludeHandler
that does not interception of requests
to open included files.public static IncludeHandler createForASTBuilding(IFileSpecificationGetter fileSpecGetter, String sourcePath, int localOffset, int absoluteOffset)
IncludeHandler
with a given starting absolute offset.
This is useful for building MXML AST nodes, because MXML node
construction routine doesn't track absolute offsets. Instead, it uses the
OffsetLookup
in MXMLScopeBuilder
to recover the absolute
offset, and mock a "one-time" IncludeHandler
in order to get the
nodes with the same absolute offsets and the definitions.sourcePath
- enter this filelocalOffset
- starting local offsetabsoluteOffset
- starting absolute offsetprotected IFileSpecification getFileSpecificationForInclude(String includer, String includeString)
IFileSpecification
for the
file the include directive references.
includeString
is an absolute path, a
IFileSpecification
for that location will be returned.IASProject
,
the included file path will be resolved firstly in the current directory
of the including file, then in each of the source folders on the project
until the first existing file is found.IFileSpecification
pointing to the intended default location will
be returned.includer
- The canonical path of a file that contains the include
directive.includeString
- Unquoted string that refers to a file to be
included.IFileSpecification
for the included file, or null if
can't resolve.public com.google.common.collect.ImmutableSet<String> getIncludedFiles()
public void clear()
protected String getIncludeStackTop()
public void enterFile(String filename)
filename
- Included file name.public void propagateLastModified(IncludeHandler childIncludeHandler)
IncludeHandler
from a
child node to this one.childIncludeHandler
- The include
-handler whose
timestamp will be used to set the time stap of this include
-handler.public long getLastModified()
public void leaveFile()
public void leaveFile(int endOffset)
endOffset
- Local end offset of the current file, including all
trailing white spaces.protected boolean isCyclicInclude(String filename)
filename
- file nameprotected IncludeHandler.Tree getIncludeTree()
protected void onNextToken(ASToken token)
ASToken
. The absolute offset is the
token's "local" start offset translated into the absolute space.
Advance absolute offset recorded in the handler by one token.
token
- The token to update.public void onNextMXMLUnitData(IMXMLUnitData unitData)
IncludeHandler
's current offset counter with the next
IMXMLUnitData
unitData
- Next IMXMLUnitData
object.protected int getAbsoluteOffset()
public com.google.common.collect.ImmutableList<OffsetCue> getOffsetCueList()
OffsetCue
's.OffsetCue
objects.public final void setProjectAndCompilationUnit(IASProject project, ICompilationUnit compilationUnit)
project
- Current project.public void handleFileNotFound(IFileSpecification fileSpec)
fileSpec
- A file specification.Copyright © 2016 The Apache Software Foundation. All rights reserved.