mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Bug 537632 - Meson Property Pages missing some fields after configure
- fix MesonPropertyPage logic concerning a configured meson project - for possible values, add "-" and "/" as valid characters - in state flow, don't just wait for blank lines, an option header can occur in the middle of a group or a new option group name can also occur Change-Id: I2c6c8f9fb15db0425f03e422b20b58ace5234fd4
This commit is contained in:
parent
0b2053dcb2
commit
ac81db720c
1 changed files with 136 additions and 104 deletions
|
@ -391,8 +391,8 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
ParseState state = ParseState.INIT;
|
ParseState state = ParseState.INIT;
|
||||||
Pattern optionPattern = Pattern.compile(Messages.MesonPropertyPage_option_pattern);
|
Pattern optionPattern = Pattern.compile(Messages.MesonPropertyPage_option_pattern);
|
||||||
Pattern optionWithValuesPattern = Pattern.compile(Messages.MesonPropertyPage_option_with_values_pattern);
|
Pattern optionWithValuesPattern = Pattern.compile(Messages.MesonPropertyPage_option_with_values_pattern);
|
||||||
Pattern optionLine = Pattern.compile("(\\w+)\\s+(\\w+)\\s+(.*)$"); //$NON-NLS-1$
|
Pattern optionLine = Pattern.compile("(\\w+)\\s+([\\w,\\-,/]+)\\s+(.*)$"); //$NON-NLS-1$
|
||||||
Pattern optionWithValuesLine = Pattern.compile("(\\w+)\\s+(\\w+)\\s+\\[(\\w+)((,\\s+\\w+)*)\\]\\s+(.*)$");
|
Pattern optionWithValuesLine = Pattern.compile("(\\w+)\\s+([\\w,\\-,/]+)\\s+\\[([\\w,\\-,/]+)((,\\s+[\\w,\\-]+)*)\\]\\s+(.*)$");
|
||||||
Pattern compilerOrLinkerArgs = Pattern.compile(Messages.MesonPropertyPage_compiler_or_link_args);
|
Pattern compilerOrLinkerArgs = Pattern.compile(Messages.MesonPropertyPage_compiler_or_link_args);
|
||||||
Pattern argLine = Pattern.compile("(\\w+)\\s+\\[([^\\]]*)\\]"); //$NON-NLS-1$
|
Pattern argLine = Pattern.compile("(\\w+)\\s+\\[([^\\]]*)\\]"); //$NON-NLS-1$
|
||||||
Pattern groupPattern = Pattern.compile("(([^:]*)):"); //$NON-NLS-1$
|
Pattern groupPattern = Pattern.compile("(([^:]*)):"); //$NON-NLS-1$
|
||||||
|
@ -400,120 +400,152 @@ public class MesonPropertyPage extends PropertyPage {
|
||||||
Composite parent = composite;
|
Composite parent = composite;
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
switch (state) {
|
boolean unprocessed = true;
|
||||||
case INIT:
|
while (unprocessed) {
|
||||||
Matcher argMatcher = compilerOrLinkerArgs.matcher(line);
|
unprocessed = false;
|
||||||
if (argMatcher.matches()) {
|
switch (state) {
|
||||||
state = ParseState.ARGS;
|
case INIT:
|
||||||
Group group = new Group(composite, SWT.BORDER);
|
Matcher argMatcher = compilerOrLinkerArgs.matcher(line);
|
||||||
group.setLayout(new GridLayout(2, true));
|
if (argMatcher.matches()) {
|
||||||
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
state = ParseState.ARGS;
|
||||||
group.setText(argMatcher.group(1));
|
Group group = new Group(composite, SWT.BORDER);
|
||||||
parent = group;
|
group.setLayout(new GridLayout(2, true));
|
||||||
} else {
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
Matcher groupMatcher = groupPattern.matcher(line);
|
group.setText(argMatcher.group(1));
|
||||||
if (groupMatcher.matches()) {
|
parent = group;
|
||||||
groupName = groupMatcher.group(1);
|
} else {
|
||||||
state = ParseState.GROUP;
|
Matcher groupMatcher = groupPattern.matcher(line);
|
||||||
|
if (groupMatcher.matches()) {
|
||||||
|
groupName = groupMatcher.group(1);
|
||||||
|
state = ParseState.GROUP;
|
||||||
|
}
|
||||||
|
parent = composite;
|
||||||
}
|
}
|
||||||
parent = composite;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GROUP:
|
|
||||||
Matcher m = optionPattern.matcher(line);
|
|
||||||
if (m.matches()) {
|
|
||||||
state = ParseState.OPTION;
|
|
||||||
Group group = new Group(composite, SWT.BORDER);
|
|
||||||
group.setLayout(new GridLayout(2, true));
|
|
||||||
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
||||||
group.setText(groupName);
|
|
||||||
parent = group;
|
|
||||||
break;
|
break;
|
||||||
}
|
case GROUP:
|
||||||
m = optionWithValuesPattern.matcher(line);
|
Matcher m = optionPattern.matcher(line);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
state = ParseState.OPTION_WITH_VALUES;
|
state = ParseState.OPTION;
|
||||||
Group group = new Group(composite, SWT.BORDER);
|
if (parent == composite) {
|
||||||
group.setLayout(new GridLayout(2, true));
|
Group group = new Group(composite, SWT.BORDER);
|
||||||
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
group.setLayout(new GridLayout(2, true));
|
||||||
group.setText(groupName);
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
parent = group;
|
group.setText(groupName);
|
||||||
}
|
parent = group;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ARGS:
|
}
|
||||||
Matcher m2 = argLine.matcher(line);
|
m = optionWithValuesPattern.matcher(line);
|
||||||
if (m2.matches()) {
|
if (m.matches()) {
|
||||||
String argName = m2.group(1);
|
state = ParseState.OPTION_WITH_VALUES;
|
||||||
String argValue = m2.group(2);
|
if (parent == composite) {
|
||||||
argValue = argValue.replaceAll("',", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
Group group = new Group(composite, SWT.BORDER);
|
||||||
argValue = argValue.replaceAll("'", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
group.setLayout(new GridLayout(2, true));
|
||||||
String argDescription = Messages.MesonPropertyPage_arg_description;
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
IMesonPropertyPageControl argControl = new MesonPropertyText(parent, argName, argValue, argDescription);
|
group.setText(groupName);
|
||||||
controls.add(argControl);
|
parent = group;
|
||||||
}
|
}
|
||||||
state = ParseState.INIT;
|
break;
|
||||||
parent = composite;
|
}
|
||||||
break;
|
|
||||||
case OPTION:
|
if (line.contains(":")) { //$NON-NLS-1$
|
||||||
Matcher m3 = optionLine.matcher(line);
|
state = ParseState.INIT;
|
||||||
if (line.startsWith("----")) { //$NON-NLS-1$
|
unprocessed = true;
|
||||||
|
parent = composite;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case ARGS:
|
||||||
if (line.isEmpty()) {
|
Matcher m2 = argLine.matcher(line);
|
||||||
|
if (m2.matches()) {
|
||||||
|
String argName = m2.group(1);
|
||||||
|
String argValue = m2.group(2);
|
||||||
|
argValue = argValue.replaceAll("',", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
argValue = argValue.replaceAll("'", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
String argDescription = Messages.MesonPropertyPage_arg_description;
|
||||||
|
IMesonPropertyPageControl argControl = new MesonPropertyText(parent, argName, argValue, argDescription);
|
||||||
|
controls.add(argControl);
|
||||||
|
}
|
||||||
state = ParseState.INIT;
|
state = ParseState.INIT;
|
||||||
parent = composite;
|
parent = composite;
|
||||||
break;
|
break;
|
||||||
}
|
case OPTION:
|
||||||
if (m3.matches()) {
|
Matcher m3 = optionLine.matcher(line);
|
||||||
String name = m3.group(1);
|
if (line.startsWith("----")) { //$NON-NLS-1$
|
||||||
String value = m3.group(2);
|
break;
|
||||||
String description = m3.group(3);
|
|
||||||
boolean isInteger = false;
|
|
||||||
try {
|
|
||||||
Integer.parseInt(value);
|
|
||||||
isInteger = true;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// do nothing
|
|
||||||
}
|
}
|
||||||
if (isInteger) {
|
if (line.isEmpty()) {
|
||||||
IMesonPropertyPageControl control = new MesonPropertyInteger(parent, this, name, value, description);
|
state = ParseState.INIT;
|
||||||
controls.add(control);
|
parent = composite;
|
||||||
} else if (Messages.MesonPropertyPage_true.equals(value) ||
|
break;
|
||||||
Messages.MesonPropertyPage_false.equals(value)) {
|
}
|
||||||
IMesonPropertyPageControl control = new MesonPropertyCheckbox(parent, name, Boolean.getBoolean(value), description);
|
if (m3.matches()) {
|
||||||
|
String name = m3.group(1);
|
||||||
|
String value = m3.group(2);
|
||||||
|
String description = m3.group(3);
|
||||||
|
boolean isInteger = false;
|
||||||
|
try {
|
||||||
|
Integer.parseInt(value);
|
||||||
|
isInteger = true;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
if (isInteger) {
|
||||||
|
IMesonPropertyPageControl control = new MesonPropertyInteger(parent, this, name, value, description);
|
||||||
|
controls.add(control);
|
||||||
|
} else if (Messages.MesonPropertyPage_true.equals(value) ||
|
||||||
|
Messages.MesonPropertyPage_false.equals(value)) {
|
||||||
|
IMesonPropertyPageControl control = new MesonPropertyCheckbox(parent, name, Boolean.getBoolean(value), description);
|
||||||
|
controls.add(control);
|
||||||
|
} else {
|
||||||
|
IMesonPropertyPageControl control = new MesonPropertyText(parent, name, value, description);
|
||||||
|
controls.add(control);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (line.contains(":")) { //$NON-NLS-1$
|
||||||
|
state = ParseState.INIT;
|
||||||
|
parent = composite;
|
||||||
|
unprocessed = true;
|
||||||
|
} else {
|
||||||
|
state = ParseState.GROUP;
|
||||||
|
unprocessed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPTION_WITH_VALUES:
|
||||||
|
Matcher m4 = optionWithValuesLine.matcher(line);
|
||||||
|
if (line.startsWith("----")) { //$NON-NLS-1$
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (line.isEmpty()) {
|
||||||
|
state = ParseState.INIT;
|
||||||
|
parent = composite;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (m4.matches()) {
|
||||||
|
String name = m4.group(1);
|
||||||
|
String value = m4.group(2);
|
||||||
|
String possibleValue = m4.group(3);
|
||||||
|
String extraValues = m4.group(4);
|
||||||
|
String description = m4.group(6);
|
||||||
|
String[] values = new String[] {possibleValue};
|
||||||
|
if (!extraValues.isEmpty()) {
|
||||||
|
values = extraValues.split(",\\s+");
|
||||||
|
values[0] = possibleValue;
|
||||||
|
}
|
||||||
|
IMesonPropertyPageControl control = new MesonPropertyCombo(parent, name, values, value, description);
|
||||||
controls.add(control);
|
controls.add(control);
|
||||||
} else {
|
} else {
|
||||||
IMesonPropertyPageControl control = new MesonPropertyText(parent, name, value, description);
|
if (line.contains(":")) { //$NON-NLS-1$
|
||||||
controls.add(control);
|
state = ParseState.INIT;
|
||||||
|
parent = composite;
|
||||||
|
unprocessed = true;
|
||||||
|
} else {
|
||||||
|
state = ParseState.GROUP;
|
||||||
|
unprocessed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OPTION_WITH_VALUES:
|
|
||||||
Matcher m4 = optionWithValuesLine.matcher(line);
|
|
||||||
if (line.startsWith("----")) { //$NON-NLS-1$
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (line.isEmpty()) {
|
|
||||||
state = ParseState.INIT;
|
|
||||||
parent = composite;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (m4.matches()) {
|
|
||||||
String name = m4.group(1);
|
|
||||||
String value = m4.group(2);
|
|
||||||
String possibleValue = m4.group(3);
|
|
||||||
String extraValues = m4.group(4);
|
|
||||||
String description = m4.group(6);
|
|
||||||
String[] values = new String[] {possibleValue};
|
|
||||||
if (!extraValues.isEmpty()) {
|
|
||||||
values = extraValues.split(",\\s+");
|
|
||||||
values[0] = possibleValue;
|
|
||||||
}
|
|
||||||
IMesonPropertyPageControl control = new MesonPropertyCombo(parent, name, values, value, description);
|
|
||||||
controls.add(control);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue