Skip to content

Commit feeabd4

Browse files
authored
Merge pull request #39 from UziTech/patch-1
2 parents 286b435 + b78b7c5 commit feeabd4

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

lib/goToDefinition.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export async function getDefinitions(
4949
const position = targetPosition || editor.getCursorBufferPosition();
5050

5151
const provider = providerRegistry.getProviderForEditor(editor);
52+
if (!provider) {
53+
return;
54+
}
5255
const result = await provider.getDefinition(editor, position);
5356

5457
return result && result.definitions;

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ export function consumeDefinitionsService(provider) {
3636
}
3737

3838
export function getClickProvider() {
39-
return clickProvider.getProvider;
39+
return clickProvider.getProvider();
4040
}

spec/go-to-definition-spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @babel */
2+
3+
import { getDefinitions } from "../lib/goToDefinition";
4+
5+
// Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
6+
//
7+
// To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
8+
// or `fdescribe`). Remove the `f` to unfocus the block.
9+
10+
describe("go to definition", () => {
11+
describe("getDefinitions", () => {
12+
it("returns undefined if no provider exists for editor", async () => {
13+
const providerRegistry = {
14+
getProviderForEditor() {}
15+
}
16+
const definitions = await getDefinitions(providerRegistry, { editor: true, position: true });
17+
expect(definitions).toBeUndefined();
18+
});
19+
});
20+
});

spec/main-spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/** @babel */
2+
3+
import * as main from "../lib/main";
4+
5+
// Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
6+
//
7+
// To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
8+
// or `fdescribe`). Remove the `f` to unfocus the block.
9+
10+
describe("main", () => {
11+
it("activate", async function () {
12+
// Trigger deferred activation
13+
atom.packages.triggerDeferredActivationHooks();
14+
// Activate activation hook
15+
atom.packages.triggerActivationHook("core:loaded-shell-environment");
16+
17+
await atom.packages.activatePackage("atom-ide-definitions");
18+
expect(atom.packages.isPackageLoaded("atom-ide-definitions")).toBeTruthy();
19+
});
20+
21+
it("getClickProvider", () => {
22+
const provider = main.getClickProvider();
23+
24+
expect(typeof provider.getSuggestionForWord).toEqual("function");
25+
});
26+
});

0 commit comments

Comments
 (0)