File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -62,25 +62,28 @@ function getPsr4(): { [key: string]: string } {
62
62
return autoload [ 'psr-4' ] ;
63
63
}
64
64
65
- export function generateNamespace ( folder : vscode . Uri , fileName : string ) : string {
65
+ export function generateNamespace ( folder : vscode . Uri ) : string {
66
66
let folderPath = folder . fsPath ;
67
67
const psr4 = getPsr4 ( ) ;
68
68
69
69
const rootPath = getRootPath ( ) ;
70
70
folderPath = folderPath . replace ( rootPath ?? '' , '' ) ;
71
71
folderPath = folderPath . replace ( / \/ | \\ / g, '\\' ) . replace ( / \\ / , '' ) ;
72
72
73
+
74
+
73
75
for ( const prefix of Object . keys ( psr4 ) ) {
74
76
const basePath = psr4 [ prefix ] . replace ( / \/ | \\ / g, '\\\\' ) ;
75
77
const prefixRegex = new RegExp ( `^${ basePath } ` ) ;
76
78
77
79
if ( prefixRegex . test ( folderPath ) ) {
78
80
const relativePath = folderPath . replace ( prefixRegex , '' ) ;
79
81
const namespace = prefix + relativePath ;
80
- vscode . window . showInformationMessage ( "in1" ) ;
81
82
return namespace ;
82
83
}
84
+ else if ( basePath === folderPath . concat ( '\\\\' ) ) {
85
+ return prefix . replace ( / \\ / , '' ) ;
86
+ }
83
87
}
84
- vscode . window . showInformationMessage ( "out" ) ;
85
88
return folderPath ;
86
89
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export async function wizardGeneratePhpSkeleton() {
8
8
const type = await wizardFileType ( ) ;
9
9
const fileName = await wizardFileName ( type ) ;
10
10
11
- const namespace = generateNamespace ( folder , fileName ) ;
11
+ const namespace = generateNamespace ( folder ) ;
12
12
13
13
const classSkeleton = await generatePhpSkeleton ( type , fileName , namespace ) ;
14
14
You can’t perform that action at this time.
0 commit comments