Commits

Tim Vernum  committed 987fb91

Fix name of package

  • Participants
  • Parent commits 90076af

Comments (0)

Files changed (37)

File bin/convert.sh

 cd $(dirname $0)
 cd ..
 
-CP="lib/convert/org.adjective.orthodox.jar:parser/output/ant/classes/parser:convert/output/ant/classes/"
-MAIN="org.adjective.syntactic.convert.j7to8.Main"
+CP="parser/output/ant/classes/parser:convert/output/ant/classes/main"
+MAIN="org.adjective.syntactic.convert.j8to7.Main"
 
 for FILE in "$@"
 do

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/ConversionException.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8;
-
-public class ConversionException extends RuntimeException
-{
-    public ConversionException(final String message)
-    {
-        super(message);
-    }
-
-    public ConversionException(final String message, final Throwable cause)
-    {
-        super(message, cause);
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/Convert7To8Visitor.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8;
-
-import org.adjective.syntactic.convert.j7to8.util.ClassFinder;
-import org.adjective.syntactic.convert.j7to8.util.Importer;
-import org.adjective.syntactic.convert.j7to8.util.VariableStack;
-import org.adjective.syntactic.parser.ast.*;
-import org.adjective.syntactic.parser.node.BaseNode;
-import org.adjective.syntactic.parser.node.ExpressionNode;
-import org.adjective.syntactic.parser.node.StatementNode;
-import org.adjective.syntactic.parser.node.VariableDeclarationNode;
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.util.DefaultVisitor;
-import org.adjective.syntactic.parser.util.ModifierSet;
-import org.adjective.syntactic.util.Pair;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Stack;
-
-public class Convert7To8Visitor extends DefaultVisitor<Object, Object>
-{
-    private final Stack<String> _className;
-    private final VariableStack _vars;
-    private final ClassFinder _classFinder;
-    private final Importer _importer;
-    private final LambdaConverter _lambdaConverter;
-    private final List<Pair<VariableDeclarationNode, String>> _toMarkFinal;
-
-    public Convert7To8Visitor()
-    {
-        _className = new Stack<String>();
-        _vars = new VariableStack();
-        _classFinder = new ClassFinder();
-        _importer = new Importer(_classFinder);
-        _lambdaConverter = new LambdaConverter(_importer, _classFinder);
-        _toMarkFinal = new ArrayList<Pair<VariableDeclarationNode, String>>();
-    }
-
-    @Override
-    public Object visit(final ASTCompilationUnit node, final Object data)
-    {
-        final Object val = super.visit(node, data);
-        for (Pair<VariableDeclarationNode, String> pair : _toMarkFinal)
-        {
-            markFinal(pair.tail, pair.head);
-        }
-        return val;
-    }
-
-    @Override
-    public Object visit(final ASTImportDeclaration node, final Object data)
-    {
-        _importer.add(node);
-        return super.visit(node, data);
-    }
-
-    private void markFinal(final String name, final VariableDeclarationNode node)
-    {
-        if (node.isMultiVariable())
-        {
-            Map<String, VariableDeclarationNode> split = node.split();
-            ASTBlock block = ((BaseNode) node).findAncestor(ASTBlock.class);
-            split.get(name).getModifiers().set(ModifierSet.Modifier.FINAL);
-            List<StatementNode> statements = new ArrayList<StatementNode>();
-            for (VariableDeclarationNode decl : split.values())
-            {
-                assert decl instanceof ASTLocalVariableDeclaration;
-                statements.add(new ASTVariableDeclarationStatement((ASTLocalVariableDeclaration) decl));
-            }
-            block.replace(node.jjtGetParent(), statements);
-        }
-        else
-        {
-            node.getModifiers().set(ModifierSet.Modifier.FINAL);
-        }
-    }
-
-    @Override
-    public Object visit(final ASTClassOrInterfaceDeclaration node, final Object data)
-    {
-        _className.push(node.getName().getIdentifier());
-        _classFinder.define(node);
-        try
-        {
-            return super.visit(node, data);
-        }
-        finally
-        {
-            _className.pop();
-        }
-    }
-
-    @Override
-    public Object visit(final ASTMethodDeclaration node, final Object data)
-    {
-        _vars.pushScope();
-        try
-        {
-            return super.visit(node, data);
-        }
-        finally
-        {
-            _vars.popScope();
-        }
-    }
-
-    @Override
-    public Object visit(final ASTBlock node, final Object data)
-    {
-        _vars.pushScope();
-        try
-        {
-            return super.visit(node, data);
-        }
-        finally
-        {
-            _vars.popScope();
-        }
-    }
-
-    @Override
-    public Object visit(final ASTFormalParameter node, final Object data)
-    {
-        _vars.store(node.getName().getIdentifier(), node);
-        return super.visit(node, data);
-    }
-
-    @Override
-    public Object visit(final ASTLocalVariableDeclaration node, final Object data)
-    {
-        for (ASTVariableDeclarator var : node.getVariables())
-        {
-            _vars.store(var.getIdentifier().getIdentifier(), node);
-
-            if (!var.hasInitializer())
-            {
-                continue;
-            }
-
-            final ExpressionNode init = var.getInitializer();
-            if (!init.is(ASTExpression.class))
-            {
-                continue;
-            }
-
-            ExpressionNode expr = init.as(ASTExpression.class).getBaseExpression();
-            if (!expr.is(ASTPrimaryExpression.class))
-            {
-                continue;
-            }
-
-            expr = expr.as(ASTPrimaryExpression.class).getPrefix();
-
-            if (!expr.is(ASTLambdaExpression.class))
-            {
-                continue;
-            }
-
-            final ASTLambdaExpression lambda = expr.as(ASTLambdaExpression.class);
-            final ExpressionNode convert = _lambdaConverter.convertLambda(lambda,
-                                                                          getType(node, var));
-            fixBody(lambda.getBody());
-            var.replaceInitializer(new ASTExpression(convert));
-        }
-
-        return super.visit(node, data);
-    }
-
-    private void fixBody(final ASTLambdaBody body)
-    {
-        body.jjtAccept(new DefaultVisitor<Object, Object>()
-        {
-            @Override
-            public Object visit(final ASTPrimaryExpression node, final Object data)
-            {
-                final ExpressionNode prefix = node.getPrefix();
-                if (node.jjtGetNumChildren() == 1)
-                {
-                    if (prefix.is(ASTQualifiedIdentifier.class))
-                    {
-                        String id = prefix.as(ASTQualifiedIdentifier.class).getName();
-                        markFinal(id);
-                    }
-                }
-                if (prefix.is(ASTThis.class))
-                {
-                    final ASTQualifiedIdentifier newPrefix = new ASTQualifiedIdentifier(_className.peek());
-                    final ASTMemberSuffix newSuffix = new ASTMemberSuffix(prefix.as(ASTThis.class));
-                    node.setTo(newPrefix, merge(newSuffix, node.getSuffixes()));
-                }
-                return super.visit(node, data);
-            }
-
-        }, null);
-    }
-
-    private void markFinal(final String var)
-    {
-        final VariableDeclarationNode node = _vars.get(var);
-        if (node == null)
-        {
-            return;
-        }
-        _toMarkFinal.add(new Pair<VariableDeclarationNode, String>(node, var));
-    }
-
-    private <T> Iterable<T> merge(final T first, final Iterable<T> rest)
-    {
-        final ArrayList<T> list = new ArrayList<T>();
-        list.add(first);
-        for (T t : rest)
-        {
-            list.add(t);
-        }
-        return list;
-    }
-
-    private JavaType getType(ASTLocalVariableDeclaration declaration, ASTVariableDeclarator variable)
-    {
-        return BaseNode.makeType(declaration.getTypeNode(), variable.getArraySuffix());
-    }
-
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/LambdaConverter.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8;
-
-import org.adjective.syntactic.convert.j7to8.type.MethodInfo;
-import org.adjective.syntactic.convert.j7to8.type.TypeInfo;
-import org.adjective.syntactic.convert.j7to8.util.ClassFinder;
-import org.adjective.syntactic.convert.j7to8.util.Importer;
-import org.adjective.syntactic.parser.ast.*;
-import org.adjective.syntactic.parser.name.ParameterizedName;
-import org.adjective.syntactic.parser.name.SimpleParameterizedName;
-import org.adjective.syntactic.parser.name.SimpleTypeParameter;
-import org.adjective.syntactic.parser.name.TypeParameter;
-import org.adjective.syntactic.parser.node.ExpressionNode;
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.type.SimpleJavaType;
-import org.adjective.syntactic.parser.util.ModifierSet;
-import org.adjective.syntactic.util.ArrayUtil;
-import org.adjective.syntactic.util.JavaTypeUtil;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-public class LambdaConverter
-{
-    private final Importer _importer;
-    private final ClassFinder _classFinder;
-
-    public LambdaConverter(final Importer importer, final ClassFinder classFinder)
-    {
-        _classFinder = classFinder;
-        _importer = importer;
-    }
-
-    public ExpressionNode convertLambda(final ASTLambdaExpression lambda, final JavaType forType)
-    {
-        final ModifierSet set = new ModifierSet(ModifierSet.Modifier.PUBLIC);
-        final ASTModifiers modifiers = new ASTModifiers(set);
-        final TypeInfo typeInfo = getTypeInfo(forType);
-        final MethodInfo methodInfo = getFunctionalMethod(typeInfo);
-        final ASTMethodDeclaration astMethod = makeMethodDeclaration(methodInfo,
-                                                                     lambda.getParameters(),
-                                                                     lambda.getBody());
-        final ASTMember member = new ASTMember(modifiers, astMethod);
-        ASTClassOrInterfaceBody body = new ASTClassOrInterfaceBody(new ASTClassOrInterfaceBodyElement(member));
-        final JavaType astType = substituteType(astMethod.getParameters(), methodInfo, forType);
-        return new ASTAllocationExpression(JavaTypeUtil.withoutWildcard(astType), new ASTArguments(), body);
-    }
-
-    private TypeInfo getTypeInfo(final JavaType forType)
-    {
-        final String name = _importer.getQualifiedName(forType);
-        final TypeInfo typeInfo = _classFinder.getClass(name, getTypeParameters(forType));
-        if (typeInfo == null)
-        {
-            throw new ConversionException("Cannot find '" + name + "'");
-        }
-        return typeInfo;
-    }
-
-    private TypeParameter[] getTypeParameters(final JavaType forType)
-    {
-        return ArrayUtil.last(forType.getParameterizedTypeName()).getParameters();
-    }
-
-    private MethodInfo getFunctionalMethod(final TypeInfo typeInfo)
-    {
-        final Collection<MethodInfo> methods = typeInfo.getAbstractMethods();
-        if (methods.size() != 1)
-        {
-            throw new ConversionException("Class '" + typeInfo.getName()
-                                                  + "' should have exactly 1 method but has " + methods.size());
-        }
-
-        return methods.iterator().next();
-    }
-
-    private ASTMethodDeclaration makeMethodDeclaration(final MethodInfo method, final ASTLambdaParameters parameters, final ASTLambdaBody lambdaBody)
-    {
-        final ASTMethodBody body = getMethodBody(lambdaBody);
-        final ASTNameList exceptions = method.getExceptionTypes().length == 0 ? null
-                : new ASTNameList(method.getExceptionTypes());
-        return new ASTMethodDeclaration(method.getReturnType(),
-                                        new ASTIdentifier(method.getName()),
-                                        makeFormalParameters(method, parameters),
-                                        new ASTArraySuffixList(),
-                                        exceptions,
-                                        body);
-    }
-
-    private JavaType substituteType(final ASTFormalParameters parameters, final MethodInfo method, final JavaType type)
-    {
-        final Integer[] typeParameters = method.getClassTypeParameters();
-        if (ArrayUtil.isNull(typeParameters))
-        {
-            return type;
-        }
-        final ParameterizedName lastName = ArrayUtil.last(type.getParameterizedTypeName());
-        TypeParameter[] classParameters = Arrays.copyOf(lastName.getParameters(), lastName.getParameters().length);
-        for (int i = 0; i < typeParameters.length; i++)
-        {
-            final Integer classIndex = typeParameters[i];
-            if (classIndex != null)
-            {
-                classParameters[classIndex] = new SimpleTypeParameter(TypeParameter.Kind.EXACT,
-                                                                      parameters.getParameterTypes()[i]);
-            }
-        }
-
-        ParameterizedName[] name = new ParameterizedName[type.getParameterizedTypeName().length];
-        System.arraycopy(type.getParameterizedTypeName(), 0, name, 0, name.length - 1);
-        name[name.length - 1] = new SimpleParameterizedName(lastName.getName(), classParameters);
-        return new SimpleJavaType(name, type.getArrayDepth());
-    }
-
-    private ASTFormalParameters makeFormalParameters(final MethodInfo method, final ASTLambdaParameters parameters)
-    {
-        final JavaType[] parameterTypes;
-        if (parameters.hasDeclaredParameterTypes())
-        {
-            parameterTypes = parameters.getParameterListNode().getParameterTypes();
-        }
-        else
-        {
-            parameterTypes = method.getParameterTypes();
-        }
-        final String[] parameterNames = new String[parameterTypes.length];
-        final Iterator<ASTIdentifier> iterator = parameters.getParameterNames().iterator();
-        for (int i = 0; i < parameterNames.length; i++)
-        {
-            if (iterator.hasNext())
-            {
-                parameterNames[i] = iterator.next().getIdentifier();
-            }
-            else
-            {
-                throw new ConversionException("Incorrect number of arguments to " + method + " - " + parameterNames.length + " expected");
-            }
-        }
-        ASTFormalParameter[] formalParameters = new ASTFormalParameter[parameterTypes.length];
-        for (int i = 0; i < formalParameters.length; i++)
-        {
-            formalParameters[i] = new ASTFormalParameter(parameterTypes[i],
-                                                         i == formalParameters.length - 1 && method.isVarArgs(),
-                                                         parameterNames[i]);
-        }
-        return new ASTFormalParameters(formalParameters);
-    }
-
-    private ASTMethodBody getMethodBody(final ASTLambdaBody lambdaBody)
-    {
-        ASTBlock block;
-        if (lambdaBody.isExpression())
-        {
-            ASTReturnStatement stmt = new ASTReturnStatement(lambdaBody.getExpression());
-            block = new ASTBlock(stmt);
-        }
-        else
-        {
-            block = lambdaBody.getBlock();
-        }
-        return new ASTMethodBody(block);
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/Main.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-
-package org.adjective.syntactic.convert.j7to8;
-
-import org.adjective.syntactic.parser.node.BaseNode;
-import org.adjective.syntactic.parser.util.PrintSourceVisitor;
-import org.adjective.syntactic.parser.jj.JavaParser;
-
-public class Main
-{
-    public static void main(String[] args)
-    {
-        for (String arg : args)
-        {
-            process(arg);
-        }
-    }
-
-    private static void process(final String filename)
-    {
-        BaseNode ast = parse(filename);
-        if (ast != null)
-        {
-            ast.jjtAccept(new Convert7To8Visitor(), null);
-            ast.jjtAccept(new PrintSourceVisitor(), System.out);
-        }
-    }
-
-    private static BaseNode parse(final String arg)
-    {
-        try
-        {
-            return (BaseNode) JavaParser.process(arg);
-        }
-        catch (RuntimeException e)
-        {
-            System.err.println("Cannot parse: " + arg);
-            throw e;
-        }
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/ASTMethodInfo.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.ast.ASTMethodDeclaration;
-import org.adjective.syntactic.parser.ast.ASTNameList;
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.util.ModifierSet;
-
-public class ASTMethodInfo extends AbstractMethodInfo implements MethodInfo
-{
-    private final ASTMethodDeclaration _method;
-    private final TypeParameterLookup _parameterLookup;
-    private final ModifierSet _modifiers;
-
-    public ASTMethodInfo(final ModifierSet modifiers, final ASTMethodDeclaration method, final TypeParameterLookup lookup)
-    {
-        _method = method;
-        _parameterLookup = lookup;
-        _modifiers = new ModifierSet(modifiers);
-        if (isDeclaredOnObject())
-        {
-            _modifiers.clear(ModifierSet.Modifier.ABSTRACT);
-        }
-    }
-
-    private JavaType getType(final JavaType type)
-    {
-        final JavaType typeParameter = _parameterLookup.findParameter(type.getTypeName());
-        if (typeParameter != null)
-        {
-            return typeParameter;
-        }
-        else
-        {
-            return type;
-        }
-    }
-
-    private JavaType[] getTypes(final JavaType[] in)
-    {
-        JavaType[] out = new JavaType[in.length];
-        for (int i = 0; i < in.length; i++)
-        {
-            out[i] = getType(in[i]);
-        }
-        return out;
-    }
-
-    @Override
-    public JavaType getReturnType()
-    {
-        return getType(_method.getActualReturnType());
-    }
-
-    @Override
-    public String getName()
-    {
-        return _method.getName().getIdentifier();
-    }
-
-    @Override
-    public ModifierSet getModifiers()
-    {
-        return _modifiers;
-    }
-
-    @Override
-    public JavaType[] getParameterTypes()
-    {
-        return getTypes(_method.getParameters().getParameterTypes());
-    }
-
-    @Override
-    public String[] getParameterNames()
-    {
-        return _method.getParameters().getParameterNames();
-    }
-
-    @Override
-    public Integer[] getClassTypeParameters()
-    {
-        final JavaType[] types = _method.getParameters().getParameterTypes();
-        final Integer[] vals = new Integer[types.length];
-
-        for (int i = 0; i < vals.length; i++)
-        {
-            final int lookup = _parameterLookup.findParameterIndex(types[i].getTypeName());
-            if (lookup != -1)
-            {
-                vals[i] = lookup;
-            }
-        }
-
-        return vals;
-    }
-
-    @Override
-    public boolean isVarArgs()
-    {
-        return _method.getParameters().isVarArgs();
-    }
-
-    @Override
-    public JavaType[] getExceptionTypes()
-    {
-        final ASTNameList exceptions = _method.getThrows();
-        return exceptions == null ? new JavaType[0] : exceptions.getTypes();
-    }
-
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/ASTTypeInfo.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.ast.ASTClassOrInterfaceBodyElement;
-import org.adjective.syntactic.parser.ast.ASTClassOrInterfaceDeclaration;
-import org.adjective.syntactic.parser.ast.ASTMember;
-import org.adjective.syntactic.parser.ast.ASTMethodDeclaration;
-import org.adjective.syntactic.parser.ast.ASTTypeParameter;
-import org.adjective.syntactic.parser.name.TypeParameter;
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.type.MemberType;
-import org.adjective.syntactic.parser.util.ModifierSet;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ASTTypeInfo extends AbstractTypeInfo implements TypeInfo, TypeParameterLookup
-{
-    private final ASTClassOrInterfaceDeclaration _declaration;
-    private final TypeParameter[] _parameters;
-    private final ASTMethodInfo[] _methods;
-
-    public ASTTypeInfo(final ASTClassOrInterfaceDeclaration declaration, final TypeParameter[] parameters)
-    {
-        _declaration = declaration;
-        _parameters = parameters;
-        _methods = buildMethods();
-    }
-
-    private ASTMethodInfo[] buildMethods()
-    {
-        final List<ASTMethodInfo> result = new ArrayList<ASTMethodInfo>();
-        for (ASTClassOrInterfaceBodyElement element : _declaration.getBody().getElements())
-        {
-            if (!element.isMember())
-            {
-                continue;
-            }
-            final ASTMember member = element.getMember();
-            if (member.getMember().getMemberType() != MemberType.METHOD)
-            {
-                continue;
-            }
-            ModifierSet modifiers = getModifiers(member);
-            result.add(new ASTMethodInfo(modifiers, (ASTMethodDeclaration) member.getMember(), this));
-        }
-        return result.toArray(new ASTMethodInfo[result.size()]);
-    }
-
-    private ModifierSet getModifiers(final ASTMember member)
-    {
-        ModifierSet modifiers = member.getModifiers();
-        if (this._declaration.isInterface())
-        {
-            modifiers = new ModifierSet(modifiers);
-            modifiers.set(ModifierSet.Modifier.ABSTRACT);
-            modifiers.set(ModifierSet.Modifier.PUBLIC);
-        }
-        return modifiers;
-    }
-
-    @Override
-    public MethodInfo[] getMethods()
-    {
-        return _methods;
-    }
-
-    @Override
-    public String getName()
-    {
-        return _declaration.getName().getIdentifier();
-    }
-
-    @Override
-    public JavaType findParameter(final String name)
-    {
-        Integer index = findParameterIndex(name);
-        if (index == null)
-        {
-            return null;
-        }
-        else
-        {
-            return _parameters[index].getType();
-        }
-    }
-
-    @Override
-    public Integer findParameterIndex(final String name)
-    {
-        int i = 0;
-        for (ASTTypeParameter parameter : _declaration.getTypeParameters().getParameters())
-        {
-            if (parameter.getIdentifier().getIdentifier().equals(name))
-            {
-                return i;
-            }
-            i++;
-        }
-        return null;
-    }
-
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/AbstractMethodInfo.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.util.JavaTypeUtil;
-
-import java.lang.reflect.Method;
-
-public abstract class AbstractMethodInfo implements  MethodInfo {
-
-    protected boolean isDeclaredOnObject()
-    {
-        final Method[] objectMethods = Object.class.getMethods();
-        for (Method objectMethod : objectMethods)
-        {
-            if (matches(objectMethod))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private boolean matches(final Method objectMethod)
-    {
-        if (!objectMethod.getName().equals(getName()))
-        {
-            return false;
-        }
-        if (objectMethod.getParameterTypes().length != getParameterTypes().length)
-        {
-            return false;
-        }
-        for (int i = 0; i < objectMethod.getParameterTypes().length; i++)
-        {
-            if (!JavaTypeUtil.isMatchingType(getParameterTypes()[i], objectMethod.getParameterTypes()[i]))
-            {
-                return false;
-            }
-        }
-        return true;
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/AbstractTypeInfo.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.util.ModifierSet;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public abstract class AbstractTypeInfo implements TypeInfo
-{
-    @Override
-    public Collection<MethodInfo> getAbstractMethods()
-    {
-        final MethodInfo[] methods = getMethods();
-        Collection<MethodInfo> filter = new ArrayList<MethodInfo>(1);
-        for (final MethodInfo method : methods)
-        {
-            if (method.getModifiers().is(ModifierSet.Modifier.ABSTRACT))
-            {
-                filter.add(method);
-            }
-        }
-        return filter;
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/ClassInfo.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.name.TypeParameter;
-import org.adjective.syntactic.parser.type.JavaType;
-
-import java.lang.reflect.TypeVariable;
-
-public class ClassInfo extends AbstractTypeInfo implements TypeInfo, TypeParameterLookup
-{
-    private final Class<?> _cls;
-    private final TypeParameter[] _parameters;
-
-    public ClassInfo(final Class<?> cls, final TypeParameter[] parameters)
-    {
-        _cls = cls;
-        _parameters = parameters;
-    }
-
-    @Override
-    public MethodInfo[] getMethods()
-    {
-        return ClassMethodInfo.array(_cls.getMethods(), this);
-    }
-
-    @Override
-    public String getName()
-    {
-        return _cls.getName();
-    }
-
-    @Override
-    public JavaType findParameter(String name)
-    {
-        final Integer index = findParameterIndex(name);
-        return index == null ? null : _parameters[index].getType();
-    }
-
-    @Override
-    public Integer findParameterIndex(final String name)
-    {
-        final TypeVariable<? extends Class<?>>[] typeParameters = _cls.getTypeParameters();
-        for (int i = 0; i < typeParameters.length; i++)
-        {
-            TypeVariable<? extends Class<?>> typeParameter = typeParameters[i];
-            if (typeParameter.getName().equals(name))
-            {
-                return i;
-            }
-        }
-        return null;
-    }
-
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/ClassMethodInfo.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.util.ModifierSet;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-
-public class ClassMethodInfo extends AbstractMethodInfo implements MethodInfo
-{
-    private final Method _method;
-    private final TypeParameterLookup _parameterLookup;
-
-    public ClassMethodInfo(final Method method, final TypeParameterLookup parameterLookup)
-    {
-        _method = method;
-        _parameterLookup = parameterLookup;
-    }
-
-    public static ClassMethodInfo[] array(final Method[] methods, TypeParameterLookup parameterLookup)
-    {
-        final ClassMethodInfo[] info = new ClassMethodInfo[methods.length];
-        for (int i = 0; i < methods.length; i++)
-        {
-            info[i] = new ClassMethodInfo(methods[i], parameterLookup);
-        }
-        return info;
-    }
-
-    @Override
-    public JavaType getReturnType()
-    {
-        return getJavaType(_method.getGenericReturnType(), _method.getReturnType());
-    }
-
-    @Override
-    public String getName()
-    {
-        return _method.getName();
-    }
-
-    @Override
-    public ModifierSet getModifiers()
-    {
-        final ModifierSet modifiers = new ModifierSet(_method.getModifiers());
-        if (isDeclaredOnObject())
-        {
-            modifiers.clear(ModifierSet.Modifier.ABSTRACT);
-        }
-        return modifiers;
-    }
-
-    @Override
-    public JavaType[] getParameterTypes()
-    {
-        return getJavaTypes(_method.getGenericParameterTypes(), _method.getParameterTypes());
-    }
-
-    private JavaType[] getJavaTypes(final Type[] genericTypes, final Class<?>[] classes)
-    {
-        final JavaType[] javaTypes = new JavaType[genericTypes.length];
-        for (int i = 0; i < genericTypes.length; i++)
-        {
-            javaTypes[i] = getJavaType(genericTypes[i], classes[i]);
-        }
-        return javaTypes;
-    }
-
-    private JavaType getJavaType(final Type parameter, final Class<?> cls)
-    {
-        final JavaType javaType;
-        if (parameter instanceof TypeVariable)
-        {
-            javaType = lookup((TypeVariable) parameter);
-        }
-        else
-        {
-            javaType = new ClassType(cls);
-        }
-        return javaType;
-    }
-
-    private JavaType lookup(final TypeVariable var)
-    {
-        final JavaType type = this._parameterLookup.findParameter(var.getName());
-        return type != null ? type : new ClassType(Object.class);
-    }
-
-    @Override
-    public String[] getParameterNames()
-    {
-        final String[] names = new String[_method.getParameterTypes().length];
-        for (int i = 0; i < names.length; i++)
-        {
-            names[i] = "arg" + i;
-        }
-        return names;
-    }
-
-    @Override
-    public Integer[] getClassTypeParameters()
-    {
-        final Type[] genericTypes = _method.getGenericParameterTypes();
-        final Integer[] index = new Integer[genericTypes.length];
-        for (int i = 0; i < index.length; i++)
-        {
-            Type parameter = genericTypes[i];
-            if (parameter instanceof TypeVariable)
-            {
-                final TypeVariable var = (TypeVariable) parameter;
-                index[i] = _parameterLookup.findParameterIndex(var.getName());
-            }
-        }
-        return index;
-    }
-
-    @Override
-    public boolean isVarArgs()
-    {
-        return _method.isVarArgs();
-    }
-
-    @Override
-    public JavaType[] getExceptionTypes()
-    {
-        return getJavaTypes(_method.getGenericExceptionTypes(), _method.getExceptionTypes());
-    }
-
-    @Override
-    public String toString()
-    {
-        return _method.toString();
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/ClassType.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.type.BaseType;
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.name.ParameterizedName;
-import org.adjective.syntactic.parser.name.UnparameterizedName;
-
-public class ClassType implements JavaType
-{
-
-    private Class<?> _cls;
-
-    public ClassType(Class<?> cls)
-    {
-        _cls = cls;
-    }
-
-    @Override
-    public BaseType getBaseType()
-    {
-        final Class<?> cls = getBaseComponentClass();
-        if (cls.isPrimitive())
-        {
-            if (cls == Void.TYPE)
-            {
-                return BaseType.VOID;
-            }
-            if (cls == Boolean.TYPE)
-            {
-                return BaseType.BOOLEAN;
-            }
-            if (cls == Byte.TYPE)
-            {
-                return BaseType.BYTE;
-            }
-            if (cls == Short.TYPE)
-            {
-                return BaseType.SHORT;
-            }
-            if (cls == Integer.TYPE)
-            {
-                return BaseType.INT;
-            }
-            if (cls == Long.TYPE)
-            {
-                return BaseType.LONG;
-            }
-            if (cls == Float.TYPE)
-            {
-                return BaseType.FLOAT;
-            }
-            if (cls == Double.TYPE)
-            {
-                return BaseType.DOUBLE;
-            }
-            if (cls == Character.TYPE)
-            {
-                return BaseType.CHAR;
-            }
-        }
-        return BaseType.OBJECT;
-    }
-
-    private Class<?> getBaseComponentClass()
-    {
-        Class<?> cls = _cls;
-        while(cls.isArray()) {
-            cls = cls.getComponentType();
-        }
-        return cls;
-    }
-
-    @Override
-    public String getTypeName()
-    {
-        return getBaseComponentClass().getName();
-    }
-
-    @Override
-    public ParameterizedName[] getParameterizedTypeName()
-    {
-        final String[] parts = getTypeName().split("\\.");
-        final ParameterizedName[] names = new ParameterizedName[parts.length];
-        for (int i = 0; i < names.length; i++)
-        {
-            names[i] = new UnparameterizedName(parts[i]);
-        }
-        return names;
-    }
-
-    @Override
-    public int getArrayDepth()
-    {
-        int depth = 0;
-        for (Class cls = _cls; cls.isArray(); cls = cls.getComponentType())
-        {
-            depth++;
-        }
-        return depth;
-    }
-
-    public static ClassType[] array(final Class<?>... cls)
-    {
-        ClassType[] type = new ClassType[cls.length];
-        for (int i = 0; i < cls.length; i++)
-        {
-            type[i] = new ClassType(cls[i]);
-        }
-        return type;
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/MethodInfo.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.type.JavaType;
-import org.adjective.syntactic.parser.util.ModifierSet;
-
-public interface MethodInfo {
-
-    public String getName();
-    public ModifierSet getModifiers();
-    public JavaType getReturnType();
-    public JavaType[] getParameterTypes();
-    public String[] getParameterNames();
-
-    /**
-     * @return An array of integers representing, for each of the parameters of this method, the zero-based index of the enclosing class's type parameters are represented by that method parameter (or null if the method parameter is not a class type parameter)
-     * e.g. For the declaration
-     * <pre>interface C&lt;S,T&gt; {
-     *   void f( String s, T t );
-     * }</pre>
-     * This method would return <code>{ null, 1 }</code>
-     */
-    public Integer[] getClassTypeParameters();
-    public boolean isVarArgs();
-    public JavaType[] getExceptionTypes();
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/TypeInfo.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import java.util.Collection;
-
-public interface TypeInfo
-{
-    public String getName();
-    public MethodInfo[] getMethods();
-    public Collection<MethodInfo> getAbstractMethods();
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/type/TypeParameterLookup.java

-/* ------------------------------------------------------------------------
- * Copyright 2013 Tim Vernum
- * ------------------------------------------------------------------------
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.type;
-
-import org.adjective.syntactic.parser.type.JavaType;
-
-public interface TypeParameterLookup {
-    JavaType findParameter(String name);
-    Integer findParameterIndex(String name);
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/util/ClassFinder.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.util;
-
-import org.adjective.syntactic.convert.j7to8.type.ASTTypeInfo;
-import org.adjective.syntactic.convert.j7to8.type.ClassInfo;
-import org.adjective.syntactic.convert.j7to8.type.TypeInfo;
-import org.adjective.syntactic.parser.ast.ASTClassOrInterfaceDeclaration;
-import org.adjective.syntactic.parser.name.TypeParameter;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class ClassFinder
-{
-    private Map<String, ASTClassOrInterfaceDeclaration> _localTypes;
-
-    public ClassFinder()
-    {
-        _localTypes = new HashMap<String, ASTClassOrInterfaceDeclaration>();
-    }
-
-    public boolean hasClass(final String qualifiedName)
-    {
-        return findClass(qualifiedName) != null;
-    }
-
-    public TypeInfo getClass(final String qualifiedName, TypeParameter[] parameters)
-    {
-        final Class<?> cls = findClass(qualifiedName);
-        if (cls == null)
-        {
-            ASTClassOrInterfaceDeclaration local = _localTypes.get(qualifiedName);
-            return new ASTTypeInfo(local, parameters);
-        }
-        return new ClassInfo(cls, parameters);
-    }
-
-    private Class<?> findClass(final String qualifiedName)
-    {
-        try
-        {
-            return Class.forName(qualifiedName);
-        }
-        catch (ClassNotFoundException e)
-        {
-            return null;
-        }
-    }
-
-    public void define(final ASTClassOrInterfaceDeclaration node)
-    {
-        _localTypes.put(node.getName().getIdentifier(), node);
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/util/Importer.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.util;
-
-import org.adjective.syntactic.parser.ast.ASTImportDeclaration;
-import org.adjective.syntactic.parser.ast.ASTQualifiedIdentifier;
-import org.adjective.syntactic.parser.type.JavaType;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-public class Importer
-{
-    private final ClassFinder _classFinder;
-    private final Map<String, String> typeImports;
-    private final List<String> typeOnDemandImports;
-
-    public Importer(final ClassFinder classFinder)
-    {
-        _classFinder = classFinder;
-        this.typeImports = new LinkedHashMap<String, String>();
-        this.typeOnDemandImports = new ArrayList<String>();
-    }
-
-    public void add(final ASTImportDeclaration node)
-    {
-        if (node.isStatic())
-        {
-            return;
-        }
-        final ASTQualifiedIdentifier identifier = node.getIdentifier();
-        if (node.isOnDemand())
-        {
-            typeOnDemandImports.add(identifier.getName());
-        }
-        else
-        {
-            typeImports.put(identifier.getLastIdentifier().getIdentifier(), identifier.getName());
-        }
-    }
-
-    public String getQualifiedName(String simpleName)
-    {
-        final String importedName = typeImports.get(simpleName);
-        if (importedName != null)
-        {
-            return importedName;
-        }
-        for (String pkg : typeOnDemandImports)
-        {
-            final String qualifiedName = lookupClass(pkg, simpleName);
-            if (qualifiedName != null)
-            {
-                return qualifiedName;
-            }
-        }
-        return lookupClass("java.lang", simpleName);
-    }
-
-    private String lookupClass(final String pkg, final String simpleName)
-    {
-        final String qualifiedName = pkg + "." + simpleName;
-        if (classExists(qualifiedName))
-        {
-            return qualifiedName;
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    private boolean classExists(final String qualifiedName)
-    {
-        return _classFinder.hasClass(qualifiedName);
-    }
-
-    public String getQualifiedName(final JavaType type)
-    {
-        String name = type.getTypeName();
-        if (type.getParameterizedTypeName().length == 1)
-        {
-            String qN = getQualifiedName(name);
-            if (qN != null)
-            {
-                name = qN;
-            }
-        }
-        return name;
-    }
-}

File convert/source/java/main/org/adjective/syntactic/convert/j7to8/util/VariableStack.java

-/*
- * ------------------------------------------------------------------------
- *  Copyright 2013 Tim Vernum
- *  ------------------------------------------------------------------------
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ------------------------------------------------------------------------
- */
-package org.adjective.syntactic.convert.j7to8.util;
-
-import org.adjective.syntactic.parser.node.VariableDeclarationNode;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-public class VariableStack
-{
-    private Stack<Map<String, VariableDeclarationNode>> _stack;
-
-    public VariableStack()
-    {
-        _stack = new Stack<Map<String, VariableDeclarationNode>>();
-    }
-
-    public void pushScope()
-    {
-        _stack.push(new HashMap<String, VariableDeclarationNode>());
-    }
-
-    public void popScope()
-    {
-        _stack.pop();
-    }
-
-    public void store(String name, VariableDeclarationNode var)
-    {
-        final Map<String, VariableDeclarationNode> map = _stack.peek();
-        if (map.containsKey(name))
-        {
-            throw new IllegalArgumentException("Variable '" + name + "' already exists in current scope");
-        }
-        map.put(name, var);
-    }
-
-    public VariableDeclarationNode get(String name)
-    {
-        for (int i = _stack.size() - 1; i >= 0; i--)
-        {
-            final VariableDeclarationNode var = _stack.get(i).get(name);
-            if (var != null)
-            {
-                return var;
-            }
-        }
-        return null;
-    }
-
-}

File convert/source/java/main/org/adjective/syntactic/convert/j8to7/ConversionException.java

+/*
+ * ------------------------------------------------------------------------
+ *  Copyright 2013 Tim Vernum
+ *  ------------------------------------------------------------------------
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  ------------------------------------------------------------------------
+ */
+package org.adjective.syntactic.convert.j8to7;
+
+public class ConversionException extends RuntimeException
+{
+    public ConversionException(final String message)
+    {
+        super(message);
+    }
+
+    public ConversionException(final String message, final Throwable cause)
+    {
+        super(message, cause);
+    }
+}

File convert/source/java/main/org/adjective/syntactic/convert/j8to7/Convert7To8Visitor.java

+/*
+ * ------------------------------------------------------------------------
+ *  Copyright 2013 Tim Vernum
+ *  ------------------------------------------------------------------------
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.