Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorMarc-Andre Laperle2020-03-22 16:28:44 +0000
committerMarc-André Laperle2020-05-10 18:44:18 +0000
commit167ce562b2aee5cfa772cc94cf1cf66695afdb91 (patch)
tree9794037151d0a6ee0b163bec855954e65465ab13 /build
parentfc8ed250b133fc4b4706ee00926f854d5c5e6b1a (diff)
downloadorg.eclipse.cdt-167ce562b2aee5cfa772cc94cf1cf66695afdb91.tar.gz
org.eclipse.cdt-167ce562b2aee5cfa772cc94cf1cf66695afdb91.tar.xz
org.eclipse.cdt-167ce562b2aee5cfa772cc94cf1cf66695afdb91.zip
Bug 559186 - Allow using variables for the CDB path in CDB settings provider
For example, you can use ${ProjDirPath}/buid/compile_commands.json which is a more sharable setting Change-Id: Ic51775ea1f7d258c55e2e720c94f626a17444744 Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java95
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java45
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/CompilationDatabaseParserOptionPage.java62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/Messages.java3
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/messages.properties3
5 files changed, 148 insertions, 60 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
index 4a0490c26f9..09877e1ae60 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java
@@ -268,7 +268,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -298,7 +298,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, false);
@@ -326,7 +326,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -356,7 +356,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -384,7 +384,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
CompilationDatabaseParser parser = (CompilationDatabaseParser) LanguageSettingsManager
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -417,7 +417,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT + "foo");
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -450,7 +450,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(new Path("/testParseCDB_NonExistantCDB"));
+ parser.setCompilationDataBasePathProperty(new Path("/testParseCDB_NonExistantCDB").toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -483,7 +483,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(new Path(""));
+ parser.setCompilationDataBasePathProperty("");
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -516,7 +516,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getParent().getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getParent().getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -536,6 +536,63 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
assertFalse(CDataUtil.isExcluded(tu.getPath(), resCfgDescription.getSourceEntries()));
}
+ public void testParseCDB_ProjectRelativeCDBPath() throws Exception {
+ createTestProject();
+
+ ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(fProject);
+
+ CompilationDatabaseParser parser = (CompilationDatabaseParser) LanguageSettingsManager
+ .getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
+ assertTrue(parser.isEmpty());
+ parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
+ parser.setCompilationDataBasePathProperty(new Path("${ProjDirPath}")
+ .append(fCdbFile.getFullPath().makeRelativeTo(cProject.getProject().getFullPath())).toOSString());
+ parser.setExcludeFiles(true);
+ addLanguageSettingsProvider(parser);
+
+ ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
+
+ parser.processCompileCommandsFile(null, cfgDescription);
+ assertFalse(parser.isEmpty());
+ CoreModel.getDefault().setProjectDescription(cfgDescription.getProjectDescription().getProject(),
+ cfgDescription.getProjectDescription());
+ joingLanguageSettingsJobs();
+
+ assertExpectedEntries(parser);
+
+ ICConfigurationDescription resCfgDescription = getConfigurationDescription(fProject, false);
+ }
+
+ public void testParseCDB_WorkspaceVarCDBPath() throws Exception {
+ createTestProject();
+
+ ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(fProject);
+
+ CompilationDatabaseParser parser = (CompilationDatabaseParser) LanguageSettingsManager
+ .getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
+ assertTrue(parser.isEmpty());
+ parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
+ parser.setCompilationDataBasePathProperty(
+ new Path("${WorkspaceDirPath}")
+ .append(fCdbFile.getFullPath()
+ .makeRelativeTo(cProject.getProject().getWorkspace().getRoot().getFullPath()))
+ .toOSString());
+ parser.setExcludeFiles(true);
+ addLanguageSettingsProvider(parser);
+
+ ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
+
+ parser.processCompileCommandsFile(null, cfgDescription);
+ assertFalse(parser.isEmpty());
+ CoreModel.getDefault().setProjectDescription(cfgDescription.getProjectDescription().getProject(),
+ cfgDescription.getProjectDescription());
+ joingLanguageSettingsJobs();
+
+ assertExpectedEntries(parser);
+
+ ICConfigurationDescription resCfgDescription = getConfigurationDescription(fProject, false);
+ }
+
public void testParseCDB_InvalidJson() throws Exception {
createTestProject();
@@ -562,7 +619,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
parser.setExcludeFiles(true);
addLanguageSettingsProvider(parser);
@@ -596,7 +653,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -626,7 +683,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -670,7 +727,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -714,7 +771,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -745,7 +802,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -776,7 +833,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -802,7 +859,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -830,7 +887,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
@@ -861,7 +918,7 @@ public class CompilationDatabaseParserTest extends BaseTestCase {
.getExtensionProviderCopy(COMPILATION_DATABASE_PARSER_EXT, true);
assertTrue(parser.isEmpty());
parser.setBuildParserId(GCC_BUILD_COMMAND_PARSER_EXT);
- parser.setCompilationDataBasePath(fCdbFile.getLocation());
+ parser.setCompilationDataBasePathProperty(fCdbFile.getLocation().toOSString());
addLanguageSettingsProvider(parser);
ICConfigurationDescription cfgDescription = getConfigurationDescription(fProject, true);
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
index e8c1e8a4a1c..50619c09c19 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/CompilationDatabaseParser.java
@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.language.settings.providers.ICListenerAgent;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsEditableProvider;
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
@@ -48,7 +49,6 @@ import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -77,12 +77,32 @@ public class CompilationDatabaseParser extends LanguageSettingsSerializableProvi
private static final String ATTR_CDB_MODIFIED_TIME = "cdb-modified-time"; //$NON-NLS-1$
private static final String ATTR_EXCLUDE_FILES = "exclude-files"; //$NON-NLS-1$
- public IPath getCompilationDataBasePath() {
- return Path.fromOSString(getProperty(ATTR_CDB_PATH));
+ public String getCompilationDataBasePathProperty() {
+ return getProperty(ATTR_CDB_PATH);
}
- public void setCompilationDataBasePath(IPath compilationDataBasePath) {
- setProperty(ATTR_CDB_PATH, compilationDataBasePath.toOSString());
+ /**
+ * Resolve the compilation database path property by expanding variables (if any) and check that the file exists and is readable.
+ *
+ * @param cfgDescription the configuration description used to resolved variables that depend on it
+ * @return the resolved, readable path of the compilation database
+ * @throws CoreException On failure to resolve variables or non readable path
+ */
+ public String resolveCompilationDataBasePath(ICConfigurationDescription cfgDescription) throws CoreException {
+ ICdtVariableManager varManager = CCorePlugin.getDefault().getCdtVariableManager();
+ String compilationDataBasePath = varManager.resolveValue(getCompilationDataBasePathProperty(), "", null, //$NON-NLS-1$
+ cfgDescription);
+
+ if (Files.isDirectory(Paths.get(compilationDataBasePath))
+ || !Files.isReadable(Paths.get(compilationDataBasePath)))
+ throw new CoreException(new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, MessageFormat
+ .format(Messages.CompilationDatabaseParser_CDBNotFound, getCompilationDataBasePathProperty())));
+
+ return compilationDataBasePath;
+ }
+
+ public void setCompilationDataBasePathProperty(String compilationDataBasePathProperty) {
+ setProperty(ATTR_CDB_PATH, compilationDataBasePathProperty);
}
public void setExcludeFiles(boolean selection) {
@@ -206,19 +226,16 @@ public class CompilationDatabaseParser extends LanguageSettingsSerializableProvi
return false;
}
- if (getCompilationDataBasePath().isEmpty()) {
+ if (getCompilationDataBasePathProperty().isEmpty()) {
throw new CoreException(new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
Messages.CompilationDatabaseParser_CDBNotConfigured));
}
- if (!Files.exists(Paths.get(getCompilationDataBasePath().toOSString()))) {
- throw new CoreException(new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, MessageFormat.format(
- Messages.CompilationDatabaseParser_CDBNotFound, getCompilationDataBasePath().toOSString())));
- }
+ String cdbPath = resolveCompilationDataBasePath(cfgDescription);
try {
- if (!getProperty(ATTR_CDB_MODIFIED_TIME).isEmpty() && getProperty(ATTR_CDB_MODIFIED_TIME)
- .equals(getCDBModifiedTime(getCompilationDataBasePath().toOSString()).toString())) {
+ if (!getProperty(ATTR_CDB_MODIFIED_TIME).isEmpty()
+ && getProperty(ATTR_CDB_MODIFIED_TIME).equals(getCDBModifiedTime(cdbPath).toString())) {
return false;
}
} catch (IOException e) {
@@ -228,14 +245,12 @@ public class CompilationDatabaseParser extends LanguageSettingsSerializableProvi
if (getBuildParserId().isEmpty()) {
throw new CoreException(new Status(Status.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID,
- MessageFormat.format(Messages.CompilationDatabaseParser_BuildCommandParserNotConfigured,
- getCompilationDataBasePath().toOSString())));
+ MessageFormat.format(Messages.CompilationDatabaseParser_BuildCommandParserNotConfigured, cdbPath)));
}
if (!isEmpty()) {
clear();
}
- String cdbPath = getCompilationDataBasePath().toOSString();
Long cdbModifiedTime;
try {
cdbModifiedTime = getCDBModifiedTime(cdbPath);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/CompilationDatabaseParserOptionPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/CompilationDatabaseParserOptionPage.java
index 391fe05fdc8..4063eaaca25 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/CompilationDatabaseParserOptionPage.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/CompilationDatabaseParserOptionPage.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -23,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.Compi
import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.ui.language.settings.providers.AbstractLanguageSettingProviderOptionPage;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -77,7 +76,7 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
private Composite createCompositeForPageArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
- layout.numColumns = 2;
+ layout.numColumns = 3;
layout.marginWidth = 1;
layout.marginHeight = 1;
layout.marginRight = 1;
@@ -86,7 +85,7 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
Dialog.applyDialogFont(composite);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
composite.setLayoutData(gd);
return composite;
}
@@ -95,12 +94,12 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
Label label = ControlFactory.createLabel(composite,
Messages.CompilationDatabaseParserOptionPage_CompileCommandsPath);
GridData gd = new GridData();
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
label.setLayoutData(gd);
label.setEnabled(fEditable);
fCompileCommandsPath = ControlFactory.createTextField(composite, SWT.SINGLE | SWT.BORDER);
- String command = provider.getCompilationDataBasePath().toOSString();
+ String command = provider.getCompilationDataBasePathProperty();
fCompileCommandsPath.setText(command != null ? command : ""); //$NON-NLS-1$
fCompileCommandsPath.setEnabled(fEditable);
fCompileCommandsPath.addModifyListener(new ModifyListener() {
@@ -108,10 +107,10 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
public void modifyText(ModifyEvent e) {
String text = fCompileCommandsPath.getText();
CompilationDatabaseParser provider = (CompilationDatabaseParser) getProvider();
- if (provider.getCompilationDataBasePath() == null
- || !text.equals(provider.getCompilationDataBasePath().toOSString())) {
+ if (provider.getCompilationDataBasePathProperty() == null
+ || !text.equals(provider.getCompilationDataBasePathProperty())) {
CompilationDatabaseParser selectedProvider = (CompilationDatabaseParser) getProviderWorkingCopy();
- selectedProvider.setCompilationDataBasePath(Path.fromOSString(text));
+ selectedProvider.setCompilationDataBasePathProperty(text);
refreshItem(selectedProvider);
validate();
}
@@ -120,19 +119,33 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
}
private void createBrowseButton(Composite composite) {
- Button button = ControlFactory.createPushButton(composite, Messages.CompilationDatabaseParserOptionPage_Browse);
- button.setEnabled(fEditable);
- button.addSelectionListener(new SelectionAdapter() {
+ Button fileSystemButton = ControlFactory.createPushButton(composite,
+ Messages.CompilationDatabaseParserOptionPage_FileSystem);
+ fileSystemButton.setEnabled(fEditable);
+ fileSystemButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
- FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SHEET);
dialog.setText(Messages.CompilationDatabaseParserOptionPage_ChooseFile);
String fileName = fCompileCommandsPath.getText();
IPath folder = new Path(fileName).removeLastSegments(1);
dialog.setFilterPath(folder.toOSString());
String chosenFile = dialog.open();
if (chosenFile != null) {
- fCompileCommandsPath.insert(chosenFile);
+ fCompileCommandsPath.setText(chosenFile);
+ }
+ }
+ });
+
+ Button variablesButton = ControlFactory.createPushButton(composite,
+ Messages.CompilationDatabaseParserOptionPage_Variables);
+ variablesButton.setEnabled(fEditable);
+ variablesButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String result = AbstractCPropertyTab.getVariableDialog(getShell(), getConfigurationDescription());
+ if (result != null) {
+ fCompileCommandsPath.setText(result);
}
}
});
@@ -155,13 +168,13 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
Label parserLabel = ControlFactory.createLabel(composite,
Messages.CompilationDatabaseParserOptionPage_BuildParser);
GridData gd = new GridData(SWT.BEGINNING);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
parserLabel.setLayoutData(gd);
fBuildOutputParserCombo = new Combo(composite, SWT.READ_ONLY);
fBuildOutputParserCombo.setEnabled(fEditable);
gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
fBuildOutputParserCombo.setLayoutData(gd);
if (buildParsers.isEmpty()) {
fBuildOutputParserCombo.add(Messages.CompilationDatabaseParserOptionPage_NoBuildOutputParserError);
@@ -207,10 +220,11 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
Button keepExclusion = new Button(parent, SWT.CHECK);
keepExclusion.setText(Messages.CompilationDatabaseParserOptionPage_ExcludeFiles);
GridData gd = new GridData(SWT.BEGINNING);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 3;
keepExclusion.setLayoutData(gd);
keepExclusion.setSelection(((CompilationDatabaseParser) getProvider()).getExcludeFiles());
+ keepExclusion.setEnabled(fEditable);
keepExclusion.addSelectionListener(new SelectionListener() {
@Override
@@ -238,8 +252,8 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
CompilationDatabaseParser compilationDatabaseParser = (CompilationDatabaseParser) provider;
ILanguageSettingsProvider initialProvider = providerTab.getInitialProvider(providerId);
if (!(initialProvider instanceof CompilationDatabaseParser)
- || !((CompilationDatabaseParser) initialProvider).getCompilationDataBasePath()
- .equals(compilationDatabaseParser.getCompilationDataBasePath())
+ || !((CompilationDatabaseParser) initialProvider).getCompilationDataBasePathProperty()
+ .equals(compilationDatabaseParser.getCompilationDataBasePathProperty())
|| !((CompilationDatabaseParser) initialProvider).getBuildParserId()
.equals(compilationDatabaseParser.getBuildParserId())
|| ((CompilationDatabaseParser) initialProvider).getExcludeFiles() != compilationDatabaseParser
@@ -261,10 +275,10 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
}
CompilationDatabaseParser provider = (CompilationDatabaseParser) getProvider();
- if (provider.getCompilationDataBasePath() == null || provider.getCompilationDataBasePath().isEmpty()
- || !Files.exists(Paths.get(provider.getCompilationDataBasePath().toOSString()))) {
- fStatusLine.setErrorStatus(new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(),
- Messages.CompilationDatabaseParserOptionPage_CompileCommandsPathError));
+ try {
+ provider.resolveCompilationDataBasePath(getConfigurationDescription());
+ } catch (CoreException e) {
+ fStatusLine.setErrorStatus(e.getStatus());
return;
}
@@ -288,7 +302,7 @@ public final class CompilationDatabaseParserOptionPage extends AbstractLanguageS
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
- if (visible) {
+ if (visible && fEditable) {
validate();
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/Messages.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/Messages.java
index 1b0d061dc91..7bd2de6cb2f 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/Messages.java
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/Messages.java
@@ -14,7 +14,7 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.internal.ui.language.settings.providers.messages"; //$NON-NLS-1$
- public static String CompilationDatabaseParserOptionPage_Browse;
+ public static String CompilationDatabaseParserOptionPage_FileSystem;
public static String CompilationDatabaseParserOptionPage_BuildOutputParserError;
public static String CompilationDatabaseParserOptionPage_BuildParser;
public static String CompilationDatabaseParserOptionPage_ChooseFile;
@@ -22,6 +22,7 @@ public class Messages extends NLS {
public static String CompilationDatabaseParserOptionPage_CompileCommandsPathError;
public static String CompilationDatabaseParserOptionPage_ExcludeFiles;
public static String CompilationDatabaseParserOptionPage_NoBuildOutputParserError;
+ public static String CompilationDatabaseParserOptionPage_Variables;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/messages.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/messages.properties
index c9657a74420..a4598825ec2 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/messages.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/language/settings/providers/messages.properties
@@ -9,7 +9,7 @@
# SPDX-License-Identifier: EPL-2.0
################################################################################
-CompilationDatabaseParserOptionPage_Browse=Browse...
+CompilationDatabaseParserOptionPage_FileSystem=File &System...
CompilationDatabaseParserOptionPage_BuildOutputParserError=Invalid build parser
CompilationDatabaseParserOptionPage_BuildParser=Build parser:
CompilationDatabaseParserOptionPage_ChooseFile=Choose File
@@ -17,3 +17,4 @@ CompilationDatabaseParserOptionPage_CompileCommandsPath=Compilation Database pat
CompilationDatabaseParserOptionPage_CompileCommandsPathError=Compilation Database path does not exist
CompilationDatabaseParserOptionPage_ExcludeFiles=Exclude files not in the Compilation Database
CompilationDatabaseParserOptionPage_NoBuildOutputParserError=No build output parser enabled in "Providers"
+CompilationDatabaseParserOptionPage_Variables=Variables...

Back to the top