[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Include path and symbol discovery problem
|
Title: Include path and symbol discovery problem
Hallo guys,
I have managed to programmatically discover the include paths/symbols from a given log file and to refresh the project to make the include paths appear under the "Includes" node.
Now I have the problem that if I recall the the code again the discovered includes are removed from the "Includes" node and the project properties. But in the <project>.sc file in ".metadata\.plugins\org.eclipse.cdt.make.core\" the include paths and symbols are still existing (as they should be).
The code I am using is:
WorkspaceJob discoveryJob =
new WorkspaceJob("Blueworx CDT project configuration: Discovering include paths and symbols") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Discovering include paths and symbols", 100);
IStatus resultStatus = Status.OK_STATUS;
// Fetching config values from registry
String buildOutputFile = settingsHelper.getBuildOutputFile();
boolean enableBuildOutputScanner = settingsHelper.enableBuildOutputScanner();
boolean enableAutomaticDiscovery = settingsHelper.enableAutomateDiscovery();
String buildOutputFilePath = BlueworxCoreUtil.getFileSystemPath(project, buildOutputFile, true);
// See whether automatic discovery is allowed and possible
if (enableAutomaticDiscovery && enableBuildOutputScanner && buildOutputFilePath != null) {
File outFile = new File(buildOutputFilePath);
try {
if (outFile.exists()) {
// ------------------------------------------------------------------------------------
// Strange behaviour: include paths are only discovered if the project is completely refreshed, otherwise only the symbols are discovered
// Therefore waiting for all refresh jobs to be finished before reading the log file to discover the include paths and symbols
// ------------------------------------------------------------------------------------
try {
monitor.subTask("Waiting for refresh to finish");
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, new SubProgressMonitor(monitor, 30));
}
catch (OperationCanceledException e) {
BlueworxLogger
.log(
this.getClass(),
"Waiting for project refresh has been canceled during Blueworx CDT project configuration! Automatic discovery of include paths is only working after project(s) have been completely refrehsed!",
IStatus.WARNING);
}
catch (InterruptedException e) {
BlueworxLogger.logException(e);
}
// ------------------------------------------------------------------------------------
// Discovering include paths and symbols for each configuration
// ------------------------------------------------------------------------------------
ICProjectDescription projectDescription =
CoreModel.getDefault().getProjectDescription(project, false);
for (ICConfigurationDescription cConfigDescr : projectDescription.getConfigurations()) {
monitor.subTask("Discovering include paths and symbols for configuration: " +
cConfigDescr.getName());
IConfiguration iConfig = ManagedBuildManager.getConfigurationForDescription(cConfigDescr);
Configuration config = (Configuration) iConfig;
// IManagedProject imp = ManagedBuildManager.getBuildInfo(project).getManagedProject();
// for (IConfiguration config : imp.getConfigurations()) {
ICfgScannerConfigBuilderInfo2Set cfgScanConfigBldInfo2Set =
CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(config);
for (CfgInfoContext cfgInfoCtx : (Set<CfgInfoContext>) cfgScanConfigBldInfo2Set.getInfoMap()
.keySet()) {
if (cfgInfoCtx.getConfiguration() == config) {
IScannerConfigBuilderInfo2 builderInfo =
(IScannerConfigBuilderInfo2) cfgScanConfigBldInfo2Set.getInfoMap().get(cfgInfoCtx);
// read build output file to gather project specific include paths and symbols
// The next lines are taken from class BuildOutputReaderJob that is called when "load" is executed in the discovery project property page
boolean rc = SCJobsUtil.readBuildOutputFile(project, builderInfo, new NullProgressMonitor());
rc |= SCJobsUtil.getProviderScannerInfo(project, builderInfo, new NullProgressMonitor());
if (rc) {
rc = SCJobsUtil.updateScannerConfiguration(project, builderInfo, new NullProgressMonitor());
}
// This is called in the discovery page when applied is pressed but is not necessary here
//builderInfo = cfgScanConfigBldInfo2Set.applyInfo(cfgInfoCtx, builderInfo);
}
}
}
monitor.worked(40 / projectDescription.getConfigurations().length);
// --------------------------------------------------------------------------------------
// Refresh the project properties so that the discovered includes and symbols are visible
// --------------------------------------------------------------------------------------
// If auto building is disabled the discovered include paths and symbols from the given log file are not displayed in the project properties and in the c views unless I restart Eclipse, close and reopen the project or start the ScannerConfigBuilder.
// If auto building is on the ScannerConfigBuilder is automatically started by Eclipse
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription description = workspace.getDescription();
boolean isAutoBuilding = description.isAutoBuilding();
if (!isAutoBuilding) {
// ScannerConfigBuilder.build(config, ScannerConfigBuilder.FULL_BUILD, new NullProgressMonitor());
// project.build(ScannerConfigBuilder.PERFORM_CORE_UPDATE, ScannerConfigBuilder.BUILDER_ID, null,
// new SubProgressMonitor(monitor, 10));
// project.build(ScannerConfigBuilder.FORCE_DISCOVERY, ScannerConfigBuilder.BUILDER_ID, null,
// new SubProgressMonitor(monitor, 10));
project.build(ScannerConfigBuilder.FULL_BUILD, ScannerConfigBuilder.BUILDER_ID, null,
new SubProgressMonitor(monitor, 10));
}
}
else {
BlueworxLogger.log(CDTUtil.class, "Build output (log) file not existing: " + buildOutputFile,
IStatus.INFO);
monitor.worked(70);
}
}
catch (SecurityException e) {
resultStatus =
new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot access build output (log) file " +
buildOutputFilePath, e);
BlueworxLogger.logException(e);
}
}
return resultStatus;
}
};
Does anybody have an idea what I am doing wrong?
Kind regards
Marko Tomljenovic