IList<ResolveResult> ResolveCallArguments(ITextEditor editor) { var rr = new List<ResolveResult>(); int cursor_offset = editor.Caret.Offset; var line_text = editor.Document.GetLineForOffset(cursor_offset).Text; var parser = ParserFactory.CreateCommonParser(kind); var stmt = parser.ParseOneStatement(line_text) as Statement; if(stmt != null){ var command_invoke = stmt.Expr as InvocationExpression; if(command_invoke == null) return rr; var resolver = new BVE5AstResolver(new BVE5Resolver(BVE5LanguageBinding.Compilation), stmt, (BVE5UnresolvedFile)BVE5LanguageBinding.ProjectContent.GetFile(editor.FileName)); foreach(var arg in command_invoke.Arguments) rr.Add(resolver.Resolve(arg)); } return rr; }
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; }