protected internal override Task OnDispose() { textDocument?.Dispose(); return(base.OnDispose()); }
private IPeekResult CreatePeekResult(LocationInfo location) { IPeekResult result = null; var path = location.FilePath; if (!string.IsNullOrWhiteSpace(path)) { var fi = new FileInfo(path); var displayInfo = new PeekResultDisplayInfo(BuildLabel(location), path, BuildTitle(location), path); // TODO: the location stuff doesn't work 100% correctly. This needs to be fixed string contentType = null; var extension = Path.GetExtension(path); if (extension != null) { switch (extension.ToLower()) { case ".4gl": contentType = VSGeneroConstants.ContentType4GL; break; case ".inc": contentType = VSGeneroConstants.ContentTypeINC; break; case ".per": contentType = VSGeneroConstants.ContentTypePER; break; } } if (contentType != null) { ITextDocument textDoc = null; int line = location.Line - 1; if (line < 0) { textDoc = this._factory.TextDocumentFactoryService.CreateAndLoadTextDocument(path, this._factory.ContentTypeRegistryService.GetContentType(contentType)); line = textDoc.TextBuffer.CurrentSnapshot.GetLineNumberFromPosition(location.Index); } int character = location.Column - 1; // start index if (character < 0) { character = 0; } //EditorExtensions.EditorExtensions.GetLineAndColumnOfFile(path, location.Position, out line, out character); int endLine = line + 10; // end line int endIndex = 0; // end index int positionLine = 0; // id line int positionChar = 0; // id index bool isReadOnly = fi.IsReadOnly; // TODO: determine the stuff above. result = this._factory.PeekResultFactory.Create(displayInfo, path, line, character, endLine, endIndex, positionLine, positionChar, isReadOnly); result.Disposed += (x, y) => { if (textDoc != null) { textDoc.Dispose(); } }; } } else if (!string.IsNullOrWhiteSpace(location.DefinitionURL)) { #if DEV14_OR_LATER return(new UrlPeekResult(location.GetUrlString(_languageVersion))); #endif } return(result); }