package com.github.javaparser.symbolsolver;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.type.ArrayType;
import com.github.javaparser.ast.type.Type;
import com.github.javaparser.resolution.SymbolResolver;
import com.github.javaparser.resolution.types.ResolvedType;
import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade;
import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserMethodDeclaration;
import com.github.javaparser.symbolsolver.model.resolution.TypeSolver;

/**
 * This implementation of the SymbolResolver wraps the functionalities of the library to make them easily usable
 * from JavaParser nodes.
 *
 * An instance of this class should be created once and then injected in all the CompilationUnit for which we
 * want to enable symbol resolution. To do so the method inject can be used.
 *
 * @author Federico Tomassetti
 */
public class JavaSymbolSolver implements SymbolResolver {

    private TypeSolver typeSolver;

    public JavaSymbolSolver(TypeSolver typeSolver) {
        this.typeSolver = typeSolver;
    }

    /**
     * Register this SymbolResolver into a CompilationUnit, so that symbol resolution becomes available to
     * all nodes part of the CompilationUnit.
     */
    public void inject(CompilationUnit destination) {
        destination.setData(Node.SYMBOL_RESOLVER_KEY, this);
    }

    @Override
    public <T> T resolveDeclaration(Node node, Class<T> resultClass) {
        if (node instanceof MethodDeclaration) {
            return resultClass.cast(new JavaParserMethodDeclaration((MethodDeclaration)node, typeSolver));
        }
        throw new UnsupportedOperationException("Unable to find the declaration of type " + resultClass.getSimpleName()
                + " from " + node.getClass().getSimpleName());
    }

    @Override
    public <T> T toResolvedType(Type javaparserType, Class<T> resultClass) {
        if (javaparserType instanceof ArrayType) {
            return resultClass.cast(JavaParserFacade.get(typeSolver).convert((ArrayType)javaparserType, javaparserType));
        }
        throw new UnsupportedOperationException("Unable to get the resolved type of class "
                + resultClass.getSimpleName() + " from " + javaparserType);
    }

    @Override
    public ResolvedType calculateType(Expression expression) {
        throw new UnsupportedOperationException("Unable to calculate type of " + expression);
    }
}

@@ -123,24 +123,91 @@
 r.ast.Node;%0A
+import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;%0A
 import com.g
@@ -243,32 +243,32 @@
 hodDeclaration;%0A
-
 import com.githu
@@ -450,16 +450,103 @@
 solver;%0A
+import com.github.javaparser.resolution.declarations.ResolvedReferenceTypeDeclaration;%0A
 import c
@@ -669,24 +669,101 @@
 rserFacade;%0A
+import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFactory;%0A
 import com.g
@@ -2020,32 +2020,401 @@
 er));%0A        %7D%0A
+        if (node instanceof ClassOrInterfaceDeclaration) %7B%0A            ResolvedReferenceTypeDeclaration resolvedReferenceTypeDeclaration = JavaParserFactory.toTypeDeclaration(node, typeSolver);%0A            if (resultClass.isInstance(resolvedReferenceTypeDeclaration)) %7B%0A                return resultClass.cast(resolvedReferenceTypeDeclaration);%0A            %7D%0A        %7D%0A
         throw ne
@@ -2690,87 +2690,36 @@
     
-if (javaparserType instanceof ArrayType) %7B%0A            return resultClass.cast(
+ResolvedType resolvedType = 
 Java
@@ -2758,20 +2758,32 @@
 vert
-((Array
+ToUsage(javaparser
 Type
-)
+, 
 java
@@ -2796,26 +2796,112 @@
 Type
-, javaparser
+);%0A        if (resultClass.isInstance(resolvedType)) %7B%0A            return resultClass.cast(resolved
 Type)
-)
 ;%0A  
@@ -3172,81 +3172,56 @@
     
-throw new UnsupportedOperationException(%22Unable to calculate type of %22 + 
+return JavaParserFacade.get(typeSolver).getType(
 expr

revise the implementation of JavaSymbolSolver to address the current interface