} // GetExpressionType /// <summary> /// Get overloads for a method /// </summary> internal List <Afrodite.Symbol> GetOverloads(string name, string filename, int line, int column) { List <Afrodite.Symbol> overloads = new List <Afrodite.Symbol> (); if (!DepsInstalled) { return(overloads); } using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom()) { if (null != parseTree) { Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath(name, filename, line, column); overloads = new List <Afrodite.Symbol> () { symbol }; } else { LoggingService.LogDebug("GetOverloads: Unable to acquire codedom"); } } return(overloads); } // GetOverloads
/// <summary> /// Get the type of a given expression /// </summary> public string GetExpressionType(string symbol, string filename, int line, int column) { if (!DepsInstalled) { return(symbol); } using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom()) { if (null != parseTree) { LoggingService.LogDebug("GetExpressionType: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol sym = parseTree.LookupSymbolAt(filename, line, column); if (null != sym) { LoggingService.LogDebug("Got {0}", sym.SymbolType.TypeName); return(sym.SymbolType.TypeName); } } else { LoggingService.LogDebug("GetExpressionType: Unable to acquire codedom"); } } return(symbol); } // GetExpressionType
} // AddPackage /// <summary> /// Gets the completion list for a given symbol at a given location /// </summary> internal List <Afrodite.Symbol> Complete(string symbol, string filename, int line, int column, ValaCompletionDataList results) { List <Afrodite.Symbol> nodes = new List <Afrodite.Symbol> (); if (!DepsInstalled) { return(nodes); } using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom()) { if (null != parseTree) { LoggingService.LogDebug("Complete: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol sym = parseTree.GetSymbolForNameAndPath(symbol, filename, line, column); LoggingService.LogDebug("Complete: Got {0}", (null == sym)? "null": sym.Name); if (null != sym) { nodes = sym.Children; AddResults(nodes, results); } } else { LoggingService.LogDebug("Complete: Unable to acquire codedom"); } } return(nodes); } // Complete
/// <summary> /// Gets the completion list for a given type name in a given file /// </summary> internal List <Afrodite.Symbol> CompleteType(string typename, string filename, int linenum, int column, ValaCompletionDataList results) { List <Afrodite.Symbol> nodes = new List <Afrodite.Symbol> (); if (!DepsInstalled) { return(nodes); } using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom()) { if (null != parseTree) { Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath(typename, filename, linenum, column); if (null == symbol) { LoggingService.LogDebug("CompleteType: Unable to lookup {0} in {1} at {2}:{3}", typename, filename, linenum, column); } else { nodes = symbol.Children; } } else { LoggingService.LogDebug("CompleteType: Unable to acquire codedom"); } } return(nodes); }
} // GetConstructorsForExpression /// <summary> /// Get types visible from a given source location /// </summary> internal void GetTypesVisibleFrom(string filename, int line, int column, ValaCompletionDataList results) { if (!DepsInstalled) { return; } // Add contents of parents ICollection <Afrodite.Symbol> containers = GetClassesForFile(filename); AddResults(containers, results); foreach (Afrodite.Symbol klass in containers) { // TODO: check source references once afrodite reliably captures the entire range for (Afrodite.Symbol parent = klass.Parent; parent != null; parent = parent.Parent) { AddResults(parent.Children.FindAll(delegate(Afrodite.Symbol sym){ return(0 <= Array.IndexOf(containerTypes, sym.SymbolType.ToLower())); }), results); } } using (Afrodite.Ast parseTree = engine.TryAcquireAst()) { if (null == parseTree) { return; } AddResults(GetNamespacesForFile(filename), results); AddResults(GetClassesForFile(filename), results); Afrodite.SourceFile file = parseTree.LookupSourceFile(filename); if (null != file) { Afrodite.Symbol parent; foreach (Afrodite.Symbol directive in file.UsingDirectives) { Afrodite.Symbol ns = parseTree.Lookup(directive.FullyQualifiedName, out parent); if (null != ns) { containers = new List <Afrodite.Symbol> (); AddResults(new Afrodite.Symbol[] { ns }, results); foreach (Afrodite.Symbol child in ns.Children) { foreach (string containerType in containerTypes) { if (containerType.Equals(child.SymbolType, StringComparison.OrdinalIgnoreCase)) { containers.Add(child); } } } AddResults(containers, results); } } } } } // GetTypesVisibleFrom
} // Complete internal Afrodite.Symbol GetFunction(string name, string filename, int line, int column) { if (!DepsInstalled) { return(null); } using (Afrodite.CodeDom parseTree = engine.TryAcquireCodeDom()) { if (null != parseTree) { LoggingService.LogDebug("GetFunction: Looking up symbol at {0}:{1}:{2}", filename, line, column); Afrodite.Symbol symbol = parseTree.GetSymbolForNameAndPath(name, filename, line, column); LoggingService.LogDebug("GetFunction: Got {0}", (null == symbol)? "null": symbol.Name); return(symbol); } else { LoggingService.LogDebug("GetFunction: Unable to acquire codedom"); } } return(null); }