Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #260 from thecotne/fix_language_server
Browse files Browse the repository at this point in the history
fix @hegel/language-server
  • Loading branch information
JSMonk authored Jun 16, 2020
2 parents a7a6677 + 44b9a8c commit 42b6084
Show file tree
Hide file tree
Showing 33 changed files with 289 additions and 124 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,8 @@
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}/client/client.js",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}/client/client.js",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test"
]
"runtimeExecutable": "${execPath}/client.js",
"args": ["--extensionDevelopmentPath=${workspaceFolder}/packages/language-server/build"]
}
]
}
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"files.trimTrailingWhitespace": false
"files.trimTrailingWhitespace": false,
"search.exclude": {
"**/.docz": true,
"**/.git": true,
"**/bower_components": true,
"**/build": true,
"**/dist": true,
"**/node_modules": true
}
}
1 change: 1 addition & 0 deletions packages/cli/.hegelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include:
exclude:
- ./node_modules/**
- ./build/**
- ./.history/**
types:
- ./@types
- ./node_modules/@types
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@hegel/cli",
"version": "0.0.45",
"description": "",
"main": "index.js",
"main": "./build/index.js",
"bin": {
"hegel": "./build/index.js"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Artem Kobzar",
"version": "0.0.45",
"description": "",
"main": "build/index.js",
"main": "./build/index.js",
"files": [
"build/*",
"README.md"
Expand Down
10 changes: 10 additions & 0 deletions packages/language-server/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"sourceType": "module",
"presets": [
["@babel/preset-env", { "targets": { "node": "current" }, "modules": false }],
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
8 changes: 0 additions & 8 deletions packages/language-server/.vscodeignore

This file was deleted.

6 changes: 3 additions & 3 deletions packages/language-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ At current time it can:

- [x]: show diagnostic information.

![Diagonstics](images/diagnostics.png)
![Diagonstics](https://raw.githubusercontent.com/JSMonk/hegel/master/packages/language-server/images/diagnostics.png)

- [x]: show information on hovering an element.

![Hover](images/hover.png)
![Hover](https://raw.githubusercontent.com/JSMonk/hegel/master/packages/language-server/images/hover.png)

- [x]: autocomplete variables on typing.

![Autocompletion](images/autocompletion.png)
![Autocompletion](https://raw.githubusercontent.com/JSMonk/hegel/master/packages/language-server/images/autocompletion.png)

## Extension Settings

Expand Down
60 changes: 60 additions & 0 deletions packages/language-server/extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "hegel-language-server",
"displayName": "Hegel",
"description": "Language server for Hegel Type Checker",
"version": "0.0.45",
"engines": {
"vscode": "^1.31.0"
},
"publisher": "JSMonk",
"icon": "images/logo.png",
"categories": [
"Programming Languages",
"Linters"
],
"repository": {
"type": "git",
"url": "https://github.com/JSMonk/hegel"
},
"activationEvents": [
"onLanguage:javascript",
"workspaceContains:**/.hegelrc"
],
"main": "./client.js",
"contributes": {
"configuration": {
"type": "object",
"title": "Client configuration",
"properties": {
"hegelLanguageServer.maxNumberOfProblems": {
"type": "number",
"default": 100,
"description": "Controls the maximum number of problems produced by the server."
},
"hegelLanguageServer.trace.server": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Traces the communication between VSCode and the hegelLanguageServer service."
}
}
},
"languages": [
{
"id": "javascript",
"extensions": [
".js",
".cjs",
".mjs"
]
}
]
},
"dependencies": {
"@hegel/typings": "*"
}
}
13 changes: 0 additions & 13 deletions packages/language-server/jsconfig.json

This file was deleted.

79 changes: 22 additions & 57 deletions packages/language-server/package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,33 @@
{
"name": "hegel-language-server",
"displayName": "Hegel",
"description": "Language server for Hegel Type Checker",
"version": "0.0.45",
"engines": {
"vscode": "^1.31.0"
},
"publisher": "JSMonk",
"icon": "images/logo.png",
"categories": [
"Programming Languages",
"Linters"
],
"repository": {
"type": "git",
"url": "https://github.com/JSMonk/hegel"
},
"activationEvents": [
"onLanguage:javascript",
"workspaceContains:**/.hegelrc"
],
"main": "./client/client.js",
"contributes": {
"configuration": {
"type": "object",
"title": "Client configuration",
"properties": {
"hegelLanguageServer.maxNumberOfProblems": {
"type": "number",
"default": 100,
"description": "Controls the maximum number of problems produced by the server."
},
"hegelLanguageServer.trace.server": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Traces the communication between VSCode and the hegelLanguageServer service."
}
}
},
"languages": [
{
"id": "javascript",
"extensions": [
".js",
".cjs",
".mjs"
]
}
]
},
"name": "@hegel/language-server",
"version": "0.0.0-not-versioned",
"private": true,
"scripts": {
"test": "No tests defined yet.",
"compile": "vsce package --yarn"
"prebuild": "yarn build:clean",
"build": "yarn build:rollup; yarn build:copy; yarn build:package",
"build:rollup": "rollup --config rollup.config.js",
"build:rollup:watch": "yarn build -- --watch",
"build:rollup:dev": "yarn build -- --sourcemap",
"build:clean": "rm -rf build",
"build:copy": "yarn build:copy:manifest; yarn build:copy:images; yarn build:copy:typings; yarn build:copy:readme",
"build:copy:manifest": "cp extension.json build/package.json",
"build:copy:images": "cp -r src/images build/images",
"build:copy:typings": "mkdir -p build/node_modules/@hegel; cp -r $(node -e 'process.stdout.write(require(\"path\").dirname(require.resolve(\"@hegel/typings\")))') build/node_modules/@hegel/typings",
"build:copy:readme": "cp -r README.md build/README.md",
"build:package": "cd build; vsce package",
"build:install": "code --install-extension ./build/*.vsix"
},
"devDependencies": {
"@rollup/plugin-babel": "^5.0.2",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.3.2",
"@types/mocha": "^7.0.2",
"@types/node": "^13.13.2",
"@types/vscode": "1.14.0",
"builtin-modules": "^3.1.0",
"eslint": "^6.8.0",
"rollup": "^2.12.0",
"typescript": "^3.8.3",
"vsce": "^1.75.0",
"vscode-test": "1.3.0"
Expand Down
45 changes: 45 additions & 0 deletions packages/language-server/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import builtinModules from 'builtin-modules';
import replace from '@rollup/plugin-replace';

const base = {
output: {
format: 'cjs'
},
external: [
...builtinModules,
'vscode'
],
plugins: [
resolve({
preferBuiltins: true
}),
commonjs(),
babel({ babelHelpers: 'bundled' })
]
};

export default [
{
...base,
input: 'src/client/client.js',
output: {
...base.output,
file: 'build/client.js',
}
},
{
...base,
input: 'src/server/server.js',
output: {
...base.output,
file: 'build/server.js',
plugins: [
// workaround bug in @rollup/plugin-commonjs see https://github.com/rollup/plugins/issues/406
replace({ 'commonjsRequire.resolve': 'require.resolve' })
]
}
}
];
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const path = require("path");
const { workspace } = require("vscode");
const { TransportKind, LanguageClient } = require("vscode-languageclient");
import { workspace } from "vscode";
import { TransportKind, LanguageClient } from "vscode-languageclient";

let client;

exports.activate = (context) => {
const serverModule = context.asAbsolutePath(path.join("server", "server.js"));
const serverModule = context.asAbsolutePath('server.js');
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };

const serverOptions = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { ObjectType } = require("@hegel/core/type-graph/types/object-type");
const { GenericType } = require("@hegel/core/type-graph/types/generic-type");
const { FunctionType } = require("@hegel/core/type-graph/types/function-type");
const { ObjectType } = require("@hegel/core/build/type-graph/types/object-type");
const { GenericType } = require("@hegel/core/build/type-graph/types/generic-type");
const { FunctionType } = require("@hegel/core/build/type-graph/types/function-type");
const { CompletionItemKind } = require("vscode-languageserver");
const {
THIS_TYPE,
CONSTRUCTABLE,
} = require("@hegel/core/type-graph/constants");
} = require("@hegel/core/build/type-graph/constants");

/**
* Find type kind of variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ const { ModuleScope } = require("@hegel/core");

const EMPTY_SCOPE = new ModuleScope();

exports.EMPTY_SCOPE = EMPTY_SCOPE;
exports.EMPTY_SCOPE = EMPTY_SCOPE;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const path = require("path");
const { ModuleScope } = require("@hegel/core");
const { getBabylonAST } = require("../utils/document-ast");
const { createModuleScope } = require("@hegel/core");
Expand Down Expand Up @@ -69,32 +68,23 @@ function mixSomeTypeDefinitions(globalScope, additionalTypeGraph) {

async function getStandardTypeDefinitions(globalScope) {
stdLibTypeGraph = await getTypeGraphFor(
path.join(
__dirname,
"../../node_modules/@hegel/typings/standard/index.d.ts"
),
require.resolve("@hegel/typings/standard/index.d.ts"),
globalScope
);
return stdLibTypeGraph;
}

async function getNodeJSTypeDefinitions(globalScope) {
nodeJsGlobalTypeGraph = await getTypeGraphFor(
path.join(
__dirname,
"../../node_modules/@hegel/typings/nodejs/globals.d.ts"
),
require.resolve("@hegel/typings/nodejs/globals.d.ts"),
globalScope
);
return nodeJsGlobalTypeGraph;
}

async function getBrowserTypeDefinitions(globalScope) {
browserGlobalTypeGraph = await getTypeGraphFor(
path.join(
__dirname,
"../../node_modules/@hegel/typings/browser/index.d.ts"
),
require.resolve("@hegel/typings/browser/index.d.ts"),
globalScope
);
return browserGlobalTypeGraph;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { getConfig } = require("@hegel/cli/lib/config");
const { importModule } = require("@hegel/cli/lib/module");
const { getConfig } = require("@hegel/cli/build/config");
const { importModule } = require("@hegel/cli/build/module");
const { getBabylonAST } = require("../utils/document-ast");
const { createGlobalScope } = require("@hegel/core");
const { mixTypeDefinitions } = require("./type-definitions");
Expand Down
Loading

0 comments on commit 42b6084

Please sign in to comment.