mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[generator] changed the disabling of the new case splitting. Enabled download of antlr generator without asking
This commit is contained in:
parent
014e623b6b
commit
a9d2da2331
6 changed files with 7 additions and 40 deletions
|
@ -90,6 +90,7 @@ abstract class AbstractAntlrGeneratorFragment2 extends AbstractXtextGeneratorFra
|
|||
def protected void splitLexerClassFile(IXtextGeneratorFileSystemAccess fsa, TypeReference lexer) {
|
||||
val content = fsa.readTextFile(lexer.javaPath).toString
|
||||
var AntlrLexerSplitter splitter = new AntlrLexerSplitter(content)
|
||||
splitter.setCasesPerSpecialStateSwitch(options.getCasesPerSpecialStateSwitch());
|
||||
fsa.generateFile(lexer.javaPath, splitter.transform)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ class AntlrOptions {
|
|||
int k = -1
|
||||
boolean ignoreCase = false
|
||||
boolean classSplitting = false
|
||||
boolean specialStateSwitchSplitting = false
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
int fieldsPerClass = AntlrParserSplitter.FIELDS_PER_CLASS
|
||||
@Accessors(PUBLIC_GETTER)
|
||||
|
@ -44,7 +43,7 @@ class AntlrOptions {
|
|||
def void setCasesPerSpecialStateSwitch(String casesPerSpecialStateSwitch) {
|
||||
this.casesPerSpecialStateSwitch = Integer.parseInt(casesPerSpecialStateSwitch)
|
||||
}
|
||||
|
||||
|
||||
def void setKAsString(String k) {
|
||||
this.k = Integer.parseInt(k)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class AntlrToolFacade {
|
|||
}
|
||||
|
||||
private String downloadURL = "http://download.itemis.com/antlr-generator-3.2.0-patch.jar";
|
||||
private boolean askBeforeDownload = true;
|
||||
private boolean askBeforeDownload = false;
|
||||
|
||||
public void setAskBeforeDownload(boolean shouldAsk) {
|
||||
this.askBeforeDownload = shouldAsk;
|
||||
|
|
|
@ -45,7 +45,6 @@ public class AntlrLexerSplitter {
|
|||
private final Scanner scanner;
|
||||
|
||||
private boolean allowDFAStaticClasses = true;
|
||||
private boolean specialStateSwitchSplitting = false;
|
||||
|
||||
private int casesPerSpecialStateSwitch = LexerSpecialStateTransitionSplitter.CASES_PER_SPECIAL_STATE_SWITCH;
|
||||
|
||||
|
@ -78,7 +77,6 @@ public class AntlrLexerSplitter {
|
|||
LexerSpecialStateTransitionSplitter lexerSplitter;
|
||||
lexerSplitter = new LexerSpecialStateTransitionSplitter(false);
|
||||
lexerSplitter.setAllowDFAStaticClasses(allowDFAStaticClasses);
|
||||
lexerSplitter.setSpecialStateSwitchSplitting(specialStateSwitchSplitting);
|
||||
lexerSplitter.setCasesPerSpecialStateSwitch(casesPerSpecialStateSwitch);
|
||||
result = lexerSplitter.transform(result);
|
||||
return result;
|
||||
|
@ -238,20 +236,6 @@ public class AntlrLexerSplitter {
|
|||
this.allowDFAStaticClasses = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
public boolean isSpecialStateSwitchSplitting() {
|
||||
return specialStateSwitchSplitting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
public void setSpecialStateSwitchSplitting(boolean value) {
|
||||
this.specialStateSwitchSplitting = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
public class LexerSpecialStateTransitionSplitter {
|
||||
|
||||
public static final int CASES_PER_SPECIAL_STATE_SWITCH = 1000;
|
||||
public static final int CASES_PER_SPECIAL_STATE_SWITCH = -1;
|
||||
|
||||
public static final Pattern DFA_PATTERN = Pattern.compile(
|
||||
"(class DFA\\d+ extends DFA \\{.*" +
|
||||
|
@ -69,8 +69,6 @@ public class LexerSpecialStateTransitionSplitter {
|
|||
|
||||
private boolean allowDFAStaticClasses = true;
|
||||
|
||||
private boolean specialStateSwitchSplitting = false;
|
||||
|
||||
private int casesPerSpecialStateSwitch = CASES_PER_SPECIAL_STATE_SWITCH;
|
||||
|
||||
public LexerSpecialStateTransitionSplitter(boolean ignoreCaseCountGuard) {
|
||||
|
@ -87,10 +85,10 @@ public class LexerSpecialStateTransitionSplitter {
|
|||
staticOrNot = "static $1";
|
||||
String tmpSpecialStateTransition = extractSpecialStateMethods(specialStateTransition);
|
||||
String transformedDfa;
|
||||
if(specialStateSwitchSplitting){
|
||||
transformedDfa = staticOrNot + splitSpecialStateSwitch(tmpSpecialStateTransition) + "$3";
|
||||
}else{
|
||||
if (casesPerSpecialStateSwitch == -1) {
|
||||
transformedDfa = staticOrNot + tmpSpecialStateTransition + "$3";
|
||||
} else {
|
||||
transformedDfa = staticOrNot + splitSpecialStateSwitch(tmpSpecialStateTransition) + "$3";
|
||||
}
|
||||
dfaMatcher.appendReplacement(result, transformedDfa);
|
||||
}
|
||||
|
@ -221,20 +219,6 @@ public class LexerSpecialStateTransitionSplitter {
|
|||
this.allowDFAStaticClasses = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
public boolean isSpecialStateSwitchSplitting() {
|
||||
return specialStateSwitchSplitting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
public void setSpecialStateSwitchSplitting(boolean value) {
|
||||
this.specialStateSwitchSplitting = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.9
|
||||
*/
|
||||
|
|
|
@ -329,7 +329,6 @@ public class LexerSpecialStateTransitionSplitterTest extends Assert {
|
|||
@Test public void testSpecialStateSwitchTransformation(){
|
||||
int tmpCasesLimit = testMe.getCasesPerSpecialStateSwitch();
|
||||
|
||||
testMe.setSpecialStateSwitchSplitting(true);
|
||||
testMe.setCasesPerSpecialStateSwitch(3);
|
||||
String actualSpecialStateSwitchSplit = testMe.transform(original);
|
||||
assertEquals(transformedSpecialStateSplit,actualSpecialStateSwitchSplit);
|
||||
|
|
Loading…
Reference in a new issue