Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { ILanguageServer } from "./server";
// Show version for `-v` or `--version` arguments
if (process.argv[2] === "-v" || process.argv[2] === "--version") {
// require is used to avoid loading package if not necessary (~30ms time difference)
// tslint:disable-next-line no-var-requires
process.stdout.write(`${require("pjson").version}\n`);
process.exit(0);
}
// default argument `--stdio`
if (process.argv.length === 2) {
process.argv.push("--stdio");
}
const connection: IConnection = createConnection(ProposedFeatures.all);
let server: ILanguageServer;
connection.onInitialize(
async (params: InitializeParams): Promise => {
await Parser.init();
const absolute = Path.join(__dirname, "tree-sitter-elm.wasm");
const pathToWasm = Path.relative(process.cwd(), absolute);
connection.console.info(
`Loading Elm tree-sitter syntax from ${pathToWasm}`,
);
const language = await Parser.Language.load(pathToWasm);
const parser = new Parser();
parser.setLanguage(language);
const { Server } = await import("./server");
server = new Server(connection, params, parser);
function start(project: {}) {
// Disable console logging while in language server mode
// otherwise in stdio mode we will not be sending valid JSON
console.log = console.warn = console.error = () => {};
let connection = createConnection(ProposedFeatures.all);
run(project, function(elm: ElmApp) {
let documents: TextDocuments = new TextDocuments();
let filesWithDiagnostics = new Set();
documents.listen(connection);
connection.listen();
connection.onInitialize((params: InitializeParams) => ({
capabilities: {
textDocumentSync: {
openClose: true,
willSave: true,
change: TextDocumentSyncKind.Full
},
textDocument: {
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
import {
createConnection, TextDocuments, ProposedFeatures, TextDocumentSyncKind
} from 'vscode-languageserver';
// Creates the LSP connection
let connection = createConnection(ProposedFeatures.all);
// Create a manager for open text documents
let documents = new TextDocuments();
// The workspace folder this server is operating on
let workspaceFolder: string;
documents.onDidOpen((event) => {
connection.console.log(`[Server(${process.pid}) ${workspaceFolder ? workspaceFolder : 'generic'}] Document opened: ${event.document.uri}`);
})
documents.listen(connection);
connection.onInitialize((params) => {
if (params.initializationOptions && params.initializationOptions.genericServer) {
connection.console.log(`[Server(${process.pid}) generic] Started and initialize received`);
} else {
createConnection,
TextDocuments,
InitializeParams,
ProposedFeatures
} from "vscode-languageserver";
import { MLS } from "./service";
let mls: MLS;
// Create a connection for the server
// Also include all preview / proposed LSP features.
const connection =
process.argv.length <= 2
? createConnection(process.stdin, process.stdout) // no arg specified
: createConnection(ProposedFeatures.all);
const DEBUG = process.env.DEBUG === 'true' || false;
console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);
// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments = new TextDocuments();
// let hasConfigurationCapability: boolean = false;
// let hasWorkspaceFolderCapability: boolean = false;
// let hasDiagnosticRelatedInformationCapability: boolean = false;
// After the server has started the client sends an initilize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilites.
let workspaceRoot: string;
import * as https from 'https';
import { createConnection, ProposedFeatures, TextDocuments } from 'vscode-languageserver';
import { initTelemetry, updateTelemetry } from '@hint/utils-telemetry';
import { trackClose, trackSave, trackOptIn, TelemetryState } from './utils/analytics';
import { Analyzer } from './utils/analyze';
import * as notifications from './utils/notifications';
// Look two-levels up for `package.json` as this will be in `dist/src/` post-build.
const { version } = require('../../package.json');
const defaultProperties = { 'extension-version': version };
const [,, globalStoragePath, telemetryEnabled, everEnabledTelemetryStr] = process.argv;
const everEnabledTelemetry = everEnabledTelemetryStr === 'true';
const connection = createConnection(ProposedFeatures.all);
const analyzer = new Analyzer(globalStoragePath, connection);
const documents = new TextDocuments();
let workspace = '';
connection.onInitialize((params) => {
/*
* TODO: Cache multiple webhint instances based on analyzed document paths,
* which should allow ignoring workspaces entirely.
*/
workspace = params.rootPath || '';
return { capabilities: { textDocumentSync: documents.syncKind } };
});
connection.onNotification(notifications.telemetryEnabledChanged, (telemetryEnabled: TelemetryState) => {
Diagnostic,
Hover,
InitializeResult,
ProposedFeatures,
Range,
TextDocument,
TextDocuments,
} from 'vscode-languageserver'
import { DiagnosticSeverity } from 'vscode-languageserver-protocol'
import { Grammarly } from './grammarly'
import { AuthParams } from './socket'
process.env.DEBUG = 'grammarly:*'
const debug = createLogger('grammarly:server')
const connection = createConnection(ProposedFeatures.all)
const documents = new TextDocuments(2 /* TextDocumentSyncKind.Incremental */)
let hasConfigurationCapability: boolean = false
let hasWorkspaceFolderCapability: boolean = false
let hasDiagnosticRelatedInformationCapability: boolean = false
connection.onInitialize(
(params): InitializeResult => {
const capabilities = params.capabilities
// Does the client support the `workspace/configuration` request?
// If not, we will fall back using global settings.
hasConfigurationCapability = !!(capabilities.workspace && capabilities.workspace.configuration)
hasWorkspaceFolderCapability = !!(capabilities.workspace && capabilities.workspace.workspaceFolders)
hasDiagnosticRelatedInformationCapability = !!(
capabilities.textDocument &&
constructor(
private connection: IConnection = createConnection(ProposedFeatures.all),
private documents: TextDocuments = new TextDocuments(),
private phpUnit: PhpUnit = new PhpUnit(),
private files: FilesystemContract = new Filesystem(),
private snippetManager: SnippetManager = new SnippetManager()
) {}
run() {
const connection = createConnection(ProposedFeatures.all);
this.documents.listen(connection);
connection.onInitialize(this.onInitialize.bind(this));
connection.onCompletion(this.onCompletion.bind(this));
connection.onCompletionResolve((item: CompletionItem): CompletionItem => {
return item;
});
connection.listen();
}
}
import * as fs from 'fs-extra'
import * as path from 'path'
import { URI } from 'vscode-uri'
import { createConnection, ProposedFeatures, TextDocumentSyncKind, Range, FoldingRange, FoldingRangeKind, SignatureInformation, Position, ColorInformation, Color, ColorPresentation, WorkspaceFolder, TextDocumentEdit, TextEdit, FileChangeType, RenameFile, DocumentLink, DocumentHighlight, InitializeResult, DiagnosticSeverity, TextDocument } from 'vscode-languageserver'
import { getSafeCategory, CacheUnit, CacheFile, ClientCache, combineCache, CacheKey, removeCacheUnit, removeCachePosition, trimCache, getCacheFromChar, isFileType, CachePosition, isNamespacedType, LatestCacheFileVersion, getFromCachedFileTree, setForCachedFileTree, walkInCachedFileTree, delFromCachedFileTree, CachedFileTree } from './types/ClientCache'
import Config, { VanillaConfig } from './types/Config'
import ArgumentParserManager from './parsers/ArgumentParserManager'
import Line, { lineToLintedString } from './types/Line'
import LineParser from './parsers/LineParser'
import StringReader from './utils/StringReader'
import { Files } from 'vscode-languageserver'
import Identity from './types/Identity'
const connection = createConnection(ProposedFeatures.all)
const linesOfRel = new Map()
const stringsOfRel = new Map()
const lineBreakOfRel = new Map()
const versionOfRel = new Map()
const hasParsedInRealConfigOfRel = new Map()
const configOfRel = new Map()
const manager = new ArgumentParserManager()
let hasRealConfig = false
let cacheFile: CacheFile = { cache: {}, files: {}, version: LatestCacheFileVersion }
let workspaceFolder: WorkspaceFolder | undefined
let workspaceFolderPath: string | undefined
let dotPath: string | undefined
let cachePath: string | undefined
let dataPath: string | undefined
import { ProposedFeatures, TextDocuments, createConnection } from "vscode-languageserver";
import { Server } from "./Server";
const connection = createConnection(ProposedFeatures.all);
const documents = new TextDocuments();
let server = new Server(connection, documents);
server.listen();