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);
        }
Beispiel #2
0
 public override void TearDown()
 {
     ProjectDomService.Unload(solution);
     base.TearDown();
 }