mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
bug 401961: Adjusted LSP property page UI to function for legacy projects where no languages defined in the toolchain
This commit is contained in:
parent
807f937284
commit
856760644c
3 changed files with 66 additions and 56 deletions
|
@ -18,8 +18,10 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.jface.viewers.IDecoration;
|
import org.eclipse.jface.viewers.IDecoration;
|
||||||
|
@ -114,7 +116,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
return overlayKeys;
|
return overlayKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLanguageId != null) {
|
|
||||||
IResource rc = getResource();
|
IResource rc = getResource();
|
||||||
List<ICLanguageSettingEntry> entries = getSettingEntries(provider);
|
List<ICLanguageSettingEntry> entries = getSettingEntries(provider);
|
||||||
if (entries == null && !(rc instanceof IProject)) {
|
if (entries == null && !(rc instanceof IProject)) {
|
||||||
|
@ -130,7 +131,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
|
overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||||
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
|
List<ILanguageSettingsProvider> initialProviders = initialProvidersMap.get(cfgDescription.getId());
|
||||||
|
@ -291,9 +291,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
* @return list of setting entries for the current context.
|
* @return list of setting entries for the current context.
|
||||||
*/
|
*/
|
||||||
private List<ICLanguageSettingEntry> getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider) {
|
private List<ICLanguageSettingEntry> getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider) {
|
||||||
if (currentLanguageId == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||||
IResource rc = getResource();
|
IResource rc = getResource();
|
||||||
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, currentLanguageId);
|
List<ICLanguageSettingEntry> entries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, currentLanguageId);
|
||||||
|
@ -305,9 +302,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
* @return list of setting entries for the current context.
|
* @return list of setting entries for the current context.
|
||||||
*/
|
*/
|
||||||
private List<ICLanguageSettingEntry> getSettingEntries(ILanguageSettingsProvider provider) {
|
private List<ICLanguageSettingEntry> getSettingEntries(ILanguageSettingsProvider provider) {
|
||||||
if (currentLanguageId==null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||||
IResource rc = getResource();
|
IResource rc = getResource();
|
||||||
return provider.getSettingEntries(cfgDescription, rc, currentLanguageId);
|
return provider.getSettingEntries(cfgDescription, rc, currentLanguageId);
|
||||||
|
@ -906,7 +900,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
*/
|
*/
|
||||||
private List<ILanguageSettingsProvider> getProviders(String languageSettingId) {
|
private List<ILanguageSettingsProvider> getProviders(String languageSettingId) {
|
||||||
List<ILanguageSettingsProvider> itemsList = new LinkedList<ILanguageSettingsProvider>();
|
List<ILanguageSettingsProvider> itemsList = new LinkedList<ILanguageSettingsProvider>();
|
||||||
if (currentLanguageId != null) {
|
|
||||||
IResource rc = getResource();
|
IResource rc = getResource();
|
||||||
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
ICConfigurationDescription cfgDescription = getConfigurationDescription();
|
||||||
if (rc != null && cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
if (rc != null && cfgDescription instanceof ILanguageSettingsProvidersKeeper) {
|
||||||
|
@ -923,7 +916,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
itemsList.add(cfgProvider);
|
itemsList.add(cfgProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return itemsList;
|
return itemsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -945,15 +937,18 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
currentLanguageId = null;
|
currentLanguageId = null;
|
||||||
|
|
||||||
List<String> languageIds = LanguageSettingsManager.getLanguages(rcDes);
|
List<String> languageIds = LanguageSettingsManager.getLanguages(rcDes);
|
||||||
// Not sure what to do with null language ID, ignoring for now
|
if (languageIds.size() > 1) {
|
||||||
|
// remove null language when some real ones are defined
|
||||||
languageIds.remove(null);
|
languageIds.remove(null);
|
||||||
Collections.sort(languageIds);
|
Collections.sort(languageIds);
|
||||||
|
} else if (languageIds.isEmpty()) {
|
||||||
|
// if no languages are defined keep null language as "Unspecified language"
|
||||||
|
languageIds.add(null);
|
||||||
|
}
|
||||||
for (String langId : languageIds) {
|
for (String langId : languageIds) {
|
||||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||||
if (language == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String langName = language.getName();
|
String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
|
||||||
if (langName == null || langName.length() == 0)
|
if (langName == null || langName.length() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -980,7 +975,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
currentLanguageIdGlobal = currentLanguageId;
|
currentLanguageIdGlobal = currentLanguageId;
|
||||||
|
|
||||||
for (TreeItem t : treeLanguages.getItems()) {
|
for (TreeItem t : treeLanguages.getItems()) {
|
||||||
if (t.getData().equals(langId)) {
|
if ((t.getData() == null && langId == null) || t.getData().equals(langId)) {
|
||||||
treeLanguages.setSelection(t);
|
treeLanguages.setSelection(t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1040,7 +1035,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
if (provider instanceof ILanguageSettingsEditableProvider) {
|
if (provider instanceof ILanguageSettingsEditableProvider) {
|
||||||
for (TreeItem langItems : treeLanguages.getItems()) {
|
for (TreeItem langItems : treeLanguages.getItems()) {
|
||||||
String langId = (String)langItems.getData();
|
String langId = (String)langItems.getData();
|
||||||
if (langId != null) {
|
|
||||||
if (provider.getSettingEntries(cfgDescription, rc, langId) != null) {
|
if (provider.getSettingEntries(cfgDescription, rc, langId) != null) {
|
||||||
if (providerCopy == null) {
|
if (providerCopy == null) {
|
||||||
// copy providers to be able to "Cancel" in UI
|
// copy providers to be able to "Cancel" in UI
|
||||||
|
@ -1054,7 +1048,6 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (providerCopy != null) {
|
if (providerCopy != null) {
|
||||||
newProviders.add(providerCopy);
|
newProviders.add(providerCopy);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1101,6 +1094,20 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
// filter out files not associated with any languages such as *.o
|
// filter out files not associated with any languages such as *.o
|
||||||
if (page.isForFile()) {
|
if (page.isForFile()) {
|
||||||
List<String> languageIds = LanguageSettingsManager.getLanguages(getResDesc());
|
List<String> languageIds = LanguageSettingsManager.getLanguages(getResDesc());
|
||||||
|
if (languageIds.isEmpty() || (languageIds.size() == 1 && languageIds.get(0) == null)) {
|
||||||
|
// for legacy projects check if the file is associated with any CDT language
|
||||||
|
IResource rc = getResource();
|
||||||
|
if (rc instanceof IFile) {
|
||||||
|
try {
|
||||||
|
ILanguage language = LanguageManager.getInstance().getLanguageForFile((IFile)rc, null);
|
||||||
|
return language != null;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// who cares, not even logging
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// for regular MBS project verify language against toolchain language
|
||||||
for (String langId : languageIds) {
|
for (String langId : languageIds) {
|
||||||
if (langId != null) {
|
if (langId != null) {
|
||||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||||
|
@ -1109,6 +1116,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,6 +213,7 @@ public class Messages extends NLS {
|
||||||
public static String LanguageSettingEntryDialog_WorkspacePath;
|
public static String LanguageSettingEntryDialog_WorkspacePath;
|
||||||
public static String LanguageSettingsEntriesTab_Cannot_Determine_Languages;
|
public static String LanguageSettingsEntriesTab_Cannot_Determine_Languages;
|
||||||
public static String LanguageSettingsEntriesTab_Entries_Not_Editable;
|
public static String LanguageSettingsEntriesTab_Entries_Not_Editable;
|
||||||
|
public static String LanguageSettingsEntriesTab_UnspecifiedLanguage;
|
||||||
public static String LanguageSettingsImages_FileDoesNotExist;
|
public static String LanguageSettingsImages_FileDoesNotExist;
|
||||||
public static String LanguageSettingsImages_FolderDoesNotExist;
|
public static String LanguageSettingsImages_FolderDoesNotExist;
|
||||||
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
|
public static String LanguageSettingsImages_UsingRelativePathsNotRecommended;
|
||||||
|
|
|
@ -189,6 +189,7 @@ LanguageSettingEntryDialog_Value=Value:
|
||||||
LanguageSettingEntryDialog_WorkspacePath=Workspace Path
|
LanguageSettingEntryDialog_WorkspacePath=Workspace Path
|
||||||
LanguageSettingsEntriesTab_Cannot_Determine_Languages=Cannot determine toolchain languages.
|
LanguageSettingsEntriesTab_Cannot_Determine_Languages=Cannot determine toolchain languages.
|
||||||
LanguageSettingsEntriesTab_Entries_Not_Editable=Setting entries for this provider are supplied by the system and are not editable.
|
LanguageSettingsEntriesTab_Entries_Not_Editable=Setting entries for this provider are supplied by the system and are not editable.
|
||||||
|
LanguageSettingsEntriesTab_UnspecifiedLanguage=[ Unspecified ]
|
||||||
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
|
LanguageSettingsImages_FileDoesNotExist=The selected file does not exist or not accessible.
|
||||||
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
|
LanguageSettingsImages_FolderDoesNotExist=The selected folder does not exist or not accessible.
|
||||||
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
|
LanguageSettingsImages_UsingRelativePathsNotRecommended=Using relative paths is ambiguous and not recommended. It can cause unexpected effects.
|
||||||
|
|
Loading…
Add table
Reference in a new issue