mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 00:38:56 +00:00
Added src-gen, xtend-gen etc. to generated list of removal paths
This commit is contained in:
parent
dea769a93c
commit
9bcc8ea07d
2 changed files with 39 additions and 7 deletions
|
@ -10,12 +10,20 @@ package org.eclipse.xtext.splitting;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class GenerateRemovals {
|
||||
|
||||
public static final Set<String> GEN_DIRS = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(
|
||||
"src-gen", "xtend-gen", "xtext-gen", "emf-gen"
|
||||
)));
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 2) {
|
||||
|
@ -23,9 +31,9 @@ public class GenerateRemovals {
|
|||
}
|
||||
String outputDir = args[1];
|
||||
try {
|
||||
final Map<String, List<String>> removalPaths = new HashMap<>();
|
||||
final Map<String, Set<String>> removalPaths = new HashMap<>();
|
||||
for (String targetRepo : ValidateSplitting.REPOSITORIES) {
|
||||
removalPaths.put(targetRepo, new ArrayList<>());
|
||||
removalPaths.put(targetRepo, new LinkedHashSet<>());
|
||||
}
|
||||
|
||||
// Gather paths to be removed from the history for each target repository
|
||||
|
@ -52,6 +60,32 @@ public class GenerateRemovals {
|
|||
}
|
||||
}
|
||||
|
||||
// Add directories with generated code to the removal list
|
||||
final Pattern segmentPattern = Pattern.compile("/");
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(outputDir + "/" + FindProjects.ALL_FILES))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String file = line.replaceAll("\"|\\\\.", "");
|
||||
for (String genDir : GEN_DIRS) {
|
||||
int genDirIndex = file.indexOf(genDir);
|
||||
if (genDirIndex > 0) {
|
||||
for (String targetRepo : ValidateSplitting.REPOSITORIES) {
|
||||
Set<String> repoRemovals = removalPaths.get(targetRepo);
|
||||
Matcher matcher = segmentPattern.matcher(file);
|
||||
boolean foundRemoval = false;
|
||||
int genDirEndIndex = genDirIndex + genDir.length();
|
||||
while (!foundRemoval && matcher.find() && matcher.start() <= genDirEndIndex) {
|
||||
if (repoRemovals.contains(file.substring(0, matcher.start())))
|
||||
foundRemoval = true;
|
||||
}
|
||||
if (!foundRemoval)
|
||||
repoRemovals.add(file.substring(0, genDirEndIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write a removal list for each target repository
|
||||
for (String targetRepo : ValidateSplitting.REPOSITORIES) {
|
||||
try (FileWriter writer = new FileWriter(outputDir + "/removals-" + targetRepo + ".txt")) {
|
||||
|
|
|
@ -67,10 +67,8 @@ public class ValidateSplitting {
|
|||
if (!specifiedPaths.contains(file)) {
|
||||
Matcher matcher = segmentPattern.matcher(file);
|
||||
boolean foundSplitting = false;
|
||||
int lastMatch = -1;
|
||||
while (!foundSplitting && matcher.find()) {
|
||||
lastMatch = matcher.start();
|
||||
if (specifiedPaths.contains(file.substring(0, lastMatch)))
|
||||
if (specifiedPaths.contains(file.substring(0, matcher.start())))
|
||||
foundSplitting = true;
|
||||
}
|
||||
if (!foundSplitting)
|
||||
|
|
Loading…
Reference in a new issue