Class Util
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.util.Util
Provides convenient utility methods to other types in this package.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic final String[]arrayConcat(String[] first, String second) Returns a new array adding the second array at the end of first array.static intcombineHashCodes(int hashCode1, int hashCode2) Combines two hash codes to make a new one.static intcompare(byte[] a, byte[] b) Compares two byte arrays.static intcompare(char[] str1, char[] str2) Compares two strings lexicographically.static final char[]concat(char[] first, char[] second) static char[]concatCompoundNameToCharArray(String[] compoundName) Concatenate a String[] compound name to a continuous char[].static StringconcatenateName(String name1, String name2, char separator) static final StringconcatWith(String[] array, char separator) Returns the concatenation of the given array parts using the given separator between each part.static final StringconcatWith(String[] array, String name, char separator) Returns the concatenation of the given array parts using the given separator between each part and appending the given name at the end.static StringconvertTypeSignature(char[] sig, int start, int length) Converts a type signature from the IBinaryType representation to the DC representation.static Stringstatic final StringeditedString(String original, org.eclipse.text.edits.TextEdit edit) Apply the given edit on the given string and return the updated string.static final booleanendsWithIgnoreCase(String str, String end) Returns true iff str.toLowerCase().endsWith(end.toLowerCase()) implementation is not creating extra strings.static booleanequalArrays(Object[] a, Object[] b, int len) Compares two arrays using equals() on the elements.static booleanequalArraysOrNull(int[] a, int[] b) Compares two arrays using equals() on the elements.static booleanequalArraysOrNull(Object[] a, Object[] b) Compares two arrays using equals() on the elements.static booleanequalArraysOrNullSortFirst(String[] a, String[] b) Compares two String arrays using equals() on the elements.static booleanCompares two arrays using equals() on the elements.static booleanequalOrNull(Object a, Object b) Compares two objects using equals().static booleanequalsIgnoreJavaLikeExtension(String fileName, String string) static StringextractLastName(String qualifiedName) Given a qualified name, extract the last component.static String[]extractParameterTypes(char[] sig) Extracts the parameter types from a method signature.static StringextractReturnType(String sig) Extracts the return type from a method signature.static StringfindLineSeparator(char[] text) Finds the first line separator used by the given text.static IMethodfindMethod(IType type, char[] selector, String[] paramTypeSignatures, boolean isConstructor) Finds the IMethod element corresponding to the given selector, without creating a new dummy instance of a binary method.static voidfixTaskTags(Map defaultOptionsMap) static final char[][][]getAllTypeArguments(char[][] typeSignatures) Get all type arguments from an array of signatures.static IAnnotationgetAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) static ObjectgetAnnotationMemberValue(JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) static ObjectgetAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) static IClassFileAttributegetAttribute(IClassFileReader classFileReader, char[] attributeName) static IClassFileAttributegetAttribute(ICodeAttribute codeAttribute, char[] attributeName) static IClassFileAttributegetAttribute(IComponentInfo componentInfo, char[] attributeName) static IClassFileAttributegetAttribute(IFieldInfo fieldInfo, char[] attributeName) static IClassFileAttributegetAttribute(IMethodInfo methodInfo, char[] attributeName) static Stringstatic char[][]Returns the registered Java like extensions.static longgetJdkLevel(Object targetLibrary) Get the jdk level of this root.static StringgetLineSeparator(String text, IJavaProject project) Returns the line separator found in the given text.static StringgetNameWithoutJavaLikeExtension(String fileName) Returns the substring of the given file name, ending at the start of a Java like extension.static ObjectgetNegativeAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) static IPackageFragmentgetPackageFragment(char[] fileName, int pkgEnd, int jarSeparator) static intgetParameterCount(char[] sig) Returns the number of parameter types in a method signature.static StringgetProblemArgumentsForMarker(String[] arguments) Put all the arguments in one String.static String[]getProblemArgumentsFromMarker(String argumentsString) Separate all the arguments of a String made by getProblemArgumentsForMarkerstatic byte[]getResourceContentsAsByteArray(org.eclipse.core.resources.IFile file) Returns the given file's contents as a byte array.static char[]getResourceContentsAsCharArray(org.eclipse.core.resources.IFile file) Returns the given file's contents as a character array.static char[]getResourceContentsAsCharArray(org.eclipse.core.resources.IFile file, String encoding) static StringgetSignature(Type type) static StringgetSourceAttachmentProperty(org.eclipse.core.runtime.IPath path) static String[]getTrimmedSimpleNames(String name) Returns a trimmed version the simples names returned by Signature.static JavaElementgetUnresolvedJavaElement(int localSourceStart, int localSourceEnd, JavaElement type) Returns the IInitializer that contains the given local variable in the given typestatic JavaElementgetUnresolvedJavaElement(FieldBinding binding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding.static JavaElementgetUnresolvedJavaElement(MethodBinding methodBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding.static JavaElementgetUnresolvedJavaElement(RecordComponentBinding binding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding.static JavaElementgetUnresolvedJavaElement(TypeBinding typeBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding.static intindexOfEnclosingPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) static intindexOfJavaLikeExtension(String fileName) static intindexOfMatchingPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) static intindexOfNestedPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) protected static booleanisAttributeSupported(int attribute) Returns whether the local file system supports accessing and modifying the given attribute.static final booleanisExcluded(IJavaElement element) static final booleanisExcluded(org.eclipse.core.resources.IResource resource, char[][] inclusionPatterns, char[][] exclusionPatterns) static final booleanisExcluded(org.eclipse.core.runtime.IPath resourcePath, char[][] inclusionPatterns, char[][] exclusionPatterns, boolean isFolderPath) static final booleanisJavaLikeFileName(char[] fileName) Returns true if the given name ends with one of the known java like extension.static final booleanisJavaLikeFileName(String name) Returns true if the given name ends with one of the known java like extension.static booleanisReadOnly(org.eclipse.core.resources.IResource resource) Returns whether the given resource is read-only or not.static booleanReturns whether the local file system supports accessing and modifying the read only flag.static booleanisValidClassFileName(String name, String sourceLevel, String complianceLevel) Validate the given .class file name.static booleanisValidCompilationUnitName(String name, String sourceLevel, String complianceLevel) Validate the given compilation unit name.static booleanisValidFolderNameForPackage(String folderName, String sourceLevel, String complianceLevel) Returns true if the given folder name is valid for a package, false if it is not.static booleanReturns true if the given method signature is valid, false if it is not.static booleanisValidTypeSignature(String sig, boolean allowVoid) Returns true if the given type signature is valid, false if it is not.static StringlocalTypeName(String binaryTypeName, int lastDollar, int end) static voidstatic voidstatic voidstatic voidlog(org.eclipse.core.runtime.IStatus status) static voidlogRepeatedMessage(String key, int statusErrorID, String message) static voidlogRepeatedMessage(String key, Exception e) Log a message that is potentially repeated in the same session.static ClassFileReadernewClassFileReader(org.eclipse.core.resources.IResource resource) static char[]normalizeCRs(char[] text, char[] buffer) Normalizes the cariage returns in the given text.static StringnormalizeCRs(String text, String buffer) Normalizes the carriage returns in the given text.static StringpackageName(org.eclipse.core.runtime.IPath pkgPath, String sourceLevel, String complianceLevel) Converts the given relative path into a package name.static intprefixLength(char[] s1, char[] s2) Returns the length of the common prefix between s1 and s2.static intprefixLength(String s1, String s2) Returns the length of the common prefix between s1 and s2.static StringrelativePath(org.eclipse.core.runtime.IPath fullPath, int skipSegmentCount) Returns the toString() of the given full path minus the first given number of segments.static voidstatic intscanTypeSignature(char[] string, int start) Scans the given string for a type signature starting at the given index and returns the index of the last character.static voidsetReadOnly(org.eclipse.core.resources.IResource resource, boolean readOnly) Sets or unsets the given resource as read-only in the file system.static voidsetSourceAttachmentProperty(org.eclipse.core.runtime.IPath path, String property) static voidsort(char[][] list) static voidsort(int[] list) static voidsort(Object[] objects, Util.Comparer comparer) Sorts an array of objects in place.static voidSorts an array of strings in place using quicksort.static voidsort(Util.Comparable[] objects) Sorts an array of Comparable objects in place.static Object[]sortCopy(Object[] objects, Util.Comparer comparer) Sorts an array of Strings, returning a new array with the sorted items.static String[]Sorts an array of Strings, returning a new array with the sorted items.static IJavaElement[]sortCopy(IJavaElement[] elements) Sorts an array of Java elements based on their toStringWithAncestors(), returning a new array with the sorted items.static Util.Comparable[]sortCopy(Util.Comparable[] objects) Sorts an array of Comparable objects, returning a new array with the sorted items.static final String[]Return a new array which is the split of the given string using the given divider.static final char[][]splitTypeLevelsSignature(String typeSignature) Split signatures of all levels from a type unique key.static booleanstartsWithIgnoreCase(String[] compoundName, String[] prefix, boolean partialMatch) static char[]toAnchor(int startingIndex, char[] methodSignature, char[] methodName, boolean isVargArgs) static Stringstatic char[][]toCharArrays(String[] a) Converts a String[] to char[][].static char[][]Converts a String to char[][], where segments are separate by '.'.static FiletoLocalFile(URI uri, org.eclipse.core.runtime.IProgressMonitor monitor) static StringtoString(char[][] c) Converts a char[][] to String, where segments are separated by '.'.static StringtoString(char[][] c, char[] d) Converts a char[][] and a char[] to String, where segments are separated by '.'.static StringtoString(char[] declaringClass, char[] methodName, char[] methodSignature, boolean includeReturnType, boolean compact) static String[]toStrings(char[][] a) static String[]static StringtypeSignature(TypeReference type) static voidAsserts that the given method signature is valid.static voidvalidateTypeSignature(String sig, boolean allowVoid) Asserts that the given type signature is valid.
-
Method Details
-
arrayConcat
Returns a new array adding the second array at the end of first array. It answers null if the first and second are null. If the first array is null or if it is empty, then a new array is created with second. If the second array is null, then the first array is returned.
For example:first = null second = "a" => result = {"a"}first = {"a"} second = null => result = {"a"}first = {"a"} second = {"b"} => result = {"a", "b"}
- Parameters:
first- the first array to concatenatesecond- the array to add at the end of the first array- Returns:
- a new array adding the second array at the end of first array, or null if the two arrays are null.
-
combineHashCodes
public static int combineHashCodes(int hashCode1, int hashCode2) Combines two hash codes to make a new one. -
compare
public static int compare(byte[] a, byte[] b) Compares two byte arrays. Returns<0if a byte in a is less than the corresponding byte in b, or if a is shorter, or if a is null. Returns>0if a byte in a is greater than the corresponding byte in b, or if a is longer, or if b is null. Returns0if they are equal or both null. -
compare
public static int compare(char[] str1, char[] str2) Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings.- Returns:
- the value
0if the str1 is equal to str2; a value less than0if str1 is lexicographically less than str2; and a value greater than0if str1 is lexicographically greater than str2.
-
concatCompoundNameToCharArray
Concatenate a String[] compound name to a continuous char[]. -
concatenateName
-
concatWith
Returns the concatenation of the given array parts using the given separator between each part.
For example:
array = {"a", "b"} separator = '.' => result = "a.b"array = {} separator = '.' => result = ""
- Parameters:
array- the given arrayseparator- the given separator- Returns:
- the concatenation of the given array parts using the given separator between each part
-
concatWith
Returns the concatenation of the given array parts using the given separator between each part and appending the given name at the end.
For example:
name = "c" array = { "a", "b" } separator = '.' => result = "a.b.c"name = null array = { "a", "b" } separator = '.' => result = "a.b"name = " c" array = null separator = '.' => result = "c"
- Parameters:
array- the given arrayname- the given nameseparator- the given separator- Returns:
- the concatenation of the given array parts using the given separator between each part and appending the given name at the end
-
concat
public static final char[] concat(char[] first, char[] second) -
convertTypeSignature
Converts a type signature from the IBinaryType representation to the DC representation. -
defaultJavaExtension
-
editedString
Apply the given edit on the given string and return the updated string. Return the given string if anything wrong happen while applying the edit.- Parameters:
original- the given stringedit- the given edit- Returns:
- the updated string
-
endsWithIgnoreCase
-
equalArrays
-
equalArraysOrNull
public static boolean equalArraysOrNull(int[] a, int[] b) Compares two arrays using equals() on the elements. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and all elements are equal. -
equalArraysOrNull
Compares two arrays using equals() on the elements. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and all elements compare true with equals. -
equalArraysOrNullSortFirst
Compares two arrays using equals() on the elements. The arrays are first sorted. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and iff, after sorting both arrays, all elements compare true with equals. The original arrays are left untouched. -
equalArraysOrNullSortFirst
Compares two String arrays using equals() on the elements. The arrays are first sorted. Either or both arrays may be null. Returns true if both are null. Returns false if only one is null. If both are arrays, returns true iff they have the same length and iff, after sorting both arrays, all elements compare true with equals. The original arrays are left untouched. -
equalOrNull
-
equalsIgnoreJavaLikeExtension
-
extractLastName
-
extractParameterTypes
Extracts the parameter types from a method signature. -
extractReturnType
-
findLineSeparator
Finds the first line separator used by the given text.- Returns:
"\n"or"\r"or"\r\n", ornullif none found
-
getAttribute
public static IClassFileAttribute getAttribute(IClassFileReader classFileReader, char[] attributeName) -
getAttribute
-
getAttribute
-
getAttribute
-
getAttribute
-
getJavaLikeExtensions
public static char[][] getJavaLikeExtensions()Returns the registered Java like extensions. -
getJdkLevel
Get the jdk level of this root. The value can be:major<<16 + minor: see predefined constants on ClassFileConstants0if the root is a source package fragment root or if a Java model exception occured
-
getNameWithoutJavaLikeExtension
-
getLineSeparator
Returns the line separator found in the given text. If it is null, or not found return the line delimiter for the given project. If the project is null, returns the line separator for the workspace. If still null, return the system line separator. -
getPackageFragment
-
getParameterCount
public static int getParameterCount(char[] sig) Returns the number of parameter types in a method signature. -
getProblemArgumentsForMarker
-
getProblemArgumentsFromMarker
-
getResourceContentsAsByteArray
public static byte[] getResourceContentsAsByteArray(org.eclipse.core.resources.IFile file) throws JavaModelException Returns the given file's contents as a byte array.- Throws:
JavaModelException
-
getResourceContentsAsCharArray
public static char[] getResourceContentsAsCharArray(org.eclipse.core.resources.IFile file) throws JavaModelException Returns the given file's contents as a character array.- Throws:
JavaModelException
-
getResourceContentsAsCharArray
public static char[] getResourceContentsAsCharArray(org.eclipse.core.resources.IFile file, String encoding) throws JavaModelException - Throws:
JavaModelException
-
getSignature
-
getSourceAttachmentProperty
public static String getSourceAttachmentProperty(org.eclipse.core.runtime.IPath path) throws JavaModelException - Throws:
JavaModelException
-
setSourceAttachmentProperty
public static void setSourceAttachmentProperty(org.eclipse.core.runtime.IPath path, String property) -
getDeclaringTypeSignature
-
getTrimmedSimpleNames
-
getUnresolvedJavaElement
public static JavaElement getUnresolvedJavaElement(FieldBinding binding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding. -
getUnresolvedJavaElement
public static JavaElement getUnresolvedJavaElement(RecordComponentBinding binding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding. -
getUnresolvedJavaElement
public static JavaElement getUnresolvedJavaElement(int localSourceStart, int localSourceEnd, JavaElement type) Returns the IInitializer that contains the given local variable in the given type -
getUnresolvedJavaElement
public static JavaElement getUnresolvedJavaElement(MethodBinding methodBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding. -
getUnresolvedJavaElement
public static JavaElement getUnresolvedJavaElement(TypeBinding typeBinding, WorkingCopyOwner workingCopyOwner, Util.BindingsToNodesMap bindingsToNodes) Return the java element corresponding to the given compiler binding. -
indexOfEnclosingPath
public static int indexOfEnclosingPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) -
indexOfJavaLikeExtension
-
indexOfMatchingPath
public static int indexOfMatchingPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) -
indexOfNestedPath
public static int indexOfNestedPath(org.eclipse.core.runtime.IPath checkedPath, org.eclipse.core.runtime.IPath[] paths, int pathCount) -
isAttributeSupported
protected static boolean isAttributeSupported(int attribute) Returns whether the local file system supports accessing and modifying the given attribute. -
isReadOnly
public static boolean isReadOnly(org.eclipse.core.resources.IResource resource) Returns whether the given resource is read-only or not.- Returns:
trueif the resource is read-only,falseif it is not or if the file system does not support the read-only attribute.
-
isReadOnlySupported
public static boolean isReadOnlySupported()Returns whether the local file system supports accessing and modifying the read only flag. -
isExcluded
-
isExcluded
public static final boolean isExcluded(org.eclipse.core.runtime.IPath resourcePath, char[][] inclusionPatterns, char[][] exclusionPatterns, boolean isFolderPath) -
isExcluded
public static final boolean isExcluded(org.eclipse.core.resources.IResource resource, char[][] inclusionPatterns, char[][] exclusionPatterns) -
isValidClassFileName
Validate the given .class file name. A .class file name must obey the following rules:- it must not be null
- it must include the
".class"suffix - its prefix must be a valid identifier
- Parameters:
name- the name of a .class filesourceLevel- the source levelcomplianceLevel- the compliance level- Returns:
- a status object with code
IStatus.OKif the given name is valid as a .class file name, otherwise a status object indicating what is wrong with the name
-
isValidCompilationUnitName
public static boolean isValidCompilationUnitName(String name, String sourceLevel, String complianceLevel) Validate the given compilation unit name. A compilation unit name must obey the following rules:- it must not be null
- it must include the
".java"suffix - its prefix must be a valid identifier
- Parameters:
name- the name of a compilation unitsourceLevel- the source levelcomplianceLevel- the compliance level- Returns:
- a status object with code
IStatus.OKif the given name is valid as a compilation unit name, otherwise a status object indicating what is wrong with the name
-
isValidFolderNameForPackage
public static boolean isValidFolderNameForPackage(String folderName, String sourceLevel, String complianceLevel) Returns true if the given folder name is valid for a package, false if it is not.- Parameters:
folderName- the name of the foldersourceLevel- the source levelcomplianceLevel- the compliance level
-
isValidMethodSignature
Returns true if the given method signature is valid, false if it is not. -
isValidTypeSignature
Returns true if the given type signature is valid, false if it is not. -
localTypeName
-
log
-
logRepeatedMessage
Log a message that is potentially repeated in the same session. The first time this method is called with a given exception, the exception stack trace is written to the log.Only intended for use in debug statements.
- Parameters:
key- the given keye- the given exception- Throws:
IllegalArgumentException- if the given key is null
-
logRepeatedMessage
-
log
-
log
public static void log(org.eclipse.core.runtime.IStatus status) -
log
-
newClassFileReader
public static ClassFileReader newClassFileReader(org.eclipse.core.resources.IResource resource) throws org.eclipse.core.runtime.CoreException, ClassFormatException, IOException - Throws:
org.eclipse.core.runtime.CoreExceptionClassFormatExceptionIOException
-
normalizeCRs
public static char[] normalizeCRs(char[] text, char[] buffer) Normalizes the cariage returns in the given text. They are all changed to use the given buffer's line separator. -
normalizeCRs
-
packageName
public static String packageName(org.eclipse.core.runtime.IPath pkgPath, String sourceLevel, String complianceLevel) Converts the given relative path into a package name. Returns null if the path is not a valid package name.- Parameters:
pkgPath- the package pathsourceLevel- the source levelcomplianceLevel- the compliance level
-
prefixLength
public static int prefixLength(char[] s1, char[] s2) Returns the length of the common prefix between s1 and s2. -
prefixLength
-
relativePath
Returns the toString() of the given full path minus the first given number of segments. The returned string is always a relative path (it has no leading slash) -
resetJavaLikeExtensions
public static void resetJavaLikeExtensions() -
scanTypeSignature
public static int scanTypeSignature(char[] string, int start) Scans the given string for a type signature starting at the given index and returns the index of the last character.TypeSignature: | BaseTypeSignature | ArrayTypeSignature | ClassTypeSignature | TypeVariableSignature
- Parameters:
string- the signature stringstart- the 0-based character index of the first character- Returns:
- the 0-based character index of the last character
- Throws:
IllegalArgumentException- if this is not a type signature
-
splitOn
Return a new array which is the split of the given string using the given divider. The given end is exclusive and the given start is inclusive.
For example:divider = 'b' string = "abbaba" start = 2 end = 5 result => { "", "a", "" }
- Parameters:
divider- the given dividerstring- the given stringstart- the given starting indexend- the given ending index- Returns:
- a new array which is the split of the given string using the given divider
- Throws:
ArrayIndexOutOfBoundsException- if start is lower than 0 or end is greater than the array length
-
setReadOnly
public static void setReadOnly(org.eclipse.core.resources.IResource resource, boolean readOnly) Sets or unsets the given resource as read-only in the file system. It's a no-op if the file system does not support the read-only attribute.- Parameters:
resource- The resource to set as read-onlyreadOnly-trueto set it to read-only,falseto unset
-
sort
public static void sort(char[][] list) -
sort
Sorts an array of Comparable objects in place. -
sort
public static void sort(int[] list) -
sort
Sorts an array of objects in place. The given comparer compares pairs of items. -
sort
Sorts an array of strings in place using quicksort. -
sortCopy
Sorts an array of Comparable objects, returning a new array with the sorted items. The original array is left untouched. -
sortCopy
Sorts an array of Java elements based on their toStringWithAncestors(), returning a new array with the sorted items. The original array is left untouched. -
sortCopy
Sorts an array of Strings, returning a new array with the sorted items. The original array is left untouched. -
sortCopy
-
startsWithIgnoreCase
-
toCharArrays
Converts a String[] to char[][]. -
toCompoundChars
Converts a String to char[][], where segments are separate by '.'. -
toLocalFile
-
toString
Converts a char[][] to String, where segments are separated by '.'. -
toString
Converts a char[][] and a char[] to String, where segments are separated by '.'. -
toStrings
-
toString
public static String toString(char[] declaringClass, char[] methodName, char[] methodSignature, boolean includeReturnType, boolean compact) -
typeParameterSignatures
-
typeSignature
-
validateMethodSignature
Asserts that the given method signature is valid. -
validateTypeSignature
Asserts that the given type signature is valid. -
isJavaLikeFileName
Returns true if the given name ends with one of the known java like extension. (implementation is not creating extra strings) -
isJavaLikeFileName
public static final boolean isJavaLikeFileName(char[] fileName) Returns true if the given name ends with one of the known java like extension. (implementation is not creating extra strings) -
getAllTypeArguments
public static final char[][][] getAllTypeArguments(char[][] typeSignatures) Get all type arguments from an array of signatures. Example:
seeFor following type X<Y<Z>,V<W>,U>.A<B> signatures is: [ ['L','X','<','L','Y','<','L','Z',';'>',';','L','V','<','L','W',';'>',';','L','U',';',>',';'], ['L','A','<','L','B',';','>',';'] ]splitTypeLevelsSignature(String)Then, this method returns:[ [ ['L','Y','<','L','Z',';'>',';'], ['L','V','<','L','W',';'>',';'], ['L','U',';'] ], [ ['L','B',';'] ] ]- Parameters:
typeSignatures- Array of signatures (one per each type levels)- Returns:
- char[][][] Array of type arguments for each signature
- Throws:
IllegalArgumentException- If one of provided signature is malformed
-
getAnnotation
public static IAnnotation getAnnotation(JavaElement parent, IBinaryAnnotation binaryAnnotation, String memberValuePairName) -
getAnnotationMemberValue
public static Object getAnnotationMemberValue(JavaElement parent, MemberValuePair memberValuePair, Object binaryValue) -
getAnnotationMemberValue
-
getNegativeAnnotationMemberValue
public static Object getNegativeAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) -
splitTypeLevelsSignature
Split signatures of all levels from a type unique key. Example:
The return splitted signatures array is:For following type X<Y<Z>,V<W>,U>.A<B>, unique key is: "LX<LY<LZ;>;LV<LW;>;LU;>.LA<LB;>;"['L','X','<','L','Y','<','L','Z',';'>',';','L','V','<','L','W',';'>',';','L','U','>',';'], ['L','A','<','L','B',';','>',';']- Parameters:
typeSignature- ParameterizedSourceType type signature- Returns:
- char[][] Array of signatures for each level of given unique key
-
toAnchor
-
toAnchor
public static char[] toAnchor(int startingIndex, char[] methodSignature, char[] methodName, boolean isVargArgs) -
fixTaskTags
-
findMethod
public static IMethod findMethod(IType type, char[] selector, String[] paramTypeSignatures, boolean isConstructor) throws JavaModelException Finds the IMethod element corresponding to the given selector, without creating a new dummy instance of a binary method.- Parameters:
type- the type in which the method is declaredselector- the method nameparamTypeSignatures- the type signatures of the method argumentsisConstructor- whether we're looking for a constructor- Returns:
- an IMethod if found, otherwise null
- Throws:
JavaModelException
-