-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from kortina/ak-reference-provider
add reference provider (for peek/find references) and create note when definition not found
Showing
17 changed files
with
1,215 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as path from 'path'; | ||
|
||
import { runTests } from 'vscode-test'; | ||
|
||
async function main() { | ||
try { | ||
// The folder containing the Extension Manifest package.json | ||
// Passed to `--extensionDevelopmentPath` | ||
const extensionDevelopmentPath = path.resolve(__dirname, '../../'); | ||
|
||
// The path to the extension test script | ||
// Passed to --extensionTestsPath | ||
const extensionTestsPath = path.resolve(__dirname, './suite/index'); | ||
|
||
// Download VS Code, unzip it and run the integration test | ||
await runTests({ extensionDevelopmentPath, extensionTestsPath }); | ||
} catch (err) { | ||
console.error('Failed to run tests'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as assert from 'assert'; | ||
var chai = require('chai'); | ||
var expect = chai.expect; // Using Expect style | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode'; | ||
// import * as myExtension from '../../extension'; | ||
import { ReferenceSearch, titleCaseFilename } from '../../extension'; | ||
|
||
suite('titleCase', () => { | ||
test('titleCaseFilename', () => { | ||
expect(titleCaseFilename('the-heat-is-on.md')).to.equal('The Heat Is On'); | ||
expect(titleCaseFilename('in-the-heat-of-the-night.md')).to.equal('In the Heat of the Night'); | ||
}); | ||
}); | ||
|
||
let document = `line0 word1 | ||
line1 word1 word2 | ||
[[test.md]] #tag #another_tag <- link at line2, chars 2-12 | ||
^ tags at line2 chars 15-19 and 21-32 | ||
[[test.md]] <- link at line4, chars 0-11 | ||
[[demo.md]] <- link at line5, chars 0-11 | ||
#tag word`; // line 5, chars 0-3 | ||
suite('ReferenceSearch', () => { | ||
// vscode.window.showInformationMessage('Start ReferenceSearch.'); | ||
|
||
test('rangesForWordInDocumentData', () => { | ||
expect(ReferenceSearch.rangesForWordInDocumentData('[[test.md]]', document)).to.eql([ | ||
new vscode.Range(2, 2, 2, 13), | ||
new vscode.Range(4, 0, 4, 11), | ||
]); | ||
expect(ReferenceSearch.rangesForWordInDocumentData('#tag', document)).to.eql([ | ||
new vscode.Range(2, 15, 2, 19), | ||
new vscode.Range(6, 0, 6, 4), | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as path from 'path'; | ||
import * as Mocha from 'mocha'; | ||
import * as glob from 'glob'; | ||
|
||
export function run(): Promise<void> { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd', | ||
}); | ||
mocha.useColors(true); | ||
|
||
const testsRoot = path.resolve(__dirname, '..'); | ||
|
||
return new Promise((c, e) => { | ||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
if (err) { | ||
return e(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run((failures) => { | ||
if (failures > 0) { | ||
e(new Error(`${failures} tests failed.`)); | ||
} else { | ||
c(); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
e(err); | ||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as vscode from 'vscode'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
export class NoteRefsTreeDataProvider implements vscode.TreeDataProvider<NoteRefTreeItem> { | ||
constructor(private workspaceRoot: string | null) {} | ||
|
||
getTreeItem(element: NoteRefTreeItem): vscode.TreeItem { | ||
return element; | ||
} | ||
|
||
getChildren(element?: NoteRefTreeItem): Thenable<NoteRefTreeItem[]> { | ||
if (!this.workspaceRoot) { | ||
vscode.window.showInformationMessage('No refs in empty workspace'); | ||
return Promise.resolve([]); | ||
} | ||
|
||
if (!element) { | ||
return Promise.resolve([ | ||
new NoteRefTreeItem(`root`, vscode.TreeItemCollapsibleState.Expanded), | ||
]); | ||
} else if (element.label == `root`) { | ||
return Promise.resolve([ | ||
new NoteRefTreeItem(`child-1`, vscode.TreeItemCollapsibleState.None), | ||
new NoteRefTreeItem(`child-2`, vscode.TreeItemCollapsibleState.None), | ||
new NoteRefTreeItem(`child-3`, vscode.TreeItemCollapsibleState.None), | ||
]); | ||
} else { | ||
return Promise.resolve([]); | ||
} | ||
} | ||
} | ||
|
||
class NoteRefTreeItem extends vscode.TreeItem { | ||
constructor( | ||
public readonly label: string, | ||
public readonly collapsibleState: vscode.TreeItemCollapsibleState | ||
) { | ||
super(label, collapsibleState); | ||
} | ||
|
||
get tooltip(): string { | ||
return `${this.label}`; | ||
} | ||
|
||
get description(): string { | ||
return this.label; | ||
} | ||
|
||
iconPath = { | ||
light: path.join(__filename, '..', '..', 'resources', 'light', 'dependency.svg'), | ||
dark: path.join(__filename, '..', '..', 'resources', 'dark', 'dependency.svg'), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# Demo | ||
|
||
`⌥F12` (Peek Definition) to preview Wiki Link inline | ||
`⌥F12` (Peek Definition) to preview Wiki Link inline [[sub.md]] [[test.md]] // `cmd+k cmd+k` | ||
|
||
`F12` (Go to Definition) to open Wiki Link | ||
`F12` (Go to Definition) to open Wiki Link [[sub.md]] [[test.md]] // `ctrl+]` | ||
`F12` (Go to Definition) createNoteOnGoToDefinitionWhenMissing [[in-the-heat-of-the-night.md]] // `ctrl+]` | ||
|
||
[[sub.md]] | ||
(Peek References) for Wiki Link [[test.md]] // `cmd+k cmd+n` | ||
(Peek References) for Tag #tag // `cmd+k cmd+n` | ||
|
||
`⇧F12` (Go To References) for Wiki Link [[sub.md]] | ||
`⇧F12` (Go To References) for Tag #tag | ||
|
||
`⇧⌥F12` (Find All References) for Wiki Link [[sub.md]] | ||
`⇧⌥F12` (Find All References) for Tag #tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
line0 word1 | ||
line1 word1 word2 | ||
[[test.md]] #tag #another_tag <- link at line2, chars 2-12 | ||
^ tags at line2 chars 15-19 and 21-32 | ||
[[test.md]] <- link at line4, chars 0-11 | ||
[[demo.md]] <- link at line5, chars 0-11 | ||
#tag word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# sub | ||
|
||
[[sub2.md]] | ||
|
||
#tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# sub2 | ||
|
||
[[demo.md]] | ||
[[demo.md]] [[sub.md]] [[test.md]] | ||
|
||
#another_tag |