Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@superfaceai/language-server

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superfaceai/language-server - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

7

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

## [0.0.16] - 2021-09-27
### Changed
- Updated parser to v0.0.22
## [0.0.15] - 2021-08-06

@@ -77,3 +81,4 @@

[Unreleased]: https://github.com/superfaceai/language-server/compare/v0.0.15...HEAD
[Unreleased]: https://github.com/superfaceai/language-server/compare/v0.0.16...HEAD
[0.0.16]: https://github.com/superfaceai/language-server/compare/v0.0.15...v0.0.16
[0.0.15]: https://github.com/superfaceai/language-server/compare/v0.0.15-beta.0...v0.0.15

@@ -80,0 +85,0 @@ [0.0.15-beta.0]: https://github.com/superfaceai/language-server/compare/v0.0.14-beta.0...v0.0.15-beta.0

5

dist/diagnostics.d.ts

@@ -5,2 +5,3 @@ import * as superparser from '@superfaceai/parser';

import { ComlinkDocuments } from './documents';
import { LogFn } from './lib';
export declare type DiagnosticOptions = {

@@ -11,2 +12,4 @@ /** Specifies the maximum number of diagnostics to generate. */

export declare function diagnosticsFromSyntaxError(error: superparser.SyntaxError): Diagnostic[];
export declare function lintMap(map: ComlinkDocument, manager: ComlinkDocuments): Diagnostic[];
export declare function lintMap(map: ComlinkDocument, manager: ComlinkDocuments, context?: {
log?: LogFn;
}): Diagnostic[];

@@ -66,7 +66,7 @@ "use strict";

var position = parseLinterPath(issue.context.path).position;
var diag = vscode_languageserver_1.Diagnostic.create(vscode_languageserver_1.Range.create(position, position), parser_1.formatIssueContext(issue), severity, issue.kind);
var diag = vscode_languageserver_1.Diagnostic.create(vscode_languageserver_1.Range.create(position, position), (0, parser_1.formatIssueContext)(issue), severity, issue.kind);
return diag;
}
function lintMap(map, manager) {
var _a;
function lintMap(map, manager, context) {
var _a, _b;
// namespace

@@ -79,3 +79,3 @@ var mapNamespaceResult = map.getNamespace();

// map ast
var mapAst = lib_1.unwrapResult(map.getAst());
var mapAst = (0, lib_1.unwrapResult)(map.getAst());
if (mapAst.kind === 'ProfileDocument') {

@@ -99,3 +99,3 @@ throw new Error('Unexpected state: Invalid map document');

// profile ast
var profileAst = lib_1.unwrapResult(matchingProfile.getAst());
var profileAst = (0, lib_1.unwrapResult)(matchingProfile.getAst());
if (profileAst.kind === 'MapDocument') {

@@ -105,4 +105,5 @@ throw new Error('Unexpected state: Invalid profile document');

// lint
var profileOutput = parser_1.getProfileOutput(profileAst);
var validationResult = parser_1.validateMap(profileOutput, mapAst);
var profileOutput = (0, parser_1.getProfileOutput)(profileAst);
var validationResult = (0, parser_1.validateMap)(profileOutput, mapAst);
(_a = context === null || context === void 0 ? void 0 : context.log) === null || _a === void 0 ? void 0 : _a.call(context, 'Validation result:', validationResult);
// result formatting

@@ -113,3 +114,3 @@ var result = (validationResult.pass === false ? validationResult.errors : [])

})
.concat(((_a = validationResult.warnings) !== null && _a !== void 0 ? _a : []).map(function (warning) {
.concat(((_b = validationResult.warnings) !== null && _b !== void 0 ? _b : []).map(function (warning) {
return diagnosticFromValidationIssue(warning, vscode_languageserver_1.DiagnosticSeverity.Warning);

@@ -116,0 +117,0 @@ }));

@@ -9,3 +9,3 @@ import { MapDocumentNode, ProfileDocumentNode } from '@superfaceai/ast';

import { ComlinkDocuments } from './documents';
import { Result, WorkContext } from './lib';
import { LogFn, Result, WorkContext } from './lib';
export declare class ComlinkDocument implements TextDocument {

@@ -36,5 +36,8 @@ private textDocument;

getAst(workContext?: WorkContext<unknown>): Result<WithLocationInfo<ProfileDocumentNode> | WithLocationInfo<MapDocumentNode>, superparser.SyntaxError>;
getDiagnostics(manager: ComlinkDocuments, options?: DiagnosticOptions, workContext?: WorkContext<Diagnostic[]>): Diagnostic[];
getDiagnostics(manager: ComlinkDocuments, options?: DiagnosticOptions, context?: {
workContext?: WorkContext<Diagnostic[]>;
log?: LogFn;
}): Diagnostic[];
getSymbols(workContext?: WorkContext<DocumentSymbol[]>): Result<DocumentSymbol[], superparser.SyntaxError>;
getNamespace(workContext?: WorkContext<DocumentSymbol>): Result<string, superparser.SyntaxError>;
}

@@ -38,6 +38,10 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -147,3 +151,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
ComlinkDocument.prototype.getDiagnostics = function (manager, options, workContext) {
ComlinkDocument.prototype.getDiagnostics = function (manager, options, context) {
var _a, _b;

@@ -154,8 +158,8 @@ if (this.diagnosticCache !== undefined) {

var result = [];
var parsed = this.getAst(workContext);
var parsed = this.getAst(context === null || context === void 0 ? void 0 : context.workContext);
if (parsed.kind === 'failure') {
result.push.apply(result, __spreadArray([], __read(diagnostics_1.diagnosticsFromSyntaxError(parsed.error))));
result.push.apply(result, __spreadArray([], __read((0, diagnostics_1.diagnosticsFromSyntaxError)(parsed.error)), false));
}
else if (parsed.value.kind === 'ProfileDocument') {
var myNamespace_1 = lib_1.unwrapResult(this.getNamespace());
var myNamespace_1 = (0, lib_1.unwrapResult)(this.getNamespace());
// clear map cache to force relint

@@ -182,3 +186,3 @@ manager

else if (parsed.value.kind === 'MapDocument') {
result.push.apply(result, __spreadArray([], __read(diagnostics_1.lintMap(this, manager))));
result.push.apply(result, __spreadArray([], __read((0, diagnostics_1.lintMap)(this, manager, { log: context === null || context === void 0 ? void 0 : context.log })), false));
}

@@ -201,6 +205,6 @@ this.diagnosticCache = result;

if (ast.kind === 'ProfileDocument') {
symbols = symbols_1.listProfileSymbols(this, ast, workContext);
symbols = (0, symbols_1.listProfileSymbols)(this, ast, workContext);
}
else if (ast.kind === 'MapDocument') {
symbols = symbols_1.listMapSymbols(this, ast, workContext);
symbols = (0, symbols_1.listMapSymbols)(this, ast, workContext);
}

@@ -207,0 +211,0 @@ result = {

@@ -89,3 +89,3 @@ "use strict";

}
return [4 /*yield*/, fs_1.promises.readFile(lib_1.stripUriPrefix(uri), {
return [4 /*yield*/, fs_1.promises.readFile((0, lib_1.stripUriPrefix)(uri), {
encoding: 'utf-8',

@@ -92,0 +92,0 @@ })];

import { CancellationToken, ResultProgressReporter, WorkDoneProgressReporter } from 'vscode-languageserver';
import { DocumentUri } from 'vscode-languageserver-textdocument';
export declare type LogFn = (...values: unknown[]) => void;
export declare type WorkContext<PartialResult = void> = {

@@ -4,0 +5,0 @@ cancellationToken: CancellationToken;

@@ -73,3 +73,3 @@ "use strict";

return entries.map(function (entry) {
var entryPath = path_1.join(basePath, entry.name);
var entryPath = (0, path_1.join)(basePath, entry.name);
if (entry.isDirectory()) {

@@ -76,0 +76,0 @@ return recursiveWalk(entryPath, callback);

@@ -54,3 +54,3 @@ "use strict";

function ServerContext() {
this.connection = node_1.createConnection(node_1.ProposedFeatures.all);
this.connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
this.documents = new documents_1.ComlinkDocuments();

@@ -69,3 +69,3 @@ this.startTimestamp = Date.now();

case 0:
this.conLogWith('onInitialize', event);
this.conLog('onInitialize:', event);
result = {

@@ -140,3 +140,3 @@ capabilities: {

};
symbols = workspace_1.listWorkspaceSymbols(this.documents, workContext);
symbols = (0, workspace_1.listWorkspaceSymbols)(this.documents, workContext);
return [2 /*return*/, symbols];

@@ -225,5 +225,5 @@ }

.getWorkspaceFolders()
.then(function (folders) { return (folders !== null && folders !== void 0 ? folders : []).map(function (f) { return lib_1.stripUriPrefix(f.uri); }); })
.then(function (folders) { return workspace_1.loadWorkspaceDocuments(folders, _this.documents); })
.catch(function (err) { return _this.conLogWith('Failed to load workspace documents', err); });
.then(function (folders) { return (folders !== null && folders !== void 0 ? folders : []).map(function (f) { return (0, lib_1.stripUriPrefix)(f.uri); }); })
.then(function (folders) { return (0, workspace_1.loadWorkspaceDocuments)(folders, _this.documents); })
.catch(function (err) { return _this.conLog('Failed to load workspace documents:', err); });
return [2 /*return*/, promise];

@@ -241,4 +241,4 @@ });

_a.sent();
diagnostics = document.getDiagnostics(this.documents);
this.conLogWith('Sending diagnostics', diagnostics);
diagnostics = document.getDiagnostics(this.documents, undefined, { log: this.conLog.bind(this) });
this.conLog('Sending diagnostics:', diagnostics);
this.connection.sendDiagnostics({ uri: document.uri, diagnostics: diagnostics });

@@ -267,16 +267,23 @@ return [2 /*return*/];

*/
ServerContext.prototype.conLog = function (message) {
this.connection.console.log("[+" + this.timestampNow() + "](pid " + process.pid + ") " + message);
ServerContext.prototype.conLog = function () {
var values = [];
for (var _i = 0; _i < arguments.length; _i++) {
values[_i] = arguments[_i];
}
var processed = values.map(function (value) {
var message;
if (typeof value === 'object') {
message = util_1.default.inspect(value, {
showHidden: false,
depth: 5,
colors: false,
});
}
else {
message = value.toString();
}
return message;
}).join(' ');
this.connection.console.log("[+" + this.timestampNow() + "](pid " + process.pid + ") " + processed);
};
/**
* Logs the message to the connection log and appends `util.inspect(obj)` output.
*/
ServerContext.prototype.conLogWith = function (message, obj) {
var inspected = util_1.default.inspect(obj, {
showHidden: false,
depth: 5,
colors: false,
});
this.conLog(message + ": " + inspected);
};
ServerContext.SERVER_INFO = {

@@ -283,0 +290,0 @@ name: 'Superface Language Server',

@@ -62,3 +62,3 @@ "use strict";

var namespaceSymbol = vscode_languageserver_types_1.DocumentSymbol.create(formatNamespace(profile.header.scope, profile.header.name, profile.header.version), undefined, vscode_languageserver_types_1.SymbolKind.Namespace, document.rangeFrom({ start: profile.header.span.start, end: fileSpan.end }), document.rangeFrom({ start: profile.header.span.start, end: fileSpan.end }), namespaceSymbols);
var fileSymbol = vscode_languageserver_types_1.DocumentSymbol.create(lib_1.fileNameFromUri(document.uri), undefined, vscode_languageserver_types_1.SymbolKind.File, document.rangeFrom(fileSpan), document.rangeFrom(fileSpan), [namespaceSymbol]);
var fileSymbol = vscode_languageserver_types_1.DocumentSymbol.create((0, lib_1.fileNameFromUri)(document.uri), undefined, vscode_languageserver_types_1.SymbolKind.File, document.rangeFrom(fileSpan), document.rangeFrom(fileSpan), [namespaceSymbol]);
workContext === null || workContext === void 0 ? void 0 : workContext.workDoneProgress.done();

@@ -100,3 +100,3 @@ return [fileSymbol];

var namespaceSymbol = vscode_languageserver_types_1.DocumentSymbol.create(formatNamespace(map.header.profile.scope, map.header.profile.name, map.header.profile.version), undefined, vscode_languageserver_types_1.SymbolKind.Namespace, vscode_languageserver_types_1.Range.create(document.positionAt(map.header.span.start), document.positionAt(fileSpan.end)), vscode_languageserver_types_1.Range.create(document.positionAt(map.header.span.start), document.positionAt(map.header.span.start)), namespaceSymbols);
var fileSymbol = vscode_languageserver_types_1.DocumentSymbol.create(lib_1.fileNameFromUri(document.uri), undefined, vscode_languageserver_types_1.SymbolKind.File, vscode_languageserver_types_1.Range.create(document.positionAt(fileSpan.start), document.positionAt(fileSpan.end)), vscode_languageserver_types_1.Range.create(document.positionAt(fileSpan.start), document.positionAt(fileSpan.start)), [namespaceSymbol]);
var fileSymbol = vscode_languageserver_types_1.DocumentSymbol.create((0, lib_1.fileNameFromUri)(document.uri), undefined, vscode_languageserver_types_1.SymbolKind.File, vscode_languageserver_types_1.Range.create(document.positionAt(fileSpan.start), document.positionAt(fileSpan.end)), vscode_languageserver_types_1.Range.create(document.positionAt(fileSpan.start), document.positionAt(fileSpan.start)), [namespaceSymbol]);
workContext === null || workContext === void 0 ? void 0 : workContext.workDoneProgress.done();

@@ -103,0 +103,0 @@ return [fileSymbol];

@@ -54,6 +54,10 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};

@@ -95,3 +99,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

workContext === null || workContext === void 0 ? void 0 : workContext.workDoneProgress.begin('Walking workspace dirs...', 0, undefined, false);
return [4 /*yield*/, Promise.all(folders.map(function (folder) { return lib_1.recursiveWalk(folder, entryCallback); }))];
return [4 /*yield*/, Promise.all(folders.map(function (folder) { return (0, lib_1.recursiveWalk)(folder, entryCallback); }))];
case 1:

@@ -112,3 +116,3 @@ _a.sent();

})) !== null && _b !== void 0 ? _b : [];
return __spreadArray([baseSymbol], __read(childSymbols));
return __spreadArray([baseSymbol], __read(childSymbols), false);
}

@@ -115,0 +119,0 @@ function listWorkspaceSymbols(manager, workContext) {

@@ -5,3 +5,3 @@ {

"repository": "https://github.com/superfaceai/language-server.git",
"version": "0.0.15",
"version": "0.0.16",
"author": "Superface Team",

@@ -27,3 +27,3 @@ "license": "MIT",

"dependencies": {
"@superfaceai/parser": "0.0.22-beta.0",
"@superfaceai/parser": "0.0.22",
"vscode-languageserver": "^7",

@@ -30,0 +30,0 @@ "vscode-languageserver-textdocument": "^1.0.1"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc