当前位置: 首页>>代码示例>>Java>>正文


Java Signature.removeCapture方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:66,代码来源:Util.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:SignatureUtil.java


注:本文中的org.eclipse.jdt.core.Signature.removeCapture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。