@@ -1897,31 +1897,42 @@ public static Collection<Pair<String, String>> getTwigPathFromYamlConfigResolved
1897
1897
Collection <Pair <String , String >> paths = new ArrayList <>();
1898
1898
1899
1899
for (Pair <String , String > pair : getTwigPathFromYamlConfig (yamlFile )) {
1900
- String second = pair .getSecond ();
1900
+ // normalize path; just to be error prune
1901
+ String namespacePath = pair .getSecond ().replace ("\\ " , "/" ).replaceAll ("/+" , "/" );
1902
+ String namespace = pair .getFirst ();
1901
1903
1902
- if (second .startsWith ("%kernel.root_dir%" )) {
1904
+ if (namespacePath .startsWith ("%kernel.root_dir%" )) {
1903
1905
// %kernel.root_dir%/../app
1904
1906
// %kernel.root_dir%/foo
1905
1907
for (VirtualFile appDir : FilesystemUtil .getAppDirectories (yamlFile .getProject ())) {
1906
- String path = StringUtils .stripStart (second .substring ("%kernel.root_dir%" .length ()), "/" );
1908
+ String path = StringUtils .stripStart (namespacePath .substring ("%kernel.root_dir%" .length ()), "/" );
1907
1909
1908
1910
VirtualFile relativeFile = VfsUtil .findRelativeFile (appDir , path .split ("/" ));
1909
1911
if (relativeFile != null ) {
1910
1912
String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
1911
1913
if (relativePath != null ) {
1912
- paths .add (Pair .create (pair . getFirst () , relativePath ));
1914
+ paths .add (Pair .create (namespace , relativePath ));
1913
1915
}
1914
1916
}
1915
1917
}
1916
- } else if (second .startsWith ("%kernel.project_dir%" )) {
1918
+ } else if (namespacePath .startsWith ("%kernel.project_dir%" )) {
1917
1919
// '%kernel.root_dir%/test'
1918
- String path = StringUtils .stripStart (second .substring ("%kernel.project_dir%" .length ()), "/" );
1920
+ String path = StringUtils .stripStart (namespacePath .substring ("%kernel.project_dir%" .length ()), "/" );
1919
1921
1920
- VirtualFile relativeFile = VfsUtil .findRelativeFile (yamlFile . getProject (). getBaseDir () , path .split ("/" ));
1922
+ VirtualFile relativeFile = VfsUtil .findRelativeFile (baseDir , path .split ("/" ));
1921
1923
if (relativeFile != null ) {
1922
1924
String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
1923
1925
if (relativePath != null ) {
1924
- paths .add (Pair .create (pair .getFirst (), relativePath ));
1926
+ paths .add (Pair .create (namespace , relativePath ));
1927
+ }
1928
+ }
1929
+ } else if (!namespacePath .startsWith ("/" ) && !namespacePath .startsWith ("\\ " )) {
1930
+ // 'test/foo'
1931
+ VirtualFile relativeFile = VfsUtil .findRelativeFile (baseDir , namespacePath .split ("/" ));
1932
+ if (relativeFile != null ) {
1933
+ String relativePath = VfsUtil .getRelativePath (relativeFile , baseDir , '/' );
1934
+ if (relativePath != null ) {
1935
+ paths .add (Pair .create (namespace , relativePath ));
1925
1936
}
1926
1937
}
1927
1938
}
0 commit comments