public MemberSorter(DTE dte, bool findMembers) { ThreadHelper.ThrowIfNotOnUIThread(); this.textHandler = new TextDocumentHandler(dte); this.language = this.textHandler.Language; if (this.textHandler.HasNonEmptySelection && this.textHandler.Document != null && (this.language == Language.CSharp || this.language == Language.VB)) { this.selectionStart = this.textHandler.Selection.TopPoint; this.selectionEnd = this.textHandler.Selection.BottomPoint; ProjectItem item = this.textHandler.Document.ProjectItem; if (item != null) { if (item.FileCodeModel is FileCodeModel2 codeModel && codeModel.ParseStatus == vsCMParseStatus.vsCMParseStatusComplete) { // For CommandProcessor.CanExecute, we don't actually want to find the members (since // CanExecute is called A LOT). We just want to know if we got far enough to try. this.CanFindMembers = true; if (findMembers) { this.memberLists = FindMembers(codeModel.CodeElements, this.IsMemberSelected); } } } } }
public static EditorData CreateEditorData(TextDocumentPositionParams documentPositionParams, CancellationToken cancellationToken) { var module = TextDocumentHandler.GetAstModule(documentPositionParams.TextDocument.Uri); var code = TextDocumentHandler.GetModuleCode(documentPositionParams.TextDocument.Uri); var caret = new CodeLocation((int)documentPositionParams.Position.Character + 1, (int)documentPositionParams.Position.Line + 1); return(new EditorData { ParseCache = CreateParseCacheView(), CancelToken = cancellationToken, CaretLocation = caret, CaretOffset = DocumentHelper.LocationToOffset(code, caret), ModuleCode = code, SyntaxTree = module, GlobalVersionIds = VersionIdEvaluation.GetOSAndCPUVersions() }); }