Java 类org.objectweb.asm.signature.SignatureReader 实例源码

项目:DirectLeaks-AntiReleak-Remover    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:fastAOP    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:jqa-java-plugin    文件:ClassVisitor.java   
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
    Class<? extends ClassFileDescriptor> javaType = getJavaType(access);
    String fullQualifiedName = SignatureHelper.getObjectType(name);
    cachedType = visitorHelper.createType(fullQualifiedName, fileDescriptor, javaType);
    dependentTypeSignatureVisitor = new DependentTypeSignatureVisitor(cachedType, visitorHelper);
    ClassFileDescriptor classFileDescriptor = cachedType.getTypeDescriptor();
    classFileDescriptor.setByteCodeVersion(version);
    if (hasFlag(access, Opcodes.ACC_ABSTRACT) && !hasFlag(access, Opcodes.ACC_INTERFACE)) {
        classFileDescriptor.setAbstract(Boolean.TRUE);
    }
    setModifiers(access, classFileDescriptor);
    if (signature == null) {
        if (superName != null) {
            TypeDescriptor superClassType = visitorHelper.resolveType(SignatureHelper.getObjectType(superName), cachedType).getTypeDescriptor();
            classFileDescriptor.setSuperClass(superClassType);
        }
        for (int i = 0; interfaces != null && i < interfaces.length; i++) {
            TypeDescriptor interfaceType = visitorHelper.resolveType(SignatureHelper.getObjectType(interfaces[i]), cachedType).getTypeDescriptor();
            classFileDescriptor.getInterfaces().add(interfaceType);
        }
    } else {
        new SignatureReader(signature).accept(new ClassSignatureVisitor(cachedType, visitorHelper, dependentTypeSignatureVisitor));
    }
}
项目:meghanada-server    文件:FieldAnalyzeVisitor.java   
FieldAnalyzeVisitor parseSignature() {
  final EntryMessage m = log.traceEntry("fieldSignature={}", fieldSignature);
  boolean isStatic = (Opcodes.ACC_STATIC & this.access) > 0;
  SignatureReader signatureReader = new SignatureReader(this.fieldSignature);
  FieldSignatureVisitor visitor;
  if (isStatic) {
    visitor = new FieldSignatureVisitor(this.name, new ArrayList<>(4));
  } else {
    visitor = new FieldSignatureVisitor(this.name, this.classAnalyzeVisitor.classTypeParameters);
  }
  if (this.typeMap != null) {
    visitor.setTypeMap(this.typeMap);
  }

  this.fieldSignatureVisitor = visitor;
  signatureReader.acceptType(fieldSignatureVisitor);
  return log.traceExit(m, this);
}
项目:meghanada-server    文件:MethodAnalyzeVisitor.java   
MethodAnalyzeVisitor parseSignature() {
  final EntryMessage entryMessage =
      log.traceEntry("name={} methodSignature={}", this.name, this.methodSignature);
  final boolean isStatic = (Opcodes.ACC_STATIC & this.access) > 0;
  final SignatureReader signatureReader = new SignatureReader(this.methodSignature);
  MethodSignatureVisitor visitor;
  if (isStatic) {
    visitor = new MethodSignatureVisitor(this.name, new ArrayList<>(4));
  } else {
    visitor = new MethodSignatureVisitor(this.name, this.classAnalyzeVisitor.classTypeParameters);
  }
  if (this.typeMap != null) {
    visitor.setTypeMap(this.typeMap);
  }

  signatureReader.accept(visitor);

  this.formalType = visitor.getFormalType();
  this.parameterTypes = visitor.getParameterTypes();
  this.typeParameters = visitor.getTypeParameters();
  this.returnType = visitor.getReturnType();
  log.traceExit(entryMessage);
  return this;
}
项目:meghanada-server    文件:MethodSignatureVisitorTest.java   
@Override
public MethodVisitor visitMethod(
    int access, String name, String desc, String signature, String[] exceptions) {

  String target = signature;
  if (target == null) {
    target = desc;
  }
  SignatureReader signatureReader = new SignatureReader(target);
  this.visitor = new MethodSignatureVisitor(name, new ArrayList<>());
  signatureReader.accept(this.visitor);

  System.out.println(name);
  System.out.println(this.visitor.getFormalType());
  System.out.println(this.visitor.getParameterTypes());
  System.out.println(this.visitor.getTypeParameters());
  System.out.println(this.visitor.getReturnType());

  // result.put(name, this.visitor.getFormalType());

  return super.visitMethod(access, name, desc, signature, exceptions);
}
项目:naum    文件:ClassProcessor.java   
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
    if ("$VALUES".equals(name) && classStack.peek().isEnum()) {
        return null;
    }

    String signatureDesc = signature != null ? signature : desc;
    SignatureReader r = new SignatureReader(signatureDesc);
    CustomTraceSignatureVisitor sv = new CustomTraceSignatureVisitor(Opcodes.ACC_PUBLIC);
    r.accept(sv);

    FieldInfo field = FieldInfo.fieldInfo()
        .name(name)
        .modifiers(access)
        .type(sv.getTypeOrSuperclass())
        .value(value)
        .build();
    classStack.peek().addToFields(field);
    return new FieldProcessor(field);
}
项目:thesis-disassembler    文件:MethodBlock.java   
private void parseSignature(MethodNode method) {
    if (method.signature == null) {
        return;
    }
    SignatureVisitor visitor = new SignatureVisitor(0, method.visibleParameterAnnotations, method.invisibleParameterAnnotations);
    visitor.setLocalVariableNodes(method.localVariables);
    visitor.setStatic(Util.containsFlag(method.access, Opcodes.ACC_STATIC));
    SignatureReader signatureReader = new SignatureReader(method.signature);
    signatureReader.accept(visitor);

    mGenericExceptions = visitor.getExceptions();
    mArguments.putAll(visitor.getArguments());

    mGenericReturnType = visitor.getReturnType();

    if (visitor.getDeclaration() != null) {
        mGenericArgs = visitor.getDeclaration();
        if (mGenericArgs.indexOf("<") == 0) {
            int gtPosition = mGenericArgs.indexOf(">") + 1;
            mGenericReturnType = mGenericArgs.substring(0, gtPosition) + " " + mGenericReturnType;
            mGenericArgs = mGenericArgs.substring(gtPosition);
        }
    }
}
项目:thesis-disassembler    文件:MethodInvocationExpression.java   
public MethodInvocationExpression(int opCode, String name, String desc, String owner, String callingMethod) {
    super(opCode);
    mName = name;
    SignatureVisitor v = new SignatureVisitor(0, null, null);
    SignatureReader r = new SignatureReader(desc);
    r.accept(v);
    mType = DataType.getTypeFromObject(v.getReturnType());
    mArgTypes = new ArrayList<>();
    for (Type argType: Type.getArgumentTypes(desc)) {
        mArgTypes.add(DataType.getType(argType));
    }
    mArgumentCount = v.getArguments().size();
    mArguments = new ArrayList<>();
    mOwnerClass = DataType.getType(Type.getObjectType(owner));
    mCallingMethod = callingMethod;
}
项目:rise    文件:ClassHierarchyIndex.java   
/**
 * Resolve the given type variable in the base class, as it is parameterized
 * by the childClass
 */
public String resolve(ClassNode child, String baseClass, String typeVariable) {
    ArrayList<String> parameterValues = new ArrayList<>();

    while (true) {
        // System.out.println(child.signature);
        // new SignatureReader(child.signature)
        // .accept(new PrintingSignatureVisitor(""));

        SignatureVisitorImpl visitor = new SignatureVisitorImpl(parameterValues);
        if (child.signature != null) {
            new SignatureReader(child.signature).accept(visitor);
            parameterValues = visitor.parameterValuesOut;
        }

        if (child.name.equals(baseClass)) {
            return visitor.parameterMap.get(typeVariable);
        }
        if (child.superName == null)
            break;
        child = getNode(child.superName);
    }
    return null;
}
项目:dependometer    文件:ClassFileParser.java   
/**
 * @see org.objectweb.asm.MethodVisitor#visitLocalVariable(String, String, String, Label, Label, int)
 */
public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end,
   int index)
{
   Type type = Type.getType(descriptor);

   if (type != null)
   {
      inspectType(type);
   }

   if (signature != null)
   {
      new SignatureReader(signature).acceptType(new SignatureInspector());
   }
}
项目:Class2Json    文件:ClassJsonVisitor.java   
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
    if (isSynthetic(access))
        return null;
    VariableJson f = new VariableJson();
    f.setName(name);
    f.setType(new TypeJson(Type.getType(desc).getClassName()));
    f.setAccess(access);
    if (signature != null) {
        SignatureReader sr = new SignatureReader(signature);
        TypeSignatureNode sn = new TypeSignatureNode();
        sr.acceptType(sn);
        TypeJson type = new TypeJson();
        sn.accept(type);
        f.setType(type);
    }
    addField(f);
    return new FieldJsonVisitor(f);
}
项目:annotation-tools    文件:SignatureTest.java   
public void test() throws Exception {
    if (line.length() > 2) {
        String signature = line.substring(2);
        SignatureWriter wrt = new SignatureWriter();
        SignatureReader rdr = new SignatureReader(signature);
        switch (line.charAt(0)) {
            case 'C':
            case 'M':
                rdr.accept(wrt);
                break;
            case 'T':
                rdr.acceptType(wrt);
                break;
            default:
                return;
        }
        assertEquals(signature, wrt.toString());
    }
}
项目:annotation-tools    文件:TraceSignatureVisitorTest.java   
public void testSignature() {
    TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
    SignatureReader r = new SignatureReader(data.signature);

    switch (data.type) {
        case 'C':
            r.accept(d);
            assertEquals(data.declaration, d.getDeclaration());
            break;
        case 'F':
            r.acceptType(d);
            assertEquals(data.declaration, d.getDeclaration());
            break;
        case 'M':
            r.accept(d);
            String fullMethodDeclaration = d.getReturnType()
                    + d.getDeclaration()
                    + (d.getExceptions() != null ? d.getExceptions() : "");
            assertEquals(data.declaration, fullMethodDeclaration);
            break;
    }

}
项目:JReFrameworker    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:JReFrameworker    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:CodenameOne    文件:NameTranslatorClassVisitor.java   
private String translateSignature(final String signature, boolean type) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter() {
        public void visitClassType(final String name) {
            String n = translator.getClassMirrorTranslation(name);
            super.visitClassType(n);
        }
    };

    if (type) {
        r.acceptType(w);        
    } else {
        r.accept(w);        
    }
    return w.toString();
}
项目:BitPlus    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:Bramspr    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:cn1    文件:NameTranslatorClassVisitor.java   
private String translateSignature(final String signature, boolean type) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter() {
        public void visitClassType(final String name) {
            String n = translator.getClassMirrorTranslation(name);
            super.visitClassType(n);
        }
    };

    if (type) {
        r.acceptType(w);        
    } else {
        r.accept(w);        
    }
    return w.toString();
}
项目:asm-legacy-svn-clone    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:asm-legacy-svn-clone    文件:TraceSignatureVisitorUnitTest.java   
public void testSignature() {
    TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
    SignatureReader r = new SignatureReader(data.signature);

    switch (data.type) {
    case 'C':
        r.accept(d);
        assertEquals(data.declaration, d.getDeclaration());
        break;
    case 'F':
        r.acceptType(d);
        assertEquals(data.declaration, d.getDeclaration());
        break;
    case 'M':
        r.accept(d);
        String fullMethodDeclaration = d.getReturnType()
                + d.getDeclaration()
                + (d.getExceptions() != null ? d.getExceptions() : "");
        assertEquals(data.declaration, fullMethodDeclaration);
        break;
    }
}
项目:asm-legacy-svn-clone    文件:CheckSignatureAdapterUnitTest.java   
public void checkSignature() {
    SignatureWriter wrt = new SignatureWriter();
    SignatureReader rdr = new SignatureReader(data.signature);
    switch (data.type) {
    case 'C':
        rdr.accept(new CheckSignatureAdapter(
                CheckSignatureAdapter.CLASS_SIGNATURE, wrt));
        break;
    case 'M':
        rdr.accept(new CheckSignatureAdapter(
                CheckSignatureAdapter.METHOD_SIGNATURE, wrt));
        break;
    case 'F':
        rdr.acceptType(new CheckSignatureAdapter(
                CheckSignatureAdapter.TYPE_SIGNATURE, wrt));
        break;
    default:
        return;
    }
    assertEquals(data.signature, wrt.toString());
}
项目:bytecode-viewer    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:rubah    文件:UpdatableClassRenamer.java   
@Override
public FieldVisitor visitField(int access, String name, String desc,
        String signature, Object value) {

    if (signature != null) {
        SignatureTypeRenamer renamer = new SignatureTypeRenamer();
        new SignatureReader(signature).accept(renamer);
        signature = renamer.toString();
    }

    return super.visitField(
            access,
            name,
            this.version.renameDescIfUpdatable(desc),
            signature,
            value);
}
项目:rubah    文件:UpdatableClassRenamer.java   
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
        String signature, String[] exceptions) {
    access &= ~ACC_FINAL;

    if (signature != null) {
        SignatureTypeRenamer renamer = new SignatureTypeRenamer();
        new SignatureReader(signature).accept(renamer);
        signature = renamer.toString();
    }

    if (exceptions != null) {
        for (int i = 0; i < exceptions.length; i++) {
            exceptions[i] = this.version.renameInternalIfUpdatable(exceptions[i]);
        }
    }

    return new MethodTypeRenamer(
            super.visitMethod(
                    access,
                    name,
                    this.version.renameMethodDescIfUpdatable(desc),
                    signature,
                    exceptions));
}
项目:ow2-asm    文件:Textifier.java   
@Override
public void visitLocalVariable(final String name, final String desc,
        final String signature, final Label start, final Label end,
        final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');

    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);

        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ")
                .append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
项目:ow2-asm    文件:TraceSignatureVisitorUnitTest.java   
public void testSignature() {
    TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
    SignatureReader r = new SignatureReader(data.signature);

    switch (data.type) {
    case 'C':
        r.accept(d);
        assertEquals(data.declaration, d.getDeclaration());
        break;
    case 'F':
        r.acceptType(d);
        assertEquals(data.declaration, d.getDeclaration());
        break;
    case 'M':
        r.accept(d);
        String fullMethodDeclaration = d.getReturnType()
                + d.getDeclaration()
                + (d.getExceptions() != null ? d.getExceptions() : "");
        assertEquals(data.declaration, fullMethodDeclaration);
        break;
    }
}
项目:ow2-asm    文件:CheckSignatureAdapterUnitTest.java   
public void checkSignature() {
    SignatureWriter wrt = new SignatureWriter();
    SignatureReader rdr = new SignatureReader(data.signature);
    switch (data.type) {
    case 'C':
        rdr.accept(new CheckSignatureAdapter(
                CheckSignatureAdapter.CLASS_SIGNATURE, wrt));
        break;
    case 'M':
        rdr.accept(new CheckSignatureAdapter(
                CheckSignatureAdapter.METHOD_SIGNATURE, wrt));
        break;
    case 'F':
        rdr.acceptType(new CheckSignatureAdapter(
                CheckSignatureAdapter.TYPE_SIGNATURE, wrt));
        break;
    default:
        return;
    }
    assertEquals(data.signature, wrt.toString());
}
项目:jnome    文件:ASMClassParser.java   
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
  if(! isSynthetic(access)) {
    MemberVariableDeclarator decl = new MemberVariableDeclarator();
    decl.addModifiers(accessToFieldModifier(access));
    VariableDeclaration declaration = new JavaVariableDeclaration(name);
    decl.add(declaration);
    if(signature != null) {
      new SignatureReader(signature).accept(new FieldSignatureExtractor(decl,language()));
    } else {
      new SignatureReader(desc).accept(new FieldSignatureExtractor(decl,language()));
    }
    _type.add(decl);
  }
  return null;
}
项目:objectweb-asm-4.0    文件:TraceSignatureVisitorUnitTest.java   
public void testSignature() {
    TraceSignatureVisitor d = new TraceSignatureVisitor(data.access);
    SignatureReader r = new SignatureReader(data.signature);

    switch (data.type) {
        case 'C':
            r.accept(d);
            assertEquals(data.declaration, d.getDeclaration());
            break;
        case 'F':
            r.acceptType(d);
            assertEquals(data.declaration, d.getDeclaration());
            break;
        case 'M':
            r.accept(d);
            String fullMethodDeclaration = d.getReturnType()
                    + d.getDeclaration()
                    + (d.getExceptions() != null ? d.getExceptions() : "");
            assertEquals(data.declaration, fullMethodDeclaration);
            break;
    }
}
项目:objectweb-asm-4.0    文件:CheckSignatureAdapterUnitTest.java   
public void checkSignature() {
    SignatureWriter wrt = new SignatureWriter();
    SignatureReader rdr = new SignatureReader(data.signature);
    switch (data.type) {
        case 'C':
            rdr.accept(new CheckSignatureAdapter(CheckSignatureAdapter.CLASS_SIGNATURE,
                    wrt));
            break;
        case 'M':
            rdr.accept(new CheckSignatureAdapter(CheckSignatureAdapter.METHOD_SIGNATURE,
                    wrt));
            break;
        case 'F':
            rdr.acceptType(new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE,
                    wrt));
            break;
        default:
            return;
    }
    assertEquals(data.signature, wrt.toString());
}
项目:jconts    文件:MethodContext.java   
/**
 * This method assumes that return type of the method is
 * <code>com.google.code.jconts.Computation&lt;T&gt;</code>. It extracts the type
 * argument <code>T</code> and returns it signature.
 */
private String valueSignature() {
    final SignatureWriter sign = new SignatureWriter();
    SignatureAdapter adaptor = new SignatureAdapter() {
        public SignatureVisitor visitReturnType() {
            return new SignatureAdapter() {
                @Override
                public SignatureVisitor visitTypeArgument(char wildcard) {
                    return sign;
                }

                // FIXME: All other are error!
            };
        };
    };
    new SignatureReader(signature).accept(adaptor);
    return sign.toString();
}
项目:DirectLeaks-AntiReleak-Remover    文件:Remapper.java   
/**
 * @param signature
 *            signature for mapper
 * @param typeSignature
 *            true if signature is a FieldTypeSignature, such as the
 *            signature parameter of the ClassVisitor.visitField or
 *            MethodVisitor.visitLocalVariable methods
 * @return signature rewritten as a string
 */
public String mapSignature(String signature, boolean typeSignature) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter();
    SignatureVisitor a = createSignatureRemapper(w);
    if (typeSignature) {
        r.acceptType(a);
    } else {
        r.accept(a);
    }
    return w.toString();
}
项目:Spigot-Attribute-Remover    文件:Remapper.java   
/**
 * @param signature
 *            signature for mapper
 * @param typeSignature
 *            true if signature is a FieldTypeSignature, such as the
 *            signature parameter of the ClassVisitor.visitField or
 *            MethodVisitor.visitLocalVariable methods
 * @return signature rewritten as a string
 */
public String mapSignature(String signature, boolean typeSignature) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter();
    SignatureVisitor a = createSignatureRemapper(w);
    if (typeSignature) {
        r.acceptType(a);
    } else {
        r.accept(a);
    }
    return w.toString();
}
项目:CustomWorldGen    文件:ModAPITransformer.java   
private void stripInterface(ClassNode classNode, String interfaceName, boolean stripRefs)
{
    final String ifaceName = interfaceName.replace('.', '/');
    boolean found = classNode.interfaces.remove(ifaceName);
    if (found && classNode.signature != null)
    {
        SignatureReader sr = new SignatureReader(classNode.signature);
        final RemovingSignatureWriter signatureWriter = new RemovingSignatureWriter(ifaceName);
        sr.accept(signatureWriter);
        classNode.signature = signatureWriter.toString();
        if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed from type signature");
    }
    if (found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed", interfaceName);
    if (!found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s NOT removed - not found", interfaceName);

    if (found && stripRefs)
    {
        if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method signature references", interfaceName);
        for (Iterator<MethodNode> iterator = classNode.methods.iterator(); iterator.hasNext();)
        {
            MethodNode node = iterator.next();
            if (node.desc.contains(ifaceName))
            {
                if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method containing reference %s", interfaceName, node.name);
                iterator.remove();
            }
        }
        if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - all method signature references stripped", interfaceName);
    }
    else if (found)
    {
        if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - NOT stripping method signature references", interfaceName);
    }
}
项目:fastAOP    文件:Remapper.java   
/**
 * @param signature
 *            signature for mapper
 * @param typeSignature
 *            true if signature is a FieldTypeSignature, such as the
 *            signature parameter of the ClassVisitor.visitField or
 *            MethodVisitor.visitLocalVariable methods
 * @return signature rewritten as a string
 */
public String mapSignature(String signature, boolean typeSignature) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter();
    SignatureVisitor a = createSignatureRemapper(w);
    if (typeSignature) {
        r.acceptType(a);
    } else {
        r.accept(a);
    }
    return w.toString();
}
项目:jqa-java-plugin    文件:ClassVisitor.java   
@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
    MethodDescriptor methodDescriptor = visitorHelper.getMethodDescriptor(cachedType, SignatureHelper.getMethodSignature(name, desc));
    methodDescriptor.setName(name);
    setModifiers(access, methodDescriptor);
    if (hasFlag(access, Opcodes.ACC_ABSTRACT)) {
        methodDescriptor.setAbstract(Boolean.TRUE);
    }
    if (hasFlag(access, Opcodes.ACC_NATIVE)) {
        methodDescriptor.setNative(Boolean.TRUE);
    }
    if (signature == null) {
        String returnType = SignatureHelper.getType(org.objectweb.asm.Type.getReturnType(desc));
        methodDescriptor.setReturns(visitorHelper.resolveType(returnType, cachedType).getTypeDescriptor());
        org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            String parameterType = SignatureHelper.getType(types[i]);
            TypeDescriptor typeDescriptor = visitorHelper.resolveType(parameterType, cachedType).getTypeDescriptor();
            ParameterDescriptor parameterDescriptor = visitorHelper.addParameterDescriptor(methodDescriptor, i);
            parameterDescriptor.setType(typeDescriptor);
        }
    } else {
        new SignatureReader(signature).accept(new MethodSignatureVisitor(cachedType, methodDescriptor, visitorHelper, dependentTypeSignatureVisitor));
    }
    for (int i = 0; exceptions != null && i < exceptions.length; i++) {
        TypeDescriptor exceptionType = visitorHelper.resolveType(SignatureHelper.getObjectType(exceptions[i]), cachedType).getTypeDescriptor();
        methodDescriptor.getDeclaredThrowables().add(exceptionType);
    }
    return new MethodVisitor(cachedType, methodDescriptor, visitorHelper, dependentTypeSignatureVisitor);
}
项目:jqa-java-plugin    文件:MethodVisitor.java   
@Override
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
    if (visitorHelper.getClassModelConfiguration().isMethodDeclaresVariable() && !THIS.equals(name)) {
        final VariableDescriptor variableDescriptor = visitorHelper.getVariableDescriptor(name, SignatureHelper.getFieldSignature(name, desc));
        if (signature == null) {
            TypeDescriptor type = visitorHelper.resolveType(SignatureHelper.getType((desc)), containingType).getTypeDescriptor();
            variableDescriptor.setType(type);
        } else {
            new SignatureReader(signature).accept(new AbstractTypeSignatureVisitor(containingType, visitorHelper) {

                @Override
                public SignatureVisitor visitArrayType() {
                    return dependentTypeSignatureVisitor;
                }

                @Override
                public SignatureVisitor visitTypeArgument(char wildcard) {
                    return dependentTypeSignatureVisitor;
                }

                @Override
                public void visitEnd(TypeDescriptor resolvedTypeDescriptor) {
                    variableDescriptor.setType(resolvedTypeDescriptor);
                }
            });
        }
        methodDescriptor.getVariables().add(variableDescriptor);
    }
}
项目:meghanada-server    文件:ClassAnalyzeVisitor.java   
@Override
public void visit(
    int api, int access, String name, String signature, String superClass, String[] interfaces) {
  // log.debug("Name:{}", name);
  // call class
  this.access = access;
  final boolean isInterface = (Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE;
  // log.debug("name {} sig {} IF:{}", name, signature, isInterface);

  if (signature != null) {
    // generics
    // log.debug("name {} sig {}", name, signature);
    final SignatureReader signatureReader = new SignatureReader(signature);
    ClassSignatureVisitor classSignatureVisitor =
        new ClassSignatureVisitor(this.className, isInterface);
    signatureReader.accept(classSignatureVisitor);

    this.classTypeParameters = classSignatureVisitor.getTypeParameters();
    this.classIndex = classSignatureVisitor.getClassIndex();
    if (!this.classIndex.getSupers().contains(ClassNameUtils.OBJECT_CLASS)) {
      this.classIndex.addSuper(ClassNameUtils.OBJECT_CLASS);
    }
  } else {
    this.classTypeParameters = new ArrayList<>(4);
    final List<String> supers = new ArrayList<>(4);
    if (superClass != null) {
      final String superClassFQCN = ClassNameUtils.replaceSlash(superClass);
      supers.add(superClassFQCN);
    }
    Arrays.stream(interfaces)
        .forEach(interfaceName -> supers.add(ClassNameUtils.replaceSlash(interfaceName)));
    this.classIndex = new ClassIndex(this.className, new ArrayList<>(4), supers);
    this.classIndex.setInterface(isInterface);
  }
}