mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix ModuleStructureValidator running on Unix
GitOrigin-RevId: eb95b3647ac77c7501f2d0bb4ec80f68ce917d38
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2a81821c04
commit
43d3aacb1d
+27
-4
@@ -188,15 +188,14 @@ final class ModuleStructureValidator {
|
||||
def classes = new HashSet<String>(predefinedTypes)
|
||||
for (moduleName in moduleNames) {
|
||||
def outputDirectory = JpsJavaExtensionService.instance.getOutputDirectory(buildContext.findModule(moduleName), false)
|
||||
def outputDirectoryPrefix = outputDirectory.path.replace("\\", "/") + "/"
|
||||
outputDirectory.eachFileRecurse(FileType.FILES) {
|
||||
if (!it.name.endsWith('.class') || it.name.endsWith("Kt.class")) {
|
||||
return
|
||||
}
|
||||
|
||||
def className = it.path
|
||||
.replace(outputDirectory.path + "\\", "")
|
||||
.replace(".class", "")
|
||||
.replace("\\", ".")
|
||||
def normalizedPath = it.path.replace("\\", "/")
|
||||
def className = removeSuffixStrict(removePrefixStrict(normalizedPath, outputDirectoryPrefix), ".class").replace("/", ".")
|
||||
classes.add(className)
|
||||
}
|
||||
}
|
||||
@@ -208,6 +207,30 @@ final class ModuleStructureValidator {
|
||||
}
|
||||
}
|
||||
|
||||
private String removePrefixStrict(String string, String prefix) {
|
||||
if (prefix == null || prefix.isEmpty()) {
|
||||
throw new IllegalArgumentException("'prefix' is null or empty")
|
||||
}
|
||||
|
||||
if (!string.startsWith(prefix)) {
|
||||
throw new IllegalStateException("String must start with '$prefix': $string")
|
||||
}
|
||||
|
||||
return string.substring(prefix.length())
|
||||
}
|
||||
|
||||
private String removeSuffixStrict(String string, String suffix) {
|
||||
if (suffix == null || suffix.isEmpty()) {
|
||||
throw new IllegalArgumentException("'suffix' is null or empty")
|
||||
}
|
||||
|
||||
if (!string.endsWith(suffix)) {
|
||||
throw new IllegalStateException("String must end with '$suffix': $string")
|
||||
}
|
||||
|
||||
return string.substring(0, string.length() - suffix.length())
|
||||
}
|
||||
|
||||
private void validateXmlRegistrationsRec(String source, Node xml, HashSet<String> classes) {
|
||||
for (attribute in xml.attributes()) {
|
||||
def name = attribute.key.toString()
|
||||
|
||||
Reference in New Issue
Block a user