mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 491619 - Choosing a C++ dialect should reindex
- changed gcc builtin settings providers to prefer non-shared - added isIndexerAffected method override to ToolSettingsTab which looks at new isIndexerAffected boolean - add logic to ToolSettingsTab setOptions() method to look for dirty options that return true for isForScannerDiscovery() or are special options that affect include path or defines - add performok method to ToolSettingsTab to look if isIndexerAffected when user hits OK without hitting APPLY - change the message for bringing up the question dialog for end-user to choose whether to reindex or not Change-Id: Icd740caafe638f272b6f1434d5817f2377ffe04a
This commit is contained in:
parent
7436cb9ae4
commit
9fd79b0596
6 changed files with 89 additions and 17 deletions
|
@ -102,8 +102,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
ILanguageSettingsProvider provider = providers.get(3);
|
ILanguageSettingsProvider provider = providers.get(3);
|
||||||
String id = provider.getId();
|
String id = provider.getId();
|
||||||
assertEquals(GCC_SPECS_DETECTOR_ID, id);
|
assertEquals(GCC_SPECS_DETECTOR_ID, id);
|
||||||
assertEquals(true, LanguageSettingsManager.isPreferShared(id));
|
assertEquals(false, LanguageSettingsManager.isPreferShared(id));
|
||||||
assertEquals(true, LanguageSettingsManager.isWorkspaceProvider(provider));
|
assertEquals(false, LanguageSettingsManager.isWorkspaceProvider(provider));
|
||||||
}
|
}
|
||||||
assertEquals(4, providers.size());
|
assertEquals(4, providers.size());
|
||||||
}
|
}
|
||||||
|
@ -134,15 +134,15 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase {
|
||||||
assertTrue(defaultIds.length > 0);
|
assertTrue(defaultIds.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no settings file in project area
|
// settings file in project area
|
||||||
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
IFile xmlStorageFile = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
assertEquals(false, xmlStorageFile.exists());
|
assertEquals(true, xmlStorageFile.exists());
|
||||||
assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder
|
assertEquals(true, xmlStorageFile.getParent().exists()); // .settings folder
|
||||||
|
|
||||||
// no settings file in workspace area
|
// settings file in workspace area
|
||||||
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML);
|
||||||
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation);
|
||||||
assertEquals(false, xmlStorageFilePrjWsp.exists());
|
assertEquals(true, xmlStorageFilePrjWsp.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -615,7 +615,8 @@
|
||||||
class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector"
|
class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector"
|
||||||
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
|
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector"
|
||||||
name="%GCCBuiltinCompilerSettings.name"
|
name="%GCCBuiltinCompilerSettings.name"
|
||||||
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"">
|
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""
|
||||||
|
prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -623,7 +624,8 @@
|
||||||
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin"
|
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin"
|
||||||
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
|
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
|
||||||
name="%GCCBuiltinCompilerSettingsCygwin.name"
|
name="%GCCBuiltinCompilerSettingsCygwin.name"
|
||||||
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"">
|
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""
|
||||||
|
prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -631,7 +633,8 @@
|
||||||
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW"
|
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW"
|
||||||
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW"
|
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW"
|
||||||
name="%GCCBuiltinCompilerSettingsMinGW.name"
|
name="%GCCBuiltinCompilerSettingsMinGW.name"
|
||||||
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"">
|
parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}""
|
||||||
|
prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
|
@ -938,6 +938,7 @@ public class ManagedBuildManager extends AbstractCExtension {
|
||||||
&& option.getValueType() != IOption.UNDEF_LIBRARY_PATHS
|
&& option.getValueType() != IOption.UNDEF_LIBRARY_PATHS
|
||||||
&& option.getValueType() != IOption.UNDEF_LIBRARY_FILES
|
&& option.getValueType() != IOption.UNDEF_LIBRARY_FILES
|
||||||
&& option.getValueType() != IOption.UNDEF_MACRO_FILES
|
&& option.getValueType() != IOption.UNDEF_MACRO_FILES
|
||||||
|
&& !option.isForScannerDiscovery()
|
||||||
)) {
|
)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
|
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.Option;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
import org.eclipse.cdt.managedbuilder.internal.macros.BuildMacroProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
|
||||||
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
|
||||||
|
@ -98,6 +99,8 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
private int[] defaultWeights = new int[] {4, 1};
|
private int[] defaultWeights = new int[] {4, 1};
|
||||||
private int[] hideTipBoxWeights = new int[] {1, 0};
|
private int[] hideTipBoxWeights = new int[] {1, 0};
|
||||||
|
|
||||||
|
private boolean isIndexerAffected;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createControls(Composite par) {
|
public void createControls(Composite par) {
|
||||||
super.createControls(par);
|
super.createControls(par);
|
||||||
|
@ -562,6 +565,9 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
*/
|
*/
|
||||||
protected void setOption(IOption op1, IOption op2, IHoldsOptions dst, IResourceInfo res){
|
protected void setOption(IOption op1, IOption op2, IHoldsOptions dst, IResourceInfo res){
|
||||||
try {
|
try {
|
||||||
|
if (op1.isForScannerDiscovery()
|
||||||
|
&& ((Option)op1).isDirty())
|
||||||
|
isIndexerAffected = true;
|
||||||
switch (op1.getValueType()) {
|
switch (op1.getValueType()) {
|
||||||
case IOption.BOOLEAN :
|
case IOption.BOOLEAN :
|
||||||
boolean boolVal = op1.getBooleanValue();
|
boolean boolVal = op1.getBooleanValue();
|
||||||
|
@ -577,14 +583,9 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
case IOption.STRING :
|
case IOption.STRING :
|
||||||
ManagedBuildManager.setOption(res, dst, op2, op1.getStringValue());
|
ManagedBuildManager.setOption(res, dst, op2, op1.getStringValue());
|
||||||
break;
|
break;
|
||||||
case IOption.STRING_LIST :
|
|
||||||
case IOption.INCLUDE_PATH :
|
case IOption.INCLUDE_PATH :
|
||||||
case IOption.PREPROCESSOR_SYMBOLS :
|
case IOption.PREPROCESSOR_SYMBOLS :
|
||||||
case IOption.LIBRARIES :
|
|
||||||
case IOption.OBJECTS :
|
|
||||||
case IOption.INCLUDE_FILES:
|
case IOption.INCLUDE_FILES:
|
||||||
case IOption.LIBRARY_PATHS:
|
|
||||||
case IOption.LIBRARY_FILES:
|
|
||||||
case IOption.MACRO_FILES:
|
case IOption.MACRO_FILES:
|
||||||
case IOption.UNDEF_INCLUDE_PATH:
|
case IOption.UNDEF_INCLUDE_PATH:
|
||||||
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
||||||
|
@ -592,10 +593,21 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
case IOption.UNDEF_LIBRARY_PATHS:
|
case IOption.UNDEF_LIBRARY_PATHS:
|
||||||
case IOption.UNDEF_LIBRARY_FILES:
|
case IOption.UNDEF_LIBRARY_FILES:
|
||||||
case IOption.UNDEF_MACRO_FILES:
|
case IOption.UNDEF_MACRO_FILES:
|
||||||
|
if (((Option)op1).isDirty())
|
||||||
|
isIndexerAffected = true;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
String[] data = ((List<String>)op1.getValue()).toArray(new String[0]);
|
String[] data = ((List<String>)op1.getValue()).toArray(new String[0]);
|
||||||
ManagedBuildManager.setOption(res, dst, op2, data);
|
ManagedBuildManager.setOption(res, dst, op2, data);
|
||||||
break;
|
break;
|
||||||
|
case IOption.LIBRARIES :
|
||||||
|
case IOption.LIBRARY_PATHS:
|
||||||
|
case IOption.LIBRARY_FILES:
|
||||||
|
case IOption.STRING_LIST :
|
||||||
|
case IOption.OBJECTS :
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
String[] data2 = ((List<String>)op1.getValue()).toArray(new String[0]);
|
||||||
|
ManagedBuildManager.setOption(res, dst, op2, data2);
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -728,6 +740,7 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
|
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
|
||||||
IResourceInfo ri1 = getResCfg(src);
|
IResourceInfo ri1 = getResCfg(src);
|
||||||
IResourceInfo ri2 = getResCfg(dst);
|
IResourceInfo ri2 = getResCfg(dst);
|
||||||
|
isIndexerAffected = false;
|
||||||
copyHoldsOptions(ri1.getParent().getToolChain(), ri2.getParent().getToolChain(), ri2);
|
copyHoldsOptions(ri1.getParent().getToolChain(), ri2.getParent().getToolChain(), ri2);
|
||||||
ITool[] t1, t2;
|
ITool[] t1, t2;
|
||||||
if (ri1 instanceof IFolderInfo){
|
if (ri1 instanceof IFolderInfo){
|
||||||
|
@ -748,6 +761,61 @@ public class ToolSettingsTab extends AbstractCBuildPropertyTab implements IPrefe
|
||||||
updateData(getResDesc());
|
updateData(getResDesc());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void performOK() {
|
||||||
|
// We need to override performOK so we can determine if any option
|
||||||
|
// was chosen that affects the indexer and the user directly chooses
|
||||||
|
// to press OK instead of Apply.
|
||||||
|
isIndexerAffected = false;
|
||||||
|
if (!isDirty()) {
|
||||||
|
super.performOK();
|
||||||
|
return; // don't bother if already applied
|
||||||
|
}
|
||||||
|
ICResourceDescription res = getResDesc();
|
||||||
|
IResourceInfo info = getResCfg(res);
|
||||||
|
ITool[] t1;
|
||||||
|
if (info instanceof IFolderInfo){
|
||||||
|
t1 = ((IFolderInfo)info).getFilteredTools();
|
||||||
|
} else if (info instanceof IFileInfo) {
|
||||||
|
t1 = ((IFileInfo)info).getToolsToInvoke();
|
||||||
|
} else return;
|
||||||
|
for (ITool t : t1) {
|
||||||
|
IOption op1[] = t.getOptions();
|
||||||
|
for (IOption op : op1) {
|
||||||
|
if (((Option)op).isDirty()) {
|
||||||
|
if (op.isForScannerDiscovery())
|
||||||
|
isIndexerAffected = true;
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
switch (op.getValueType()) {
|
||||||
|
case IOption.INCLUDE_PATH :
|
||||||
|
case IOption.PREPROCESSOR_SYMBOLS :
|
||||||
|
case IOption.INCLUDE_FILES:
|
||||||
|
case IOption.MACRO_FILES:
|
||||||
|
case IOption.UNDEF_INCLUDE_PATH:
|
||||||
|
case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
|
||||||
|
case IOption.UNDEF_INCLUDE_FILES:
|
||||||
|
case IOption.UNDEF_LIBRARY_PATHS:
|
||||||
|
case IOption.UNDEF_LIBRARY_FILES:
|
||||||
|
case IOption.UNDEF_MACRO_FILES:
|
||||||
|
isIndexerAffected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (BuildException e) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.performOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isIndexerAffected() {
|
||||||
|
return isIndexerAffected;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the correspondence of tools in the copy-from set (<tt>t1</tt>) and the
|
* Computes the correspondence of tools in the copy-from set (<tt>t1</tt>) and the
|
||||||
* copy-to set (<tt>t2</tt>) in an apply operation. The resulting pairs are in the order
|
* copy-to set (<tt>t2</tt>) in an apply operation. The resulting pairs are in the order
|
||||||
|
|
|
@ -98,7 +98,7 @@ AbstractPage_6=Configuration:
|
||||||
AbstractPage_7=Exclude resource from build
|
AbstractPage_7=Exclude resource from build
|
||||||
AbstractPage_8=Cannot apply
|
AbstractPage_8=Cannot apply
|
||||||
AbstractPage_9=Internal error
|
AbstractPage_9=Internal error
|
||||||
AbstractPage_rebuildIndex_question=Changes to the include search paths or defined symbols will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now?
|
AbstractPage_rebuildIndex_question=Changes made will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now?
|
||||||
|
|
||||||
AbstractLangsListTab_ShowBuiltin=Show built-in values
|
AbstractLangsListTab_ShowBuiltin=Show built-in values
|
||||||
AbstractLangsListTab_Languages=Languages
|
AbstractLangsListTab_Languages=Languages
|
||||||
|
|
|
@ -634,7 +634,6 @@ implements
|
||||||
}
|
}
|
||||||
final ICResourceDescription local_cfgd = lc;
|
final ICResourceDescription local_cfgd = lc;
|
||||||
|
|
||||||
final boolean rebuildIndex= isIndexerAffected();
|
|
||||||
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||||
|
|
||||||
private void sendOK() {
|
private void sendOK() {
|
||||||
|
@ -701,6 +700,7 @@ implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean rebuildIndex= isIndexerAffected();
|
||||||
if (rebuildIndex)
|
if (rebuildIndex)
|
||||||
rebuildIndex();
|
rebuildIndex();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue