public static ResolveResult Resolve(Lazy<ICompilation> compilation, BVE5UnresolvedFile unresolvedFile, SyntaxTree syntaxTree,
		                                    TextLocation location, out AstNode node, CancellationToken cancellationToken = default(CancellationToken))
        {
            node = syntaxTree.GetNodeAt(location);
            if(node == null)
                return null;

            if(BVE5AstResolver.IsUnresolvableNode(node)){
                if(node is Identifier){
                    node = node.Parent;
                }/*else if(node.NodeType == NodeType.Token){
                    if(node.Parent is IndexerExpression){
                        Console.WriteLine (2);
                        // There's no other place where one could hover to see the indexer's tooltip,
                        // so we need to resolve it when hovering over the '[' or ']'.
                        // For constructor initializer, the same applies to the 'base'/'this' token.
                        node = node.Parent;
                    }else{
                        return null;
                    }
                }*/else{
                    // don't resolve arbitrary nodes - we don't want to show tooltips for everything
                    return null;
                }
            }else{
                // It's a resolvable node.
                // However, we usually don't want to show the tooltip everywhere
                // For example, hovering with the mouse over an empty line between two methods causes
                // node==TypeDeclaration, but we don't want to show any tooltip.

                /*if(!node.GetChildByRole(Roles.Identifier).IsNull){
                    // We'll suppress the tooltip for resolvable nodes if there is an identifier that
                    // could be hovered over instead:
                    return null;
                }*/
            }
            if(node == null)
                return null;

            InvocationExpression parent_invocation = null;
            if(node is MemberReferenceExpression){
                // we also need to resolve the invocation
                parent_invocation = node.Parent as InvocationExpression;
            }

            // TODO: I think we should provide an overload so that an existing CSharpAstResolver can be reused
            var resolver = new BVE5AstResolver(compilation.Value, syntaxTree, unresolvedFile);
            ResolveResult rr = resolver.Resolve(node, cancellationToken);
            if(rr is MethodGroupResolveResult && parent_invocation != null)
                return resolver.Resolve(parent_invocation);
            else
                return rr;
        }
        /// <summary>
        /// Creates a new BVE5 AST resolver.
        /// Use this overload if you are resolving code snippets (not necessarily complete files).
        /// </summary>
        /// <param name="resolver">The resolver state at the root node (to be more precise: just outside the root node).</param>
        /// <param name="rootNode">The root node of the tree to be resolved.</param>
        /// <param name="unresolvedFile">
        /// Optional: Result of <see cref="SyntaxTree.ToTypeSystem()"/> for the file being resolved.
        /// <para>
        /// This is used for setting up the context on the resolver. The unresolved file must be registered in the compilation.
        /// </para>
        /// <para>
        /// When a unresolvedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
        /// member declarations in the AST with members in the type system.
        /// When no unresolvedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
        /// member's signature in the AST with the signature in the type system.
        /// </para>
        /// </param>
        public BVE5AstResolver(BVE5Resolver resolver, AstNode rootNode, BVE5UnresolvedFile unresolvedFile = null)
        {
            if(resolver == null)
                throw new ArgumentNullException("resolver");

            if(rootNode == null)
                throw new ArgumentNullException("rootNode");

            initial_resolver_state = resolver;
            root_node = rootNode;
            unresolved_file = unresolvedFile;
            resolve_visitor = new ResolveVisitor(initial_resolver_state, unresolvedFile);
        }
        /// <summary>
        /// Creates a new BVE5 AST resolver.
        /// Use this overload if you are resolving within a complete BVE5 file.
        /// </summary>
        /// <param name="compilation">The current compilation.</param>
        /// <param name="syntaxTree">The syntax tree to be resolved.</param>
        /// <param name="unresolvedFile">
        /// Optional: Result of <see cref="SyntaxTree.ToTypeSystem()"/> for the file being resolved.
        /// <para>
        /// This is used for setting up the context on the resolver. The unresolved file must be registered in the compilation.
        /// </para>
        /// <para>
        /// When a unresolvedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
        /// member declarations in the AST with members in the type system.
        /// When no unresolvedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
        /// member's signature in the AST with the signature in the type system.
        /// </para>
        /// </param>
        public BVE5AstResolver(ICompilation compilation, SyntaxTree syntaxTree, BVE5UnresolvedFile unresolvedFile = null)
        {
            if(compilation == null)
                throw new ArgumentNullException("compilation");

            if(syntaxTree == null)
                throw new ArgumentNullException("syntaxTree");

            initial_resolver_state = new BVE5Resolver(compilation);
            root_node = syntaxTree;
            unresolved_file = unresolvedFile;
            resolve_visitor = new ResolveVisitor(initial_resolver_state, unresolvedFile);
        }
        /// <summary>
        /// Creates a new BVE5 AST resolver.
        /// Use this overload if you are resolving within a complete BVE5 file.
        /// </summary>
        /// <param name="compilation">The current compilation.</param>
        /// <param name="syntaxTree">The syntax tree to be resolved.</param>
        /// <param name="unresolvedFile">
        /// Optional: Result of <see cref="SyntaxTree.ToTypeSystem()"/> for the file being resolved.
        /// <para>
        /// This is used for setting up the context on the resolver. The unresolved file must be registered in the compilation.
        /// </para>
        /// <para>
        /// When the unresolvedFile is specified, the resolver will use the member's StartLocation/EndLocation to identify
        /// member declarations in the AST with members in the type system.
        /// When no unresolvedFile is specified (<c>null</c> value for this parameter), the resolver will instead compare the
        /// member's signature in the AST with the signature in the type system.
        /// </para>
        /// </param>
        public BVE5AstResolver(BVE5Compilation compilation, SyntaxTree syntaxTree, BVE5UnresolvedFile unresolvedFile = null)
        {
            if(compilation == null)
                throw new ArgumentNullException("compilation");

            if(syntaxTree == null)
                throw new ArgumentNullException("syntaxTree");

            initial_resolver_state = new BVE5Resolver(compilation);
            root_node = syntaxTree;
            unresolved_file = unresolvedFile;
            resolve_visitor = new ResolveVisitor(initial_resolver_state, unresolvedFile, FileKindHelper.GetTypeNameFromFileKind(syntaxTree.Kind));
        }