-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFindResultDoc.ts
More file actions
45 lines (38 loc) · 1.51 KB
/
FindResultDoc.ts
File metadata and controls
45 lines (38 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
import * as vscode from 'vscode';
import CscopeExecutor from './CscopeExecutor';
export default class FindResultDoc {
private links: vscode.DocumentLink[];
private docContent : string;
private docUri : string;
constructor (uri: vscode.Uri, fileList : any){
const [briefText, symbol, functionIndex] = <[string, string, number]>JSON.parse(uri.query);
const briefing = `${briefText} "${symbol}":\n`;
this.docUri = uri.toString();
// const fileList = executor.runSearch(symbol, functionIndex);
let content = '';
let lineNum = 1;
const workspacePathLen = vscode.workspace.rootPath.length;
this.links = [];
fileList.forEach((line) =>{
// const fileInfo = line.fileName.slice(workspacePathLen) + ':' + line.lineNum
const fileInfo = line.fileName + ':' + line.lineNum;
content += fileInfo + ` ${line.otherText}\n`;
const linkRange = new vscode.Range(lineNum, 0, lineNum, fileInfo.length);
const linkTarget = vscode.Uri.parse(`file:${line.fileName}#${line.lineNum}`);
const docLink = new vscode.DocumentLink(linkRange, linkTarget);
this.links.push(docLink);
lineNum++;
});
this.docContent = briefing + content;
}
getDocContent():string{
return this.docContent;
}
getUri() :string{
return this.docUri;
}
getDocLinks():vscode.ProviderResult<vscode.DocumentLink[]>{
return this.links;
}
}