Skip to content

Commit 303c868

Browse files
committed
Fix auto prefixes for single level namespaces
1 parent 2a28fec commit 303c868

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>clojure</artifactId>
66
<name>clojure</name>
77
<packaging>jar</packaging>
8-
<version>1.13.0-alpha5</version>
8+
<version>1.13.0-alpha6_1</version>
99
<url>http://clojure.org/</url>
1010
<description>Clojure core environment and runtime library.</description>
1111

‎src/jvm/clojure/storm/Utils.java‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,38 @@ private static void collectFiles(File dir, List<File> collectedFiles) {
337337
}
338338
}
339339

340+
public static String getFileNameNoExtension(File file) {
341+
String fileName = file.getName();
342+
int dot = fileName.lastIndexOf('.');
343+
return (dot == -1) ? fileName : fileName.substring(0, dot);
344+
}
345+
340346
public static Set<String> getSrcDirRootNamespaces(File dir) {
341347
Set<String> namespaces = new HashSet<String>();
342348
List<File> allDirFiles = new ArrayList();
343349

344-
Pattern pattern = Pattern.compile(".+?" + dir.getName() + "/(.+?)/.*");
350+
Pattern topLevelDirNsPattern = Pattern.compile(".+?" + dir.getName() + "/(.+?)/.*");
345351
collectFiles(dir, allDirFiles);
346352
for (File f : allDirFiles) {
347353
if (f.getName().endsWith(".clj") ||
348354
f.getName().endsWith(".cljc")) {
349355

350-
Matcher matcher = pattern.matcher(f.getAbsolutePath().replace("\\","/"));
351-
352-
if (matcher.find() && matcher.groupCount() >= 1) {
353-
String rootDir = matcher.group(1);
356+
String fileAbsPath = f.getAbsolutePath().replace("\\","/");
357+
358+
Pattern topLevelFileNsPattern = Pattern.compile(".+?" + dir.getName() + "/" + f.getName());
359+
360+
Matcher topLevelDirNsMatcher = topLevelDirNsPattern.matcher(fileAbsPath);
361+
Matcher topLevelFileNsMatcher = topLevelFileNsPattern.matcher(fileAbsPath);
362+
363+
if (topLevelDirNsMatcher.find() && topLevelDirNsMatcher.groupCount() >= 1) {
364+
String rootDir = topLevelDirNsMatcher.group(1);
354365
namespaces.add(Compiler.demunge(rootDir));
355-
}
356366
}
367+
if (topLevelFileNsMatcher.find()) {
368+
String nsFile = getFileNameNoExtension(f);
369+
namespaces.add(Compiler.demunge(nsFile));
370+
}
371+
}
357372
}
358373
return namespaces;
359374
}

0 commit comments

Comments
 (0)