@@ -0,0 +1,3031 @@
+/*%0A * Copyright 2015 Michael Rozumyanskiy%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.michaelrocks.lightsaber.processor.analysis;%0A%0Aimport com.michaelrocks.lightsaber.processor.ProcessorContext;%0Aimport com.michaelrocks.lightsaber.processor.descriptors.ParameterizedType;%0Aimport org.objectweb.asm.Type;%0Aimport org.objectweb.asm.signature.SignatureVisitor;%0A%0Aimport static org.objectweb.asm.Opcodes.ASM5;%0A%0Aclass ParameterizedTypeSignatureParser extends SignatureVisitor %7B%0A    private final ProcessorContext processorContext;%0A%0A    private Type classType;%0A    private Type classTypeParameter;%0A    private boolean isValid = true;%0A%0A    public ParameterizedTypeSignatureParser(final ProcessorContext processorContext) %7B%0A        super(ASM5);%0A        this.processorContext = processorContext;%0A    %7D%0A%0A    public ParameterizedType getParameterizedType() %7B%0A        return isValid ? new ParameterizedType(classType, classTypeParameter) : null;%0A    %7D%0A%0A    @Override%0A    public void visitClassType(final String name) %7B%0A        if (classType == null) %7B%0A            classType = Type.getObjectType(name);%0A        %7D else if (classTypeParameter == null) %7B%0A            classTypeParameter = Type.getObjectType(name);%0A        %7D else %7B%0A            reportError(classType + %22 has multiple type arguments%22);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public SignatureVisitor visitTypeArgument(final char wildcard) %7B%0A        if (wildcard == INSTANCEOF) %7B%0A            return this;%0A        %7D%0A%0A        reportError(%22Injectable field cannot have wildcards in its signature%22);%0A        return this;%0A    %7D%0A%0A    // Prohibited callbacks.%0A%0A    @Override%0A    public void visitInnerClassType(final String name) %7B%0A        reportError(%22Injectable field cannot have an inner class type in its signature%22);%0A    %7D%0A%0A    @Override%0A    public void visitBaseType(final char descriptor) %7B%0A        reportError(%22Injectable field cannot be a primitive type%22);%0A    %7D%0A%0A    @Override%0A    public SignatureVisitor visitArrayType() %7B%0A        reportError(%22Injectable field cannot be an array%22);%0A        return this;%0A    %7D%0A%0A    @Override%0A    public void visitTypeVariable(final String name) %7B%0A        reportError(%22Injectable field cannot have type variables in its signature%22);%0A    %7D%0A%0A    @Override%0A    public void visitTypeArgument() %7B%0A        reportError(%22Injectable field cannot have unbounded type arguments in its signature%22);%0A    %7D%0A%0A    private void reportError(final String message) %7B%0A        processorContext.reportError(message);%0A        isValid = false;%0A    %7D%0A%7D%0A

Implement signature parser that creates ParameterizedType