org.eclipse.jdt.core.Signature.toCharArray()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.eclipse.jdt.core.Signature.toCharArray()方法的一些代码示例,展示了Signature.toCharArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Signature.toCharArray()方法的具体详情如下:
包路径:org.eclipse.jdt.core.Signature
类名称:Signature
方法名:toCharArray

Signature.toCharArray介绍

[英]Converts the given type signature to a readable string. The signature is expected to be dot-based.

For example:

toString({'[', 'L', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', ';'}) -> {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '[', ']'} 
toString({'I'}) -> {'i', 'n', 't'} 
toString({'+', 'L', 'O', 'b', 'j', 'e', 'c', 't', ';'}) -> {'?', ' ', 'e', 'x', 't', 'e', 'n', 'd', 's', ' ', 'O', 'b', 'j', 'e', 'c', 't'}

Note: This method assumes that a type signature containing a '$' is an inner type signature. While this is correct in most cases, someone could define a non-inner type name containing a '$'. Handling this correctly in all cases would have required resolving the signature, which generally not feasible.
[中]将给定的类型签名转换为可读字符串。签名应该是基于点的。
例如:

toString({'[', 'L', 'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', ';'}) -> {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'S', 't', 'r', 'i', 'n', 'g', '[', ']'} 
toString({'I'}) -> {'i', 'n', 't'} 
toString({'+', 'L', 'O', 'b', 'j', 'e', 'c', 't', ';'}) -> {'?', ' ', 'e', 'x', 't', 'e', 'n', 'd', 's', ' ', 'O', 'b', 'j', 'e', 'c', 't'}

注意:此方法假定包含'$'的类型签名是内部类型签名。虽然在大多数情况下这是正确的,但有人可以定义一个包含'$'的非内部类型名称。在所有情况下正确处理这一点都需要解决签名问题,这通常是不可行的。

代码示例

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

public final String getQualifiedTypeName() {
  if (fQualifiedName == null)
    fQualifiedName= String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature())));
  return fQualifiedName;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

public final String getQualifiedTypeName() {
  if (fQualifiedName == null)
    fQualifiedName= String.valueOf(Signature.toCharArray(Signature.getTypeErasure(fProposal.getSignature())));
  return fQualifiedName;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private boolean checkParameters(char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) {
  char[][] arguments = Signature.getParameterTypes(methodDescriptor);
  int parameterCount = parameterSimpleNames.length;
  if (parameterCount != arguments.length) return false;
  for (int i = 0; i < parameterCount; i++)
    if (!checkTypeName(parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase))
      return false;
  return true;
}
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private boolean checkParameters(char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) {
  char[][] arguments = Signature.getParameterTypes(methodDescriptor);
  int parameterCount = parameterSimpleNames.length;
  if (parameterCount != arguments.length) return false;
  for (int i = 0; i < parameterCount; i++)
    if (!checkTypeName(parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase))
      return false;
  return true;
}
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

private boolean checkParameters(char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) {
  char[][] arguments = Signature.getParameterTypes(methodDescriptor);
  int parameterCount = parameterSimpleNames.length;
  if (parameterCount != arguments.length) return false;
  for (int i = 0; i < parameterCount; i++)
    if (!checkTypeName(parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase))
      return false;
  return true;
}
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private boolean checkParameters(char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) {
  char[][] arguments = Signature.getParameterTypes(methodDescriptor);
  int parameterCount = parameterSimpleNames.length;
  if (parameterCount != arguments.length) return false;
  for (int i = 0; i < parameterCount; i++)
    if (!checkTypeName(parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase))
      return false;
  return true;
}
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

private boolean checkParameters(char[] methodDescriptor, char[][] parameterSimpleNames, char[][] parameterQualifications, boolean isCaseSensitive, boolean isCamelCase) {
  char[][] arguments = Signature.getParameterTypes(methodDescriptor);
  int parameterCount = parameterSimpleNames.length;
  if (parameterCount != arguments.length) return false;
  for (int i = 0; i < parameterCount; i++)
    if (!checkTypeName(parameterSimpleNames[i], parameterQualifications[i], Signature.toCharArray(arguments[i]), isCaseSensitive, isCamelCase))
      return false;
  return true;
}
private boolean checkStandardAnnotations(long annotationTagBits, TypeReferencePattern pattern) {

代码示例来源:origin: org.eclipse.recommenders.completion.rcp/subwords

private String[] getParameterTypes() {
  final char[] signature = SignatureUtil.fix83600(fProposal.getSignature());
  final char[][] types = Signature.getParameterTypes(signature);
  final String[] ret = new String[types.length];
  for (int i = 0; i < types.length; i++) {
    ret[i] = new String(Signature.toCharArray(types[i]));
  }
  return ret;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private String[] getParameterTypes() {
  char[] signature= SignatureUtil.fix83600(fProposal.getSignature());
  char[][] types= Signature.getParameterTypes(signature);
  String[] ret= new String[types.length];
  for (int i= 0; i < types.length; i++) {
    ret[i]= new String(Signature.toCharArray(types[i]));
  }
  return ret;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private StringBuffer appendConstantDynamic(StringBuffer s, String messageKind, int opcode,
    int index, IConstantPoolEntry entry) {
  return s.append(Messages.bind(messageKind, new String[] {
      OpcodeStringValues.BYTECODE_NAMES[opcode],
      Integer.toString(index),
      Integer.toString(((IConstantPoolEntry2) entry).getBootstrapMethodAttributeIndex()),
      new String(entry.getFieldName()),
      returnClassName(Signature.toCharArray(entry.getFieldDescriptor()))
    }));
}
/**

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private char[] getSignatureForField(char[] fieldDescriptor) {
  char[] newFieldDescriptor = CharOperation.replaceOnCopy(fieldDescriptor, '/', '.');
  newFieldDescriptor = CharOperation.replaceOnCopy(newFieldDescriptor, '$', '%');
  char[] fieldDescriptorSignature = Signature.toCharArray(newFieldDescriptor);
  CharOperation.replace(fieldDescriptorSignature, '%', '$');
  return fieldDescriptorSignature;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private char[] getSignatureForField(char[] fieldDescriptor) {
  char[] newFieldDescriptor = CharOperation.replaceOnCopy(fieldDescriptor, '/', '.');
  newFieldDescriptor = CharOperation.replaceOnCopy(newFieldDescriptor, '$', '%');
  char[] fieldDescriptorSignature = Signature.toCharArray(newFieldDescriptor);
  CharOperation.replace(fieldDescriptorSignature, '%', '$');
  return fieldDescriptorSignature;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

private char[] getSignatureForField(char[] fieldDescriptor) {
  char[] newFieldDescriptor = CharOperation.replaceOnCopy(fieldDescriptor, '/', '.');
  newFieldDescriptor = CharOperation.replaceOnCopy(newFieldDescriptor, '$', '%');
  char[] fieldDescriptorSignature = Signature.toCharArray(newFieldDescriptor);
  CharOperation.replace(fieldDescriptorSignature, '%', '$');
  return fieldDescriptorSignature;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private char[] getSignatureForField(char[] fieldDescriptor) {
  char[] newFieldDescriptor = CharOperation.replaceOnCopy(fieldDescriptor, '/', '.');
  newFieldDescriptor = CharOperation.replaceOnCopy(newFieldDescriptor, '$', '%');
  char[] fieldDescriptorSignature = Signature.toCharArray(newFieldDescriptor);
  CharOperation.replace(fieldDescriptorSignature, '%', '$');
  return fieldDescriptorSignature;
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

private char[] getSignatureForField(char[] fieldDescriptor) {
  char[] newFieldDescriptor = CharOperation.replaceOnCopy(fieldDescriptor, '/', '.');
  newFieldDescriptor = CharOperation.replaceOnCopy(newFieldDescriptor, '$', '%');
  char[] fieldDescriptorSignature = Signature.toCharArray(newFieldDescriptor);
  CharOperation.replace(fieldDescriptorSignature, '%', '$');
  return fieldDescriptorSignature;
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
  if (!pattern.findDeclarations) return false; // only relevant when finding declarations
  if (!(binaryInfo instanceof IBinaryField)) return false;

  IBinaryField field = (IBinaryField) binaryInfo;
  if (!pattern.matchesName(pattern.name, field.getName())) return false;
  if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase()))
    return false;

  char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
  return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase());
}
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
  if (!pattern.findDeclarations) return false; // only relevant when finding declarations
  if (!(binaryInfo instanceof IBinaryField)) return false;

  IBinaryField field = (IBinaryField) binaryInfo;
  if (!pattern.matchesName(pattern.name, field.getName())) return false;
  if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase()))
    return false;

  char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
  return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase());
}
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
  if (!pattern.findDeclarations) return false; // only relevant when finding declarations
  if (!(binaryInfo instanceof IBinaryField)) return false;

  IBinaryField field = (IBinaryField) binaryInfo;
  if (!pattern.matchesName(pattern.name, field.getName())) return false;
  if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase()))
    return false;

  char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
  return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase());
}
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
  if (!pattern.findDeclarations) return false; // only relevant when finding declarations
  if (!(binaryInfo instanceof IBinaryField)) return false;

  IBinaryField field = (IBinaryField) binaryInfo;
  if (!pattern.matchesName(pattern.name, field.getName())) return false;
  if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase()))
    return false;

  char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
  return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase());
}
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

boolean matchField(FieldPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
  if (!pattern.findDeclarations) return false; // only relevant when finding declarations
  if (!(binaryInfo instanceof IBinaryField)) return false;

  IBinaryField field = (IBinaryField) binaryInfo;
  if (!pattern.matchesName(pattern.name, field.getName())) return false;
  if (!checkDeclaringType(enclosingBinaryType, pattern.declaringSimpleName, pattern.declaringQualification, pattern.isCaseSensitive(), pattern.isCamelCase()))
    return false;

  char[] fieldTypeSignature = Signature.toCharArray(convertClassFileFormat(field.getTypeName()));
  return checkTypeName(pattern.typeSimpleName, pattern.typeQualification, fieldTypeSignature, pattern.isCaseSensitive(), pattern.isCamelCase());
}
boolean matchMethod(MethodPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {

相关文章