1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

cosmetics: bunch of misleading local variables renamed

This commit is contained in:
Andrew Gvozdev 2010-01-16 03:09:42 +00:00
parent b091ceb573
commit d0ff1ec5f5

View file

@ -297,9 +297,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
TreeItem[] items = langTree.getSelection(); TreeItem[] items = langTree.getSelection();
if (items.length > 0) { if (items.length > 0) {
ICLanguageSetting ls = (ICLanguageSetting) items[0].getData(); ICLanguageSetting langSetting = (ICLanguageSetting) items[0].getData();
if (ls != null) { if (langSetting != null) {
lang = ls; lang = langSetting;
update(); update();
} }
} }
@ -381,33 +381,33 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* Refreshes languages list and calls table refresh. * Refreshes languages list and calls table refresh.
*/ */
@Override @Override
public void updateData(ICResourceDescription cfg) { public void updateData(ICResourceDescription rcDes) {
if (cfg == null || !canBeVisible()) return; if (rcDes == null || !canBeVisible()) return;
updateExport(); updateExport();
langTree.removeAll(); langTree.removeAll();
TreeItem firstItem = null; TreeItem firstItem = null;
ls = getLangSetting(cfg); ls = getLangSetting(rcDes);
if (ls != null) { if (ls != null) {
Arrays.sort(ls, CDTListComparator.getInstance()); Arrays.sort(ls, CDTListComparator.getInstance());
for (ICLanguageSetting element : ls) { for (ICLanguageSetting langSetting : ls) {
if ((element.getSupportedEntryKinds() & getKind()) != 0) { if ((langSetting.getSupportedEntryKinds() & getKind()) != 0) {
TreeItem t = new TreeItem(langTree, SWT.NONE); TreeItem t = new TreeItem(langTree, SWT.NONE);
String s = element.getLanguageId(); String langId = langSetting.getLanguageId();
if (s != null && !s.equals(EMPTY_STR)) { if (langId != null && !langId.equals(EMPTY_STR)) {
// Bug #178033: get language name via LangManager. // Bug #178033: get language name via LangManager.
ILanguageDescriptor ld = LanguageManager.getInstance().getLanguageDescriptor(s); ILanguageDescriptor langDes = LanguageManager.getInstance().getLanguageDescriptor(langId);
if (ld == null) if (langDes == null)
s = null; langId = null;
else else
s = ld.getName(); langId = langDes.getName();
} }
if (s == null || s.equals(EMPTY_STR)) if (langId == null || langId.equals(EMPTY_STR))
s = element.getName(); langId = langSetting.getName();
t.setText(0, s); t.setText(0, langId);
t.setData(element); t.setData(langSetting);
if (firstItem == null) { if (firstItem == null) {
firstItem = t; firstItem = t;
lang = element; lang = langSetting;
} }
} }
} }
@ -421,27 +421,27 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private void updateExport() { private void updateExport() {
exported = new ArrayList<ICSettingEntry>(); exported = new ArrayList<ICSettingEntry>();
ICExternalSetting[] vals = getResDesc().getConfiguration().getExternalSettings(); ICExternalSetting[] extSettings = getResDesc().getConfiguration().getExternalSettings();
if (!(vals == null || vals.length == 0)) { if (!(extSettings == null || extSettings.length == 0)) {
for (ICExternalSetting v : vals) { for (ICExternalSetting extSetting : extSettings) {
ICSettingEntry[] ents = v.getEntries(getKind()); ICSettingEntry[] entries = extSetting.getEntries(getKind());
if (ents == null || ents.length == 0) continue; if (entries == null || entries.length == 0) continue;
for (ICSettingEntry en : ents) for (ICSettingEntry entry : entries)
exported.add(en); exported.add(entry);
} }
} }
} }
private void performAdd(ICLanguageSettingEntry ent) { private void performAdd(ICLanguageSettingEntry entry) {
if (ent != null) { if (entry != null) {
fHadSomeModification= true; fHadSomeModification= true;
if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) { if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) {
addToAll(ent); addToAll(entry);
} else { } else {
if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) { if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
performMulti(ent, null); performMulti(entry, null);
} else { } else {
changeIt(ent, null); changeIt(entry, null);
} }
} }
update(); update();
@ -449,40 +449,40 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
} }
private void changeIt(ICLanguageSettingEntry add, ICLanguageSettingEntry[] del) { private void changeIt(ICLanguageSettingEntry add, ICLanguageSettingEntry[] del) {
List<ICLanguageSettingEntry> ls = getSettingEntriesList(getKind()); List<ICLanguageSettingEntry> lsEntries = getSettingEntriesList(getKind());
if (del != null) { if (del != null) {
for (ICLanguageSettingEntry d : del) { for (ICLanguageSettingEntry d : del) {
for (ICLanguageSettingEntry e : ls) { for (ICLanguageSettingEntry entry : lsEntries) {
if (d.getName().equals(e.getName())) { if (d.getName().equals(entry.getName())) {
ls.remove(e); lsEntries.remove(entry);
break; break;
} }
} }
} }
} }
if (add != null) if (add != null)
ls.add(add); lsEntries.add(add);
setSettingEntries(getKind(), ls, toAllLang); setSettingEntries(getKind(), lsEntries, toAllLang);
} }
private void performMulti(ICLanguageSettingEntry ent, ICLanguageSettingEntry del) { private void performMulti(ICLanguageSettingEntry ent, ICLanguageSettingEntry del) {
MultiLanguageSetting ms = (MultiLanguageSetting)lang; MultiLanguageSetting ms = (MultiLanguageSetting)lang;
ICLanguageSetting[] ls = (ICLanguageSetting[])ms.getItems(); ICLanguageSetting[] langSettings = (ICLanguageSetting[])ms.getItems();
ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind()); ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind());
for (int i=0; i<ls.length; i++) { for (int i=0; i<langSettings.length; i++) {
List<ICLanguageSettingEntry> entries = List<ICLanguageSettingEntry> entries =
new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i])); new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i]));
if (del != null) { if (del != null) {
for (ICLanguageSettingEntry e : entries) { for (ICLanguageSettingEntry entry : entries) {
if (e.getName().equals(del.getName())) { if (entry.getName().equals(del.getName())) {
entries.remove(e); entries.remove(entry);
break; break;
} }
} }
} }
if (ent != null) if (ent != null)
entries.add(ent); entries.add(ent);
ls[i].setSettingEntries(getKind(), entries); langSettings[i].setSettingEntries(getKind(), entries);
} }
} }
@ -532,12 +532,12 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* Unified buttons handler * Unified buttons handler
*/ */
@Override @Override
public void buttonPressed(int i) { public void buttonPressed(int buttonIndex) {
ICLanguageSettingEntry old; ICLanguageSettingEntry old;
int n = table.getSelectionIndex(); int n = table.getSelectionIndex();
int ids[] = table.getSelectionIndices(); int ids[] = table.getSelectionIndices();
switch (i) { switch (buttonIndex) {
case BUTTON_ADD: case BUTTON_ADD:
toAllCfgs = false; toAllCfgs = false;
toAllLang = false; toAllLang = false;
@ -567,7 +567,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
old = (ICLanguageSettingEntry)(table.getItem(n).getData()); old = (ICLanguageSettingEntry)(table.getItem(n).getData());
int x = shownEntries.indexOf(old); int x = shownEntries.indexOf(old);
if (x < 0) break; if (x < 0) break;
if (i == BUTTON_MOVE_DOWN) x++; // "down" simply means "up underlying item" if (buttonIndex == BUTTON_MOVE_DOWN) x++; // "down" simply means "up underlying item"
old = shownEntries.get(x); old = shownEntries.get(x);
ICLanguageSettingEntry old2 = shownEntries.get(x - 1); ICLanguageSettingEntry old2 = shownEntries.get(x - 1);
shownEntries.remove(x); shownEntries.remove(x);
@ -576,7 +576,7 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
shownEntries.add(x, old2); shownEntries.add(x, old2);
setSettingEntries(getKind(), shownEntries, false); setSettingEntries(getKind(), shownEntries, false);
update(i == BUTTON_MOVE_UP ? -1 : 1); update(buttonIndex == BUTTON_MOVE_UP ? -1 : 1);
break; break;
default: default:
break; break;
@ -597,21 +597,21 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private void deleteExportSetting(ICSettingEntry ent) { private void deleteExportSetting(ICSettingEntry ent) {
// if (ent.isReadOnly() || ent.isBuiltIn()) continue; // if (ent.isReadOnly() || ent.isBuiltIn()) continue;
ICConfigurationDescription cfg = getResDesc().getConfiguration(); ICConfigurationDescription cfg = getResDesc().getConfiguration();
ICExternalSetting[] vals = cfg.getExternalSettings(); ICExternalSetting[] extSettings = cfg.getExternalSettings();
if (!(vals == null || vals.length == 0)) { if (!(extSettings == null || extSettings.length == 0)) {
for (ICExternalSetting val : vals) { for (ICExternalSetting extSetting : extSettings) {
ICSettingEntry[] ents = val.getEntries(getKind()); ICSettingEntry[] entries = extSetting.getEntries(getKind());
if (ents == null || ents.length == 0) continue; if (entries == null || entries.length == 0) continue;
for (int j=0; j<ents.length; j++) { for (int j=0; j<entries.length; j++) {
if (ents[j].equalsByName(ent)) { if (entries[j].equalsByName(ent)) {
ICSettingEntry[] arr = new ICSettingEntry[ents.length - 1]; ICSettingEntry[] arr = new ICSettingEntry[entries.length - 1];
int index = 0; int index = 0;
for (int k=0; k<ents.length; k++) for (int k=0; k<entries.length; k++)
if (k != j) arr[index++] = ents[k]; if (k != j) arr[index++] = entries[k];
cfg.removeExternalSetting(val); cfg.removeExternalSetting(extSetting);
cfg.createExternalSetting(val.getCompatibleLanguageIds(), cfg.createExternalSetting(extSetting.getCompatibleLanguageIds(),
val.getCompatibleContentTypeIds(), extSetting.getCompatibleContentTypeIds(),
val.getCompatibleExtensions(), extSetting.getCompatibleExtensions(),
arr); arr);
return; return;
} }
@ -626,16 +626,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
* @param ent - entry to add * @param ent - entry to add
*/ */
private void addToAll(ICLanguageSettingEntry ent) { private void addToAll(ICLanguageSettingEntry ent) {
ICConfigurationDescription[] cfgs = page.getCfgsEditable(); ICResourceDescription curRcDes = page.getResDesc();
ICResourceDescription cur_cfg = page.getResDesc();
String id = lang.getName(); // getLanguageId() sometimes returns null. String id = lang.getName(); // getLanguageId() sometimes returns null.
for (ICConfigurationDescription cfg : cfgs) { for (ICConfigurationDescription cfgDes : page.getCfgsEditable()) {
ICResourceDescription rcfg = page.getResDesc(cfg); ICResourceDescription rcDes = page.getResDesc(cfgDes);
if (rcfg == null) if (rcDes == null)
continue; continue;
if (!toAllCfgs && !(cur_cfg.equals(rcfg))) if (!toAllCfgs && !(curRcDes.equals(rcDes)))
continue; continue;
for (ICLanguageSetting l : getLangSetting(rcfg)) { for (ICLanguageSetting l : getLangSetting(rcDes)) {
if (id == l.getName() || toAllLang) { if (id == l.getName() || toAllLang) {
List<ICLanguageSettingEntry> lst = l.getSettingEntriesList(getKind()); List<ICLanguageSettingEntry> lst = l.getSettingEntriesList(getKind());
lst.add(ent); lst.add(ent);
@ -651,9 +650,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
if (page.isMultiCfg()) { if (page.isMultiCfg()) {
ICLanguageSetting [] sr = ls; ICLanguageSetting [] sr = ls;
if (dst instanceof ICMultiItemsHolder) { if (dst instanceof ICMultiItemsHolder) {
for (Object ob : ((ICMultiItemsHolder)dst).getItems()) { for (Object item : ((ICMultiItemsHolder)dst).getItems()) {
if (ob instanceof ICResourceDescription) { if (item instanceof ICResourceDescription) {
ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)ob); ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)item);
if (ds == null || sr.length != ds.length) return; if (ds == null || sr.length != ds.length) return;
for (int i=0; i<sr.length; i++) { for (int i=0; i<sr.length; i++) {
ICLanguageSettingEntry[] ents = null; ICLanguageSettingEntry[] ents = null;
@ -764,8 +763,8 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
return foDes.getLanguageSettings(); return foDes.getLanguageSettings();
case ICSettingBase.SETTING_FILE: case ICSettingBase.SETTING_FILE:
ICFileDescription fiDes = (ICFileDescription)rcDes; ICFileDescription fiDes = (ICFileDescription)rcDes;
ICLanguageSetting ls = fiDes.getLanguageSetting(); ICLanguageSetting langSetting = fiDes.getLanguageSetting();
return (ls != null) ? new ICLanguageSetting[] { ls } : null; return (langSetting != null) ? new ICLanguageSetting[] { langSetting } : null;
} }
return null; return null;
} }
@ -773,15 +772,15 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
private ICLanguageSetting[] getLS(ICMultiFolderDescription foDes) { private ICLanguageSetting[] getLS(ICMultiFolderDescription foDes) {
ICLanguageSetting[] lsets; ICLanguageSetting[] lsets;
ICLanguageSetting[][] ls = foDes.getLanguageSettingsM(comp); ICLanguageSetting[][] lsArray2D = foDes.getLanguageSettingsM(comp);
ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(ls, comp)); ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(lsArray2D, comp));
lsets = new ICLanguageSetting[fs.length]; lsets = new ICLanguageSetting[fs.length];
for (int i=0; i<fs.length; i++) { for (int i=0; i<fs.length; i++) {
ArrayList<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>(ls.length); ArrayList<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>(lsArray2D.length);
for (ICLanguageSetting[] element : ls) { for (ICLanguageSetting[] lsArray : lsArray2D) {
int x = Arrays.binarySearch(element, fs[i], comp); int x = Arrays.binarySearch(lsArray, fs[i], comp);
if (x >= 0) if (x >= 0)
list.add(element[x]); list.add(lsArray[x]);
} }
if (list.size() == 1) if (list.size() == 1)
lsets[i] = list.get(0); lsets[i] = list.get(0);
@ -795,9 +794,9 @@ public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
@Override @Override
public boolean canBeVisible() { public boolean canBeVisible() {
if (getResDesc() == null) return true; if (getResDesc() == null) return true;
ICLanguageSetting [] ls = getLangSetting(getResDesc()); ICLanguageSetting [] langSettings = getLangSetting(getResDesc());
if (ls == null) return false; if (langSettings == null) return false;
for (ICLanguageSetting element : ls) { for (ICLanguageSetting element : langSettings) {
if ((element.getSupportedEntryKinds() & getKind()) != 0) if ((element.getSupportedEntryKinds() & getKind()) != 0)
return true; return true;
} }