/// <summary> /// Returns function declaration line from source code. /// </summary> /// <param name="node">The node.</param> /// <param name="document">The document.</param> /// <returns></returns> public static TextPoint GetFunctionDeclarationFromSource( FunctionDeclaration node, TextDocument document) { TextPoint endPoint = null; string name = node.Name; var functionLineText = GetCodeLineText(document, node.Location.sLin); if (!string.IsNullOrEmpty(functionLineText)) { int startIndex = functionLineText.ToLower().IndexOf("function", StringComparison.CurrentCultureIgnoreCase); if (startIndex > -1) { int nameIndex = functionLineText.IndexOf(name); endPoint = new LuaTextPoint(document, nameIndex + name.Length + 2, node.Location.sLin); } } return endPoint; }
/// <summary> /// Converts a LexLocation type to TextPoint. /// </summary> /// <param name="location">LexLocation instance.</param> /// <param name="document">TextDocument</param> /// <returns>new LexLocation instance</returns> public static TextPoint LexLocationToTextPoint(TextDocument document, LexLocation location) { TextPoint point = new LuaTextPoint(document, location.sCol, location.sLin); return point; }
/// <summary> /// Gets CodeElement by actual EditPoint. /// </summary> /// <returns></returns> public CodeElement GetElementByEditPoint() { var textDocument = (TextDocument) ProjectItem.Document.Object("TextDocument"); var point = new LuaTextPoint(textDocument, textDocument.Selection.ActivePoint.LineCharOffset, textDocument.Selection.ActivePoint.Line); var element = GetElementByEditPoint(point); return element; }