Skip to content

Commit 54d5ea1

Browse files
committed
051
1 parent 541552b commit 54d5ea1

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ All notable changes to the "php-namespace-resolver" extension will be documented
102102

103103
- fixes for `importAll`
104104
- we now also check for type hints & return types for classes to import
105+
106+
## 0.5.1
107+
108+
- show output panel when phpcommand fails

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "php-namespace-resolver",
33
"displayName": "PHP Namespace Resolver",
44
"description": "Import and expand php namespaces",
5-
"version": "0.5.0",
5+
"version": "0.5.1",
66
"publisher": "ctf0",
77
"author": "ctf0",
88
"repository": "https://github.com/ctf0/PHP-Namespace-Resolver",

src/NamespaceCheck.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { execa } from 'execa';
1212
import groupBy from 'lodash.groupby';
1313
import * as vscode from 'vscode';
14-
import Resolver from './Resolver';
14+
import { PKG_LABEL, Resolver } from './Resolver';
1515

1616
export default async function checkForNamespaces(resolver: Resolver, createDiagnosticCollection: vscode.DiagnosticCollection) {
1717
if (resolver.CWD) {
@@ -191,7 +191,7 @@ function createDiagnostic(item) {
191191
vscode.DiagnosticSeverity.Warning,
192192
);
193193

194-
diagnostic.source = 'PHP Namespace Resolver';
194+
diagnostic.source = PKG_LABEL;
195195

196196
return diagnostic;
197197
}

src/Resolver.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import * as vscode from 'vscode';
77
import * as Parser from './Parser';
88
import BUILT_IN_CLASSES_FB from './classes';
99

10+
export const PKG_LABEL = 'PHP Namespace Resolver';
1011
const COMP_JSON = 'composer.json';
11-
const regexWordWithNamespace = new RegExp(/[a-zA-Z0-9\\]+/);
1212
const DATA_TYPES = ['object', 'resource', 'array', 'string', 'int', 'float', 'bool', 'null', 'void', 'mixed'];
13+
const regexWordWithNamespace = new RegExp(/[a-zA-Z0-9\\]+/);
14+
const outputChannel = vscode.window.createOutputChannel(PKG_LABEL, 'log');
1315

14-
export default class Resolver {
16+
export class Resolver {
1517
BUILT_IN_CLASSES: any = BUILT_IN_CLASSES_FB;
1618
CLASS_AST: any;
1719
CWD: string;
@@ -465,7 +467,7 @@ export default class Resolver {
465467
const alpha = this.config('sort.alphabetically');
466468

467469
if (useStatements.length <= 1) {
468-
throw new Error('PHP Namespace Resolver: Nothing to sort.');
470+
throw new Error(`${PKG_LABEL}: Nothing to sort.`);
469471
}
470472

471473
let sortFunction = (a, b) => {
@@ -633,8 +635,8 @@ export default class Resolver {
633635
message = message.replace(/\$\(.+?\)/, '').trim();
634636

635637
return error
636-
? vscode.window.showErrorMessage(`PHP Namespace Resolver: ${message}`)
637-
: vscode.window.showInformationMessage(`PHP Namespace Resolver: ${message}`);
638+
? vscode.window.showErrorMessage(`${PKG_LABEL}: ${message}`)
639+
: vscode.window.showInformationMessage(`${PKG_LABEL}: ${message}`);
638640
}
639641

640642
/**
@@ -843,7 +845,7 @@ export default class Resolver {
843845
const phpCommand = this.config('php.command');
844846

845847
if (!phpCommand) {
846-
throw new Error('config required : phpCommand');
848+
throw new Error('config required : "namespaceResolver.php.command"');
847849
}
848850

849851
try {
@@ -855,6 +857,10 @@ export default class Resolver {
855857
return JSON.parse(stdout);
856858
} catch (error) {
857859
// console.error(error);
860+
861+
outputChannel.clear();
862+
outputChannel.appendLine(error.message);
863+
outputChannel.show();
858864
}
859865
}
860866

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as vscode from 'vscode';
22
import checkForNamespaces from './NamespaceCheck';
3-
import Resolver from './Resolver';
3+
import { PKG_LABEL, Resolver } from './Resolver';
44

55
export async function activate(context) {
66
const resolver = new Resolver();
7-
const createDiagnosticCollection = vscode.languages.createDiagnosticCollection('PHP Namespace Resolver');
7+
const createDiagnosticCollection = vscode.languages.createDiagnosticCollection(PKG_LABEL);
88

99
context.subscriptions.push(
1010
createDiagnosticCollection,

0 commit comments

Comments
 (0)