Skip to content

Commit

Permalink
Revert "Merge pull request #147 from gabro/grooming"
Browse files Browse the repository at this point in the history
This reverts commit 5832cbd, reversing
changes made to 9f74b48.
  • Loading branch information
tgodzik committed Oct 6, 2019
1 parent 6606b10 commit be8d6bb
Show file tree
Hide file tree
Showing 8 changed files with 1,143 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- git checkout -b travis-temp
# change the version in package.json
- yarn version --no-git-tag-version --new-version $NEW_VERSION
- npx github-changes -o scalameta -r metals-vscode --no-merges -t "VSCode Extension Changelog" -k $GITHUB_TOKEN
- yarn github-changes -o scalameta -r metals-vscode --no-merges -t "VSCode Extension Changelog" -k $GITHUB_TOKEN
- sed -i '1i Check out the Metals release notes at [https://scalameta.org/metals/blog/](https://scalameta.org/metals/blog/)\n' CHANGELOG.md
- git commit -am "$TRAVIS_TAG"
# push the changes to package.json
Expand Down
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ src/**
.gitignore
tsconfig.json
vsc-extension-quickstart.md
node_modules
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"homepage": "http://metals.rocks",
"engines": {
"vscode": "^1.38.0"
"vscode": "^1.34.0"
},
"icon": "images/logo.png",
"categories": [
Expand Down Expand Up @@ -227,24 +227,27 @@
"vscode:prepublish": "yarn compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"test": "yarn compile",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "yarn compile && node ./node_modules/vscode/bin/test",
"build": "vsce package --yarn",
"vscode:publish": "vsce publish --yarn"
},
"devDependencies": {
"@types/mocha": "^2.2.42",
"@types/node": "^8.10.25",
"@types/semver": "^6.0.2",
"@types/semver": "^5.5.0",
"@types/shell-quote": "^1.6.1",
"@types/vscode": "^1.38.0",
"typescript": "^3.6.3",
"vsce": "^1.67.1"
"github-changes": "^1.1.2",
"typescript": "^3.2.2",
"vsce": "^1.54.0"
},
"dependencies": {
"locate-java-home": "^1.1.2",
"promisify-child-process": "3.1.1",
"semver": "^6.3.0",
"shell-quote": "^1.7.2",
"vscode-languageclient": "^5.2.1"
"promisify-child-process": "3.1.0",
"semver": "^5.6.0",
"shell-quote": "^1.6.1",
"vscode": "^1.1.34",
"vscode-languageclient": "^5.1.0"
},
"extensionDependencies": [
"scala-lang.scala"
Expand Down
89 changes: 45 additions & 44 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,7 @@ function launchMetals(
}
};
Object.entries(clientCommands).forEach(([name, command]) =>
registerCommand(
ClientCommands[name as keyof typeof ClientCommands],
command
)
registerCommand(name, command)
);

// should be the compilation of a currently opened file
Expand All @@ -358,7 +355,12 @@ function launchMetals(

let codeLensRefresher: CodeLensProvider = {
onDidChangeCodeLenses: compilationDoneEmitter.event,
provideCodeLenses: () => undefined
provideCodeLenses: (
document: VscodeTextDocument,
token: CancellationToken
) => undefined,
resolveCodeLens: (codeLens: CodeLens, token: CancellationToken) =>
undefined
};

languages.registerCodeLensProvider(
Expand All @@ -368,45 +370,43 @@ function launchMetals(

// Handle the metals/executeClientCommand extension notification.
client.onNotification(ExecuteClientCommand.type, params => {
switch (params.command) {
case "metals-goto-location":
const location =
params.arguments && (params.arguments[0] as Location);
if (location) {
workspace
.openTextDocument(Uri.parse(location.uri))
.then(textDocument => window.showTextDocument(textDocument))
.then(editor => {
const range = new Range(
location.range.start.line,
location.range.start.character,
location.range.end.line,
location.range.end.character
);
// Select an offset position instead of range position to
// avoid triggering noisy document highlight.
editor.selection = new Selection(range.start, range.start);
editor.revealRange(range, TextEditorRevealType.InCenter);
});
}
break;
case "metals-model-refresh":
compilationDoneEmitter.fire();
break;
case "metals-doctor-run":
case "metals-doctor-reload":
const isRun = params.command === "metals-doctor-run";
const isReload = params.command === "metals-doctor-reload";
if (isRun || (doctor && isReload)) {
const html = params.arguments && params.arguments[0];
if (typeof html === "string") {
const panel = getDoctorPanel(isReload);
panel.webview.html = html;
const isRun = params.command === "metals-doctor-run";
const isReload = params.command === "metals-doctor-reload";
if (isRun || (doctor && isReload)) {
const html = params.arguments && params.arguments[0];
if (typeof html === "string") {
const panel = getDoctorPanel(isReload);
panel.webview.html = html;
}
} else {
switch (params.command) {
case "metals-goto-location":
const location =
params.arguments && (params.arguments[0] as Location);
if (location) {
workspace
.openTextDocument(Uri.parse(location.uri))
.then(textDocument => window.showTextDocument(textDocument))
.then(editor => {
const range = new Range(
location.range.start.line,
location.range.start.character,
location.range.end.line,
location.range.end.character
);
// Select an offset position instead of range position to
// avoid triggering noisy document highlight.
editor.selection = new Selection(range.start, range.start);
editor.revealRange(range, TextEditorRevealType.InCenter);
});
}
}
break;
default:
outputChannel.appendLine(`unknown command: ${params.command}`);
break;
case "metals-model-refresh":
compilationDoneEmitter.fire();
break;
default:
outputChannel.appendLine(`unknown command: ${params.command}`);
}
}

// Ignore other commands since they are less important.
Expand All @@ -433,7 +433,7 @@ function launchMetals(
if (params.command && values.includes(params.command)) {
registerCommand(params.command, () => {
client.sendRequest(ExecuteCommandRequest.type, {
command: params.command!
command: params.command
});
});
}
Expand Down Expand Up @@ -580,6 +580,7 @@ function launchMetals(
scalaDebugger
.initialize(outputChannel)
.forEach(disposable => context.subscriptions.push(disposable));
registerCommand(scalaDebugger.startSessionCommand, scalaDebugger.start);
} else {
outputChannel.appendLine("Debugging Scala sources is not supported");
}
Expand Down
1 change: 1 addition & 0 deletions src/scalaDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "vscode";

export const startAdapterCommand = "debug-adapter-start";
export const startSessionCommand = "metals-debug-session-start";
const configurationType = "scala";

export function initialize(outputChannel: vscode.OutputChannel): Disposable[] {
Expand Down
22 changes: 22 additions & 0 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Note: This example test is leveraging the Mocha test framework.
// Please refer to their documentation on https://mochajs.org/ for help.
//

// The module 'assert' provides assertion methods from node
import * as assert from 'assert';

// 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';

// Defines a Mocha test suite to group tests of similar kind together
suite("Extension Tests", () => {

// Defines a Mocha unit test
test("Something 1", () => {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
});
});
22 changes: 22 additions & 0 deletions src/test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
//
// This file is providing the test runner to use when running extension tests.
// By default the test runner in use is Mocha based.
//
// You can provide your own test runner if you want to override it by exporting
// a function run(testRoot: string, clb: (error:Error) => void) that the extension
// host can call to run the tests. The test runner is expected to use console.log
// to report the results back to the caller. When the tests are finished, return
// a possible error to the callback or null if none.

import * as testRunner from 'vscode/lib/testrunner';

// You can directly control Mocha options by uncommenting the following lines
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
testRunner.configure({
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
});

module.exports = testRunner;
Loading

0 comments on commit be8d6bb

Please sign in to comment.