diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index b20671be40c..f399fdbbdde 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -95,7 +95,6 @@ public class PathEntryTranslator { public static final int INCLUDE_USER = 1 << 1; public static final int INCLUDE_ALL = INCLUDE_BUILT_INS | INCLUDE_USER; - static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$ static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$ static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$ @@ -117,7 +116,7 @@ public class PathEntryTranslator { static final IPathEntry[] NO_PATHENTRIES = new IPathEntry[0]; - private static final char[] SPEC_CHARS = new char[]{'*', '?'}; + private static final char[] SPEC_CHARS = new char[] { '*', '?' }; private PathSettingsContainer fRcDataHolder; private IProject fProject; private CConfigurationData fCfgData; @@ -125,7 +124,6 @@ public class PathEntryTranslator { private Map fResourceMap = new HashMap(); private IWorkspaceRoot fRoot = ResourcesPlugin.getWorkspace().getRoot(); - private static class VarSubstitutor extends CoreVariableSubstitutor { ICConfigurationDescription fCfg; ICdtVariableManager fMngr = CCorePlugin.getDefault().getCdtVariableManager(); @@ -138,7 +136,7 @@ public class PathEntryTranslator { @Override protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException { - if(!CdtVarPathEntryVariableManager.isPathEntryVariable(macro, fCfg, fMngr)) + if (!CdtVarPathEntryVariableManager.isPathEntryVariable(macro, fCfg, fMngr)) return super.resolveMacro(macro); return new ResolvedMacro(macro.getName(), CdtVariableResolver.createVariableReference(macro.getName())); } @@ -148,7 +146,7 @@ public class PathEntryTranslator { private IPath[] fRefProjPaths; private ICExternalSetting[] fExtSettings; - public ReferenceSettingsInfo(ICConfigurationDescription des){ + public ReferenceSettingsInfo(ICConfigurationDescription des) { fExtSettings = des.getExternalSettings(); Map map = des.getReferenceInfo(); fRefProjPaths = new IPath[map.size()]; @@ -158,21 +156,21 @@ public class PathEntryTranslator { } } - public ReferenceSettingsInfo(IPath[] projPaths, ICExternalSetting extSettings[]){ - if(projPaths != null) + public ReferenceSettingsInfo(IPath[] projPaths, ICExternalSetting extSettings[]) { + if (projPaths != null) fRefProjPaths = projPaths.clone(); - if(extSettings != null) + if (extSettings != null) fExtSettings = extSettings.clone(); } - public IPath[] getReferencedProjectsPaths(){ - if(fRefProjPaths != null) + public IPath[] getReferencedProjectsPaths() { + if (fRefProjPaths != null) return fRefProjPaths.clone(); return new IPath[0]; } - public Map getRefProjectsMap(){ - if(fRefProjPaths != null && fRefProjPaths.length != 0){ + public Map getRefProjectsMap() { + if (fRefProjPaths != null && fRefProjPaths.length != 0) { Map map = new HashMap(fRefProjPaths.length); for (IPath fRefProjPath : fRefProjPaths) { map.put(fRefProjPath.segment(0), ""); //$NON-NLS-1$ @@ -182,8 +180,8 @@ public class PathEntryTranslator { return new HashMap(0); } - public ICExternalSetting[] getExternalSettings(){ - if(fExtSettings != null) + public ICExternalSetting[] getExternalSettings() { + if (fExtSettings != null) return fExtSettings.clone(); return new ICExternalSetting[0]; } @@ -218,8 +216,8 @@ public class PathEntryTranslator { @SuppressWarnings("unchecked") private Map[] fEntryStorage = new Map[STORAGE_SIZE]; - private int kindToIndex(int kind){ - switch (kind){ + private int kindToIndex(int kind) { + switch (kind) { case IPathEntry.CDT_LIBRARY: return INDEX_CDT_LIBRARY; case IPathEntry.CDT_PROJECT: @@ -242,15 +240,15 @@ public class PathEntryTranslator { throw new IllegalArgumentException(UtilMessages.getString("PathEntryTranslator.0")); //$NON-NLS-1$ } - public static int[] getSupportedKinds(){ + public static int[] getSupportedKinds() { return ENTRY_KINDS.clone(); } - public Map get(int kind){ + public Map get(int kind) { return fEntryStorage[kindToIndex(kind)]; } - public Map put(int kind, Map object){ + public Map put(int kind, Map object) { int index = kindToIndex(kind); Map old = fEntryStorage[index]; fEntryStorage[index] = object; @@ -262,7 +260,7 @@ public class PathEntryTranslator { ICLanguageSettingEntry fLangEntry; ResolvedEntry fResolvedEntry; - public LangEntryInfo(ICLanguageSettingEntry lEntry, ResolvedEntry re){ + public LangEntryInfo(ICLanguageSettingEntry lEntry, ResolvedEntry re) { fLangEntry = lEntry; fResolvedEntry = re; } @@ -272,25 +270,25 @@ public class PathEntryTranslator { List fResolvedEntries; KindBasedStore> fLangEntries; - private RcDesInfo(ResourceInfo rcInfo){ + private RcDesInfo(ResourceInfo rcInfo) { fResolvedEntries = new ArrayList(); fLangEntries = new KindBasedStore>(); } - public void add(LangEntryInfo info){ + public void add(LangEntryInfo info) { List list = fLangEntries.get(info.fLangEntry.getKind()); - if(list == null){ + if (list == null) { list = new ArrayList(); fLangEntries.put(info.fLangEntry.getKind(), list); } list.add(info); } - public ICLanguageSettingEntry[] getEntries(int kind){ + public ICLanguageSettingEntry[] getEntries(int kind) { List list = fLangEntries.get(kind); - if(list != null){ + if (list != null) { ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[list.size()]; - for(int i = 0; i < entries.length; i++){ + for (int i = 0; i < entries.length; i++) { LangEntryInfo info = list.get(i); entries[i] = info.fLangEntry; } @@ -302,25 +300,25 @@ public class PathEntryTranslator { } } - private static ICLanguageSettingEntry createLangEntry(ResolvedEntry entry){ + private static ICLanguageSettingEntry createLangEntry(ResolvedEntry entry) { PathEntryValueInfo value = entry.getResolvedValue(); int flags = ICSettingEntry.RESOLVED; - if(entry.isReadOnly()) + if (entry.isReadOnly()) flags |= ICSettingEntry.READONLY; - if(entry.isBuiltIn()) + if (entry.isBuiltIn()) flags |= ICSettingEntry.BUILTIN; - switch(entry.fEntry.getEntryKind()){ + switch (entry.fEntry.getEntryKind()) { case IPathEntry.CDT_LIBRARY:{ ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry; IPath path = value.getFullPath(); - if(path != null){ + if (path != null) { flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; } else { path = value.getLocation(); } - if(path != null){ + if (path != null) { return new CLibraryFileEntry(value.getName(), flags, libEntry.getSourceAttachmentPath(), libEntry.getSourceAttachmentRootPath(), @@ -334,13 +332,13 @@ public class PathEntryTranslator { // return INDEX_CDT_SOURCE; case IPathEntry.CDT_INCLUDE:{ IPath path = value.getFullPath(); - if(path != null){ + if (path != null) { flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; } else { path = value.getLocation(); } - if(path != null){ + if (path != null) { return new CIncludePathEntry(value.getName(), flags); } break; @@ -349,7 +347,7 @@ public class PathEntryTranslator { // return INDEX_CDT_CONTAINER; case IPathEntry.CDT_MACRO: String name = value.getName(); - if(name.length() != 0){ + if (name.length() != 0) { String mValue = value.getValue(); return new CMacroEntry(name, mValue, flags); } @@ -358,26 +356,26 @@ public class PathEntryTranslator { // return INDEX_CDT_OUTPUT; case IPathEntry.CDT_INCLUDE_FILE:{ IPath path = value.getFullPath(); - if(path != null){ + if (path != null) { flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; } else { path = value.getLocation(); } - if(path != null){ + if (path != null) { return new CIncludeFileEntry(value.getName(), flags); } break; } case IPathEntry.CDT_MACRO_FILE:{ IPath path = value.getFullPath(); - if(path != null){ + if (path != null) { flags |= ICSettingEntry.VALUE_WORKSPACE_PATH; } else { path = value.getLocation(); } - if(path != null){ + if (path != null) { return new CMacroFileEntry(value.getName(), flags); } break; @@ -403,32 +401,32 @@ public class PathEntryTranslator { private String fValue; private ResolvedEntry fResolvedEntry; - private PathEntryValueInfo(ResolvedEntry rEntry){ + private PathEntryValueInfo(ResolvedEntry rEntry) { fResolvedEntry = rEntry; init(); } - public IPath getFullPath(){ - if(fResourceInfo != null) + public IPath getFullPath() { + if (fResourceInfo != null) return fResourceInfo.fRc.getFullPath(); return null; } - public IPath getLocation(){ - if(fResourceInfo != null) + public IPath getLocation() { + if (fResourceInfo != null) return fResourceInfo.fRc.getLocation(); return fLocation; } - public String getName(){ - if(fName != null) + public String getName() { + if (fName != null) return fName; return ""; //$NON-NLS-1$ } - public String getValue(){ - if(fValue != null) + public String getValue() { + if (fValue != null) return fValue; return ""; //$NON-NLS-1$ } @@ -439,7 +437,7 @@ public class PathEntryTranslator { IPath basePath = null, valuePath = null; boolean isFile = false; boolean calcPath = false; - switch(peKind){ + switch (peKind) { case IPathEntry.CDT_MACRO: IMacroEntry me = (IMacroEntry)entry; fName = me.getMacroName(); @@ -481,8 +479,8 @@ public class PathEntryTranslator { break; } - if(calcPath){ - do{ + if (calcPath) { + do { IPath unresolvedBase = basePath; IPath unresolvedValue = valuePath; IPathEntryVariableManager mngr = CCorePlugin.getDefault().getPathEntryVariableManager(); @@ -524,7 +522,7 @@ public class PathEntryTranslator { } fLocation = valuePath; - }while(false); + } while (false); } } } @@ -550,30 +548,30 @@ public class PathEntryTranslator { fIsReadOnly = isReadOnly; } - public boolean isReadOnly(){ + public boolean isReadOnly() { return fIsReadOnly; } - public boolean isBuiltIn(){ + public boolean isBuiltIn() { return fIsBuiltIn; } - public ResourceInfo getResourceInfo(){ - if(fResourceInfo == null){ + public ResourceInfo getResourceInfo() { + if (fResourceInfo == null) { fResourceInfo = findResourceInfo(fRoot, getEntryFullPath(fEntry), true); } return fResourceInfo; } - public ResourceInfo[] getFilterInfos(){ - if(fFilterInfos == null){ + public ResourceInfo[] getFilterInfos() { + if (fFilterInfos == null) { IPath[] paths = obtainFilters(fEntry); - if(paths.length == 0){ + if (paths.length == 0) { fFilterInfos = new ResourceInfo[0]; } else { ResourceInfo rcInfo = getResourceInfo(); - if(rcInfo.fExists){ - if(rcInfo.fRc.getType() == IResource.FILE){ + if (rcInfo.fExists) { + if (rcInfo.fRc.getType() == IResource.FILE) { fFilterInfos = new ResourceInfo[0]; } else { List list = new ArrayList(); @@ -585,7 +583,7 @@ public class PathEntryTranslator { } } else { fFilterInfos = new ResourceInfo[paths.length]; - for(int i = 0; i < paths.length; i++){ + for (int i = 0; i < paths.length; i++) { fFilterInfos[i] = processInexistingResourceFilter((IContainer)rcInfo.fRc, paths[i]); } } @@ -594,11 +592,11 @@ public class PathEntryTranslator { return fFilterInfos; } - private ResourceInfo[] processFilter(IContainer container, IPath path){ + private ResourceInfo[] processFilter(IContainer container, IPath path) { return resolveFilter(container, path); } - private ResourceInfo processInexistingResourceFilter(IContainer container, IPath path){ + private ResourceInfo processInexistingResourceFilter(IContainer container, IPath path) { IFolder f = container.getFolder(path); ResourceInfo rcInfo = new ResourceInfo(f, false); addRcInfoToMap(rcInfo); @@ -607,12 +605,12 @@ public class PathEntryTranslator { return rcInfo; } - public IPathEntry getEntry(){ + public IPathEntry getEntry() { return fEntry; } - public PathEntryValueInfo getResolvedValue(){ - if(fResolvedValue == null){ + public PathEntryValueInfo getResolvedValue() { + if (fResolvedValue == null) { fResolvedValue = new PathEntryValueInfo(this); } return fResolvedValue; @@ -628,97 +626,96 @@ public class PathEntryTranslator { private boolean fIsExported; private IProject fProject; - PathEntryComposer(IPath path, IProject project/*, ICConfigurationDescription cfg*/){ + PathEntryComposer(IPath path, IProject project/*, ICConfigurationDescription cfg*/) { fPath = toProjectPath(path); fProject = project; } - private static IPath toProjectPath(IPath path){ - if(path.segmentCount() > 1) + private static IPath toProjectPath(IPath path) { + if (path.segmentCount() > 1) path = new Path(path.segment(0)); return path.makeAbsolute(); } - PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project/*, ICConfigurationDescription cfg*/){ + PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project/*, ICConfigurationDescription cfg*/) { fPath = new Path(entry.getValue()); fLangEntry = entry; fProject = project; IPath[] exclusions = entry.getExclusionPatterns(); - if(exclusions.length != 0){ + if (exclusions.length != 0) { fFiltersSet = new HashSet(exclusions.length); fFiltersSet.addAll(Arrays.asList(entry.getExclusionPatterns())); } } - PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project/*, ICConfigurationDescription cfg*/){ + PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project/*, ICConfigurationDescription cfg*/) { fPath = path; fLangEntry = entry; fIsExported = exported; fProject = project; } - public void addFilter(IPath path){ - if(fFiltersSet == null) + public void addFilter(IPath path) { + if (fFiltersSet == null) fFiltersSet = new HashSet(); fFiltersSet.add(path); } - public ICSettingEntry getSettingEntry(){ + public ICSettingEntry getSettingEntry() { return fLangEntry; } - public IPath getPath(){ + public IPath getPath() { return fPath; } - public IPath[] getExclusionPatterns(){ - if(fFiltersSet != null) + public IPath[] getExclusionPatterns() { + if (fFiltersSet != null) return fFiltersSet.toArray(new IPath[fFiltersSet.size()]); return new IPath[0]; } - private IPath[][] getEntryPath(ICSettingEntry entry, ICConfigurationDescription cfg){ + private IPath[][] getEntryPath(ICSettingEntry entry, ICConfigurationDescription cfg) { return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0, cfg); } - private IPath[][] valueToEntryPath(String value, boolean isWsp, ICConfigurationDescription cfg){ + private IPath[][] valueToEntryPath(String value, boolean isWsp, ICConfigurationDescription cfg) { String[] pathVarValues = resolveKeepingPathEntryFars(value, cfg); IPath result[][] = new IPath[2][pathVarValues.length]; - for (int i=0; i fRefProjMap; private IProject fProject; - private PathEntryCollector(IProject project/*, ICConfigurationDescription cfg*/){ + private PathEntryCollector(IProject project/*, ICConfigurationDescription cfg*/) { fStorage = PathSettingsContainer.createRootContainer(); fStorage.setValue(this); fStore = new KindBasedStore>(false); @@ -830,21 +827,21 @@ public class PathEntryTranslator { fProject = project; } - private PathEntryCollector(PathSettingsContainer container, KindBasedStore> store, IProject project/*, ICConfigurationDescription cfg*/){ + private PathEntryCollector(PathSettingsContainer container, KindBasedStore> store, IProject project/*, ICConfigurationDescription cfg*/) { fStorage = container; fStore = store; fNameKeyMapStore = new KindBasedStore>(false); fProject = project; } - public void setSourceOutputEntries(int kind, ICExclusionPatternPathEntry entries[]){ + public void setSourceOutputEntries(int kind, ICExclusionPatternPathEntry entries[]) { Map map = getEntriesMap(kind, true); Map nameKeyMap = getEntriesNameKeyMap(kind, true); for (ICExclusionPatternPathEntry entry : entries) { entry = CDataUtil.makeAbsolute(fProject, entry, true); EntryNameKey nameKey = new EntryNameKey(entry); PathEntryComposer old = nameKeyMap.get(nameKey); - if(old != null){ + if (old != null) { entry = CDataUtil.addRemoveExclusionsToEntry(entry, ((ICExclusionPatternPathEntry)old.fLangEntry).getExclusionPatterns(), true); @@ -855,10 +852,10 @@ public class PathEntryTranslator { } } - public void setRefProjects(IPath []paths){ - if(paths == null || paths.length == 0) + public void setRefProjects(IPath []paths) { + if (paths == null || paths.length == 0) { fRefProjMap = null; - else { + } else { fRefProjMap = new LinkedHashMap(); for (IPath path : paths) { PathEntryComposer cs = new PathEntryComposer(path, fProject/*, fCfg*/); @@ -868,12 +865,12 @@ public class PathEntryTranslator { } } - public PathEntryCollector createChild(IPath path){ - if(path.segmentCount() == 0) + public PathEntryCollector createChild(IPath path) { + if (path.segmentCount() == 0) return this; PathEntryCollector cr = (PathEntryCollector)fStorage.getChildContainer(path, false, false).getValue(); - if(cr != this){ + if (cr != this) { IPath basePath = cr.getPath(); path = path.removeFirstSegments(basePath.segmentCount()); return cr.createChild(path); @@ -886,7 +883,7 @@ public class PathEntryTranslator { IKindBasedInfo> info[] = cloneStore.getContents(); for (IKindBasedInfo> kindInfo : info) { LinkedHashMap map = kindInfo.getInfo(); - if(map != null){ + if (map != null) { @SuppressWarnings("unchecked") LinkedHashMap clone = (LinkedHashMap)map.clone(); kindInfo.setInfo(clone); @@ -897,11 +894,11 @@ public class PathEntryTranslator { return newCr; } - public IPath getPath(){ + public IPath getPath() { return fStorage.getPath(); } - public void setEntries(int kind, ICLanguageSettingEntry entries[], Set exportedEntries){ + public void setEntries(int kind, ICLanguageSettingEntry entries[], Set exportedEntries) { IPath path = getPath(); HashSet parentSet = getEntriesSetCopy(kind); @SuppressWarnings("unchecked") @@ -911,14 +908,14 @@ public class PathEntryTranslator { addedThisSet.removeAll(parentSet); - if(removedParentSet.size() != 0){ + if (removedParentSet.size() != 0) { PathEntryCollector parent = getParent(); IPath parentPath = parent.getPath(); int segsToRemove = parentPath.segmentCount(); - if(segsToRemove > path.segmentCount()) + if (segsToRemove > path.segmentCount()) segsToRemove = path.segmentCount() - 1; - if(segsToRemove < 0) + if (segsToRemove < 0) segsToRemove = 0; IPath filterPath = path.removeFirstSegments(segsToRemove); @@ -931,11 +928,11 @@ public class PathEntryTranslator { } } - if(addedThisSet.size() != 0){ + if (addedThisSet.size() != 0) { Map map = getEntriesMap(kind, true); IPath fullPath = fProject.getFullPath().append(path); - for(int i = 0; i < entries.length; i++){ - if(!addedThisSet.remove(entries[i])) + for (int i = 0; i < entries.length; i++) { + if (!addedThisSet.remove(entries[i])) continue; ICLanguageSettingEntry entry = entries[i]; @@ -944,26 +941,26 @@ public class PathEntryTranslator { } } - private LinkedHashMap getEntriesMap(int kind, boolean create){ + private LinkedHashMap getEntriesMap(int kind, boolean create) { LinkedHashMap map = fStore.get(kind); - if(map == null && create){ + if (map == null && create) { map = new LinkedHashMap(); fStore.put(kind, map); } return map; } - private LinkedHashMap getEntriesNameKeyMap(int kind, boolean create){ + private LinkedHashMap getEntriesNameKeyMap(int kind, boolean create) { LinkedHashMap map = fNameKeyMapStore.get(kind); - if(map == null && create){ + if (map == null && create) { map = new LinkedHashMap(); fNameKeyMapStore.put(kind, map); } return map; } - private void addFilter(int kind, IPath path, Set entriesSet){ - if(entriesSet.size() == 0) + private void addFilter(int kind, IPath path, Set entriesSet) { + if (entriesSet.size() == 0) return; Map map = fStore.get(kind); @@ -973,25 +970,25 @@ public class PathEntryTranslator { } } - public PathEntryCollector getParent(){ - if(fStorage.isRoot()) + public PathEntryCollector getParent() { + if (fStorage.isRoot()) return null; PathSettingsContainer cr = fStorage.getParentContainer(); return (PathEntryCollector)cr.getValue(); } - private HashSet getEntriesSetCopy(int kind){ + private HashSet getEntriesSetCopy(int kind) { Map map = getEntriesMap(kind, false); - if(map != null){ + if (map != null) { return new HashSet(map.keySet()); } return new HashSet(0); } - private List getCollectedEntriesList(final int kind){ + private List getCollectedEntriesList(final int kind) { final List list = new ArrayList(); final Set set = new HashSet(); - fStorage.accept(new IPathSettingsContainerVisitor(){ + fStorage.accept(new IPathSettingsContainerVisitor() { public boolean visit(PathSettingsContainer container) { PathEntryCollector clr = (PathEntryCollector)container.getValue(); @@ -1004,48 +1001,48 @@ public class PathEntryTranslator { return list; } - private void getLocalCollectedEntries(int kind, List list, Set addedEntries){ + private void getLocalCollectedEntries(int kind, List list, Set addedEntries) { Map map = getEntriesMap(kind, false); - if(map == null) + if (map == null) return; for (PathEntryComposer pathEntryComposer : map.values()) { - if(addedEntries.add(pathEntryComposer)){ + if (addedEntries.add(pathEntryComposer)) { list.add(pathEntryComposer); } } } - public List getEntries(int peKind, List list, int flags, ICConfigurationDescription cfg){ - if(list == null){ + public List getEntries(int peKind, List list, int flags, ICConfigurationDescription cfg) { + if (list == null) { list = new ArrayList(); } int sKind = peKindToSettingKind(peKind); List composerList = null; - if(sKind != 0){ + if (sKind != 0) { composerList = getCollectedEntriesList(sKind); - } else if(peKind == IPathEntry.CDT_PROJECT){ - if(fRefProjMap != null && fRefProjMap.size() != 0){ + } else if (peKind == IPathEntry.CDT_PROJECT) { + if (fRefProjMap != null && fRefProjMap.size() != 0) { composerList = new ArrayList(fRefProjMap.values()); } } - if(composerList != null){ + if (composerList != null) { PathEntryKyndStore store = new PathEntryKyndStore(); for (PathEntryComposer cs : composerList) { ICSettingEntry entry = cs.getSettingEntry(); - if(checkFilter(cs, entry, flags)){ + if (checkFilter(cs, entry, flags)) { IPathEntry[] pe = null; - if(isBuiltIn(entry) && cs.getPath().segmentCount() > 1){ + if (isBuiltIn(entry) && cs.getPath().segmentCount() > 1) { String name = entry.getName(); Map map = store.get(peKind); - if(map == null){ + if (map == null) { map = new HashMap(); store.put(peKind, map); } - if(!map.containsKey(name)){ + if (!map.containsKey(name)) { pe = cs.toPathEntry(cfg, false); - if(pe != null){ + if (pe != null) { if (pe.length > 1) { System.out.println(); } @@ -1055,7 +1052,7 @@ public class PathEntryTranslator { } else { pe = cs.toPathEntry(cfg, true); } - if(pe != null) + if (pe != null) list.addAll(Arrays.asList(pe)); } } @@ -1064,26 +1061,24 @@ public class PathEntryTranslator { return list; } - private static boolean checkFilter(PathEntryComposer cs, ICSettingEntry entry, int flags){ + private static boolean checkFilter(PathEntryComposer cs, ICSettingEntry entry, int flags) { boolean builtIn = isBuiltIn(entry); -// if(builtIn && cs.getPath().segmentCount() > 1) +// if (builtIn && cs.getPath().segmentCount() > 1) // return false; - if((flags & INCLUDE_BUILT_INS) != 0 && builtIn) + if ((flags & INCLUDE_BUILT_INS) != 0 && builtIn) return true; - if((flags & INCLUDE_USER) != 0 && !builtIn) + if ((flags & INCLUDE_USER) != 0 && !builtIn) return true; return false; } - private static boolean isBuiltIn(ICSettingEntry entry){ - return entry != null ? - entry.isBuiltIn() || entry.isReadOnly() : false; + private static boolean isBuiltIn(ICSettingEntry entry) { + return entry != null && (entry.isBuiltIn() || entry.isReadOnly()); } - - public List getEntries(List list, int flags, ICConfigurationDescription cfg){ - if(list == null) + public List getEntries(List list, int flags, ICConfigurationDescription cfg) { + if (list == null) list = new ArrayList(); int peKinds[] = PathEntryKyndStore.getSupportedKinds(); for (int peKind : peKinds) { @@ -1093,24 +1088,24 @@ public class PathEntryTranslator { return list; } - public IPathEntry[] getEntries(int flags, ICConfigurationDescription cfg){ + public IPathEntry[] getEntries(int flags, ICConfigurationDescription cfg) { List list = getEntries(null, flags,cfg); IPathEntry[] entries = list.toArray(new IPathEntry[list.size()]); return entries; } } - private static LangEntryInfo createLangEntryInfo(ResolvedEntry entry){ + private static LangEntryInfo createLangEntryInfo(ResolvedEntry entry) { ICLanguageSettingEntry le = createLangEntry(entry); - if(le != null){ + if (le != null) { return new LangEntryInfo(le, entry); } return null; } - private static boolean areEntriesReadOnly(PathEntryResolveInfoElement el){ - switch(el.getRawEntry().getEntryKind()){ + private static boolean areEntriesReadOnly(PathEntryResolveInfoElement el) { + switch (el.getRawEntry().getEntryKind()) { case IPathEntry.CDT_LIBRARY: case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_MACRO: @@ -1126,17 +1121,17 @@ public class PathEntryTranslator { } - private IPath getEntryFullPath(IPathEntry entry){ + private IPath getEntryFullPath(IPathEntry entry) { IPath path = entry.getPath(); - if(path == null) + if (path == null) return fProject.getFullPath(); - else if(path.isAbsolute()) + else if (path.isAbsolute()) return path; return fProject.getFullPath().append(path); } - private IPath[] obtainFilters(IPathEntry entry){ + private IPath[] obtainFilters(IPathEntry entry) { switch (entry.getEntryKind()) { case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_INCLUDE_FILE: @@ -1148,7 +1143,7 @@ public class PathEntryTranslator { return new IPath[0]; } - public PathEntryTranslator(IProject project, CConfigurationData data){ + public PathEntryTranslator(IProject project, CConfigurationData data) { fProject = project; fCfgData = data; fRcDataHolder = createRcDataHolder(data); @@ -1156,28 +1151,28 @@ public class PathEntryTranslator { fTranslatedFilters.setValue(new ResourceInfo[]{new ResourceInfo(fRoot, true)}); } - private static PathSettingsContainer createRcDataHolder(CConfigurationData data){ + private static PathSettingsContainer createRcDataHolder(CConfigurationData data) { return CDataUtil.createRcDataHolder(data); } - public ReferenceSettingsInfo applyPathEntries(PathEntryResolveInfo info, int op){ + public ReferenceSettingsInfo applyPathEntries(PathEntryResolveInfo info, int op) { ResolvedEntry[] rEntries = getResolvedEntries(info); return addPathEntries(rEntries, op); } - private RcDesInfo getRcDesInfo(PathSettingsContainer cr, ResourceInfo rcInfo){ + private RcDesInfo getRcDesInfo(PathSettingsContainer cr, ResourceInfo rcInfo) { IResource rc = rcInfo.fRc; IPath projPath = rc.getProjectRelativePath(); PathSettingsContainer child = cr.getChildContainer(projPath, true, true); RcDesInfo rcDes = (RcDesInfo)child.getValue(); - if(rcDes == null){ + if (rcDes == null) { rcDes = new RcDesInfo(rcInfo); child.setValue(rcDes); } return rcDes; } - private ReferenceSettingsInfo addPathEntries(ResolvedEntry[] rEntries, int op){ + private ReferenceSettingsInfo addPathEntries(ResolvedEntry[] rEntries, int op) { PathSettingsContainer cr = PathSettingsContainer.createRootContainer(); cr.setValue(new RcDesInfo(new ResourceInfo(fProject, true))); List srcList = new ArrayList(); @@ -1188,10 +1183,10 @@ public class PathEntryTranslator { ICOutputEntry outEntries[] = null; ResourceInfo rcInfo; for (ResolvedEntry rEntry : rEntries) { - if(rEntry.isReadOnly()) + if (rEntry.isReadOnly()) continue; - if(toLanguageEntryKind(rEntry.fEntry.getEntryKind()) == 0){ - switch(rEntry.fEntry.getEntryKind()){ + if (toLanguageEntryKind(rEntry.fEntry.getEntryKind()) == 0) { + switch (rEntry.fEntry.getEntryKind()) { case IPathEntry.CDT_SOURCE: srcList.add(rEntry.fEntry); break; @@ -1205,7 +1200,7 @@ public class PathEntryTranslator { continue; } - if(rEntry.getEntry().isExported()){ + if (rEntry.getEntry().isExported()) { exportSettingsList.add(rEntry); } rcInfo = rEntry.getResourceInfo(); @@ -1219,10 +1214,10 @@ public class PathEntryTranslator { } } - if(srcList.size() != 0){ + if (srcList.size() != 0) { srcEntries = toCSourceEntries(srcList); } - if(outList.size() != 0){ + if (outList.size() != 0) { outEntries = toCOutputEntries(outList); } @@ -1234,19 +1229,19 @@ public class PathEntryTranslator { applyLangSettings(cr, op); IPath refProjPaths[] = new IPath[projList.size()]; - for(int i = 0; i < refProjPaths.length; i++){ + for (int i = 0; i < refProjPaths.length; i++) { ResolvedEntry e = projList.get(i); refProjPaths[i] = e.getResourceInfo().fRc.getFullPath(); } ICExternalSetting extSettings[]; - if(exportSettingsList.size() != 0){ + if (exportSettingsList.size() != 0) { extSettings = new ICExternalSetting[1]; List list = new ArrayList(exportSettingsList.size()); - for(int i = 0; i < exportSettingsList.size(); i++){ + for (int i = 0; i < exportSettingsList.size(); i++) { ResolvedEntry re = exportSettingsList.get(i); ICLanguageSettingEntry le = createLangEntry(re); - if(le != null) + if (le != null) list.add(le); } ICLanguageSettingEntry expEntries[] = list.toArray(new ICLanguageSettingEntry[list.size()]); @@ -1258,66 +1253,64 @@ public class PathEntryTranslator { return new ReferenceSettingsInfo(refProjPaths, extSettings); } - private static ICSourceEntry[] toCSourceEntries(List list){ + private static ICSourceEntry[] toCSourceEntries(List list) { ICSourceEntry[] entries = new ICSourceEntry[list.size()]; - for(int i = 0; i < entries.length; i++){ + for (int i = 0; i < entries.length; i++) { entries[i] = toCSourceEntry((ISourceEntry)list.get(i), true); } return entries; } - private static ICOutputEntry[] toCOutputEntries(List list){ + private static ICOutputEntry[] toCOutputEntries(List list) { ICOutputEntry[] entries = new ICOutputEntry[list.size()]; - for(int i = 0; i < entries.length; i++){ + for (int i = 0; i < entries.length; i++) { entries[i] = toCOutputEntry((IOutputEntry)list.get(i), true); } return entries; } - private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative){ + private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative) { IPath path = entry.getPath(); - if(makeProjRelative && path.isAbsolute()) + if (makeProjRelative && path.isAbsolute()) path = path.removeFirstSegments(1); return new CSourceEntry(path, entry.getExclusionPatterns(), - ICSettingEntry.VALUE_WORKSPACE_PATH - | ICSettingEntry.RESOLVED); + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); } - private static ICOutputEntry toCOutputEntry(IOutputEntry entry, boolean makeProjRelative){ + private static ICOutputEntry toCOutputEntry(IOutputEntry entry, boolean makeProjRelative) { IPath path = entry.getPath(); - if(makeProjRelative && path.isAbsolute()) + if (makeProjRelative && path.isAbsolute()) path = path.removeFirstSegments(1); return new COutputEntry(path, entry.getExclusionPatterns(), - ICSettingEntry.VALUE_WORKSPACE_PATH - | ICSettingEntry.RESOLVED); + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); } - private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, ICSettingEntry[] newUsrEntries){ + private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, ICSettingEntry[] newUsrEntries) { Set set = new LinkedHashSet(); Class componentType = null; - if(newUsrEntries != null){ + if (newUsrEntries != null) { for (ICSettingEntry entry : newUsrEntries) { - if(entry.isBuiltIn() || entry.isReadOnly()) + if (entry.isBuiltIn() || entry.isReadOnly()) continue; set.add(entry); } componentType = newUsrEntries.getClass().getComponentType(); } - if(oldEntries != null){ + if (oldEntries != null) { for (ICSettingEntry entry : oldEntries) { - if(entry.isBuiltIn() || entry.isReadOnly()) + if (entry.isBuiltIn() || entry.isReadOnly()) set.add(entry); } - if(componentType == null) + if (componentType == null) componentType = oldEntries.getClass().getComponentType(); } - if(componentType != null){ + if (componentType != null) { ICSettingEntry[] result = (ICSettingEntry[])Array.newInstance(componentType, set.size()); set.toArray(result); return result; @@ -1325,7 +1318,7 @@ public class PathEntryTranslator { return null; } - private void applySourceEntries(ICSourceEntry entries[], int op){ + private void applySourceEntries(ICSourceEntry entries[], int op) { ICSourceEntry[] oldEntries = fCfgData.getSourceEntries(); oldEntries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, oldEntries, true); entries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, entries, true); @@ -1333,7 +1326,7 @@ public class PathEntryTranslator { switch (op) { case OP_ADD: - if(entries != null && entries.length != 0){ + if (entries != null && entries.length != 0) { Set set = new LinkedHashSet(); set.addAll(Arrays.asList(oldEntries)); set.addAll(Arrays.asList(entries)); @@ -1341,7 +1334,7 @@ public class PathEntryTranslator { } break; case OP_REMOVE: - if(entries != null && entries.length != 0){ + if (entries != null && entries.length != 0) { Set set = new HashSet(); set.addAll(Arrays.asList(oldEntries)); set.removeAll(Arrays.asList(entries)); @@ -1350,7 +1343,7 @@ public class PathEntryTranslator { break; case OP_REPLACE: default: - if(entries != null){ + if (entries != null) { fCfgData.setSourceEntries(entries); } else { fCfgData.setSourceEntries(new ICSourceEntry[0]); @@ -1359,9 +1352,9 @@ public class PathEntryTranslator { } } - private void applyOutputEntries(ICOutputEntry entries[], int op){ + private void applyOutputEntries(ICOutputEntry entries[], int op) { CBuildData bData = fCfgData.getBuildData(); - if(bData == null){ + if (bData == null) { CCorePlugin.log(UtilMessages.getString("PathEntryTranslator.2")); //$NON-NLS-1$ return; } @@ -1373,7 +1366,7 @@ public class PathEntryTranslator { switch (op) { case OP_ADD: - if(entries != null && entries.length != 0){ + if (entries != null && entries.length != 0) { Set set = new LinkedHashSet(); set.addAll(Arrays.asList(oldEntries)); set.addAll(Arrays.asList(entries)); @@ -1381,7 +1374,7 @@ public class PathEntryTranslator { } break; case OP_REMOVE: - if(entries != null && entries.length != 0){ + if (entries != null && entries.length != 0) { Set set = new HashSet(); set.addAll(Arrays.asList(oldEntries)); set.removeAll(Arrays.asList(entries)); @@ -1390,7 +1383,7 @@ public class PathEntryTranslator { break; case OP_REPLACE: default: - if(entries != null){ + if (entries != null) { bData.setOutputDirectories(entries); } else { bData.setOutputDirectories(new ICOutputEntry[0]); @@ -1399,7 +1392,7 @@ public class PathEntryTranslator { } } - private void applyLangSettings(PathSettingsContainer cr, int op){ + private void applyLangSettings(PathSettingsContainer cr, int op) { PathSettingsContainer crs[] = cr.getChildren(true); for (PathSettingsContainer cur : crs) { RcDesInfo desInfo = (RcDesInfo)cur.getValue(); @@ -1414,17 +1407,16 @@ public class PathEntryTranslator { CResourceData[] rcDatas = getResourceDatas(); for (CResourceData rcData : rcDatas) { PathSettingsContainer c = cr.getChildContainer(rcData.getPath(), false, false); - if(cr.getPath().makeRelative().equals(rcData.getPath().makeRelative())){ + if (cr.getPath().makeRelative().equals(rcData.getPath().makeRelative())) { continue; } - RcDesInfo desInfo = (RcDesInfo)c.getValue(); - + RcDesInfo desInfo = (RcDesInfo) c.getValue(); applyEntries(rcData, desInfo, op); } } - private CResourceData[] getResourceDatas(){ + private CResourceData[] getResourceDatas() { PathSettingsContainer crs[] = fRcDataHolder.getChildren(true); List list = new ArrayList(crs.length); for (PathSettingsContainer cur : crs) { @@ -1435,15 +1427,15 @@ public class PathEntryTranslator { private CResourceData getResourceData(IPath path, boolean create, boolean exactPath) throws CoreException{ PathSettingsContainer rcDataH = fRcDataHolder.getChildContainer(path, false, exactPath); - if(rcDataH != null){ + if (rcDataH != null) { return (CResourceData)rcDataH.getValue(); } else if (create) { ResourceInfo rcInfo = findResourceInfo(fProject, path, true); CResourceData base = getResourceData(path, false, false); CResourceData newRcData; - if(rcInfo.fRc.getType() == IResource.FILE){ - if(base.getType() == ICSettingBase.SETTING_FILE){ + if (rcInfo.fRc.getType() == IResource.FILE) { + if (base.getType() == ICSettingBase.SETTING_FILE) { newRcData = fCfgData.createFileData(path, (CFileData)base); } else { CFolderData folderData = (CFolderData)base; @@ -1452,7 +1444,7 @@ public class PathEntryTranslator { newRcData = fCfgData.createFileData(path, folderData, baseLData); } } else { - while(base.getType() == ICSettingBase.SETTING_FILE){ + while (base.getType() == ICSettingBase.SETTING_FILE) { base = getResourceData(base.getPath().removeLastSegments(1), false, false); } @@ -1465,13 +1457,13 @@ public class PathEntryTranslator { return null; } - private void applyEntries(CResourceData data, RcDesInfo info, int op){ + private void applyEntries(CResourceData data, RcDesInfo info, int op) { CLanguageData lDatas[] = data.getType() == ICSettingBase.SETTING_FILE ? - new CLanguageData[]{((CFileData)data).getLanguageData()} - : ((CFolderData)data).getLanguageDatas(); + new CLanguageData[] { ((CFileData)data).getLanguageData() } : + ((CFolderData) data).getLanguageDatas(); for (CLanguageData lData : lDatas) { - if(lData == null) + if (lData == null) continue; applyEntries(lData, info, op); @@ -1479,18 +1471,18 @@ public class PathEntryTranslator { } - private void applyEntries(CLanguageData lData, RcDesInfo info, int op){ + private void applyEntries(CLanguageData lData, RcDesInfo info, int op) { int kinds[] = KindBasedStore.getLanguageEntryKinds(); int supported = lData.getSupportedEntryKinds(); for (int kind : kinds) { - if((supported & kind) == 0) + if ((supported & kind) == 0) continue; ICLanguageSettingEntry opEntries[] = info.getEntries(kind); ICLanguageSettingEntry oldEntries[] = lData.getEntries(kind); opEntries = (ICLanguageSettingEntry[])replaceUserEntries(oldEntries, opEntries); - if(op == OP_REPLACE) + if (op == OP_REPLACE) oldEntries = null; ICLanguageSettingEntry result[] = composeNewEntries(oldEntries, opEntries, op); lData.setEntries(kind, result); @@ -1499,14 +1491,14 @@ public class PathEntryTranslator { private ICLanguageSettingEntry[] composeNewEntries(ICLanguageSettingEntry oldEntries[], ICLanguageSettingEntry newEntries[], - int op){ + int op) { ICLanguageSettingEntry result[]; - switch(op){ + switch (op) { case OP_ADD:{ Set oldSet = new HashSet(Arrays.asList(oldEntries)); Set newSet = new HashSet(Arrays.asList(newEntries)); newSet.removeAll(oldSet); - if(newSet.size() == 0){ + if (newSet.size() == 0) { result = oldEntries; } else { result = new ICLanguageSettingEntry[oldEntries.length + newSet.size()]; @@ -1519,7 +1511,7 @@ public class PathEntryTranslator { Set oldSet = new HashSet(Arrays.asList(oldEntries)); Set newSet = new HashSet(Arrays.asList(newEntries)); oldSet.removeAll(newSet); - if(oldSet.size() == 0){ + if (oldSet.size() == 0) { result = new ICLanguageSettingEntry[0]; } else { result = new ICLanguageSettingEntry[oldSet.size()]; @@ -1536,20 +1528,20 @@ public class PathEntryTranslator { return result; } - public ReferenceSettingsInfo applyPathEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries, int op){ + public ReferenceSettingsInfo applyPathEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries, int op) { ResolvedEntry[] rEntries = getResolvedEntries(usrEntries, sysEntries); return addPathEntries(rEntries, op); } - private void propagateValues(PathSettingsContainer cr, List langEntryInfoList){ + private void propagateValues(PathSettingsContainer cr, List langEntryInfoList) { RcDesInfo rcDes = (RcDesInfo)cr.getValue(); - if(rcDes != null){ + if (rcDes != null) { List rEntries = rcDes.fResolvedEntries; List curLanfInfos = new ArrayList(rEntries.size() + langEntryInfoList.size()); for (ResolvedEntry re : rEntries) { LangEntryInfo li = createLangEntryInfo(re); - if(li != null){ + if (li != null) { curLanfInfos.add(li); } } @@ -1568,17 +1560,17 @@ public class PathEntryTranslator { } } - private void filterAndPropagate(PathSettingsContainer cr, List list){ + private void filterAndPropagate(PathSettingsContainer cr, List list) { list = new ArrayList(list); IPath path = cr.getPath(); - for(Iterator iter = list.iterator(); iter.hasNext();){ + for (Iterator iter = list.iterator(); iter.hasNext();) { LangEntryInfo li = iter.next(); ResolvedEntry re = li.fResolvedEntry; ResourceInfo[] filters = re.getFilterInfos(); for (ResourceInfo filter : filters) { IResource rc = filter.fRc; IPath projPath = rc.getProjectRelativePath(); - if(projPath.isPrefixOf(path.makeRelative())){ + if (projPath.isPrefixOf(path.makeRelative())) { iter.remove(); break; } @@ -1588,8 +1580,8 @@ public class PathEntryTranslator { propagateValues(cr, list); } - private int toLanguageEntryKind(int peKind){ - switch(peKind){ + private int toLanguageEntryKind(int peKind) { + switch (peKind) { case IPathEntry.CDT_LIBRARY: return ICSettingEntry.LIBRARY_FILE; // case IPathEntry.CDT_PROJECT: @@ -1612,8 +1604,8 @@ public class PathEntryTranslator { return 0; } - private static int peKindToSettingKind(int peKind){ - switch(peKind){ + private static int peKindToSettingKind(int peKind) { + switch (peKind) { case IPathEntry.CDT_LIBRARY: return ICSettingEntry.LIBRARY_FILE; // case IPathEntry.CDT_PROJECT: @@ -1636,7 +1628,7 @@ public class PathEntryTranslator { return 0; } - private ResolvedEntry[] getResolvedEntries(PathEntryResolveInfo info){ + private ResolvedEntry[] getResolvedEntries(PathEntryResolveInfo info) { PathEntryResolveInfoElement els[] = info.getElements(); List list = new ArrayList(); for (PathEntryResolveInfoElement el : els) { @@ -1645,28 +1637,28 @@ public class PathEntryTranslator { return list.toArray(new ResolvedEntry[list.size()]); } - private List getResolvedEntries(PathEntryResolveInfoElement el, List list){ - if(list == null) + private List getResolvedEntries(PathEntryResolveInfoElement el, List list) { + if (list == null) list = new ArrayList(); IPathEntry[] rpEntries = el.getResolvedEntries(); ResolvedEntry resolvedE; IPathEntry rawEntry = el.getRawEntry(); - if(rawEntry.getEntryKind() == IPathEntry.CDT_PROJECT){ + if (rawEntry.getEntryKind() == IPathEntry.CDT_PROJECT) { resolvedE = createResolvedEntry(rawEntry, el); - if(resolvedE != null) + if (resolvedE != null) list.add(resolvedE); } for (IPathEntry rpEntry : rpEntries) { resolvedE = createResolvedEntry(rpEntry, el); - if(resolvedE != null) + if (resolvedE != null) list.add(resolvedE); } return list; } - private ResolvedEntry createResolvedEntry(IPathEntry entry, PathEntryResolveInfoElement el){ - switch(entry.getEntryKind()){ + private ResolvedEntry createResolvedEntry(IPathEntry entry, PathEntryResolveInfoElement el) { + switch (entry.getEntryKind()) { // case IPathEntry.CDT_PROJECT: // //should not be here case IPathEntry.CDT_CONTAINER: @@ -1677,19 +1669,19 @@ public class PathEntryTranslator { } - private ResolvedEntry[] getResolvedEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries){ + private ResolvedEntry[] getResolvedEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries) { int length = usrEntries != null ? usrEntries.length : 0; - if(sysEntries != null) + if (sysEntries != null) length += sysEntries.length; ResolvedEntry[] rEntries = new ResolvedEntry[length]; int num = 0; - if(usrEntries != null){ + if (usrEntries != null) { for (IPathEntry usrEntry : usrEntries) { rEntries[num++] = new ResolvedEntry(usrEntry, false); } } - if(sysEntries != null){ + if (sysEntries != null) { for (IPathEntry sysEntry : sysEntries) { rEntries[num++] = new ResolvedEntry(sysEntry, true); } @@ -1697,26 +1689,26 @@ public class PathEntryTranslator { return rEntries; } - private ResourceInfo[] resolveFilter(IContainer container, IPath path){ + private ResourceInfo[] resolveFilter(IContainer container, IPath path) { IPath containerFullPath = container.getFullPath(); IPath fullPath = containerFullPath.append(path); PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullPath, false, false); ResourceInfo[] baseInfos = (ResourceInfo[])cr.getValue(); ResourceInfo[] result; - if(!baseInfos[0].fExists){ - //resource does not exis, always create new rc info and not add it to map + if (!baseInfos[0].fExists) { + // resource does not exist, always create new rc info and not add it to map ResourceInfo inexistent = new ResourceInfo(container.getFolder(path), false); result = new ResourceInfo[]{inexistent}; } else { - //base exists + // base exists IPath baseTranslatedPath = cr.getPath(); - if(baseTranslatedPath.equals(fullPath)){ + if (baseTranslatedPath.equals(fullPath)) { result = baseInfos; - } else if(containerFullPath.isPrefixOf(baseTranslatedPath)){ + } else if (containerFullPath.isPrefixOf(baseTranslatedPath)) { IPath filterToTranslate = fullPath.removeFirstSegments(baseTranslatedPath.segmentCount()); result = performTranslation(baseTranslatedPath, baseInfos, filterToTranslate); } else { - //should never be here + // should never be here throw new IllegalStateException(); } } @@ -1724,13 +1716,13 @@ public class PathEntryTranslator { return result; } - private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo baseInfos[], IPath filter){ + private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo baseInfos[], IPath filter) { ResourceInfo result[]; int segCount = filter.segmentCount(); String seg; int i = 0; - for(; i < segCount; i++){ - if(!baseInfos[0].fExists) + for (; i < segCount; i++) { + if (!baseInfos[0].fExists) break; seg = filter.segment(0); baseInfos = performTranslation(basePath, baseInfos, seg); @@ -1738,12 +1730,12 @@ public class PathEntryTranslator { filter = filter.removeFirstSegments(1); } - if(i < segCount){ + if (i < segCount) { result = new ResourceInfo[baseInfos.length]; ResourceInfo baseInfo; IFolder rc; - for(int k = 0; k < baseInfos.length; k++){ + for (int k = 0; k < baseInfos.length; k++) { baseInfo = baseInfos[k]; rc = (IFolder)baseInfo.fRc; rc = rc.getFolder(filter); @@ -1756,28 +1748,28 @@ public class PathEntryTranslator { return result; } - private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo[] baseInfos, String seg){ + private ResourceInfo[] performTranslation(IPath basePath, ResourceInfo[] baseInfos, String seg) { IPath filterFullPath = basePath.append(seg); boolean needsParsing = hasSpecChars(seg); List list = new ArrayList(); char[] segChars = seg.toCharArray(); for (ResourceInfo baseInfo : baseInfos) { IResource baseRc = baseInfo.fRc; - if(baseRc.getType() == IResource.FILE){ + if (baseRc.getType() == IResource.FILE) { continue; } else { IContainer baseCr = (IContainer)baseRc; IResource rc = baseCr.findMember(seg); - if(rc != null){ + if (rc != null) { ResourceInfo rcInfo = new ResourceInfo(rc, true); addRcInfoToMap(rcInfo); list.add(rcInfo); - } else if (needsParsing){ + } else if (needsParsing) { try { IResource children[] = baseCr.members(); ResourceInfo rcInfo; for (IResource child : children) { - if(CoreModelUtil.match(segChars, child.getName().toCharArray(), true)){ + if (CoreModelUtil.match(segChars, child.getName().toCharArray(), true)) { rcInfo = new ResourceInfo(child, true); addRcInfoToMap(rcInfo); list.add(rcInfo); @@ -1790,7 +1782,7 @@ public class PathEntryTranslator { } } - if(list.size() == 0){ + if (list.size() == 0) { IFolder f = fRoot.getFolder(filterFullPath); ResourceInfo rcInfo = new ResourceInfo(f, false); addRcInfoToMap(rcInfo); @@ -1803,19 +1795,19 @@ public class PathEntryTranslator { return result; } - private boolean hasSpecChars(String str){ + private boolean hasSpecChars(String str) { for (char ch : SPEC_CHARS) { - if(str.indexOf(ch) != -1) + if (str.indexOf(ch) != -1) return true; } return false; } - private void addResolvedFilterToMap(IPath fullFilterPath ,ResourceInfo[] resolved, boolean check){ - if(check){ + private void addResolvedFilterToMap(IPath fullFilterPath ,ResourceInfo[] resolved, boolean check) { + if (check) { PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullFilterPath, false, false); ResourceInfo[] infos = (ResourceInfo[])cr.getValue(); - if(!infos[0].fExists) + if (!infos[0].fExists) return; } @@ -1823,18 +1815,18 @@ public class PathEntryTranslator { cr.setValue(resolved); } - private ResourceInfo findResourceInfo(IContainer container, IPath relPath, boolean folderIfNotExist){ + private ResourceInfo findResourceInfo(IContainer container, IPath relPath, boolean folderIfNotExist) { IPath fullPath = container.getFullPath().append(relPath); ResourceInfo rcInfo = fResourceMap.get(fullPath); - if(rcInfo == null){ + if (rcInfo == null) { IResource rc = container.findMember(relPath); boolean exists = true; - if(rc == null){ + if (rc == null) { exists = false; - if(container.getType() == IResource.ROOT && relPath.segmentCount() == 1){ + if (container.getType() == IResource.ROOT && relPath.segmentCount() == 1) { rc = fRoot.getProject(relPath.segment(0)); - } else if(folderIfNotExist) { + } else if (folderIfNotExist) { rc = container.getFolder(relPath); } else { rc = container.getFile(relPath); @@ -1847,13 +1839,13 @@ public class PathEntryTranslator { return rcInfo; } - private void addRcInfoToMap(ResourceInfo rcInfo){ + private void addRcInfoToMap(ResourceInfo rcInfo) { IPath fullPath = rcInfo.fRc.getFullPath(); fResourceMap.put(fullPath, rcInfo); addResolvedFilterToMap(fullPath, new ResourceInfo[]{rcInfo}, true); } - public static IPathEntry[] decodePathEntries(IProject project, ICStorageElement el){ + public static IPathEntry[] decodePathEntries(IProject project, ICStorageElement el) { ArrayList pathEntries = new ArrayList(); ICStorageElement children[] = el.getChildren(); for (ICStorageElement child : children) { @@ -1870,9 +1862,9 @@ public class PathEntryTranslator { return entries; } - private static String getAttribute(ICStorageElement el, String attr){ + private static String getAttribute(ICStorageElement el, String attr) { String v = el.getAttribute(attr); - if(v != null) + if (v != null) return v; return ""; //$NON-NLS-1$ } @@ -1923,9 +1915,9 @@ public class PathEntryTranslator { // recreate the entry switch (kind) { - case IPathEntry.CDT_PROJECT : + case IPathEntry.CDT_PROJECT: return CoreModel.newProjectEntry(path, isExported); - case IPathEntry.CDT_LIBRARY : { + case IPathEntry.CDT_LIBRARY: { IPath libraryPath = new Path(getAttribute(element, ATTRIBUTE_LIBRARY)); // source attachment info (optional) IPath sourceAttachmentPath = element.getAttribute(ATTRIBUTE_SOURCEPATH) != null ? new Path( @@ -1941,7 +1933,7 @@ public class PathEntryTranslator { return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); } - case IPathEntry.CDT_SOURCE : { + case IPathEntry.CDT_SOURCE: { // must be an entry in this project or specify another // project String projSegment = path.segment(0); @@ -1952,9 +1944,9 @@ public class PathEntryTranslator { // another project return CoreModel.newProjectEntry(path, isExported); } - case IPathEntry.CDT_OUTPUT : + case IPathEntry.CDT_OUTPUT: return CoreModel.newOutputEntry(path, exclusionPatterns); - case IPathEntry.CDT_INCLUDE : { + case IPathEntry.CDT_INCLUDE: { // include path info IPath includePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE)); // isSysteminclude @@ -1972,7 +1964,7 @@ public class PathEntryTranslator { IPath includeFilePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE_FILE)); return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); } - case IPathEntry.CDT_MACRO : { + case IPathEntry.CDT_MACRO: { String macroName = getAttribute(element, ATTRIBUTE_NAME); String macroValue = getAttribute(element, ATTRIBUTE_VALUE); if (!baseRef.isEmpty()) { @@ -1980,53 +1972,53 @@ public class PathEntryTranslator { } return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported); } - case IPathEntry.CDT_MACRO_FILE : { + case IPathEntry.CDT_MACRO_FILE: { IPath macroFilePath = new Path(getAttribute(element, ATTRIBUTE_MACRO_FILE)); return CoreModel.newMacroFileEntry(path, basePath, baseRef, macroFilePath, exclusionPatterns, isExported); } - case IPathEntry.CDT_CONTAINER : { + case IPathEntry.CDT_CONTAINER: { IPath id = new Path(getAttribute(element, ATTRIBUTE_PATH)); return CoreModel.newContainerEntry(id, isExported); } - default : { + default: { ICModelStatus status = new CModelStatus(IStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$ throw new CModelException(status); } } } - private static CConfigurationData getCfgData(ICConfigurationDescription cfgDes){ + private static CConfigurationData getCfgData(ICConfigurationDescription cfgDes) { return cfgDes instanceof CConfigurationDescriptionCache ? (CConfigurationData)cfgDes : ((IInternalCCfgInfo)cfgDes).getConfigurationData(false); } - private static void addOutputEntries(PathEntryCollector cr, CConfigurationData data){ + private static void addOutputEntries(PathEntryCollector cr, CConfigurationData data) { CBuildData bData = data.getBuildData(); - if(bData != null){ + if (bData != null) { ICOutputEntry oEntries[] = bData.getOutputDirectories(); - if(oEntries != null && oEntries.length != 0){ + if (oEntries != null && oEntries.length != 0) { cr.setSourceOutputEntries(ICSettingEntry.OUTPUT_PATH, oEntries); } } } - public static PathEntryCollector collectEntries(IProject project, ICConfigurationDescription des){ + public static PathEntryCollector collectEntries(IProject project, ICConfigurationDescription des) { CConfigurationData data = getCfgData(des); ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(des); ICConfigurationDescription[] allCfgs = des.isPreferenceConfiguration() ? - new ICConfigurationDescription[]{des} - : des.getProjectDescription().getConfigurations(); + new ICConfigurationDescription[] { des } : + des.getProjectDescription().getConfigurations(); CConfigurationData[] allDatas = new CConfigurationData[allCfgs.length]; - for(int i = 0; i < allCfgs.length; i++){ + for (int i = 0; i < allCfgs.length; i++) { allDatas[i] = getCfgData(allCfgs[i]); } final PathEntryCollector cr = new PathEntryCollector(project/*, des*/); PathSettingsContainer rcDatas = createRcDataHolder(data); ICSourceEntry sEntries[] = data.getSourceEntries(); - if(sEntries != null && sEntries.length != 0){ + if (sEntries != null && sEntries.length != 0) { cr.setSourceOutputEntries(ICSettingEntry.SOURCE_PATH, sEntries); } for (CConfigurationData allData : allDatas) { @@ -2040,15 +2032,14 @@ public class PathEntryTranslator { } final int kinds[] = KindBasedStore.getLanguageEntryKinds(); - rcDatas.accept(new IPathSettingsContainerVisitor(){ - + rcDatas.accept(new IPathSettingsContainerVisitor() { public boolean visit(PathSettingsContainer container) { CResourceData data = (CResourceData)container.getValue(); if (data != null) { PathEntryCollector child = cr.createChild(container.getPath()); for (int kind : kinds) { List list = new ArrayList(); - if(collectResourceDataEntries(kind, data, list)){ + if (collectResourceDataEntries(kind, data, list)) { ICLanguageSettingEntry[] entries = list.toArray(new ICLanguageSettingEntry[list.size()]); child.setEntries(kind, entries, exportedSettings); } @@ -2056,40 +2047,39 @@ public class PathEntryTranslator { } return true; } - }); return cr; } - private static boolean collectResourceDataEntries(int kind, CResourceData data, List list){ + private static boolean collectResourceDataEntries(int kind, CResourceData data, List list) { CLanguageData[] lDatas = null; - if(data instanceof CFolderData) { + if (data instanceof CFolderData) { lDatas = ((CFolderData)data).getLanguageDatas(); - } else if(data instanceof CFileData) { + } else if (data instanceof CFileData) { CLanguageData lData = ((CFileData)data).getLanguageData(); - if (lData!=null) + if (lData != null) lDatas = new CLanguageData[] {lData}; } else { Exception e = new Exception(UtilMessages.getString("PathEntryTranslator.1") + data.getClass().getName()); //$NON-NLS-1$ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e); CCorePlugin.log(status); } - if (lDatas==null || lDatas.length==0) { + if (lDatas == null || lDatas.length == 0) { return false; } boolean supported = false; for (CLanguageData lData : lDatas) { - if(collectLanguageDataEntries(kind, lData, list)) + if (collectLanguageDataEntries(kind, lData, list)) supported = true; } return supported; } - private static boolean collectLanguageDataEntries(int kind, CLanguageData lData, List list){ - if((kind & lData.getSupportedEntryKinds()) != 0){ + private static boolean collectLanguageDataEntries(int kind, CLanguageData lData, List list) { + if ((kind & lData.getSupportedEntryKinds()) != 0) { ICLanguageSettingEntry[] entries = lData.getEntries(kind); - if(entries != null && entries.length != 0){ + if (entries != null && entries.length != 0) { list.addAll(Arrays.asList(entries)); } return true; @@ -2098,7 +2088,7 @@ public class PathEntryTranslator { return false; } - public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfg, int flags){ + public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfg, int flags) { PathEntryCollector cr = collectEntries(project, cfg); return cr.getEntries(flags, cfg); }