mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
some more cleanup
This commit is contained in:
parent
0784585fe4
commit
e219640575
2 changed files with 48 additions and 37 deletions
|
@ -85,8 +85,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void execute(ICConfigurationDescription cfgDescription) {
|
protected void execute() {
|
||||||
super.execute(cfgDescription);
|
super.execute();
|
||||||
}
|
}
|
||||||
protected boolean isExecuted() {
|
protected boolean isExecuted() {
|
||||||
return isExecuted;
|
return isExecuted;
|
||||||
|
@ -182,7 +182,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
provider.setConsoleEnabled(true);
|
provider.setConsoleEnabled(true);
|
||||||
assertEquals(true, provider.isConsoleEnabled());
|
assertEquals(true, provider.isConsoleEnabled());
|
||||||
|
|
||||||
provider.execute(null);
|
provider.execute();
|
||||||
assertEquals(true, provider.isExecuted());
|
assertEquals(true, provider.isExecuted());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
|
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
|
||||||
assertEquals(false, provider.isConsoleEnabled());
|
assertEquals(false, provider.isConsoleEnabled());
|
||||||
provider.setConsoleEnabled(true);
|
provider.setConsoleEnabled(true);
|
||||||
provider.execute(null);
|
provider.execute();
|
||||||
assertEquals(true, provider.isExecuted());
|
assertEquals(true, provider.isExecuted());
|
||||||
assertFalse(provider.equals(clone0));
|
assertFalse(provider.equals(clone0));
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
provider2.setSettingEntries(null, null, null, null);
|
provider2.setSettingEntries(null, null, null, null);
|
||||||
assertFalse(provider2.equals(clone));
|
assertFalse(provider2.equals(clone));
|
||||||
|
|
||||||
clone.execute(null);
|
clone.execute();
|
||||||
assertTrue(provider2.equals(clone));
|
assertTrue(provider2.equals(clone));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,15 +183,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This ICConsoleParser handles each individual run for one language from
|
* This ICConsoleParser handles each individual run for one language TODO
|
||||||
* {@link AbstractBuiltinSpecsDetector#runForEachLanguage(ICConfigurationDescription, URI, String[], IProgressMonitor)}
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private class ConsoleParserAdapter implements ICBuildOutputParser {
|
private class ConsoleParserAdapter implements ICBuildOutputParser {
|
||||||
@Override
|
@Override
|
||||||
public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException {
|
public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException {
|
||||||
// Also see startupForLanguage() in AbstractBuiltinSpecsDetector.runForEachLanguage(...)
|
AbstractBuiltinSpecsDetector.this.cwdTracker = cwdTracker;
|
||||||
AbstractBuiltinSpecsDetector.this.startup(cfgDescription, cwdTracker);
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean processLine(String line) {
|
public boolean processLine(String line) {
|
||||||
|
@ -199,7 +196,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
// not used here, see instead shutdownForLanguage() in AbstractBuiltinSpecsDetector.runForEachLanguage(...)
|
AbstractBuiltinSpecsDetector.this.cwdTracker = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,20 +234,20 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
protected String resolveCommand(String languageId) throws CoreException {
|
protected String resolveCommand(String languageId) throws CoreException {
|
||||||
String cmd = getCommand();
|
String cmd = getCommand();
|
||||||
if (cmd!=null && (cmd.contains(COMPILER_MACRO) || cmd.contains(SPEC_FILE_MACRO) || cmd.contains(SPEC_EXT_MACRO))) {
|
if (cmd != null && (cmd.contains(COMPILER_MACRO) || cmd.contains(SPEC_FILE_MACRO) || cmd.contains(SPEC_EXT_MACRO))) {
|
||||||
if (cmd.contains(COMPILER_MACRO)) {
|
if (cmd.contains(COMPILER_MACRO)) {
|
||||||
String compiler = getCompilerCommand(languageId);
|
String compiler = getCompilerCommand(languageId);
|
||||||
if (compiler!=null)
|
if (compiler != null)
|
||||||
cmd = cmd.replace(COMPILER_MACRO, compiler);
|
cmd = cmd.replace(COMPILER_MACRO, compiler);
|
||||||
}
|
}
|
||||||
if (cmd.contains(SPEC_FILE_MACRO)) {
|
if (cmd.contains(SPEC_FILE_MACRO)) {
|
||||||
String specFileName = getSpecFile(languageId);
|
String specFileName = getSpecFile(languageId);
|
||||||
if (specFileName!=null)
|
if (specFileName != null)
|
||||||
cmd = cmd.replace(SPEC_FILE_MACRO, specFileName);
|
cmd = cmd.replace(SPEC_FILE_MACRO, specFileName);
|
||||||
}
|
}
|
||||||
if (cmd.contains(SPEC_EXT_MACRO)) {
|
if (cmd.contains(SPEC_EXT_MACRO)) {
|
||||||
String specFileExt = getSpecFileExtension(languageId);
|
String specFileExt = getSpecFileExtension(languageId);
|
||||||
if (specFileExt!=null)
|
if (specFileExt != null)
|
||||||
cmd = cmd.replace(SPEC_EXT_MACRO, specFileExt);
|
cmd = cmd.replace(SPEC_EXT_MACRO, specFileExt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +290,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
// AG FIXME - temporary log to remove before CDT Juno release
|
// AG FIXME - temporary log to remove before CDT Juno release
|
||||||
LanguageSettingsLogger.logInfo(getPrefixForLog() + "registerListener [" + System.identityHashCode(this) + "] " + this);
|
LanguageSettingsLogger.logInfo(getPrefixForLog() + "registerListener [" + System.identityHashCode(this) + "] " + this);
|
||||||
|
|
||||||
execute(cfgDescription);
|
currentCfgDescription = cfgDescription;
|
||||||
|
execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -302,7 +300,26 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
LanguageSettingsLogger.logInfo(getPrefixForLog() + "unregisterListener [" + System.identityHashCode(this) + "] " + this);
|
LanguageSettingsLogger.logInfo(getPrefixForLog() + "unregisterListener [" + System.identityHashCode(this) + "] " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void execute(final ICConfigurationDescription cfgDescription) {
|
@Override
|
||||||
|
public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException {
|
||||||
|
super.startup(cfgDescription, cwdTracker);
|
||||||
|
|
||||||
|
mappedRootURI = null;
|
||||||
|
buildDirURI = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shutdown() {
|
||||||
|
mappedRootURI = null;
|
||||||
|
buildDirURI = null;
|
||||||
|
|
||||||
|
ICConfigurationDescription cfgDescription = currentCfgDescription;
|
||||||
|
super.shutdown();
|
||||||
|
// keep currentCfgDescription, do not let super.shutdown() to clear it
|
||||||
|
currentCfgDescription = cfgDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void execute() {
|
||||||
if (isExecuted) {
|
if (isExecuted) {
|
||||||
// AG FIXME - temporary log to remove before CDT Juno release
|
// AG FIXME - temporary log to remove before CDT Juno release
|
||||||
// LanguageSettingsLogger.logInfo(getPrefixForLog() + "Already executed [" + System.identityHashCode(this) + "] " + this);
|
// LanguageSettingsLogger.logInfo(getPrefixForLog() + "Already executed [" + System.identityHashCode(this) + "] " + this);
|
||||||
|
@ -315,8 +332,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
IStatus status;
|
IStatus status;
|
||||||
try {
|
try {
|
||||||
startup(cfgDescription, null);
|
startup(currentCfgDescription, null);
|
||||||
status = runForEachLanguage(cfgDescription, null, null, monitor);
|
status = runForEachLanguage(currentCfgDescription, null, null, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
|
status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
|
||||||
|
@ -365,8 +382,6 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean isChanged = false;
|
boolean isChanged = false;
|
||||||
mappedRootURI = null;
|
|
||||||
buildDirURI = null;
|
|
||||||
|
|
||||||
List<String> languageIds = getLanguageScope();
|
List<String> languageIds = getLanguageScope();
|
||||||
if (languageIds != null) {
|
if (languageIds != null) {
|
||||||
|
@ -386,9 +401,6 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
try {
|
try {
|
||||||
startupForLanguage(languageId);
|
startupForLanguage(languageId);
|
||||||
runForLanguage(languageId, currentCommandResolved, env, workingDirectoryURI, new SubProgressMonitor(monitor, TICKS_RUN_FOR_ONE_LANGUAGE));
|
runForLanguage(languageId, currentCommandResolved, env, workingDirectoryURI, new SubProgressMonitor(monitor, TICKS_RUN_FOR_ONE_LANGUAGE));
|
||||||
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
|
IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e);
|
||||||
MakeCorePlugin.log(s);
|
MakeCorePlugin.log(s);
|
||||||
|
@ -400,6 +412,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
List<ICLanguageSettingEntry> newEntries = getSettingEntries(cfgDescription, null, languageId);
|
List<ICLanguageSettingEntry> newEntries = getSettingEntries(cfgDescription, null, languageId);
|
||||||
isChanged = newEntries != oldEntries;
|
isChanged = newEntries != oldEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
throw new OperationCanceledException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,21 +423,17 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
IStatus s = serializeLanguageSettings(currentCfgDescription);
|
IStatus s = serializeLanguageSettings(currentCfgDescription);
|
||||||
status.merge(s);
|
status.merge(s);
|
||||||
}
|
}
|
||||||
if (monitor.isCanceled())
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
|
|
||||||
monitor.worked(TICKS_SERIALIZATION);
|
monitor.worked(TICKS_SERIALIZATION);
|
||||||
|
|
||||||
} catch (OperationCanceledException e) {
|
} catch (OperationCanceledException e) {
|
||||||
if (!status.isOK()) {
|
// user chose to cancel operation, do not threaten them with error reporting
|
||||||
|
} catch (Exception e) {
|
||||||
|
status.merge(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e));
|
||||||
MakeCorePlugin.log(status);
|
MakeCorePlugin.log(status);
|
||||||
}
|
|
||||||
status.merge(new Status(IStatus.CANCEL, MakeCorePlugin.PLUGIN_ID, IStatus.OK, "Operation cancelled by user", e));
|
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
|
|
||||||
// release resources
|
// release resources
|
||||||
buildDirURI = null;
|
|
||||||
mappedRootURI = null;
|
|
||||||
shutdown();
|
shutdown();
|
||||||
currentCfgDescription = cfgDescription; // current description gets cleared in super.shutdown(), keep it
|
currentCfgDescription = cfgDescription; // current description gets cleared in super.shutdown(), keep it
|
||||||
}
|
}
|
||||||
|
@ -433,7 +444,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
protected void startupForLanguage(String languageId) throws CoreException {
|
protected void startupForLanguage(String languageId) throws CoreException {
|
||||||
currentLanguageId = languageId;
|
currentLanguageId = languageId;
|
||||||
|
|
||||||
specFile = null; // can get set in resolveCommand()
|
specFile = null; // init before calling resolveCommand(), can be set there
|
||||||
currentCommandResolved = resolveCommand(currentLanguageId);
|
currentCommandResolved = resolveCommand(currentLanguageId);
|
||||||
|
|
||||||
detectedSettingEntries = new ArrayList<ICLanguageSettingEntry>();
|
detectedSettingEntries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
@ -515,8 +526,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// AG TODO - better message
|
// AG TODO - better message
|
||||||
String msg = "Internal error running scanner discovery";
|
Status status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, "Internal error running scanner discovery", e);
|
||||||
MakeCorePlugin.log(new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, msg, e)));
|
MakeCorePlugin.log(new CoreException(status));
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
buildRunnerHelper.close();
|
buildRunnerHelper.close();
|
||||||
|
@ -546,7 +557,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
if (currentProject != null) {
|
if (currentProject != null) {
|
||||||
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryConsole";
|
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryConsole";
|
||||||
} else {
|
} else {
|
||||||
// FIXME This console is not colored!
|
// TODO This console is not colored!
|
||||||
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryGlobalConsole";
|
extConsoleId = "org.eclipse.cdt.make.internal.ui.scannerconfig.ScannerDiscoveryGlobalConsole";
|
||||||
}
|
}
|
||||||
ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId);
|
ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue