diff options
author | Jonah Graham | 2018-11-20 16:20:42 +0000 |
---|---|---|
committer | Jonah Graham | 2018-11-22 21:47:02 +0000 |
commit | 170e654b4796bad1453ae85a427b97317d67a69a (patch) | |
tree | 6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util | |
parent | 35996a5c5ca5c254959ba48241eaada6dbf8628d (diff) | |
download | org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip |
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then
Source -> Clean Up... -> choosing:
- Format source code
- Remove trailing white spaces on all lines
and completing the wizard
Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util')
8 files changed, 420 insertions, 413 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java index a3df4120477..c8ec3492bfa 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CCommandDSC.java @@ -33,58 +33,56 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** - * Class that represents a compiler command and related scanner configuration - * + * Class that represents a compiler command and related scanner configuration + * * @author vhirsl */ public class CCommandDSC { - protected final static String SINGLE_SPACE = " "; //$NON-NLS-1$ - protected final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$ - protected final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$ - protected final static String OPTION_ELEM = "option"; //$NON-NLS-1$ - protected final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$ - protected final static String KEY_ATTR = "key"; //$NON-NLS-1$ - protected final static String VALUE_ATTR = "value"; //$NON-NLS-1$ - protected final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$ - protected final static String KIND_ATTR = "kind"; //$NON-NLS-1$ - + protected final static String SINGLE_SPACE = " "; //$NON-NLS-1$ + protected final static String CMD_DESCRIPTION_ELEM = "commandDescription"; //$NON-NLS-1$ + protected final static String CMD_SI_ELEM = "commandScannerInfo"; //$NON-NLS-1$ + protected final static String OPTION_ELEM = "option"; //$NON-NLS-1$ + protected final static String SI_ITEM_ELEM = "siItem"; //$NON-NLS-1$ + protected final static String KEY_ATTR = "key"; //$NON-NLS-1$ + protected final static String VALUE_ATTR = "value"; //$NON-NLS-1$ + protected final static String QUOTE_INCLUDE_ATTR = "quote"; //$NON-NLS-1$ + protected final static String KIND_ATTR = "kind"; //$NON-NLS-1$ + protected int commandId; - protected List<KVStringPair> compilerCommand; // members are KVStringPair objects + protected List<KVStringPair> compilerCommand; // members are KVStringPair objects protected boolean discovered; - protected boolean cppFileType; // C or C++ file type + protected boolean cppFileType; // C or C++ file type protected IProject project; - protected List<String> symbols; - protected List<String> includes; - protected List<String> quoteIncludes; + protected List<String> symbols; + protected List<String> includes; + protected List<String> quoteIncludes; public CCommandDSC(boolean cppFileType) { this(cppFileType, null); } - + public CCommandDSC(boolean cppFileType, IProject project) { compilerCommand = new ArrayList<KVStringPair>(); discovered = false; this.cppFileType = cppFileType; - - symbols = new ArrayList<String>(); - includes = new ArrayList<String>(); - quoteIncludes = new ArrayList<String>(); - this.project = project; + + symbols = new ArrayList<String>(); + includes = new ArrayList<String>(); + quoteIncludes = new ArrayList<String>(); + this.project = project; + } + + public boolean appliesToCPPFileType() { + return cppFileType; } - public boolean appliesToCPPFileType() { - return cppFileType; - } - public void addSCOption(KVStringPair option) { - if (project != null && - (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()) || - option.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || - option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) || - option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) || - option.getKey().equals(SCDOptionsEnum.IQUOTE.toString()))) - { + if (project != null && (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString()) + || option.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) + || option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) + || option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) + || option.getKey().equals(SCDOptionsEnum.IQUOTE.toString()))) { String value = option.getValue(); value = CygpathTranslator.translateIncludePaths(project, Collections.singletonList(value)).get(0); value = SafeStringInterner.safeIntern(makeRelative(project, new Path(value)).toOSString()); @@ -92,39 +90,40 @@ public class CCommandDSC { } compilerCommand.add(option); } - - public Integer getCommandIdAsInteger() { - return Integer.valueOf(getCommandId()); - } - /** - * @return Returns the commandId. - */ - public int getCommandId() { - return commandId; - } - /** - * @param commandId The commandId to set. - */ - public void setCommandId(int commandId) { - this.commandId = commandId; - } - + + public Integer getCommandIdAsInteger() { + return Integer.valueOf(getCommandId()); + } + + /** + * @return Returns the commandId. + */ + public int getCommandId() { + return commandId; + } + + /** + * @param commandId The commandId to set. + */ + public void setCommandId(int commandId) { + this.commandId = commandId; + } + @Override public String toString() { String commandAsString = ""; //$NON-NLS-1$ - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); String value = optionPair.getValue(); - commandAsString += optionPair.getKey() + SINGLE_SPACE + - value + SINGLE_SPACE; + commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; } return commandAsString.trim(); } - + public int getId() { return commandId; } - + /** * Returns a command where -imacros and -include options have been removed * @param quoteIncludePaths whether or not paths for includes must be put inside double quotes. @@ -132,99 +131,96 @@ public class CCommandDSC { */ public String getSCDRunnableCommand(boolean quoteIncludePaths, boolean quoteDefines) { String commandAsString = ""; //$NON-NLS-1$ - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); - if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { - commandAsString += optionPair.getValue() + SINGLE_SPACE; - } - else { - // skip -include and -imacros options - if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) - continue; - String value = optionPair.getValue(); - if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) || - optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) { - value = makeAbsolute(project, value); - if (quoteIncludePaths) { - value= "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - else if (quoteDefines && optionPair.getKey().equals(SCDOptionsEnum.DEFINE.toString())) { - if (value.indexOf('\'') == -1) { - value= "'" + value + "'"; //$NON-NLS-1$//$NON-NLS-2$ - } - else { - value= value.replaceAll("\"", "\\\\\""); //$NON-NLS-1$//$NON-NLS-2$ - value= "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; - } + if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { + commandAsString += optionPair.getValue() + SINGLE_SPACE; + } else { + // skip -include and -imacros options + if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) + continue; + String value = optionPair.getValue(); + if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.ISYSTEM.toString()) + || optionPair.getKey().equals(SCDOptionsEnum.IQUOTE.toString())) { + value = makeAbsolute(project, value); + if (quoteIncludePaths) { + value = "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + } + } else if (quoteDefines && optionPair.getKey().equals(SCDOptionsEnum.DEFINE.toString())) { + if (value.indexOf('\'') == -1) { + value = "'" + value + "'"; //$NON-NLS-1$//$NON-NLS-2$ + } else { + value = value.replaceAll("\"", "\\\\\""); //$NON-NLS-1$//$NON-NLS-2$ + value = "\"" + value + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + commandAsString += optionPair.getKey() + SINGLE_SPACE + value + SINGLE_SPACE; + } } return commandAsString.trim(); } - + /** * @return the compiler command */ public String getCompilerName() { String compiler = ""; //$NON-NLS-1$ - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); - if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { - compiler = optionPair.getValue(); - break; - } + if (optionPair.getKey().equals(SCDOptionsEnum.COMMAND.toString())) { + compiler = optionPair.getValue(); + break; + } } return compiler.trim(); } - + /** * @return list of strings */ public List<String> getImacrosFile() { List<String> imacrosFiles = new ArrayList<String>(); - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())) { - imacrosFiles.add(makeAbsolute(project,optionPair.getValue())); + imacrosFiles.add(makeAbsolute(project, optionPair.getValue())); } } return imacrosFiles; } - + /** * @return list of strings */ public List<String> getIncludeFile() { List<String> includeFiles = new ArrayList<String>(); - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { KVStringPair optionPair = i.next(); if (optionPair.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())) { - includeFiles.add(makeAbsolute(project,optionPair.getValue())); + includeFiles.add(makeAbsolute(project, optionPair.getValue())); } } return includeFiles; } - -// public List getFilesList() { -// return files; -// } - + + // public List getFilesList() { + // return files; + // } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object arg0) { if (arg0 != null && arg0.getClass().equals(this.getClass())) { - CCommandDSC other = (CCommandDSC)arg0; - return (compilerCommand.equals(other.compilerCommand) && - cppFileType == other.cppFileType); + CCommandDSC other = (CCommandDSC) arg0; + return (compilerCommand.equals(other.compilerCommand) && cppFileType == other.cppFileType); } return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -233,167 +229,170 @@ public class CCommandDSC { return compilerCommand.hashCode(); } - /** - * @return Returns the includes as strings. - */ - public List<String> getIncludes() { - return makeAbsolute(project, includes); - } - /** - * @param includes The includes to set. - */ - public void setIncludes(List<String> includes) { - this.includes = includes; - } - /** - * @return Returns the quote include paths as strings (for #include "...") - */ - public List<String> getQuoteIncludes() { - return makeAbsolute(project, quoteIncludes); - } - /** - * @param includes - quote include paths (for #include "...") - */ - public void setQuoteIncludes(List<String> includes) { - quoteIncludes = includes; - } - /** - * @return Returns the symbols. - */ - public List<String> getSymbols() { - return symbols; - } - /** - * @param symbols The symbols to set. - */ - public void setSymbols(List<String> symbols) { - this.symbols = symbols; - } - /** - * @return Returns the discovered. - */ - public boolean isDiscovered() { - return discovered; - } - /** - * @param discovered The discovered to set. - */ - public void setDiscovered(boolean discovered) { - this.discovered = discovered; - } - - public void serialize(Element cmdElem) { - Document doc = cmdElem.getOwnerDocument(); - // serialize the command - Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM); - for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext(); ) { - Element optionElem = doc.createElement(OPTION_ELEM); - KVStringPair option = i.next(); - optionElem.setAttribute(KEY_ATTR, option.getKey()); - optionElem.setAttribute(VALUE_ATTR, option.getValue()); - cmdDescElem.appendChild(optionElem); - } - cmdElem.appendChild(cmdDescElem); - // serialize includes and symbols - Element siElem = doc.createElement(CMD_SI_ELEM); - for (Iterator<String> j = quoteIncludes.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$ - siElem.appendChild(siItem); - } - for (Iterator<String> j = includes.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siElem.appendChild(siItem); - } - for (Iterator<String> j = symbols.iterator(); j.hasNext(); ) { - Element siItem = doc.createElement(SI_ITEM_ELEM); - siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$ - siItem.setAttribute(VALUE_ATTR, j.next()); - siElem.appendChild(siItem); - } - cmdElem.appendChild(siElem); - } - - public void deserialize(Element cmdElem) { - // read command options - NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM); - if (descList.getLength() > 0) { - Element descElem = (Element) descList.item(0); - NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM); - for (int i = 0; i < optionList.getLength(); ++i) { - Element optionElem = (Element) optionList.item(i); - String key = SafeStringInterner.safeIntern(optionElem.getAttribute(KEY_ATTR)); - String value = SafeStringInterner.safeIntern(optionElem.getAttribute(VALUE_ATTR)); - KVStringPair option = new KVStringPair(key, value); - addSCOption(option); - } - } - // read associated scanner info - NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM); - if (siList.getLength() > 0) { - Element siElem = (Element) siList.item(0); - NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM); - for (int i = 0; i < siItemList.getLength(); ++i) { - Element siItemElem = (Element) siItemList.item(i); - String kind = siItemElem.getAttribute(KIND_ATTR); - String value = siItemElem.getAttribute(VALUE_ATTR); - String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR); - if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$ - if (quote.equals("true")) { //$NON-NLS-1$ - quoteIncludes.add(SafeStringInterner.safeIntern(value)); - } - else { - includes.add(value); - } - } - else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$ - symbols.add(SafeStringInterner.safeIntern(value)); - } - } - setDiscovered(true); - } - } - - public void resolveOptions(IProject project) { - if (!isDiscovered()) { - // that's wrong for sure, options cannot be resolved fron the optionPairs?? - ArrayList<String> symbols = new ArrayList<String>(); - ArrayList<String> includes = new ArrayList<String>(); - ArrayList<String> quoteincludes = new ArrayList<String>(); - for (Iterator<KVStringPair> options = compilerCommand.iterator(); options.hasNext(); ) { - KVStringPair optionPair = options.next(); - String key = optionPair.getKey(); - String value = optionPair.getValue(); - if (key.equals(SCDOptionsEnum.INCLUDE.toString()) || key.equals(SCDOptionsEnum.ISYSTEM.toString())) { - includes.add(SafeStringInterner.safeIntern(value)); - } - else if (key.equals(SCDOptionsEnum.IQUOTE.toString())) { - quoteincludes.add(SafeStringInterner.safeIntern(value)); - } - else if (key.equals(SCDOptionsEnum.DEFINE.toString())) { - symbols.add(SafeStringInterner.safeIntern(value)); - } - } - setIncludes(includes); - setQuoteIncludes(quoteincludes); - setSymbols(symbols); - } - setDiscovered(true); - } - + /** + * @return Returns the includes as strings. + */ + public List<String> getIncludes() { + return makeAbsolute(project, includes); + } + + /** + * @param includes The includes to set. + */ + public void setIncludes(List<String> includes) { + this.includes = includes; + } + + /** + * @return Returns the quote include paths as strings (for #include "...") + */ + public List<String> getQuoteIncludes() { + return makeAbsolute(project, quoteIncludes); + } + + /** + * @param includes - quote include paths (for #include "...") + */ + public void setQuoteIncludes(List<String> includes) { + quoteIncludes = includes; + } + + /** + * @return Returns the symbols. + */ + public List<String> getSymbols() { + return symbols; + } + + /** + * @param symbols The symbols to set. + */ + public void setSymbols(List<String> symbols) { + this.symbols = symbols; + } + + /** + * @return Returns the discovered. + */ + public boolean isDiscovered() { + return discovered; + } + + /** + * @param discovered The discovered to set. + */ + public void setDiscovered(boolean discovered) { + this.discovered = discovered; + } + + public void serialize(Element cmdElem) { + Document doc = cmdElem.getOwnerDocument(); + // serialize the command + Element cmdDescElem = doc.createElement(CMD_DESCRIPTION_ELEM); + for (Iterator<KVStringPair> i = compilerCommand.iterator(); i.hasNext();) { + Element optionElem = doc.createElement(OPTION_ELEM); + KVStringPair option = i.next(); + optionElem.setAttribute(KEY_ATTR, option.getKey()); + optionElem.setAttribute(VALUE_ATTR, option.getValue()); + cmdDescElem.appendChild(optionElem); + } + cmdElem.appendChild(cmdDescElem); + // serialize includes and symbols + Element siElem = doc.createElement(CMD_SI_ELEM); + for (Iterator<String> j = quoteIncludes.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siItem.setAttribute(QUOTE_INCLUDE_ATTR, "true"); //$NON-NLS-1$ + siElem.appendChild(siItem); + } + for (Iterator<String> j = includes.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "INCLUDE_PATH"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siElem.appendChild(siItem); + } + for (Iterator<String> j = symbols.iterator(); j.hasNext();) { + Element siItem = doc.createElement(SI_ITEM_ELEM); + siItem.setAttribute(KIND_ATTR, "SYMBOL_DEFINITION"); //$NON-NLS-1$ + siItem.setAttribute(VALUE_ATTR, j.next()); + siElem.appendChild(siItem); + } + cmdElem.appendChild(siElem); + } + + public void deserialize(Element cmdElem) { + // read command options + NodeList descList = cmdElem.getElementsByTagName(CMD_DESCRIPTION_ELEM); + if (descList.getLength() > 0) { + Element descElem = (Element) descList.item(0); + NodeList optionList = descElem.getElementsByTagName(OPTION_ELEM); + for (int i = 0; i < optionList.getLength(); ++i) { + Element optionElem = (Element) optionList.item(i); + String key = SafeStringInterner.safeIntern(optionElem.getAttribute(KEY_ATTR)); + String value = SafeStringInterner.safeIntern(optionElem.getAttribute(VALUE_ATTR)); + KVStringPair option = new KVStringPair(key, value); + addSCOption(option); + } + } + // read associated scanner info + NodeList siList = cmdElem.getElementsByTagName(CMD_SI_ELEM); + if (siList.getLength() > 0) { + Element siElem = (Element) siList.item(0); + NodeList siItemList = siElem.getElementsByTagName(SI_ITEM_ELEM); + for (int i = 0; i < siItemList.getLength(); ++i) { + Element siItemElem = (Element) siItemList.item(i); + String kind = siItemElem.getAttribute(KIND_ATTR); + String value = siItemElem.getAttribute(VALUE_ATTR); + String quote = siItemElem.getAttribute(QUOTE_INCLUDE_ATTR); + if (kind.equals("INCLUDE_PATH")) { //$NON-NLS-1$ + if (quote.equals("true")) { //$NON-NLS-1$ + quoteIncludes.add(SafeStringInterner.safeIntern(value)); + } else { + includes.add(value); + } + } else if (kind.equals("SYMBOL_DEFINITION")) { //$NON-NLS-1$ + symbols.add(SafeStringInterner.safeIntern(value)); + } + } + setDiscovered(true); + } + } + + public void resolveOptions(IProject project) { + if (!isDiscovered()) { + // that's wrong for sure, options cannot be resolved fron the optionPairs?? + ArrayList<String> symbols = new ArrayList<String>(); + ArrayList<String> includes = new ArrayList<String>(); + ArrayList<String> quoteincludes = new ArrayList<String>(); + for (Iterator<KVStringPair> options = compilerCommand.iterator(); options.hasNext();) { + KVStringPair optionPair = options.next(); + String key = optionPair.getKey(); + String value = optionPair.getValue(); + if (key.equals(SCDOptionsEnum.INCLUDE.toString()) || key.equals(SCDOptionsEnum.ISYSTEM.toString())) { + includes.add(SafeStringInterner.safeIntern(value)); + } else if (key.equals(SCDOptionsEnum.IQUOTE.toString())) { + quoteincludes.add(SafeStringInterner.safeIntern(value)); + } else if (key.equals(SCDOptionsEnum.DEFINE.toString())) { + symbols.add(SafeStringInterner.safeIntern(value)); + } + } + setIncludes(includes); + setQuoteIncludes(quoteincludes); + setSymbols(symbols); + } + setDiscovered(true); + } + public static IPath makeRelative(IProject project, IPath path) { IResource resource = findResource(project, path); if (resource != null) { if (resource.getProject() == project) { path = resource.getProjectRelativePath(); } -// else { -// path = resource.getFullPath(); -// } + // else { + // path = resource.getFullPath(); + // } } return path; } @@ -404,7 +403,7 @@ public class CCommandDSC { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); resource = root.findMember(path, false); if (resource == null) { - resource= ResourceLookup.selectFileForLocation(path, project); + resource = ResourceLookup.selectFileForLocation(path, project); } } return resource; @@ -412,7 +411,7 @@ public class CCommandDSC { public static List<String> makeRelative(IProject project, List<String> paths) { List<String> list = new ArrayList<String>(paths.size()); - for (Iterator<String> iter=paths.iterator(); iter.hasNext(); ) { + for (Iterator<String> iter = paths.iterator(); iter.hasNext();) { String path = iter.next(); path = makeRelative(project, new Path(path)).toOSString(); list.add(SafeStringInterner.safeIntern(path)); @@ -420,7 +419,6 @@ public class CCommandDSC { return list; } - public static final String makeAbsolute(IProject project, String path) { IPath ppath = new Path(path); if (project != null && !ppath.isAbsolute()) { @@ -435,14 +433,14 @@ public class CCommandDSC { path = ppath.toOSString(); } } -// path = new File(project.getLocation().toOSString(), path).getAbsolutePath(); + // path = new File(project.getLocation().toOSString(), path).getAbsolutePath(); } return SafeStringInterner.safeIntern(path); } public static List<String> makeAbsolute(IProject project, List<String> paths) { List<String> list = new ArrayList<String>(paths.size()); - for (Iterator<String> iter=paths.iterator(); iter.hasNext(); ) { + for (Iterator<String> iter = paths.iterator(); iter.hasNext();) { String path = iter.next(); path = makeAbsolute(project, path); list.add(SafeStringInterner.safeIntern(path)); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java index c19dfd95f6b..5ed1a7e566a 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/CygpathTranslator.java @@ -42,7 +42,7 @@ import org.eclipse.core.runtime.Platform; /** * Use binary parser's 'cygpath' command to translate cygpaths to absolute paths. * Note that this class does not support build configurations. - * + * * @author vhirsl */ public class CygpathTranslator { @@ -63,8 +63,7 @@ public class CygpathTranslator { } catch (ClassCastException e) { } } - } - catch (CoreException e) { + } catch (CoreException e) { } } @@ -72,7 +71,7 @@ public class CygpathTranslator { // first check if cygpath translation is needed at all boolean translationNeeded = false; if (Platform.getOS().equals(Platform.OS_WIN32)) { - for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) { + for (Iterator<String> i = sumIncludes.iterator(); i.hasNext();) { String include = i.next(); if (include.startsWith("/")) { //$NON-NLS-1$ translationNeeded = true; @@ -113,22 +112,20 @@ public class CygpathTranslator { } List<String> translatedIncludePaths = new ArrayList<String>(); - for (Iterator<String> i = sumIncludes.iterator(); i.hasNext(); ) { + for (Iterator<String> i = sumIncludes.iterator(); i.hasNext();) { String includePath = i.next(); IPath realPath = new Path(includePath); // only allow native pathes if they have a device prefix // to avoid matches on the current drive, e.g. /usr/bin = C:\\usr\\bin if (realPath.getDevice() != null && realPath.toFile().exists()) { translatedIncludePaths.add(includePath); - } - else { + } else { String translatedPath = includePath; if (useCygPathExtension) { try { translatedPath = cygpath.cygPath.getFileName(includePath); - } - catch (IOException e) { + } catch (IOException e) { TraceUtil.outputError("CygpathTranslator unable to translate path: ", includePath); //$NON-NLS-1$ } } else if (useCygwinFromPath) { @@ -141,9 +138,10 @@ public class CygpathTranslator { // try default conversions // /cygdrive/x/ --> X:\ if ("cygdrive".equals(realPath.segment(0))) { //$NON-NLS-1$ - String drive= realPath.segment(1); + String drive = realPath.segment(1); if (drive.length() == 1) { - translatedPath= realPath.removeFirstSegments(2).makeAbsolute().setDevice(drive.toUpperCase() + ':').toOSString(); + translatedPath = realPath.removeFirstSegments(2).makeAbsolute() + .setDevice(drive.toUpperCase() + ':').toOSString(); } } } @@ -151,16 +149,13 @@ public class CygpathTranslator { // Check if the translated path exists if (new File(translatedPath).exists()) { translatedIncludePaths.add(translatedPath); - } - else if (useCygPathExtension || useCygwinFromPath) { + } else if (useCygPathExtension || useCygwinFromPath) { // TODO VMIR for now add even if it does not exist translatedIncludePaths.add(translatedPath); - } - else { + } else { translatedIncludePaths.add(includePath); } - } - else { + } else { // TODO VMIR for now add even if it does not exist translatedIncludePaths.add(translatedPath); } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java index d05ead6a63f..71fe959e9ee 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/KVStringPair.java @@ -15,28 +15,29 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.util; /** * Key - Value String Pair - * + * * @author vhirsl */ public class KVStringPair { private String key; private String value; - + /** - * + * */ public KVStringPair(String key, String value) { this.key = key; this.value = value; } - + public String getKey() { return key; } - + public String getValue() { return value; } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @@ -48,6 +49,7 @@ public class KVStringPair { } return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -55,6 +57,7 @@ public class KVStringPair { public int hashCode() { return 17 * key.hashCode() + value.hashCode(); } + /* (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java index d30d1f434db..6a90e090447 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/LogWriter.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation *******************************************************************************/ @@ -29,14 +29,14 @@ import org.eclipse.core.runtime.IStatus; /** * Log writer utility - * + * * @author vhirsl */ public class LogWriter { protected File logFile = null; protected Writer log = null; protected boolean newSession = true; - + protected static final String SESSION = "*** SESSION";//$NON-NLS-1$ protected static final String ENTRY = "ENTRY";//$NON-NLS-1$ protected static final String SUBENTRY = "SUBENTRY";//$NON-NLS-1$ @@ -52,16 +52,16 @@ public class LogWriter { } /** - * + * */ public LogWriter(File log) { this.logFile = log; - if(log.length() > MAXLOG_SIZE){ - log.delete(); + if (log.length() > MAXLOG_SIZE) { + log.delete(); } openLogFile(); } - + protected void closeLogFile() throws IOException { try { if (log != null) { @@ -72,10 +72,11 @@ public class LogWriter { log = null; } } - + protected void openLogFile() { try { - log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$ + log = new BufferedWriter( + new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$ if (newSession) { writeHeader(); newSession = false; @@ -85,6 +86,7 @@ public class LogWriter { //log = logForStream(System.err); } } + protected void writeHeader() throws IOException { writeln(); write(SESSION); @@ -92,12 +94,12 @@ public class LogWriter { String date = getDate(); write(date); writeSpace(); - for (int i=SESSION.length()+date.length(); i<78; i++) { + for (int i = SESSION.length() + date.length(); i < 78; i++) { write("-");//$NON-NLS-1$ } writeln(); } - + protected String getDate() { try { DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$ @@ -117,6 +119,7 @@ public class LogWriter { write(s); writeln(); } + /** * Shuts down the log. */ @@ -151,17 +154,18 @@ public class LogWriter { writeln("0");//$NON-NLS-1$ throwable.printStackTrace(new PrintWriter(log)); if (isCoreException) { - CoreException e = (CoreException) throwable; - write(e.getStatus(), 0); + CoreException e = (CoreException) throwable; + write(e.getStatus(), 0); } } - public synchronized void log(IStatus status){ + public synchronized void log(IStatus status) { try { this.write(status, 0); } catch (IOException e) { } } + protected void write(IStatus status, int depth) throws IOException { if (depth == 0) { write(ENTRY); @@ -190,7 +194,7 @@ public class LogWriter { if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { - write(children[i], depth+1); + write(children[i], depth + 1); } } } @@ -198,19 +202,21 @@ public class LogWriter { protected void writeln() throws IOException { write(LINE_SEPARATOR); } + protected void write(String message) throws IOException { if (message != null) log.write(message); } + protected void writeSpace() throws IOException { write(" ");//$NON-NLS-1$ } - - public synchronized void flushLog(){ + + public synchronized void flushLog() { try { log.flush(); - } catch (IOException e) {} + } catch (IOException e) { + } } - } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java index fd81f98cbfa..9067165d611 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/PathInfoToLangSettingsConverter.java @@ -26,28 +26,25 @@ import org.eclipse.cdt.make.core.scannerconfig.PathInfo; import org.eclipse.core.runtime.IPath; public class PathInfoToLangSettingsConverter { - public static int getSupportedEntryKinds(IDiscoveredPathInfo info){ - if(info instanceof IPerFileDiscoveredPathInfo){ - return getSupportedEntryKinds((IPerFileDiscoveredPathInfo)info); + public static int getSupportedEntryKinds(IDiscoveredPathInfo info) { + if (info instanceof IPerFileDiscoveredPathInfo) { + return getSupportedEntryKinds((IPerFileDiscoveredPathInfo) info); } - return ICLanguageSettingEntry.INCLUDE_PATH - | ICLanguageSettingEntry.MACRO; + return ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO; } - public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info){ - return ICLanguageSettingEntry.INCLUDE_FILE - | ICLanguageSettingEntry.INCLUDE_PATH - | ICLanguageSettingEntry.MACRO - | ICLanguageSettingEntry.MACRO_FILE; + public static int getSupportedEntryKinds(IPerFileDiscoveredPathInfo info) { + return ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO + | ICLanguageSettingEntry.MACRO_FILE; } - public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info){ + public static ICLanguageSettingEntry[] entriesForKind(int kind, int flags, PathInfo info) { switch (kind) { case ICLanguageSettingEntry.INCLUDE_PATH: ICLanguageSettingEntry[] incPaths = calculateEntries(kind, flags, info.getIncludePaths()); IPath[] quotedPaths = info.getQuoteIncludePaths(); - if(quotedPaths.length != 0){ - if(incPaths.length != 0){ + if (quotedPaths.length != 0) { + if (incPaths.length != 0) { ICLanguageSettingEntry quotedEntries[] = calculateEntries(kind, flags, quotedPaths); ICLanguageSettingEntry[] tmp = new ICLanguageSettingEntry[incPaths.length + quotedEntries.length]; System.arraycopy(incPaths, 0, tmp, 0, incPaths.length); @@ -68,15 +65,15 @@ public class PathInfoToLangSettingsConverter { return new ICLanguageSettingEntry[0]; } - private static ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values){ + private static ICLanguageSettingEntry[] calculateEntries(int kind, int flags, IPath[] values) { ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[values.length]; - for(int i = 0; i < values.length; i++){ - entries[i] = (ICLanguageSettingEntry)CDataUtil.createEntry(kind, values[i].toString(), null, null, flags); + for (int i = 0; i < values.length; i++) { + entries[i] = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, values[i].toString(), null, null, flags); } return entries; } - private static ICMacroEntry[] calculateEntries(int flags, Map<String, String> map){ + private static ICMacroEntry[] calculateEntries(int flags, Map<String, String> map) { ICMacroEntry entries[] = new ICMacroEntry[map.size()]; int num = 0; Set<Entry<String, String>> entrySet = map.entrySet(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java index 5efa17f273f..84bfbf56f67 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SCDOptionsEnum.java @@ -16,53 +16,51 @@ package org.eclipse.cdt.make.internal.core.scannerconfig.util; /** * Enumeration class for scanner configuration affecting command line options - * + * * @author vhirsl */ public final class SCDOptionsEnum { - public static final SCDOptionsEnum COMMAND = new SCDOptionsEnum(0); // gcc or similar command + public static final SCDOptionsEnum COMMAND = new SCDOptionsEnum(0); // gcc or similar command public static final int MIN = 1; - public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name - public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name - public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I- - public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir - public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc - public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++ - public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file - public static final SCDOptionsEnum IMACROS_FILE = new SCDOptionsEnum(8); // -imacros file - public static final SCDOptionsEnum IDIRAFTER = new SCDOptionsEnum(9); // -idirafter dir - public static final SCDOptionsEnum ISYSTEM = new SCDOptionsEnum(10); // -isystem dir - public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix - public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir - public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir - public static final SCDOptionsEnum IQUOTE = new SCDOptionsEnum(14); // -iquote dir + public static final SCDOptionsEnum DEFINE = new SCDOptionsEnum(1); // -D name + public static final SCDOptionsEnum UNDEFINE = new SCDOptionsEnum(2); // -U name + public static final SCDOptionsEnum IDASH = new SCDOptionsEnum(3); // -I- + public static final SCDOptionsEnum INCLUDE = new SCDOptionsEnum(4); // -I dir + public static final SCDOptionsEnum NOSTDINC = new SCDOptionsEnum(5); // -nostdinc + public static final SCDOptionsEnum NOSTDINCPP = new SCDOptionsEnum(6); // -nostdinc++ + public static final SCDOptionsEnum INCLUDE_FILE = new SCDOptionsEnum(7); // -include file + public static final SCDOptionsEnum IMACROS_FILE = new SCDOptionsEnum(8); // -imacros file + public static final SCDOptionsEnum IDIRAFTER = new SCDOptionsEnum(9); // -idirafter dir + public static final SCDOptionsEnum ISYSTEM = new SCDOptionsEnum(10); // -isystem dir + public static final SCDOptionsEnum IPREFIX = new SCDOptionsEnum(11); // -iprefix prefix + public static final SCDOptionsEnum IWITHPREFIX = new SCDOptionsEnum(12); // -iwithprefix dir + public static final SCDOptionsEnum IWITHPREFIXBEFORE = new SCDOptionsEnum(13); // -iwithprefixbefore dir + public static final SCDOptionsEnum IQUOTE = new SCDOptionsEnum(14); // -iquote dir public static final int MAX = 14; - - private static final String[] SCDOPTION_STRING_VALS = { - "cc", //$NON-NLS-1$ - "-D", //$NON-NLS-1$ - "-U", //$NON-NLS-1$ - "-I-", //$NON-NLS-1$ - "-I", //$NON-NLS-1$ - "-nostdinc", //$NON-NLS-1$ - "-nostdinc++", //$NON-NLS-1$ - "-include", //$NON-NLS-1$ - "-imacros", //$NON-NLS-1$ - "-idirafter", //$NON-NLS-1$ - "-isystem", //$NON-NLS-1$ - "-iprefix", //$NON-NLS-1$ - "-iwithprefix", //$NON-NLS-1$ - "-iwithprefixbefore", //$NON-NLS-1$ - "-iquote" //$NON-NLS-1$ - }; - private static final SCDOptionsEnum SCDOPTIONS[] = { - COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, - IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE, IQUOTE + + private static final String[] SCDOPTION_STRING_VALS = { "cc", //$NON-NLS-1$ + "-D", //$NON-NLS-1$ + "-U", //$NON-NLS-1$ + "-I-", //$NON-NLS-1$ + "-I", //$NON-NLS-1$ + "-nostdinc", //$NON-NLS-1$ + "-nostdinc++", //$NON-NLS-1$ + "-include", //$NON-NLS-1$ + "-imacros", //$NON-NLS-1$ + "-idirafter", //$NON-NLS-1$ + "-isystem", //$NON-NLS-1$ + "-iprefix", //$NON-NLS-1$ + "-iwithprefix", //$NON-NLS-1$ + "-iwithprefixbefore", //$NON-NLS-1$ + "-iquote" //$NON-NLS-1$ }; - + private static final SCDOptionsEnum SCDOPTIONS[] = { COMMAND, DEFINE, UNDEFINE, IDASH, INCLUDE, NOSTDINC, + NOSTDINCPP, INCLUDE_FILE, IMACROS_FILE, IDIRAFTER, ISYSTEM, IPREFIX, IWITHPREFIX, IWITHPREFIXBEFORE, + IQUOTE }; + /** - * + * */ private SCDOptionsEnum(int val) { this._enum = val; @@ -71,40 +69,45 @@ public final class SCDOptionsEnum { public int getEnumValue() { return _enum; } - + public static SCDOptionsEnum getSCDOptionsEnum(int val) { if (val >= 0 && val <= MAX) { return SCDOPTIONS[val]; } return null; } - - public static SCDOptionsEnum getSCDOptionsEnum(String desc) { - for (int i = 0; i <= MAX; ++i) { - if (desc.equals(SCDOPTION_STRING_VALS[i])) { - return SCDOPTIONS[i]; - } - } - return null; - } - + + public static SCDOptionsEnum getSCDOptionsEnum(String desc) { + for (int i = 0; i <= MAX; ++i) { + if (desc.equals(SCDOPTION_STRING_VALS[i])) { + return SCDOPTIONS[i]; + } + } + return null; + } + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object arg0) { - if (arg0 == null) return false; - if (arg0 == this) return true; - if (arg0 instanceof SCDOptionsEnum) return (_enum == ((SCDOptionsEnum)arg0)._enum); + if (arg0 == null) + return false; + if (arg0 == this) + return true; + if (arg0 instanceof SCDOptionsEnum) + return (_enum == ((SCDOptionsEnum) arg0)._enum); return false; } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { - return _enum*17 + 11; + return _enum * 17 + 11; } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -112,6 +115,6 @@ public final class SCDOptionsEnum { public String toString() { return SCDOPTION_STRING_VALS[_enum]; } - + private final int _enum; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java index 1d88ea545aa..9b01afc6710 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java @@ -21,7 +21,6 @@ import java.util.Map; import org.eclipse.cdt.internal.core.SafeStringInterner; - /** * Represents a symbol definition with possible multiple values * example: @@ -31,10 +30,10 @@ import org.eclipse.cdt.internal.core.SafeStringInterner; * @author vhirsl */ public class SymbolEntry { - private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$ + private static final String UNSPECIFIED_VALUE = "1"; //$NON-NLS-1$ private String name; - private Map<String, Boolean> values; // Values can be either in the active (selected) group or in the removed group - + private Map<String, Boolean> values; // Values can be either in the active (selected) group or in the removed group + public SymbolEntry(String name, String value, boolean active) { this.name = SafeStringInterner.safeIntern(name); if (values == null) { @@ -44,42 +43,45 @@ public class SymbolEntry { } public boolean add(String value, boolean active) { - Boolean old= values.put(SafeStringInterner.safeIntern(value), Boolean.valueOf(active)); + Boolean old = values.put(SafeStringInterner.safeIntern(value), Boolean.valueOf(active)); return old == null || old.booleanValue() != active; } - + public void remove(String value) { values.remove(value); } - + public void removeAll() { values = null; } - + public List<String> getActive() { return get(true, true, true); } + public List<String> getActiveRaw() { return get(false, true, true); } - + public List<String> getRemoved() { return get(true, true, false); } + public List<String> getRemovedRaw() { return get(false, true, false); } - + public List<String> getAll() { return get(true, false, true /*don't care*/); } + public List<String> getAllRaw() { return get(false, false, true /*don't care*/); } /** * Utility function to retrieve values as a set. - * + * * @param format - false = raw * @param subset - false = all * @param active - false = removed @@ -92,13 +94,13 @@ public class SymbolEntry { continue; if (format) { rv.add(name + "=" + (val == null ? UNSPECIFIED_VALUE : val));//$NON-NLS-1$ - } - else { + } else { rv.add(name + (val == null ? "" : "=" + val));//$NON-NLS-1$ //$NON-NLS-2$ - } + } } return rv; } + /** * Returns only value part of all active entries * @return List @@ -113,11 +115,11 @@ public class SymbolEntry { } return rv; } - + public int numberOfValues() { return values.size(); } - + @Override public String toString() { StringBuilder buffer = new StringBuilder(name); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java index 427cc0b56d1..b7570a541fb 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/TraceUtil.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM - Initial API and implementation * Markus Schorn (Wind River Systems) @@ -31,11 +31,12 @@ public class TraceUtil { public static final String EOL = System.getProperty("line.separator"); //$NON-NLS-1$ public static boolean SCANNER_CONFIG = false; private static LogWriter logger = null; - + static { - if (MakeCorePlugin.getDefault()!=null) // in case of running simple junit tests + if (MakeCorePlugin.getDefault() != null) // in case of running simple junit tests logger = new LogWriter(MakeCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$ } + /* (non-Javadoc) * @see java.lang.Object#finalize() */ @@ -44,17 +45,17 @@ public class TraceUtil { logger.shutdown(); super.finalize(); } - + public static boolean isTracing() { return SCANNER_CONFIG; } - + public static void outputTrace(String prefix, String[] tokens, String postfix) { if (isTracing()) { System.out.print(prefix + ' '); for (int i = 0; i < tokens.length; i++) { System.out.print(tokens[i] + ' '); - + } System.out.println(postfix); } @@ -65,7 +66,7 @@ public class TraceUtil { System.out.println(prefix + ' ' + msg + ' ' + postfix); } } - + /** * For traces of type: * Title: @@ -78,21 +79,23 @@ public class TraceUtil { * item2[1] * ... */ - public static void outputTrace(String title, String subtitle1, List<String> item1, List<String> item1new, String subtitle2, List<String> item2) { + public static void outputTrace(String title, String subtitle1, List<String> item1, List<String> item1new, + String subtitle2, List<String> item2) { if (isTracing()) { //System.out.println(); System.out.println(title); - final String prefix = " "; //$NON-NLS-1$ - final String doublePrefix = " "; //$NON-NLS-1$ - System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ + final String prefix = " "; //$NON-NLS-1$ + final String doublePrefix = " "; //$NON-NLS-1$ + System.out.println(prefix + subtitle1 + " (" + item1.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ int count = 0; - for (Iterator<String> i = item1.iterator(), j = item1new.iterator(); i.hasNext(); ) { - System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" +i.next() + (j.hasNext()?"\' -> \'" + j.next():"") + '\''); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + for (Iterator<String> i = item1.iterator(), j = item1new.iterator(); i.hasNext();) { + System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() //$NON-NLS-1$ + + (j.hasNext() ? "\' -> \'" + j.next() : "") + '\''); //$NON-NLS-1$ //$NON-NLS-2$ } - System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println(prefix + subtitle2 + " (" + item2.size() + "):"); //$NON-NLS-1$ //$NON-NLS-2$ count = 0; - for (Iterator<String> i = item2.iterator(); i.hasNext(); ) { - System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() + '\''); //$NON-NLS-1$ + for (Iterator<String> i = item2.iterator(); i.hasNext();) { + System.out.println(doublePrefix + String.valueOf(++count) + "\t\'" + i.next() + '\''); //$NON-NLS-1$ } } } @@ -139,8 +142,8 @@ public class TraceUtil { } } logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } public static void summaryTrace(String title, int workingDirsN, int commandsN, int filesN) { @@ -153,8 +156,8 @@ public class TraceUtil { logger.writeln(" Number of generic commands: " + Integer.toString(commandsN)); //$NON-NLS-1$ logger.writeln(" Number of compiled files: " + Integer.toString(filesN)); //$NON-NLS-1$ logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } /** @@ -167,8 +170,8 @@ public class TraceUtil { logger.writeln(); logger.writeln(trace); logger.flushLog(); + } catch (IOException e) { } - catch (IOException e) {} } } |