Example #1
0
        private List <TypeSignature> parseFormalTypeParameters()
        {
            if (current != '<')
            {
                throw new IllegalStateException();
            }
            advance();
            var result = new ArrayList <TypeSignature>();
            int pos    = position;
            FormalTypeParameterSignature currentParameterType = null;

            for (;;)
            {
                switch (current)
                {
                case ':':
                    if (position == pos && currentParameterType == null)
                    {
                        throw new IllegalStateException();
                    }
                    if (currentParameterType == null)
                    {
                        var name = signature.substring(pos, position);
                        currentParameterType = new FormalTypeParameterSignature(name);
                        result.add(currentParameterType);
                    }
                    switch (advance())
                    {
                    case ':':
                    case '>':
                        break;

                    default:
                        currentParameterType.formalTypeParameterBounds.add(parseFieldTypeSignature());
                        pos = position;
                        break;
                    }
                    break;

                case '>':
                    if (currentParameterType == null)
                    {
                        var name = signature.substring(pos, position);
                        currentParameterType = new FormalTypeParameterSignature(name);
                        result.add(currentParameterType);
                    }
                    advance();
                    return(result);

                default:
                    currentParameterType = null;
                    advance();
                    break;

                case -1:
                    throw new IllegalStateException();
                }
            }
        }
        private List<TypeSignature> parseFormalTypeParameters() {
            if (current != '<') {
                throw new IllegalStateException();
            }
            advance();
            var result = new ArrayList<TypeSignature>();
            int pos = position;
            FormalTypeParameterSignature currentParameterType = null;
            for (;;) {
                switch (current) {
                case ':':
                    if (position == pos && currentParameterType == null) {
                        throw new IllegalStateException();
                    }
                    if (currentParameterType == null) {
                        var name = signature.substring(pos, position);
                        currentParameterType = new FormalTypeParameterSignature(name);
                        result.add(currentParameterType);
                    }
                    switch (advance()) {
                    case ':':
                    case '>':
                        break;
                        
                    default:
                        currentParameterType.formalTypeParameterBounds.add(parseFieldTypeSignature());
                        pos = position;
                        break;
                    }
                    break;
                    
                case '>':
                    if (currentParameterType == null) {
                        var name = signature.substring(pos, position);
                        currentParameterType = new FormalTypeParameterSignature(name);
                        result.add(currentParameterType);
                    }
                    advance();
                    return result;

                default:
                    currentParameterType = null;
                    advance();
                    break;
                    
                case -1:
                    throw new IllegalStateException();
                }
            }
        }