From b0780772c9298e72972e48927bbca15963b208a9 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 28 Jul 2008 16:51:12 +0000 Subject: [PATCH] Compiler warnings. --- .../core/settings/model/CExternalSetting.java | 73 +++++++++---------- .../model/CProjectDescriptionEvent.java | 67 +++++++++-------- 2 files changed, 69 insertions(+), 71 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java index dded8897ded..c06072754e1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CExternalSetting.java @@ -25,7 +25,7 @@ public final class CExternalSetting implements ICExternalSetting { private String[] fExtensions; // private String fId; - public CExternalSetting(ICExternalSetting base){ + public CExternalSetting(ICExternalSetting base) { fLanguageIds = base.getCompatibleLanguageIds(); fContentTypeIds = base.getCompatibleContentTypeIds(); fExtensions = base.getCompatibleExtensions(); @@ -34,28 +34,27 @@ public final class CExternalSetting implements ICExternalSetting { initEntryStore(base.getEntries()); } - public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]){ + public CExternalSetting(ICExternalSetting base, ICSettingEntry entries[]) { this(base); initEntryStore(entries); } - public CExternalSetting(String[] languageIDs, - String[] contentTypeIds, String[] extensions, - ICSettingEntry[] entries){ - if(languageIDs != null) - fLanguageIds = (String[])languageIDs.clone(); - if(contentTypeIds != null) - fContentTypeIds = (String[])contentTypeIds.clone(); - if(extensions != null) - fExtensions = (String[])extensions.clone(); + public CExternalSetting(String[] languageIDs, String[] contentTypeIds, String[] extensions, + ICSettingEntry[] entries) { + if (languageIDs != null) + fLanguageIds = languageIDs.clone(); + if (contentTypeIds != null) + fContentTypeIds = contentTypeIds.clone(); + if (extensions != null) + fExtensions = extensions.clone(); initEntryStore(entries); } - private void initEntryStore(ICSettingEntry entries[]){ + private void initEntryStore(ICSettingEntry entries[]) { ICSettingEntry entry; - for(int i = 0; i < entries.length; i++){ + for (int i = 0; i < entries.length; i++) { entry = entries[i]; addEntry(entry); @@ -64,22 +63,22 @@ public final class CExternalSetting implements ICExternalSetting { // trimToSize(); } - private void addEntry(ICSettingEntry entry){ + private void addEntry(ICSettingEntry entry) { getEntriesSet(entry.getKind(), true).addEntry(entry); } -/* private void trimToSize(){ - int kinds[] = KindBasedStore.getSupportedKinds(); - for(int i = 0; i < kinds.length; i++){ - CEntriesSet set = getEntriesSet(kinds[i], false); - if(set != null) - set.trimToSize(); - } - } -*/ - private CEntriesSet getEntriesSet(int kind, boolean create){ +// private void trimToSize() { +// int kinds[] = KindBasedStore.getSupportedKinds(); +// for (int i = 0; i < kinds.length; i++) { +// CEntriesSet set = getEntriesSet(kinds[i], false); +// if (set != null) +// set.trimToSize(); +// } +// } + + private CEntriesSet getEntriesSet(int kind, boolean create) { CEntriesSet set = (CEntriesSet)fStore.get(kind); - if(set == null && create){ + if (set == null && create) { set = new CEntriesSet(); fStore.put(kind, set); } @@ -87,43 +86,43 @@ public final class CExternalSetting implements ICExternalSetting { } public String[] getCompatibleContentTypeIds() { - if(fContentTypeIds != null) - return (String[])fContentTypeIds.clone(); + if (fContentTypeIds != null) + return fContentTypeIds.clone(); return null; } public String[] getCompatibleExtensions() { - if(fExtensions != null) - return (String[])fExtensions.clone(); + if (fExtensions != null) + return fExtensions.clone(); return null; } public String[] getCompatibleLanguageIds() { - if(fLanguageIds != null) - return (String[])fLanguageIds.clone(); + if (fLanguageIds != null) + return fLanguageIds.clone(); return null; } public ICSettingEntry[] getEntries(int kind) { CEntriesSet set = getEntriesSet(kind, false); - if(set != null) + if (set != null) return set.toArray(); return new ICSettingEntry[0]; } -// public String getId(){ +// public String getId() { // return fId; // } public ICSettingEntry[] getEntries() { - List result = new ArrayList(); + List result = new ArrayList(); int kinds[] = KindBasedStore.getAllEntryKinds(); - for(int i = 0; i < kinds.length; i++){ + for (int i = 0; i < kinds.length; i++) { CEntriesSet list = getEntriesSet(kinds[i], false); - if(list != null) + if (list != null) result.addAll(Arrays.asList(list.toArray())); } - return (ICSettingEntry[])result.toArray(new ICSettingEntry[result.size()]); + return result.toArray(new ICSettingEntry[result.size()]); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java index 1b96fe0e27f..5725ffe8d7d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java @@ -35,115 +35,114 @@ public final class CProjectDescriptionEvent { ICDescriptionDelta delta, ICProjectDescription newDes, ICProjectDescription oldDes, - ICProjectDescription appliedDes){ + ICProjectDescription appliedDes) { fType = type; fProjDelta = delta; fNewDescription = newDes; fOldDescription = oldDes; fAppliedDescription = appliedDes; - if(fNewDescription != null){ + if (fNewDescription != null) { fProject = fNewDescription.getProject(); - } else if(fOldDescription != null){ + } else if (fOldDescription != null) { fProject = fOldDescription.getProject(); } } - public IProject getProject(){ + public IProject getProject() { return fProject; } - public int getEventType(){ + public int getEventType() { return fType; } - public ICDescriptionDelta getProjectDelta(){ + public ICDescriptionDelta getProjectDelta() { return fProjDelta; } - public ICDescriptionDelta getActiveCfgDelta(){ - if(fActiveCfgDelta == null){ + public ICDescriptionDelta getActiveCfgDelta() { + if (fActiveCfgDelta == null) { fActiveCfgDelta = getDelta(true); } return fActiveCfgDelta; } - public ICDescriptionDelta getDefaultSettingCfgDelta(){ - if(fIndexCfgDelta == null){ + public ICDescriptionDelta getDefaultSettingCfgDelta() { + if (fIndexCfgDelta == null) { fIndexCfgDelta = getDelta(false); } return fIndexCfgDelta; } - private ICDescriptionDelta getDelta(boolean active){ + private ICDescriptionDelta getDelta(boolean active) { ICDescriptionDelta delta = null; - switch(getEventType()){ + switch(getEventType()) { case LOADED: case ABOUT_TO_APPLY: case APPLIED: case DATA_APPLIED: - if(fProjDelta != null){ + if (fProjDelta != null) { ICProjectDescription oldDes = getOldCProjectDescription(); ICProjectDescription newDes = getNewCProjectDescription(); - if(oldDes == null){ + if (oldDes == null) { ICConfigurationDescription cfg = getCfg(newDes, active); - if(cfg != null){ + if (cfg != null) { delta = findCfgDelta(fProjDelta, cfg.getId()); } - } else if(newDes == null){ + } else if (newDes == null) { ICConfigurationDescription cfg = getCfg(oldDes, active); - if(cfg != null){ + if (cfg != null) { delta = findCfgDelta(fProjDelta, cfg.getId()); } } else { ICConfigurationDescription newCfg = getCfg(newDes, active); ICConfigurationDescription oldCfg = getCfg(oldDes, active); - if(oldCfg == null){ - if(newCfg != null){ + if (oldCfg == null) { + if (newCfg != null) { delta = new CProjectDescriptionDelta(newCfg, null); } - } else if (newCfg == null){ + } else if (newCfg == null) { delta = new CProjectDescriptionDelta(null, oldCfg); + } else if (newCfg.getId().equals(oldCfg.getId())) { + delta = findCfgDelta(fProjDelta, newCfg.getId()); } else { - if(newCfg.getId().equals(oldCfg.getId())){ - delta = findCfgDelta(fProjDelta, newCfg.getId()); - } else { - delta = CProjectDescriptionManager.getInstance().createDelta(newCfg, oldCfg); - } + delta = CProjectDescriptionManager.getInstance().createDelta(newCfg, oldCfg); } } } + break; + case COPY_CREATED: break; } return delta; } - private ICConfigurationDescription getCfg(ICProjectDescription des, boolean active){ + private ICConfigurationDescription getCfg(ICProjectDescription des, boolean active) { return active ? des.getActiveConfiguration() : des.getDefaultSettingConfiguration(); } - private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){ - if(delta == null) + private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id) { + if (delta == null) return null; ICDescriptionDelta children[] = delta.getChildren(); - for(int i = 0; i < children.length; i++){ + for (int i = 0; i < children.length; i++) { ICSettingObject s = children[i].getNewSetting(); - if(s != null && id.equals(s.getId())) + if (s != null && id.equals(s.getId())) return children[i]; } return null; } - public ICProjectDescription getOldCProjectDescription(){ + public ICProjectDescription getOldCProjectDescription() { return fOldDescription; } - public ICProjectDescription getNewCProjectDescription(){ + public ICProjectDescription getNewCProjectDescription() { return fNewDescription; } - public ICProjectDescription getAppliedCProjectDescription(){ + public ICProjectDescription getAppliedCProjectDescription() { return fAppliedDescription; } - }