本文整理汇总了Java中org.eclipse.jdt.core.Signature.removeCapture方法的典型用法代码示例。如果您正苦于以下问题:Java Signature.removeCapture方法的具体用法?Java Signature.removeCapture怎么用?Java Signature.removeCapture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.Signature
的用法示例。
在下文中一共展示了Signature.removeCapture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: splitTypeLevelsSignature
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* Split signatures of all levels from a type unique key.
*
* <p>Example: For following type X<Y<Z>,V<W>,U>.A<B>, unique key is:
* "LX<LY<LZ;>;LV<LW;>;LU;>.LA<LB;>;"
*
* <p>The return splitted signatures array is: [ ['L','X','<','L','Y','<','L','Z'
* ,';'>',';','L','V','<','L','W',';'>',';','L','U','>',';'], ['L','A','<','L','B',';','>',';']
*
* @param typeSignature ParameterizedSourceType type signature
* @return char[][] Array of signatures for each level of given unique key
*/
public static final char[][] splitTypeLevelsSignature(String typeSignature) {
// In case of IJavaElement signature, replace '$' by '.'
char[] source = Signature.removeCapture(typeSignature.toCharArray());
CharOperation.replace(source, '$', '.');
// Init counters and arrays
char[][] signatures = new char[10][];
int signaturesCount = 0;
// int[] lengthes = new int [10];
int paramOpening = 0;
// Scan each signature character
for (int idx = 0, ln = source.length; idx < ln; idx++) {
switch (source[idx]) {
case '>':
paramOpening--;
if (paramOpening == 0) {
if (signaturesCount == signatures.length) {
System.arraycopy(
signatures, 0, signatures = new char[signaturesCount + 10][], 0, signaturesCount);
}
}
break;
case '<':
paramOpening++;
break;
case '.':
if (paramOpening == 0) {
if (signaturesCount == signatures.length) {
System.arraycopy(
signatures, 0, signatures = new char[signaturesCount + 10][], 0, signaturesCount);
}
signatures[signaturesCount] = new char[idx + 1];
System.arraycopy(source, 0, signatures[signaturesCount], 0, idx);
signatures[signaturesCount][idx] = Signature.C_SEMICOLON;
signaturesCount++;
}
break;
case '/':
source[idx] = '.';
break;
}
}
// Resize signatures array
char[][] typeSignatures = new char[signaturesCount + 1][];
typeSignatures[0] = source;
for (int i = 1, j = signaturesCount - 1; i <= signaturesCount; i++, j--) // NOSONAR
{
typeSignatures[i] = signatures[j];
}
return typeSignatures;
}
示例2: fix83600
import org.eclipse.jdt.core.Signature; //导入方法依赖的package包/类
/**
* TODO this is a temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=83600 and
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=85293
*
* @param signature the method signature to convert
* @return the fixed signature
*/
public static char[] fix83600(char[] signature) {
if (signature == null || signature.length < 2) return signature;
return Signature.removeCapture(signature);
}