public class SourceMapper extends ReferenceInfoAdapter implements ISourceElementRequestor, SuffixConstants
JarPackageFragment| Modifier and Type | Class and Description |
|---|---|
static class |
SourceMapper.LocalVariableElementKey |
ISourceElementRequestor.FieldInfo, ISourceElementRequestor.MethodInfo, ISourceElementRequestor.ParameterInfo, ISourceElementRequestor.TypeInfo, ISourceElementRequestor.TypeParameterInfo| Modifier and Type | Field and Description |
|---|---|
protected BinaryType |
binaryType
The binary type source is being mapped for
|
protected java.util.HashMap |
categories |
protected java.util.HashSet |
finalParameters
Set that contains all final local variables.
|
protected int[] |
memberDeclarationStart
The position within the source of the start of the
current member element, or -1 if we are outside a member.
|
protected java.lang.String[] |
memberName
The name of the current member element.
|
protected SourceRange[] |
memberNameRange
The
SourceRange of the name of the current member element. |
protected char[][][] |
methodParameterNames
The parameter names for the current member method element.
|
protected char[][][] |
methodParameterTypes
The parameter types for the current member method element.
|
protected java.util.HashMap |
parameterNames
Table that maps a binary method to its parameter names.
|
protected java.util.HashMap |
parametersRanges
Table that contains all source ranges for local variables.
|
protected java.lang.String |
rootPath
Specifies the location of the package fragment root within
the zip (empty specifies the default root).
|
protected java.util.ArrayList |
rootPaths
Specifies the location of the package fragment roots within
the zip (empty specifies the default root).
|
protected IJavaElement |
searchedElement
The element searched for
|
protected IPath |
sourcePath
The location of the zip file containing source.
|
protected java.util.HashMap |
sourceRanges
Table that maps a binary element to its
SourceRanges. |
static SourceRange |
UNKNOWN_RANGE
The unknown source range {-1, 0}
|
static boolean |
VERBOSE |
EXTENSION_aj, EXTENSION_AJ, EXTENSION_class, EXTENSION_CLASS, EXTENSION_java, EXTENSION_JAVA, SUFFIX_aj, SUFFIX_AJ, SUFFIX_class, SUFFIX_CLASS, SUFFIX_java, SUFFIX_JAVA, SUFFIX_STRING_aj, SUFFIX_STRING_AJ, SUFFIX_STRING_class, SUFFIX_STRING_CLASS, SUFFIX_STRING_java, SUFFIX_STRING_JAVA| Constructor and Description |
|---|
SourceMapper() |
SourceMapper(IPath sourcePath,
java.lang.String rootPath,
java.util.Map options) |
SourceMapper(IPath sourcePath,
java.lang.String rootPath,
java.util.Map options,
java.lang.String encoding)
Creates a
SourceMapper that locates source in the zip file
at the given location in the specified package fragment root. |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptImport(int declarationStart,
int declarationEnd,
int nameStart,
int nameEnd,
char[][] tokens,
boolean onDemand,
int modifiers) |
void |
acceptLineSeparatorPositions(int[] positions) |
void |
acceptPackage(ImportReference importReference) |
void |
acceptProblem(CategorizedProblem problem) |
void |
close()
Closes this
SourceMapper's zip file. |
java.lang.String[] |
convertTypeNamesToSigs(char[][] typeNames)
NOT API, public only for access by Unit tests.
|
void |
enterCompilationUnit() |
void |
enterConstructor(ISourceElementRequestor.MethodInfo methodInfo) |
void |
enterField(ISourceElementRequestor.FieldInfo fieldInfo) |
void |
enterInitializer(int declarationSourceStart,
int modifiers) |
void |
enterMethod(ISourceElementRequestor.MethodInfo methodInfo) |
void |
enterType(ISourceElementRequestor.TypeInfo typeInfo) |
void |
exitCompilationUnit(int declarationEnd) |
void |
exitConstructor(int declarationEnd) |
void |
exitField(int initializationStart,
int declarationEnd,
int declarationSourceEnd) |
void |
exitInitializer(int declarationEnd) |
void |
exitMethod(int declarationEnd,
Expression defaultValue) |
void |
exitType(int declarationEnd) |
char[] |
findSource(IType type,
IBinaryType info)
Locates and returns source code for the given (binary) type, in this
SourceMapper's ZIP file, or returns
null if source
code cannot be found. |
char[] |
findSource(IType type,
java.lang.String simpleSourceFileName)
Locates and returns source code for the given (binary) type, in this
SourceMapper's ZIP file, or returns
null if source
code cannot be found. |
char[] |
findSource(java.lang.String fullName) |
int |
getFlags(IJavaElement element) |
char[][] |
getImports(BinaryType type)
Return a char[][] array containing the imports of the attached source for the binary type
|
char[][] |
getMethodParameterNames(IMethod method)
Returns parameters names for the given method, or
null if no parameter names are known for the method.
|
SourceRange |
getNameRange(IJavaElement element)
Returns the SourceRange for the name of the given element, or
{-1, -1} if no source range is known for the name of the element.
|
SourceRange |
getSourceRange(IJavaElement element)
Returns the
SourceRange for the given element, or
{-1, -1} if no source range is known for the element. |
protected IType |
getType(java.lang.String typeName)
Returns the type with the given
typeName. |
protected IJavaElement[] |
getUnqualifiedMethodHandle(IMethod method,
boolean noDollar)
Creates a handle that has parameter types that are not
fully qualified so that the correct source is found.
|
void |
mapSource(IType type,
char[] contents,
IBinaryType info)
Maps the given source code to the given binary type and its children.
|
ISourceRange |
mapSource(IType type,
char[] contents,
IBinaryType info,
IJavaElement elementToFind)
Maps the given source code to the given binary type and its children.
|
protected void |
setMethodParameterNames(IMethod method,
char[][] parameterNames)
Sets the mapping for this method to its parameter names.
|
protected void |
setSourceRange(IJavaElement element,
SourceRange sourceRange,
SourceRange nameRange)
Sets the mapping for this element to its source ranges for its source range
and name range.
|
acceptAnnotationTypeReference, acceptAnnotationTypeReference, acceptConstructorReference, acceptFieldReference, acceptMethodReference, acceptTypeReference, acceptTypeReference, acceptUnknownReference, acceptUnknownReferenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacceptAnnotationTypeReference, acceptAnnotationTypeReference, acceptConstructorReference, acceptFieldReference, acceptMethodReference, acceptTypeReference, acceptTypeReference, acceptUnknownReference, acceptUnknownReferencepublic static boolean VERBOSE
protected java.util.ArrayList rootPaths
null is
not a valid root path.protected BinaryType binaryType
protected IPath sourcePath
protected java.lang.String rootPath
null is
not a valid root path.protected java.util.HashMap parameterNames
char[][].protected java.util.HashMap sourceRanges
SourceRanges.
Keys are the element handles, entries are SourceRange[] which
is a two element array; the first being source range, the second
being name range.protected java.util.HashMap categories
protected java.util.HashMap parametersRanges
char[][].protected java.util.HashSet finalParameters
public static final SourceRange UNKNOWN_RANGE
protected int[] memberDeclarationStart
protected SourceRange[] memberNameRange
SourceRange of the name of the current member element.protected java.lang.String[] memberName
protected char[][][] methodParameterNames
protected char[][][] methodParameterTypes
protected IJavaElement searchedElement
public SourceMapper()
public SourceMapper(IPath sourcePath,
java.lang.String rootPath,
java.util.Map options)
public SourceMapper(IPath sourcePath,
java.lang.String rootPath,
java.util.Map options,
java.lang.String encoding)
SourceMapper that locates source in the zip file
at the given location in the specified package fragment root.public void acceptImport(int declarationStart,
int declarationEnd,
int nameStart,
int nameEnd,
char[][] tokens,
boolean onDemand,
int modifiers)
acceptImport in interface ISourceElementRequestordeclarationStart - This is the position of the first character of the import
keyword.declarationEnd - This is the position of the ';' ending the import statement or
the end of the comment following the import.nameStart - This is the position of the first character of the import declaration's
name.nameEnd - This is the position of the last character of the import declaration's
name.tokens - This are the tokens of the import like specified in the source.onDemand - set to true if the import is an import on demand (e.g. import
java.io.*). False otherwise.modifiers - can be set to static from 1.5 on.ISourceElementRequestorpublic void acceptLineSeparatorPositions(int[] positions)
acceptLineSeparatorPositions in interface ISourceElementRequestorISourceElementRequestorpublic void acceptPackage(ImportReference importReference)
acceptPackage in interface ISourceElementRequestorISourceElementRequestorpublic void acceptProblem(CategorizedProblem problem)
acceptProblem in interface ISourceElementRequestorISourceElementRequestorpublic void close()
SourceMapper's zip file. Once this is done, this
SourceMapper cannot be used again.public java.lang.String[] convertTypeNamesToSigs(char[][] typeNames)
public void enterType(ISourceElementRequestor.TypeInfo typeInfo)
enterType in interface ISourceElementRequestorISourceElementRequestorpublic void enterCompilationUnit()
enterCompilationUnit in interface ISourceElementRequestorISourceElementRequestorpublic void enterConstructor(ISourceElementRequestor.MethodInfo methodInfo)
enterConstructor in interface ISourceElementRequestorISourceElementRequestorpublic void enterField(ISourceElementRequestor.FieldInfo fieldInfo)
enterField in interface ISourceElementRequestorISourceElementRequestorpublic void enterInitializer(int declarationSourceStart,
int modifiers)
enterInitializer in interface ISourceElementRequestorISourceElementRequestorpublic void enterMethod(ISourceElementRequestor.MethodInfo methodInfo)
enterMethod in interface ISourceElementRequestorISourceElementRequestorpublic void exitType(int declarationEnd)
exitType in interface ISourceElementRequestorISourceElementRequestorpublic void exitCompilationUnit(int declarationEnd)
exitCompilationUnit in interface ISourceElementRequestorISourceElementRequestorpublic void exitConstructor(int declarationEnd)
exitConstructor in interface ISourceElementRequestorISourceElementRequestorpublic void exitField(int initializationStart,
int declarationEnd,
int declarationSourceEnd)
exitField in interface ISourceElementRequestorISourceElementRequestorpublic void exitInitializer(int declarationEnd)
exitInitializer in interface ISourceElementRequestorISourceElementRequestorpublic void exitMethod(int declarationEnd,
Expression defaultValue)
exitMethod in interface ISourceElementRequestorISourceElementRequestorpublic char[] findSource(IType type, IBinaryType info)
null if source
code cannot be found.public char[] findSource(IType type, java.lang.String simpleSourceFileName)
null if source
code cannot be found.
The given simpleSourceFileName is the .java file name (without the enclosing
folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class)public char[] findSource(java.lang.String fullName)
public int getFlags(IJavaElement element)
public SourceRange getNameRange(IJavaElement element)
public char[][] getMethodParameterNames(IMethod method)
public SourceRange getSourceRange(IJavaElement element)
SourceRange for the given element, or
{-1, -1} if no source range is known for the element.protected IType getType(java.lang.String typeName)
typeName. Returns inner classes
as well.protected IJavaElement[] getUnqualifiedMethodHandle(IMethod method, boolean noDollar)
public void mapSource(IType type, char[] contents, IBinaryType info)
public ISourceRange mapSource(IType type, char[] contents, IBinaryType info, IJavaElement elementToFind)
protected void setMethodParameterNames(IMethod method, char[][] parameterNames)
parameterNamesprotected void setSourceRange(IJavaElement element, SourceRange sourceRange, SourceRange nameRange)
sourceRangespublic char[][] getImports(BinaryType type)