Skip to content

Commit

Permalink
[php] setting to disable suggestions and hover (for #9003)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Jan 23, 2017
1 parent 2e3c7b2 commit 1ff2c48
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions extensions/php/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"type": "object",
"order": 20,
"properties": {
"php.builtInCompletions.enable": {
"php.suggest.basic": {
"type": "boolean",
"default": true,
"description": "%configuration.builtInCompletions.enable%"
"description": "%configuration.suggest.basic%"
},
"php.validate.enable": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion extensions/php/package.nls.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"configuration.builtInCompletions.enable": "Enable/disable built-in PHP completions.",
"configuration.suggest.basic": "Configures if the built-in HTML language suggestions are enabled. The support suggests PHP globals and variables.",

This comment has been minimized.

Copy link
@felixfbecker

felixfbecker Jan 24, 2017

Contributor

This says "HTML", should say "PHP"

This comment has been minimized.

Copy link
@aeschli

aeschli Jan 24, 2017

Author Contributor

Thanks, I pushed a fix.

"configuration.validate.enable": "Enable/disable built-in PHP validation.",
"configuration.validate.executablePath": "Points to the PHP executable.",
"configuration.validate.run": "Whether the linter is run on save or on type.",
Expand Down
2 changes: 1 addition & 1 deletion extensions/php/src/features/completionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
public provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken): Promise<CompletionItem[]> {
let result: CompletionItem[] = [];

let shouldProvideCompletionItems = workspace.getConfiguration('php').get<boolean>('builtInCompletions.enable', true);
let shouldProvideCompletionItems = workspace.getConfiguration('php').get<boolean>('suggest.basic', true);
if (!shouldProvideCompletionItems) {
return Promise.resolve(result);
}
Expand Down
7 changes: 6 additions & 1 deletion extensions/php/src/features/hoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@

'use strict';

import { HoverProvider, Hover, MarkedString, TextDocument, CancellationToken, Position } from 'vscode';
import { HoverProvider, Hover, MarkedString, TextDocument, CancellationToken, Position, workspace } from 'vscode';
import phpGlobals = require('./phpGlobals');
import { textToMarkedString } from './utils/markedTextUtil';

export default class PHPHoverProvider implements HoverProvider {

public provideHover(document: TextDocument, position: Position, token: CancellationToken): Hover {
let enable = workspace.getConfiguration('php').get<boolean>('suggest.basic', true);
if (!enable) {
return null;
}

let wordRange = document.getWordRangeAtPosition(position);
if (!wordRange) {
return;
Expand Down
7 changes: 6 additions & 1 deletion extensions/php/src/features/signatureHelpProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

import { SignatureHelpProvider, SignatureHelp, SignatureInformation, CancellationToken, TextDocument, Position } from 'vscode';
import { SignatureHelpProvider, SignatureHelp, SignatureInformation, CancellationToken, TextDocument, Position, workspace } from 'vscode';
import phpGlobals = require('./phpGlobals');

var _NL = '\n'.charCodeAt(0);
Expand Down Expand Up @@ -70,6 +70,11 @@ class BackwardIterator {
export default class PHPSignatureHelpProvider implements SignatureHelpProvider {

public provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken): Promise<SignatureHelp> {
let enable = workspace.getConfiguration('php').get<boolean>('suggest.basic', true);
if (!enable) {
return null;
}

var iterator = new BackwardIterator(document, position.character - 1, position.line);

var paramCount = this.readArguments(iterator);
Expand Down

0 comments on commit 1ff2c48

Please sign in to comment.