jisedlac commented on a change in pull request #3378: URL: https://github.com/apache/netbeans/pull/3378#discussion_r772375569
########## File path: java/java.lsp.server/vscode/src/runConfiguration.ts ########## @@ -0,0 +1,222 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as vscode from 'vscode'; +import { homedir } from 'os'; + +export async function initializeRunConfiguration(): Promise<boolean> { + const java = await vscode.workspace.findFiles('**/*.java', '**/node_modules/**', 1); + if (java?.length > 0) { + const maven = await vscode.workspace.findFiles('pom.xml', '**/node_modules/**', 1); + if (maven?.length > 0) { + return true; + } + const gradle = await vscode.workspace.findFiles('build.gradle', '**/node_modules/**', 1); + if (gradle?.length > 0) { + return true; + } + } + return false; +} + +class RunConfigurationProvider implements vscode.DebugConfigurationProvider { + + resolveDebugConfiguration(_folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, _token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> { + return new Promise<vscode.DebugConfiguration>(resolve => { + resolve(config); + }); + } + + resolveDebugConfigurationWithSubstitutedVariables?(_folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, _token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> { + return new Promise<vscode.DebugConfiguration>(resolve => { + const args = argumentsNode.getValue(); + if (args) { + if (!config.args) { + config.args = args; + } else { + config.args = `${config.args} ${args}`; + } + } + + const vmArgs = vmOptionsNode.getValue(); + if (vmArgs) { + if (!config.vmArgs) { + config.vmArgs = vmArgs; + } else { + config.vmArgs = `${config.vmArgs} ${vmArgs}`; + } + } + + const env = environmentVariablesNode.getValue(); + if (env) { + const envs = env.split(','); + if (!config.env) { + config.env = {}; + } + for (let val of envs) { + const vals = val.trim().split('='); + config.env[vals[0]] = vals[1]; + } + } + + const cwd = workingDirectoryNode.getValue(); + if (cwd) { + config.cwd = cwd; + } + + resolve(config); + }); + } + +} +export const runConfigurationProvider = new RunConfigurationProvider(); + +class RunConfigurationNodeProvider implements vscode.TreeDataProvider<vscode.TreeItem> { + Review comment: I don't see any benefit in using `org.openide.nodes.Node` here. The discussed feature is a pure VS Code-side UI implementation with no dependencies on NetBeans. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
