🚀 Support custom memory limit

pull/102/head
jens1o 2017-04-10 14:02:02 +02:00
parent f635ba8c4a
commit 9e5703d749
2 changed files with 27 additions and 1 deletions

View File

@ -54,5 +54,17 @@
"mz": "^2.4.0", "mz": "^2.4.0",
"semver": "^5.3.0", "semver": "^5.3.0",
"vscode-languageclient": "^3.0.3" "vscode-languageclient": "^3.0.3"
},
"contributes": {
"configuration": {
"title": "PHP-Intellisense",
"properties": {
"phpintellisense.memoryLimit": {
"type": "string",
"default": "-1",
"description": "The memory limit of the php language server. [Number][K|M|G]. Use '-1' to allow unlimited use of the RAM(default)."
}
}
}
} }
} }

View File

@ -12,6 +12,20 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const conf = vscode.workspace.getConfiguration('php'); const conf = vscode.workspace.getConfiguration('php');
const executablePath = conf.get<string>('executablePath') || 'php'; const executablePath = conf.get<string>('executablePath') || 'php';
const specificSettings = vscode.workspace.getConfiguration('phpintellisense');
const memoryLimit = specificSettings.get<string>('memoryLimit') || '-1';
if (memoryLimit !== '-1' && !memoryLimit.match('~^(\d+)(K|M|G|)$~')) {
const selected = await vscode.window.showErrorMessage(
'The memory limit you\'d provided is not numeric, nor "-1" nor valid php shorthand notation!',
'Open settings'
);
if (selected === 'Open settings') {
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
}
}
// Check path (if PHP is available and version is ^7.0.0) // Check path (if PHP is available and version is ^7.0.0)
let stdout: string; let stdout: string;
try { try {
@ -51,7 +65,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const serverOptions = () => new Promise<ChildProcess | StreamInfo>((resolve, reject) => { const serverOptions = () => new Promise<ChildProcess | StreamInfo>((resolve, reject) => {
function spawnServer(...args: string[]): ChildProcess { function spawnServer(...args: string[]): ChildProcess {
// The server is implemented in PHP // The server is implemented in PHP
args.unshift(context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php'))); args.unshift(context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php') + ' --memory-limit=' + memoryLimit));
const childProcess = spawn(executablePath, args); const childProcess = spawn(executablePath, args);
childProcess.stderr.on('data', (chunk: Buffer) => { childProcess.stderr.on('data', (chunk: Buffer) => {
console.error(chunk + ''); console.error(chunk + '');