internal static ParameterHintingResult 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; } var workspace = new InspectionActionTestBase.TestWorkspace (); var projectId = ProjectId.CreateNewId(); //var solutionId = SolutionId.CreateNewId(); var documentId = DocumentId.CreateNewId(projectId); workspace.Open(ProjectInfo.Create( projectId, VersionStamp.Create(), "TestProject", "TestProject", LanguageNames.CSharp, null, null, new CSharpCompilationOptions ( OutputKind.DynamicallyLinkedLibrary, false, "", "", "Script", null, OptimizationLevel.Debug, false, false ), new CSharpParseOptions ( LanguageVersion.CSharp6, DocumentationMode.None, SourceCodeKind.Regular, ImmutableArray.Create("DEBUG", "TEST") ), new [] { DocumentInfo.Create( documentId, "a.cs", null, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(SourceText.From(parsedText), VersionStamp.Create())) ) }, null, InspectionActionTestBase.DefaultMetadataReferences ) ); var engine = new ParameterHintingEngine (workspace, new TestFactory ()); var compilation = workspace.CurrentSolution.GetProject(projectId).GetCompilationAsync().Result; if (!workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(editorText)))) { Assert.Fail(); } var document = workspace.CurrentSolution.GetDocument(documentId); var semanticModel = document.GetSemanticModelAsync().Result; return engine.GetParameterDataProviderAsync(document, semanticModel, cursorPosition).Result; }
internal static ParameterHintingResult 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; } var workspace = new InspectionActionTestBase.TestWorkspace(); var projectId = ProjectId.CreateNewId(); //var solutionId = SolutionId.CreateNewId(); var documentId = DocumentId.CreateNewId(projectId); workspace.Open(ProjectInfo.Create( projectId, VersionStamp.Create(), "TestProject", "TestProject", LanguageNames.CSharp, null, null, new CSharpCompilationOptions( OutputKind.DynamicallyLinkedLibrary, false, "", "", "Script", null, OptimizationLevel.Debug, false, false ), new CSharpParseOptions( LanguageVersion.CSharp6, DocumentationMode.None, SourceCodeKind.Regular, ImmutableArray.Create("DEBUG", "TEST") ), new [] { DocumentInfo.Create( documentId, "a.cs", null, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(SourceText.From(parsedText), VersionStamp.Create())) ) }, null, InspectionActionTestBase.DefaultMetadataReferences ) ); var engine = new ParameterHintingEngine(workspace, new TestFactory()); var compilation = workspace.CurrentSolution.GetProject(projectId).GetCompilationAsync().Result; if (!workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(editorText)))) { Assert.Fail(); } var document = workspace.CurrentSolution.GetDocument(documentId); var semanticModel = document.GetSemanticModelAsync().Result; return(engine.GetParameterDataProviderAsync(document, semanticModel, cursorPosition).Result); }
internal static MonoDevelop.Ide.CodeCompletion.ParameterHintingResult CreateProvider(string text, bool force = false) { 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 workspace = new InspectionActionTestBase.TestWorkspace(); var projectId = ProjectId.CreateNewId(); //var solutionId = SolutionId.CreateNewId(); var documentId = DocumentId.CreateNewId(projectId); workspace.Open(ProjectInfo.Create( projectId, VersionStamp.Create(), "TestProject", "TestProject", LanguageNames.CSharp, null, null, new CSharpCompilationOptions( OutputKind.DynamicallyLinkedLibrary, false, "", "", "Script", null, OptimizationLevel.Debug, false, false ), new CSharpParseOptions( LanguageVersion.CSharp6, DocumentationMode.None, SourceCodeKind.Regular, ImmutableArray.Create("DEBUG", "TEST") ), new [] { DocumentInfo.Create( documentId, "a.cs", null, SourceCodeKind.Regular, TextLoader.From(TextAndVersion.Create(SourceText.From(parsedText), VersionStamp.Create())) ) }, null, InspectionActionTestBase.DefaultMetadataReferences ) ); var engine = new MonoDevelop.CSharp.Completion.RoslynParameterHintingEngine(); var compilation = workspace.CurrentSolution.GetProject(projectId).GetCompilationAsync().Result; if (!workspace.TryApplyChanges(workspace.CurrentSolution.WithDocumentText(documentId, SourceText.From(editorText)))) { Assert.Fail(); } var document = workspace.CurrentSolution.GetDocument(documentId); var semanticModel = document.GetSemanticModelAsync().Result; if (force) { var workspace1 = TypeSystemService.Workspace; var mefExporter = (IMefHostExportProvider)workspace1.Services.HostServices; var helpProviders = mefExporter.GetExports <ISignatureHelpProvider, LanguageMetadata> () .FilterToSpecificLanguage(LanguageNames.CSharp).ToList(); return(engine.GetParameterDataProviderAsync(helpProviders, document, cursorPosition, new SignatureHelpTriggerInfo(SignatureHelpTriggerReason.InvokeSignatureHelpCommand)).Result); } else { return(engine.GetParameterDataProviderAsync(document, cursorPosition).Result); } }