/* -------------------------------------------------------------------------------------------- * Copyright (c) Jan Dolejsi. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.deactivate = exports.activate = exports.packageJson = exports.ptestExplorer = exports.planning = exports.codePddlWorkspaceForTests = exports.plannersConfiguration = void 0; const vscode_1 = require("vscode"); const planning_1 = require("./planning/planning"); const pddl_workspace_1 = require("pddl-workspace"); const pddl_workspace_2 = require("pddl-workspace"); const configuration_1 = require("./configuration/configuration"); const Authentication_1 = require("./util/Authentication"); const AutoCompletion_1 = require("./completion/AutoCompletion"); const SymbolRenameProvider_1 = require("./symbols/SymbolRenameProvider"); const SymbolInfoProvider_1 = require("./symbols/SymbolInfoProvider"); const Diagnostics_1 = require("./diagnostics/Diagnostics"); const StartUp_1 = require("./init/StartUp"); const PTestExplorer_1 = require("./ptest/PTestExplorer"); const PlanValidator_1 = require("./diagnostics/PlanValidator"); const debugging_1 = require("./debugger/debugging"); const ExtensionInfo_1 = require("./configuration/ExtensionInfo"); const HappeningsValidator_1 = require("./diagnostics/HappeningsValidator"); const PlanComparer_1 = require("./comparison/PlanComparer"); const Catalog_1 = require("./catalog/Catalog"); const vscode_extension_telemetry_wrapper_1 = require("vscode-extension-telemetry-wrapper"); const SearchDebugger_1 = require("./searchDebugger/SearchDebugger"); const PlanningDomainsSessions_1 = require("./session/PlanningDomainsSessions"); const PddlFormatProvider_1 = require("./formatting/PddlFormatProvider"); const ValDownloader_1 = require("./validation/ValDownloader"); const utils_1 = require("./utils"); const AssociationProvider_1 = require("./workspace/AssociationProvider"); const SuggestionProvider_1 = require("./symbols/SuggestionProvider"); const CodePddlWorkspace_1 = require("./workspace/CodePddlWorkspace"); const DomainDiagnostics_1 = require("./diagnostics/DomainDiagnostics"); const PddlOnTypeFormatter_1 = require("./formatting/PddlOnTypeFormatter"); const PddlCompletionItemProvider_1 = require("./completion/PddlCompletionItemProvider"); const ProblemInitView_1 = require("./modelView/ProblemInitView"); const ProblemObjectsView_1 = require("./modelView/ProblemObjectsView"); const DomainTypesView_1 = require("./modelView/DomainTypesView"); const ProblemConstraintsView_1 = require("./modelView/ProblemConstraintsView"); const ModelHierarchyProvider_1 = require("./symbols/ModelHierarchyProvider"); const PlannersConfiguration_1 = require("./configuration/PlannersConfiguration"); const planReport_1 = require("./planReport/planReport"); const PlannerExecutable_1 = require("./planning/PlannerExecutable"); const PDDL_CONFIGURE_PARSER = 'pddl.configureParser'; const PDDL_LOGIN_PARSER_SERVICE = 'pddl.loginParserService'; const PDDL_UPDATE_TOKENS_PARSER_SERVICE = 'pddl.updateTokensParserService'; const PDDL_LOGIN_PLANNER_SERVICE = 'pddl.loginPlannerService'; const PDDL_UPDATE_TOKENS_PLANNER_SERVICE = 'pddl.updateTokensPlannerService'; const PDDL_CONFIGURE_VALIDATOR = 'pddl.configureValidate'; let formattingProvider; let pddlConfiguration; async function activate(context) { var _a; const extensionInfo = new ExtensionInfo_1.ExtensionInfo(); // initialize the instrumentation wrapper const telemetryKey = process.env.VSCODE_PDDL_TELEMETRY_TOKEN; if (telemetryKey) { vscode_extension_telemetry_wrapper_1.initialize(extensionInfo.getId(), extensionInfo.getVersion(), telemetryKey); } try { // activate the extension, but send instrumentation data return await vscode_extension_telemetry_wrapper_1.instrumentOperation("activation", activateWithTelemetry)(context); } catch (ex) { // sadly, the next line never gets triggered, even if the activateWithTelemetry fails console.error("Error during PDDL extension activation: " + ((_a = ex.message) !== null && _a !== void 0 ? _a : ex)); vscode_1.window.showErrorMessage("There was an error starting the PDDL extension: " + ex.message); return undefined; } } exports.activate = activate; async function activateWithTelemetry(_operationId, context) { pddlConfiguration = new configuration_1.PddlConfiguration(context); const valDownloader = new ValDownloader_1.ValDownloader(context).registerCommands(); const pddlContext = utils_1.createPddlExtensionContext(context); const pddlWorkspace = new pddl_workspace_1.PddlWorkspace(pddlConfiguration.getEpsilonTimeStep(), pddlContext, utils_1.toPddlFileSystem(vscode_1.workspace.fs)); exports.plannersConfiguration = new PlannersConfiguration_1.PlannersConfiguration(context, pddlWorkspace); // run start-up actions new StartUp_1.StartUp(context, pddlConfiguration, exports.plannersConfiguration, valDownloader).atStartUp(); const codePddlWorkspace = CodePddlWorkspace_1.CodePddlWorkspace.getInstance(pddlWorkspace, context, pddlConfiguration); exports.codePddlWorkspaceForTests = codePddlWorkspace; exports.planning = new planning_1.Planning(codePddlWorkspace, pddlConfiguration, exports.plannersConfiguration, context); planReport_1.registerPlanReport(context); const planValidator = new PlanValidator_1.PlanValidator(exports.planning.output, codePddlWorkspace, pddlConfiguration, context); const happeningsValidator = new HappeningsValidator_1.HappeningsValidator(exports.planning.output, codePddlWorkspace, pddlConfiguration, context); const configureParserCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_CONFIGURE_PARSER, () => { pddlConfiguration.askNewParserPath(); }); const searchDebugger = new SearchDebugger_1.SearchDebugger(context, pddlConfiguration); exports.planning.addOptionsProvider(searchDebugger); const loginParserServiceCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_LOGIN_PARSER_SERVICE, () => { const scopePromise = pddlConfiguration.askConfigurationScope(); scopePromise.then((scope) => { if (scope === undefined) { return; } // canceled const configuration = pddlConfiguration.getConfigurationForScope(scope); if (configuration === undefined) { return; } const authentication = createAuthentication(pddlConfiguration); authentication.login((refreshtoken, accesstoken, stoken) => { pddlConfiguration.savePddlParserAuthenticationTokens(configuration, refreshtoken, accesstoken, stoken, scope.target); vscode_1.window.showInformationMessage("Login successful."); }, (message) => { vscode_1.window.showErrorMessage('Login failure: ' + message); }); }); }); const updateTokensParserServiceCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_UPDATE_TOKENS_PARSER_SERVICE, () => { const scopePromise = pddlConfiguration.askConfigurationScope(); scopePromise.then((scope) => { if (scope === undefined) { return; } // canceled const configuration = pddlConfiguration.getConfigurationForScope(scope); if (configuration === undefined) { return; } const authentication = createAuthentication(pddlConfiguration); authentication.login((refreshtoken, accesstoken, stoken) => { pddlConfiguration.savePddlParserAuthenticationTokens(configuration, refreshtoken, accesstoken, stoken, scope.target); vscode_1.window.showInformationMessage("Tokens refreshed and saved."); }, (message) => { vscode_1.window.showErrorMessage('Couldn\'t refresh the tokens, try to login: ' + message); }); }); }); const loginPlannerServiceCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_LOGIN_PLANNER_SERVICE, () => { const scopePromise = pddlConfiguration.askConfigurationScope(); scopePromise.then((scope) => { if (scope === undefined) { return; } // canceled const configuration = pddlConfiguration.getConfigurationForScope(scope); if (configuration === undefined) { return; } const authentication = createAuthentication(pddlConfiguration); authentication.login((refreshtoken, accesstoken, stoken) => { pddlConfiguration.savePddlPlannerAuthenticationTokens(configuration, refreshtoken, accesstoken, stoken, scope.target); vscode_1.window.showInformationMessage("Login successful."); }, (message) => { vscode_1.window.showErrorMessage('Login failure: ' + message); }); }); }); const updateTokensPlannerServiceCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_UPDATE_TOKENS_PLANNER_SERVICE, () => { const scopePromise = pddlConfiguration.askConfigurationScope(); scopePromise.then((scope) => { if (scope === undefined) { return; } // canceled const configuration = pddlConfiguration.getConfigurationForScope(scope); if (configuration === undefined) { return; } const authentication = createAuthentication(pddlConfiguration); authentication.login((refreshtoken, accesstoken, stoken) => { pddlConfiguration.savePddlPlannerAuthenticationTokens(configuration, refreshtoken, accesstoken, stoken, scope.target); vscode_1.window.showInformationMessage("Tokens refreshed and saved."); }, (message) => { vscode_1.window.showErrorMessage('Couldn\'t refresh the tokens, try to login: ' + message); }); }); }); context.subscriptions.push(vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(PDDL_CONFIGURE_VALIDATOR, () => { pddlConfiguration.askNewValidatorPath(); })); const completionItemProvider = vscode_1.languages.registerCompletionItemProvider(pddl_workspace_2.PDDL, new AutoCompletion_1.AutoCompletion(codePddlWorkspace), '(', ':', '-'); const completionItemProvider2 = vscode_1.languages.registerCompletionItemProvider(pddl_workspace_2.PDDL, new PddlCompletionItemProvider_1.PddlCompletionItemProvider(codePddlWorkspace), '(', ':', '-', '?'); const suggestionProvider = vscode_1.languages.registerCodeActionsProvider(pddl_workspace_2.PDDL, new SuggestionProvider_1.SuggestionProvider(codePddlWorkspace), { providedCodeActionKinds: SuggestionProvider_1.SuggestionProvider.providedCodeActionKinds }); const domainTypesView = new DomainTypesView_1.DomainTypesView(context, codePddlWorkspace); context.subscriptions.push(vscode_1.languages.registerCodeLensProvider(pddl_workspace_2.PDDL, domainTypesView)); const problemInitView = new ProblemInitView_1.ProblemInitView(context, codePddlWorkspace); context.subscriptions.push(vscode_1.languages.registerCodeLensProvider(pddl_workspace_2.PDDL, problemInitView)); const problemObjectsView = new ProblemObjectsView_1.ProblemObjectsView(context, codePddlWorkspace); context.subscriptions.push(vscode_1.languages.registerCodeLensProvider(pddl_workspace_2.PDDL, problemObjectsView)); const problemConstraintsView = new ProblemConstraintsView_1.ProblemConstraintsView(context, codePddlWorkspace); context.subscriptions.push(vscode_1.languages.registerCodeLensProvider(pddl_workspace_2.PDDL, problemConstraintsView)); registerDocumentFormattingProvider(context, codePddlWorkspace); const renameProvider = vscode_1.languages.registerRenameProvider(pddl_workspace_2.PDDL, new SymbolRenameProvider_1.SymbolRenameProvider(codePddlWorkspace)); if (vscode_1.workspace.getConfiguration("pddl").get("modelHierarchy")) { const modelHierarchyProvider = new ModelHierarchyProvider_1.ModelHierarchyProvider(context, codePddlWorkspace); context.subscriptions.push(vscode_1.languages.registerHoverProvider(pddl_workspace_2.PDDL, modelHierarchyProvider)); } const symbolInfoProvider = new SymbolInfoProvider_1.SymbolInfoProvider(codePddlWorkspace); const documentSymbolProvider = vscode_1.languages.registerDocumentSymbolProvider(pddl_workspace_2.PDDL, symbolInfoProvider); const definitionProvider = vscode_1.languages.registerDefinitionProvider(pddl_workspace_2.PDDL, symbolInfoProvider); const referencesProvider = vscode_1.languages.registerReferenceProvider(pddl_workspace_2.PDDL, symbolInfoProvider); const hoverProvider = vscode_1.languages.registerHoverProvider(pddl_workspace_2.PDDL, symbolInfoProvider); const diagnosticCollection = vscode_1.languages.createDiagnosticCollection(pddl_workspace_2.PDDL); const diagnostics = new Diagnostics_1.Diagnostics(codePddlWorkspace, diagnosticCollection, pddlConfiguration, planValidator, happeningsValidator); // tslint:disable-next-line:no-unused-expression new DomainDiagnostics_1.DomainDiagnostics(codePddlWorkspace); // tslint:disable-next-line: no-unused-expression new AssociationProvider_1.AssociationProvider(context, codePddlWorkspace); const planDefinitionProvider = vscode_1.languages.registerDefinitionProvider(pddl_workspace_2.PLAN, symbolInfoProvider); const planHoverProvider = vscode_1.languages.registerHoverProvider(pddl_workspace_2.PLAN, symbolInfoProvider); const happeningsDefinitionProvider = vscode_1.languages.registerDefinitionProvider(pddl_workspace_2.HAPPENINGS, symbolInfoProvider); const happeningsHoverProvider = vscode_1.languages.registerHoverProvider(pddl_workspace_2.HAPPENINGS, symbolInfoProvider); // tslint:disable-next-line:no-unused-expression exports.ptestExplorer = new PTestExplorer_1.PTestExplorer(context, pddlContext, codePddlWorkspace, exports.planning); // tslint:disable-next-line:no-unused-expression new Catalog_1.Catalog(context); // tslint:disable-next-line:no-unused-expression new PlanningDomainsSessions_1.PlanningDomainsSessions(context); // tslint:disable-next-line:no-unused-expression new debugging_1.Debugging(context, codePddlWorkspace, pddlConfiguration); const localPackageJson = exports.packageJson = context.extension.packageJSON; context.subscriptions.push(vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand('pddl.settings', () => { vscode_1.commands.executeCommand('workbench.action.openSettings', `@ext:${localPackageJson.publisher}.${localPackageJson.name}`); })); context.subscriptions.push(new PlanComparer_1.PlanComparer(pddlWorkspace, pddlConfiguration)); vscode_1.workspace.onDidChangeConfiguration(() => { exports.plannersConfiguration.refreshStatusBar(); if (registerDocumentFormattingProvider(context, codePddlWorkspace)) { vscode_1.window.showInformationMessage("PDDL formatter is now available. Right-click on a PDDL file..."); console.log('PDDL Formatter enabled.'); } }); const configureCommand = vscode_extension_telemetry_wrapper_1.instrumentOperationAsVsCodeCommand(configuration_1.PDDL_CONFIGURE_COMMAND, (configurationName) => { pddlConfiguration.askConfiguration(configurationName).catch(utils_1.showError); }); exports.plannersConfiguration.registerBuiltInPlannerProviders(); console.log('PDDL Extension initialized.'); // Push the disposables to the context's subscriptions so that the // client can be deactivated on extension deactivation context.subscriptions.push(diagnostics, configureParserCommand, loginParserServiceCommand, updateTokensParserServiceCommand, loginPlannerServiceCommand, updateTokensPlannerServiceCommand, completionItemProvider, completionItemProvider2, renameProvider, suggestionProvider, documentSymbolProvider, definitionProvider, referencesProvider, hoverProvider, planHoverProvider, planDefinitionProvider, happeningsHoverProvider, happeningsDefinitionProvider, problemInitView, problemObjectsView, problemConstraintsView, configureCommand); return { pddlWorkspace: pddlWorkspace, plannerExecutableFactory: new PlannerExecutable_1.PlannerExecutableFactory() }; } function deactivate() { // nothing to do } exports.deactivate = deactivate; function createAuthentication(pddlConfiguration) { const configuration = pddlConfiguration.getPddlParserServiceAuthenticationConfiguration(); return new Authentication_1.SAuthentication(configuration.url, configuration.requestEncoded, configuration.clientId, configuration.callbackPort, configuration.timeoutInMs, configuration.tokensvcUrl, configuration.tokensvcApiKey, configuration.tokensvcAccessPath, configuration.tokensvcValidatePath, configuration.tokensvcCodePath, configuration.tokensvcRefreshPath, configuration.tokensvcSvctkPath, configuration.refreshToken, configuration.accessToken, configuration.sToken); } function registerDocumentFormattingProvider(context, pddlWorkspace) { if (vscode_1.workspace.getConfiguration("pddl").get("formatter") && !formattingProvider) { formattingProvider = new PddlFormatProvider_1.PddlFormatProvider(pddlWorkspace); const formattingProviderDisposable = vscode_1.languages.registerDocumentFormattingEditProvider(pddl_workspace_2.PDDL, formattingProvider); context.subscriptions.push(formattingProviderDisposable); const rangeFormattingProviderDisposable = vscode_1.languages.registerDocumentRangeFormattingEditProvider(pddl_workspace_2.PDDL, formattingProvider); context.subscriptions.push(rangeFormattingProviderDisposable); const onTypeFormattingProviderDisposable = vscode_1.languages.registerOnTypeFormattingEditProvider(pddl_workspace_2.PDDL, new PddlOnTypeFormatter_1.PddlOnTypeFormatter(pddlWorkspace), '\n'); context.subscriptions.push(onTypeFormattingProviderDisposable); return true; } else { return false; } } //# sourceMappingURL=extension.js.map