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, null, delegate { return(parsedText); }); ProjectDomService.Parse(project, file, null, 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; IParameterDataProvider result = textEditorCompletion.HandleParameterCompletion(ctx, editorText[cursorPosition - 1]); ProjectDomService.Unload(project); return(result); }
public MemberCompletionData(CSharpTextEditorCompletion editorCompletion, INode member, OutputFlags flags) { this.editorCompletion = editorCompletion; this.flags = flags; SetMember(member); DisplayFlags = DisplayFlags.DescriptionHasMarkup; IMember m = Member as IMember; if (m != null && m.IsObsolete) { DisplayFlags |= DisplayFlags.Obsolete; } }
void InitTracker() { //if there's a CSharpTextEditorCompletion in the extension chain, we can reuse its stateTracker CSharpTextEditorCompletion c = this.Document.GetContent <CSharpTextEditorCompletion> (); if (c != null && c.StateTracker != null) { stateTracker = c.StateTracker; } else { stateTracker = new DocumentStateTracker <CSharpIndentEngine> (new CSharpIndentEngine(policy), textEditorData); } }