public ParameterDataProvider(Document doc, CodeCompletionContext context) { this.doc = doc; string basepath = (null == doc.Project)? doc.FileName.FullPath.ParentDirectory: doc.Project.BaseDirectory.FullPath; string contents = doc.Editor.Text; string line = doc.Editor.GetLineText (context.TriggerLine); method = RubyCompletion.GetSymbol (contents, context.TriggerOffset-1); int methodIndex = line.IndexOf (method, 0); // Console.WriteLine ("HandleParameterCompletion ({0} {1})", line, methodIndex); if (0 < methodIndex) { int end = line.LastIndexOfAny (RubyCompletion.wordBreakChars, methodIndex); int start = -1; if (0 < end) { start = line.LastIndexOfAny (RubyCompletion.wordBreakChars, end-1)+1; if (0 <= start) { owner = line.Substring (start, end-start); } } // Console.WriteLine ("Owner: {0}-{1}", start, end); } if ("def".Equals (owner, StringComparison.Ordinal) || 0 <= Array.IndexOf (RubyCompletion.reservedWords, method)) { method = owner = string.Empty; methodParams = new string[0]; return; } methodParams = RubyCompletion.GetMethodArguments (basepath, contents, context.TriggerLine-1, owner, method); Valid = (null != methodParams); }
// Returns the index of the parameter where the cursor is currently positioned. // -1 means the cursor is outside the method parameter list // 0 means no parameter entered // > 0 is the index of the parameter (1-based) public int GetCurrentParameterIndex (ICompletionWidget widget, CodeCompletionContext ctx) { int cursor = widget.CurrentCodeCompletionContext.TriggerOffset; int i = ctx.TriggerOffset; if (i < 0 || i >= editor.Length || editor.GetCharAt (i) == ')') return -1; if (i > cursor) return -1; else if (i == cursor) return 0; int parameterIndex = 1; while (i++ < cursor) { if (i >= widget.TextLength) break; char ch = widget.GetChar (i); if (ch == ',') parameterIndex++; else if (ch == ')') return -1; } return parameterIndex; }
public override IParameterDataProvider HandleParameterCompletion(CodeCompletionContext completionContext, char completionChar) { if (mCompletionEnabled) { // HandleCodeCompletion is always called first, so we don't need to fetch completion data if (completionChar == ')' || completionContext.TriggerLine != mCacheTriggerLine) { // invalidate cached completion mCacheXML = null; } if (!mCacheIsObject && mCacheXML != null) { if (parameterDataProvider == null) { parameterDataProvider = new HaxeParameterDataProvider (); parameterDataProvider.Update (completionContext, mCacheXML); return parameterDataProvider; } } else { if (parameterDataProvider != null) { parameterDataProvider.Clear (); parameterDataProvider = null; } } } return null; }
public void Update (CodeCompletionContext completionContext, XmlDocument data) { //showCompletion = true; offset = completionContext.TriggerOffset; signature = data.FirstChild.InnerText.Trim (); //MonoDevelop.Ide.MessageService.ShowError (signature); signature = signature.Replace (" ", ""); signature = signature.Replace ("<", "<"); signature = signature.Replace (">", ">"); string[] splitByOpenParen = signature.Split ('('); signature = ""; for (int i = 0; i < splitByOpenParen.Length; i++) { string[] splitByCloseParen = splitByOpenParen[i].Split (')'); for (int j = 0; j < splitByCloseParen.Length; j++) { if (i > 0 && j == 0) { signature += splitByCloseParen[0].Replace ("->", "->"); } else { signature += splitByCloseParen[i]; } } } //string[] splitByColon = signature.Split (':'); //if (splitByColon.Length > 1) { //parameterName = splitByColon[0]; //signature = splitByColon[1]; //} //MonoDevelop.Ide.MessageService.ShowError (parameterName); //MonoDevelop.Ide.MessageService.ShowError (signature); parameters = signature.Split (new string[] { "->" }, StringSplitOptions.None); for (int i = 0; i < parameters.Length; i++) { parameters[i] = parameters[i].Replace ("->", " -> "); //MonoDevelop.Ide.MessageService.ShowError (parameters[i]); } //MonoDevelop.Ide.MessageService.ShowError (parameters.Length.ToString ()); //MonoDevelop.Ide.MessageService.ShowError (parameters.ToString ()); }
public Task<ICompletionDataList> HandleCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, CodeCompletionContext completionContext, UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc); return completion.HandleCodeCompletionAsync (completionContext, currentChar, token); }
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var completion = CreateCompletion (editor, context, docInfo, out codeCompletionContext); completion.UpdateParsedDocument (); return completion; }
public static bool ShowWindow (char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext, System.Action closedDelegate) { try { if (wnd == null) { wnd = new CompletionListWindow (); wnd.WordCompleted += HandleWndWordCompleted; } try { if (!wnd.ShowListWindow (firstChar, list, completionWidget, completionContext, closedDelegate)) { if (list is IDisposable) ((IDisposable)list).Dispose (); DestroyWindow (); return false; } if (ForceSuggestionMode) wnd.AutoSelect = false; OnWindowShown (EventArgs.Empty); return true; } catch (Exception ex) { LoggingService.LogError (ex.ToString ()); return false; } } finally { ParameterInformationWindowManager.UpdateWindow (completionWidget); } }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength) { var l = new CompletionDataList(); if (!(triggerChar==' ' || char.IsLetter(triggerChar) || triggerChar == '@' || triggerChar == '(' || triggerChar == '_' || triggerChar == '.' || triggerChar == '\0')) return l; triggerWordLength = (char.IsLetter(triggerChar) || triggerChar=='_' || triggerChar=='@') ? 1 : 0; // Require a parsed D source var dom = base.Document.ParsedDocument as ParsedDModule; if (dom != null && dom.DDom!=null) lock(dom.DDom) DCodeCompletionSupport.BuildCompletionData( Document, dom.DDom, completionContext, l, triggerChar); return l; }
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext); completion.UpdateParsedDocument (); return completion; }
// ext may be null, but then parameter completion don't work public static bool ShowWindow (CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { try { if (ext != null) { int inserted = ext.document.Editor.EnsureCaretIsNotVirtual (); if (inserted > 0) completionContext.TriggerOffset = ext.document.Editor.Caret.Offset; } if (wnd == null) { wnd = new CompletionListWindow (); wnd.WordCompleted += HandleWndWordCompleted; } wnd.Extension = ext; try { if (!wnd.ShowListWindow (firstChar, list, completionWidget, completionContext)) { if (list is IDisposable) ((IDisposable)list).Dispose (); HideWindow (); return false; } if (ForceSuggestionMode) wnd.AutoSelect = false; wnd.Show (); DesktopService.RemoveWindowShadow (wnd); OnWindowShown (EventArgs.Empty); return true; } catch (Exception ex) { LoggingService.LogError (ex.ToString ()); return false; } } finally { ParameterInformationWindowManager.UpdateWindow (ext, completionWidget); } }
public ICompletionDataList HandleCompletion (Document realDocument, CodeCompletionContext completionContext, UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc); return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength); }
public static EditorData CreateEditorData(Document EditorDocument, DModule Ast, CodeCompletionContext ctx, char triggerChar = '\0') { bool removeChar = char.IsLetter(triggerChar) || triggerChar == '_'; var deltaOffset = 0;//removeChar ? 1 : 0; var caretOffset = ctx.TriggerOffset - (removeChar ? 1 : 0); var caretLocation = new CodeLocation(ctx.TriggerLineOffset - deltaOffset, ctx.TriggerLine); var codeCache = CreateCacheList(EditorDocument); var ed = new EditorData { CaretLocation = caretLocation, CaretOffset = caretOffset, ModuleCode = removeChar ? EditorDocument.Editor.Text.Remove(ctx.TriggerOffset - 1, 1) : EditorDocument.Editor.Text, SyntaxTree = Ast, ParseCache = codeCache }; if (EditorDocument.HasProject) { var cfg = EditorDocument.Project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration); if (cfg is DProjectConfiguration) { var dcfg = cfg as DProjectConfiguration; ed.GlobalDebugIds = dcfg.CustomDebugIdentifiers; ed.IsDebug = dcfg.DebugMode; ed.DebugLevel = dcfg.DebugLevel; ed.GlobalVersionIds = dcfg.GlobalVersionIdentifiers; double d; ulong v; if (Double.TryParse(EditorDocument.Project.Version, out d)) ed.VersionNumber = (ulong)d; else if (UInt64.TryParse(EditorDocument.Project.Version, out v)) ed.VersionNumber = v; } else if (cfg is DubProjectConfiguration) { var versions = new List<string>(VersionIdEvaluation.GetOSAndCPUVersions()); var dcfg = cfg as DubProjectConfiguration; ed.IsDebug = dcfg.DebugMode; HandleDubSettingsConditionExtraction(versions, (dcfg.ParentItem as DubProject).CommonBuildSettings); HandleDubSettingsConditionExtraction(versions, dcfg.BuildSettings); ed.GlobalVersionIds = versions.ToArray(); } } if (ed.GlobalVersionIds == null) { ed.GlobalVersionIds = VersionIdEvaluation.GetOSAndCPUVersions(); } return ed; }
public override ICompletionDataList HandleCodeCompletion (CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) { var pathCompletion = HandlePathCompletion (); if (pathCompletion != null) { return pathCompletion; } return base.HandleCodeCompletion (completionContext, completionChar, ref triggerWordLength); }
public override ICompletionDataProvider HandleCodeCompletion ( CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) { int pos = completionContext.TriggerOffset; if (pos > 0 && Editor.GetCharAt (pos - 1) == completionChar) { return HandleCodeCompletion ((CodeCompletionContext) completionContext, false, ref triggerWordLength); } return null; }
public int GetCurrentParameterIndex(ICompletionWidget widget, CodeCompletionContext ctx) { if (showCompletion) { return 0; } return -1; }
public override Task<ICompletionDataList> HandleCodeCompletionAsync (CodeCompletionContext completionContext, char completionChar, CancellationToken token = default(CancellationToken)) { var pathCompletion = HandlePathCompletion (); if (pathCompletion != null) { return Task.FromResult (pathCompletion); } return base.HandleCodeCompletionAsync (completionContext, completionChar, token); }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) { if (mCompletionEnabled && completionContext.TriggerOffset != mCacheTriggerOffset) { return GetCompletionList (completionContext); } return null; }
public override Task <ParameterHintingResult> ParameterCompletionCommand(MonoDevelop.Ide.CodeCompletion.CodeCompletionContext completionContext) { var projectedExtension = GetExtensionAt(completionContext.TriggerOffset); if (projectedExtension == null) { return(null); } return(projectedExtension.ParameterCompletionCommand(ConvertContext(completionContext))); }
public override Task <ParameterHintingResult> HandleParameterCompletionAsync(MonoDevelop.Ide.CodeCompletion.CodeCompletionContext completionContext, char completionChar, System.Threading.CancellationToken token) { var projectedExtension = GetExtensionAt(completionContext.TriggerOffset); if (projectedExtension == null) { return(Task.FromResult <ParameterHintingResult> (null)); } return(projectedExtension.HandleParameterCompletionAsync(ConvertContext(completionContext), completionChar, token)); }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength) { updater.FinishUpdate(); if (!EnableCodeCompletion) return null; if (!EnableAutoCodeCompletion && char.IsLetter(triggerChar)) return null; if (char.IsLetterOrDigit(triggerChar) || triggerChar == '_') { if (completionContext.TriggerOffset > 1){ var prevChar = document.Editor.GetCharAt(completionContext.TriggerOffset - 2); if(char.IsLetterOrDigit(prevChar) || prevChar == '"' || prevChar == '#') // Don't trigger if we're already typing an identifier or if we're typing a string suffix (kinda hacky though) return null; } } else if (!(triggerChar==' ' || triggerChar == '@' || triggerChar == '(' || triggerChar == '.' || triggerChar == '\0')) return null; triggerWordLength = (char.IsLetter(triggerChar) || triggerChar=='_' || triggerChar=='@') ? 1 : 0; // Require a parsed D source var dom = base.Document.ParsedDocument as ParsedDModule; if (dom == null || dom.DDom == null) return null; var l = new CompletionDataList(); if (D_Parser.Misc.CompletionOptions.Instance.EnableSuggestionMode) { l.AddKeyHandler(new SuggestionKeyHandler()); l.AutoCompleteUniqueMatch = false; l.AutoCompleteEmptyMatch = false; l.AutoSelect = true; } else l.AddKeyHandler(new DoubleUnderScoreWorkaroundHandler()); lock(dom.DDom) DCodeCompletionSupport.BuildCompletionData( Document, dom.DDom, completionContext, l, triggerChar); return l.Count != 0 ? l : null; }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength) { var completionDataList = new CompletionDataList(); sectionCompletion.FillCompletionList(completionDataList, completionContext, completionChar, ref triggerWordLength); directives.FillCompletionList(completionDataList, completionContext, completionChar, ref triggerWordLength); if(completionDataList.Count == 0) { return null; } return completionDataList; }
public override ICompletionDataProvider CodeCompletionCommand (CodeCompletionContext completionContext) { int pos = completionContext.TriggerOffset; string txt = Editor.GetText (pos - 1, pos); int triggerWordLength = 0; ICompletionDataProvider cp = null; if (txt.Length > 0) cp = HandleCodeCompletion ((CodeCompletionContext) completionContext, true, ref triggerWordLength); return cp; }
public static CompletionDataList CreateProvider (string text, string extension, bool isCtrlSpace) { string parsedText; string editorText; int cursorPosition = text.IndexOf ('$'); int endPos = text.IndexOf ('$', cursorPosition + 1); if (endPos == -1) parsedText = editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1); else { parsedText = text.Substring (0, cursorPosition) + new string (' ', endPos - cursorPosition) + text.Substring (endPos + 1); editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1, endPos - cursorPosition - 1) + text.Substring (endPos + 1); cursorPosition = endPos - 1; } var tww = new MonoDevelop.CSharpBinding.Tests.TestWorkbenchWindow (); var sev = new MonoDevelop.CSharpBinding.Tests.TestViewContent (); var project = new AspNetAppProject ("C#"); project.FileName = UnitTests.TestBase.GetTempFile (".csproj"); string file = UnitTests.TestBase.GetTempFile (extension); project.AddFile (file); ProjectDomService.Load (project); ProjectDom dom = ProjectDomService.GetProjectDom (project); dom.ForceUpdate (true); ProjectDomService.Parse (project, file, delegate { return parsedText; }); ProjectDomService.Parse (project, file, delegate { return parsedText; }); sev.Project = project; sev.ContentName = file; sev.Text = editorText; sev.CursorPosition = cursorPosition; tww.ViewContent = sev; var doc = new MonoDevelop.Ide.Gui.Document (tww); doc.ParsedDocument = new MonoDevelop.AspNet.Parser.AspNetParser ().Parse (null, sev.ContentName, parsedText); foreach (var e in doc.ParsedDocument.Errors) Console.WriteLine (e); var textEditorCompletion = new MonoDevelop.AspNet.Gui.AspNetEditorExtension (); Initialize (textEditorCompletion, doc); int triggerWordLength = 1; CodeCompletionContext ctx = new CodeCompletionContext (); ctx.TriggerOffset = sev.CursorPosition; int line, column; sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column); ctx.TriggerLine = line; ctx.TriggerLineOffset = column - 1; if (isCtrlSpace) return textEditorCompletion.CodeCompletionCommand (ctx) as CompletionDataList; else return textEditorCompletion.HandleCodeCompletion (ctx, editorText[cursorPosition - 1] , ref triggerWordLength) as CompletionDataList; }
public void ShowCompletion (ICompletionDataList completionList) { currentCompletionContext = CompletionWidget.CreateCodeCompletionContext (Document.Editor.Caret.Offset); int cpos, wlen; if (!GetCompletionCommandOffset (out cpos, out wlen)) { cpos = Document.Editor.Caret.Offset; wlen = 0; } currentCompletionContext.TriggerOffset = cpos; currentCompletionContext.TriggerWordLength = wlen; CompletionWindowManager.ShowWindow ('\0', completionList, CompletionWidget, currentCompletionContext, OnCompletionWindowClosed); }
static CodeCompletionContext GetCodeCompletionContext (bool cSharpContext, TestViewContent sev, UnderlyingDocument underlyingDocument) { var ctx = new CodeCompletionContext (); if (!cSharpContext) ctx.TriggerOffset = sev.CursorPosition; else ctx.TriggerOffset = underlyingDocument.Editor.CaretOffset; int line, column; sev.GetLineColumnFromPosition (ctx.TriggerOffset, out line, out column); ctx.TriggerLine = line; ctx.TriggerLineOffset = column - 1; return ctx; }
CSharpCompletionTextEditorExtension CreateCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var documentLocation = docInfo.UnderlyingDocument.Editor.OffsetToLocation (docInfo.CaretPosition); codeCompletionContext = new CodeCompletionContext () { TriggerOffset = docInfo.CaretPosition, TriggerLine = documentLocation.Line, TriggerLineOffset = documentLocation.Column - 1 }; return new CSharpCompletionTextEditorExtension (docInfo.UnderlyingDocument) { CompletionWidget = CreateCompletionWidget (editor, context, docInfo) }; }
protected override ICompletionDataList HandleCodeCompletion (CodeCompletionContext completionContext, bool forced, ref int triggerWordLength) { if ((Tracker.Engine.CurrentState is XmlDoubleQuotedAttributeValueState || Tracker.Engine.CurrentState is XmlSingleQuotedAttributeValueState)) { // completionChar may be a space even if the current char isn't, when ctrl-space is fired t int currentPosition = Editor.CursorPosition; if (currentPosition > 0) { string s = Editor.GetText (currentPosition - Tracker.Engine.CurrentStateLength, currentPosition); if (s.EndsWith ("/")) return GetPathCompletion (s); } } return base.HandleCodeCompletion (completionContext, forced, ref triggerWordLength); }
public static DParameterDataProvider Create(Document doc, DModule SyntaxTree, CodeCompletionContext ctx) { var caretLocation = new CodeLocation (ctx.TriggerLineOffset, ctx.TriggerLine); var edData = DResolverWrapper.CreateEditorData(doc); edData.CaretLocation=caretLocation; edData.CaretOffset=ctx.TriggerOffset; var argsResult = ParameterInsightResolution.ResolveArgumentContext (edData); if (argsResult == null || argsResult.ResolvedTypesOrMethods == null || argsResult.ResolvedTypesOrMethods.Length < 1) return null; return new DParameterDataProvider(doc, argsResult, ctx.TriggerOffset); }
public override ICompletionDataList CodeCompletionCommand (CodeCompletionContext completionContext) { //MonoDevelop.Ide.MessageService.ShowError ("CodeCompletionCommand"); // This default implementation of CodeCompletionCommand calls HandleCodeCompletion providing // the char at the cursor position. If it returns a provider, just return it. int pos = completionContext.TriggerOffset; if (pos > 0) { char ch = Editor.GetCharAt (pos - 1); int triggerWordLength = completionContext.TriggerWordLength; ICompletionDataList completionList = HandleCodeCompletion (completionContext, ch, ref triggerWordLength); if (completionList != null) return completionList; } return null; }
internal static IParameterDataProvider CreateProvider (string text) { string parsedText; string editorText; int cursorPosition = text.IndexOf ('$'); int endPos = text.IndexOf ('$', cursorPosition + 1); if (endPos == -1) parsedText = editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1); else { parsedText = text.Substring (0, cursorPosition) + new string (' ', endPos - cursorPosition) + text.Substring (endPos + 1); editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1, endPos - cursorPosition - 1) + text.Substring (endPos + 1); cursorPosition = endPos - 1; } TestWorkbenchWindow tww = new TestWorkbenchWindow (); TestViewContent sev = new TestViewContent (); DotNetProject project = new DotNetAssemblyProject ("C#"); project.FileName = GetTempFile (".csproj"); string file = GetTempFile (".cs"); project.AddFile (file); ProjectDomService.Load (project); // ProjectDom dom = ProjectDomService.GetProjectDom (project); ProjectDomService.Parse (project, file, delegate { return parsedText; }); ProjectDomService.Parse (project, file, delegate { return parsedText; }); sev.Project = project; sev.ContentName = file; sev.Text = editorText; sev.CursorPosition = cursorPosition; tww.ViewContent = sev; Document doc = new Document (tww); doc.ParsedDocument = new NRefactoryParser ().Parse (null, sev.ContentName, parsedText); CSharpTextEditorCompletion textEditorCompletion = new CSharpTextEditorCompletion (doc); CodeCompletionContext ctx = new CodeCompletionContext (); ctx.TriggerOffset = sev.CursorPosition; int line, column; sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column); ctx.TriggerLine = line; ctx.TriggerLineOffset = column - 1; IParameterDataProvider result = textEditorCompletion.HandleParameterCompletion (ctx, editorText[cursorPosition - 1]); ProjectDomService.Unload (project); return result; }
void PopupCompletion () { Gtk.Application.Invoke (delegate { char c = (char) Gdk.Keyval.ToUnicode (keyValue); if (currentCompletionData == null && IsCompletionChar (c)) { string expr = Buffer.GetText (TokenBegin, Cursor, false); currentCompletionData = GetCompletionData (expr); if (currentCompletionData != null) { DebugCompletionDataList dataList = new DebugCompletionDataList (currentCompletionData); ctx = ((ICompletionWidget) this).CreateCodeCompletionContext (expr.Length - currentCompletionData.ExpressionLength); CompletionWindowManager.ShowWindow (null, c, dataList, this, ctx); } else { currentCompletionData = null; } } }); }
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar) { switch (completionChar) { case '(': case ' ': case '=': case '\t': case '\n': case '.': var compUnit = Document.ParsedDocument.CompilationUnit as PythonCompilationUnit; if (compUnit != null) return GenerateCompletionData (completionContext, compUnit.Module, Editor, completionChar); return null; default: return null; } }
public static bool ShowWindow(char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext, System.Action closedDelegate) { try { if (wnd == null) { wnd = new CompletionListWindow(); wnd.WordCompleted += HandleWndWordCompleted; } try { if (!wnd.ShowListWindow(firstChar, list, completionWidget, completionContext, closedDelegate)) { if (list is IDisposable) { ((IDisposable)list).Dispose(); } DestroyWindow(); return(false); } if (ForceSuggestionMode) { wnd.AutoSelect = false; } OnWindowShown(EventArgs.Empty); return(true); } catch (Exception ex) { LoggingService.LogError(ex.ToString()); return(false); } } finally { ParameterInformationWindowManager.UpdateWindow(completionWidget); } }
internal static void ShowWindow(CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, ParameterHintingResult provider) { if (provider.Count == 0) { return; } // There can be several method parameter lists open at the same time, so // they have to be queued. The last one of queue is the one being shown // in the information window. MethodData md = new MethodData(); md.MethodProvider = provider; md.CurrentOverload = 0; md.CompletionContext = ctx; currentMethodGroup = md; UpdateOverload(ext, widget, default(CancellationToken)); UpdateWindow(ext, widget); }
public static void ShowWindow(CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, ParameterDataProvider provider) { if (provider.Count == 0) { return; } // There can be several method parameter lists open at the same time, so // they have to be queued. The last one of queue is the one being shown // in the information window. MethodData md = new MethodData(); md.MethodProvider = provider; md.CurrentOverload = 0; md.CompletionContext = ctx; methods.Add(md); UpdateOverload(ext, widget); UpdateWindow(ext, widget); }
internal void InitializeListWindow(ICompletionWidget completionWidget, CodeCompletionContext completionContext) { window.InitializeListWindow(completionWidget, completionContext); }
internal bool ShowListWindow(char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { return(window.ShowListWindow(firstChar, list, completionWidget, completionContext)); }
internal bool ShowListWindow(ICompletionDataList list, CodeCompletionContext completionContext) { return(window.ShowListWindow(list, completionContext)); }
internal bool ShowListWindow(char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { controller.InitializeSession(completionWidget, completionContext); return(ShowListWindow(list, completionContext)); }
// ext may be null, but then parameter completion don't work internal static bool ShowWindow(CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { PrepareShowWindow(ext, firstChar, completionWidget, completionContext); return(ShowWindow(list, completionContext)); }
// ext may be null, but then parameter completion don't work internal static void PrepareShowWindow(CompletionTextEditorExtension ext, char firstChar, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { isShowing = true; if (wnd == null) { wnd = new CompletionListWindow(); wnd.WordCompleted += HandleWndWordCompleted; } if (ext != null) { var widget = ext.Editor.GetNativeWidget <Gtk.Widget> (); wnd.TransientFor = widget?.Parent?.Toplevel as Gtk.Window; } else { var widget = completionWidget as Gtk.Widget; if (widget != null) { var window = widget.Toplevel as Gtk.Window; if (window != null) { wnd.TransientFor = window; } } } wnd.Extension = ext; wnd.InitializeListWindow(completionWidget, completionContext); }
public override MonoDevelop.Ide.CodeCompletion.ICompletionDataList ShowCodeTemplatesCommand(MonoDevelop.Ide.CodeCompletion.CodeCompletionContext completionContext) { var projectedExtension = GetExtensionAt(completionContext.TriggerOffset); if (projectedExtension == null) { return(null); } return(projectedExtension.ShowCodeTemplatesCommand(ConvertContext(completionContext))); }
// ext may be null, but then parameter completion don't work public static bool ShowWindow(CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext) { try { if (ext != null) { int inserted = ext.document.Editor.EnsureCaretIsNotVirtual(); if (inserted > 0) { completionContext.TriggerOffset = ext.document.Editor.Caret.Offset; } } if (wnd == null) { wnd = new CompletionListWindow(); wnd.WordCompleted += HandleWndWordCompleted; } if (ext != null) { wnd.TransientFor = ext.document.Editor.Parent.Toplevel as Gtk.Window; } wnd.Extension = ext; try { if (!wnd.ShowListWindow(firstChar, list, completionWidget, completionContext)) { if (list is IDisposable) { ((IDisposable)list).Dispose(); } HideWindow(); return(false); } if (ForceSuggestionMode) { wnd.AutoSelect = false; } wnd.Show(); DesktopService.RemoveWindowShadow(wnd); OnWindowShown(EventArgs.Empty); return(true); } catch (Exception ex) { LoggingService.LogError(ex.ToString()); return(false); } } finally { ParameterInformationWindowManager.UpdateWindow(ext, completionWidget); } }
internal void InitializeListWindow(ICompletionWidget completionWidget, CodeCompletionContext completionContext) { controller.InitializeSession(completionWidget, completionContext); }
public override System.Threading.Tasks.Task <MonoDevelop.Ide.CodeCompletion.ICompletionDataList> HandleCodeCompletionAsync(MonoDevelop.Ide.CodeCompletion.CodeCompletionContext completionContext, char completionChar, System.Threading.CancellationToken token) { var projectedExtension = GetExtensionAt(completionContext.TriggerOffset); if (projectedExtension == null) { return(null); } return(projectedExtension.HandleCodeCompletionAsync(ConvertContext(completionContext), completionChar, token)); }
internal bool ShowListWindow(ICompletionDataList list, CodeCompletionContext completionContext) { if (list == null) { throw new ArgumentNullException("list"); } CodeCompletionContext = completionContext; CompletionDataList = list; ResetState(); mutableList = completionDataList as IMutableCompletionDataList; PreviewCompletionString = completionDataList.CompletionSelectionMode == CompletionSelectionMode.OwnTextField; if (mutableList != null) { mutableList.Changing += OnCompletionDataChanging; mutableList.Changed += OnCompletionDataChanged; if (mutableList.IsChanging) { OnCompletionDataChanging(null, null); } } if (FillList()) { AutoSelect = list.AutoSelect; AutoCompleteEmptyMatch = list.AutoCompleteEmptyMatch; AutoCompleteEmptyMatchOnCurlyBrace = list.AutoCompleteEmptyMatchOnCurlyBrace; CloseOnSquareBrackets = list.CloseOnSquareBrackets; // makes control-space in midle of words to work string text = CompletionWidget.GetCompletionText(CodeCompletionContext); DefaultCompletionString = completionDataList.DefaultCompletionString ?? ""; if (text.Length == 0) { initialWordLength = 0; //completionWidget.SelectedLength; StartOffset = completionContext.TriggerOffset; UpdateWordSelection(); ResetSizes(); ShowAll(); UpdateWordSelection(); UpdateDeclarationView(); //if there is only one matching result we take it by default if (completionDataList.AutoCompleteUniqueMatch && IsUniqueMatch && !IsChanging) { CompleteWord(); CompletionWindowManager.HideWindow(); return(false); } return(true); } initialWordLength = CompletionWidget.SelectedLength > 0 ? 0 : text.Length; StartOffset = CompletionWidget.CaretOffset - initialWordLength; HideWhenWordDeleted = initialWordLength != 0; ResetSizes(); UpdateWordSelection(); //if there is only one matching result we take it by default if (completionDataList.AutoCompleteUniqueMatch && IsUniqueMatch && !IsChanging) { CompleteWord(); CompletionWindowManager.HideWindow(); return(false); } ShowAll(); UpdateDeclarationView(); return(true); } CompletionWindowManager.HideWindow(); return(false); }
public CodeCompletionContextEventArgs(ICompletionWidget widget, CodeCompletionContext codeCompletionContext, string completedWord) { this.Widget = widget; this.CodeCompletionContext = codeCompletionContext; this.CompletedWord = completedWord; }
internal bool ShowListWindow(char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext, System.Action closedDelegate) { if (mutableList != null) { mutableList.Changing -= OnCompletionDataChanging; mutableList.Changed -= OnCompletionDataChanged; HideFooter(); } //initialWordLength = 0; this.completionDataList = list; this.CompleteWithSpaceOrPunctuation = MonoDevelop.Core.PropertyService.Get("CompleteWithSpaceOrPunctuation", true); this.CodeCompletionContext = completionContext; this.closedDelegate = closedDelegate; mutableList = completionDataList as IMutableCompletionDataList; List.PreviewCompletionString = completionDataList.CompletionSelectionMode == CompletionSelectionMode.OwnTextField; if (mutableList != null) { mutableList.Changing += OnCompletionDataChanging; mutableList.Changed += OnCompletionDataChanged; if (mutableList.IsChanging) { OnCompletionDataChanging(null, null); } } this.CompletionWidget = completionWidget; if (FillList()) { // not neccessarry, because list window is not reused anymore: // Reset (true); this.AutoSelect = list.AutoSelect; this.AutoCompleteEmptyMatch = list.AutoCompleteEmptyMatch; // makes control-space in midle of words to work string text = completionWidget.GetCompletionText(completionContext); DefaultCompletionString = completionDataList.DefaultCompletionString ?? ""; if (text.Length == 0) { UpdateWordSelection(); initialWordLength = 0; //completionWidget.SelectedLength; ResetSizes(); ShowAll(); UpdateWordSelection(); //if there is only one matching result we take it by default if (completionDataList.AutoCompleteUniqueMatch && IsUniqueMatch && !IsChanging) { CompleteWord(); CompletionWindowManager.HideWindow(); } return(true); } initialWordLength = text.Length /*+ completionWidget.SelectedLength*/; PartialWord = text; UpdateWordSelection(); //if there is only one matching result we take it by default if (completionDataList.AutoCompleteUniqueMatch && IsUniqueMatch && !IsChanging) { CompleteWord(); CompletionWindowManager.HideWindow(); } else { ResetSizes(); ShowAll(); } return(true); } CompletionWindowManager.HideWindow(); return(false); }