1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 17:55:39 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-05-02 10:24:38 -07:00
parent ddb8ab8708
commit 355027f0c9
25 changed files with 751 additions and 761 deletions

View file

@ -51,13 +51,13 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
@ -114,7 +114,7 @@ public class AST2TestBase extends BaseTestCase {
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
private static Map<String, String> getGnuMap() {
Map<String, String> map= new HashMap<String, String>();
Map<String, String> map= new HashMap<>();
map.put("__GNUC__", Integer.toString(GPPLanguage.GNU_LATEST_VERSION_MAJOR));
map.put("__GNUC_MINOR__", Integer.toString(GPPLanguage.GNU_LATEST_VERSION_MINOR));
map.put("__SIZEOF_SHORT__", "2");
@ -125,7 +125,7 @@ public class AST2TestBase extends BaseTestCase {
}
private static Map<String, String> getStdMap() {
Map<String, String> map= new HashMap<String, String>();
Map<String, String> map= new HashMap<>();
map.put("__SIZEOF_SHORT__", "2");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
@ -312,7 +312,7 @@ public class AST2TestBase extends BaseTestCase {
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
}
public List<IASTName> nameList = new ArrayList<IASTName>();
public List<IASTName> nameList = new ArrayList<>();
@Override
public int visit(IASTName name) {
@ -408,7 +408,7 @@ public class AST2TestBase extends BaseTestCase {
}
public int numProblemBindings;
public int numNullBindings;
public List<IASTName> nameList = new ArrayList<IASTName>();
public List<IASTName> nameList = new ArrayList<>();
@Override
public int visit(IASTName name) {
@ -438,7 +438,7 @@ public class AST2TestBase extends BaseTestCase {
}
public int numProblemBindings;
public int numNullBindings;
public List<IASTName> nameList = new ArrayList<IASTName>();
public List<IASTName> nameList = new ArrayList<>();
@Override
public int visit(IASTName name) {

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
import org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver;
public abstract class PreprocessorTestsBase extends BaseTestCase {
private static final IParserLogService NULL_LOG = new NullLogService();
protected CPreprocessor fScanner;
protected ILocationResolver fLocationResolver;
@ -81,8 +80,7 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
if (scannerConfig == null) {
if (lang == ParserLanguage.C) {
scannerConfig= GCCScannerExtensionConfiguration.getInstance();
}
else {
} else {
scannerConfig= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
}
}
@ -176,8 +174,7 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
try {
IToken t= fScanner.nextToken();
fail("superfluous token " + t);
}
catch(EndOfFileException e) {
} catch(EndOfFileException e) {
}
}
@ -211,5 +208,4 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
assertEquals(detail, problem.getArguments()[0]);
}
}
}

View file

@ -18,8 +18,6 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.zip.ZipFile;
import junit.framework.Assert;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
@ -61,7 +59,9 @@ import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
import org.junit.Assert;
import org.osgi.framework.Bundle;
/**
* Helper methods to set up a ICProject.
*/

View file

@ -8,7 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.testplugin;
// copied from startup.jar. planned to be removed soon
@ -73,12 +72,12 @@ public class Main {
/**
* Indicates whether this instance is running in debug mode.
*/
protected boolean debug = false;
protected boolean debug;
/**
* The location of the launcher to run.
*/
protected String bootLocation = null;
protected String bootLocation;
/**
* The identifier of the application to run.
@ -98,7 +97,7 @@ public class Main {
/**
* Indicates whether items for UNinstallation should be looked for.
*/
protected boolean uninstall = false;
protected boolean uninstall;
/**
* The item to be uninstalled.
@ -108,15 +107,15 @@ public class Main {
/**
* The class path entries.
*/
protected String devClassPath = null;
protected String devClassPath;
/**
* Indicates whether this instance is running in development mode.
*/
protected boolean inDevelopmentMode = false;
protected boolean inDevelopmentMode;
// static token describing how to take down the splash screen
private static String endSplash = null;
private static String endSplash;
// constants
private static final String APPLICATION = "-application";
@ -181,7 +180,7 @@ protected Object basicRun(String[] args) throws Exception {
private String[] getArrayFromList(String prop) {
if (prop == null || prop.trim().equals(""))
return new String[0];
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
StringTokenizer tokens = new StringTokenizer(prop, ",");
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
@ -190,6 +189,7 @@ private String[] getArrayFromList(String prop) {
}
return list.toArray(new String[list.size()]);
}
/**
* Creates and returns a platform <code>BootLoader</code> which can be used to start
* up and run the platform. The given base, if not <code>null</code>,
@ -200,9 +200,11 @@ private String[] getArrayFromList(String prop) {
* @param base the location of the boot loader
*/
public Class getBootLoader(String base) throws Exception {
URLClassLoader loader = new URLClassLoader(getBootPath(base), null);
try (URLClassLoader loader = new URLClassLoader(getBootPath(base), null)) {
return loader.loadClass(BOOTLOADER);
}
}
/**
* Returns the <code>URL</code>-based class path describing where the boot classes
* are located when running in development mode.
@ -346,6 +348,7 @@ protected String searchForBoot(String start) {
throw new RuntimeException("Could not find bootstrap code. Check location of boot plug-in or specify -boot.");
return result.replace(File.separatorChar, '/') + "/";
}
/**
* Returns the update loader for the given boot path.
*
@ -354,9 +357,11 @@ protected String searchForBoot(String start) {
* @exception Exception thrown is a problem occurs determining this loader
*/
public Class getUpdateLoader(String base) throws Exception {
URLClassLoader loader = new URLClassLoader(getBootPath(base), null);
try (URLClassLoader loader = new URLClassLoader(getBootPath(base), null)) {
return loader.loadClass(UPDATELOADER);
}
}
/**
* Runs the platform with the given arguments. The arguments must identify
* an application to run (e.g., <code>-application com.example.application</code>).
@ -503,6 +508,7 @@ protected String[] processCommandLine(String[] args) throws Exception {
}
return passThruArgs;
}
/**
* Runs the application to be launched.
*
@ -517,6 +523,7 @@ public Object run(String[] args) throws Exception {
else
return basicRun(passThruArgs);
}
/**
* Performs an update run.
*

View file

@ -24,7 +24,7 @@ public class TestScannerProvider extends AbstractCExtension implements IScannerI
public static String[] sIncludes;
public static String[] sIncludeFiles;
public static String[] sMacroFiles;
public static Map<String, String> sDefinedSymbols = new HashMap<String, String>();
public static Map<String, String> sDefinedSymbols = new HashMap<>();
public final static String SCANNER_ID = CTestPlugin.PLUGIN_ID + ".TestScanner";
public static void clear() {

View file

@ -15,7 +15,6 @@ import org.eclipse.core.runtime.IPath;
/**
* Helper interface capturing 'path' characteristic for {@link ICSettingEntry}
* and {@link ICLanguageSettingEntry} interfaces.
*
*/
public interface ICPathEntry extends ICSettingEntry {
IPath getFullPath();
@ -23,5 +22,4 @@ public interface ICPathEntry extends ICSettingEntry {
IPath getLocation();
boolean isValueWorkspacePath();
}

View file

@ -76,14 +76,14 @@ public class CDataUtil {
private static final String DELIM = " "; //$NON-NLS-1$
private static Random randomNumber;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
public static final String[] EMPTY_STRING_ARRAY = {};
/**
* Pool of setting entries implemented as WeakHashSet. That allows to gain memory savings
* at the expense of CPU time. WeakHashSet handles garbage collection when a list is not
* referenced anywhere else. See JavaDoc {@link java.lang.ref.WeakReference} about weak reference objects.
*/
private static WeakHashSet<ICSettingEntry> settingEntriesPool = new WeakHashSetSynchronized<ICSettingEntry>();
private static WeakHashSet<ICSettingEntry> settingEntriesPool = new WeakHashSetSynchronized<>();
public static int genRandomNumber() {
if (randomNumber == null) {
@ -101,8 +101,8 @@ public class CDataUtil {
public static String genId(String baseId) {
String suffix = new Integer(genRandomNumber()).toString();
return baseId != null ?
new StringBuffer(baseId).append(".").append(suffix).toString() //$NON-NLS-1$
: suffix;
new StringBuilder(baseId).append(".").append(suffix).toString() : //$NON-NLS-1$
suffix;
}
public static boolean objectsEqual(Object o1, Object o2) {
@ -122,7 +122,7 @@ public class CDataUtil {
return ""; //$NON-NLS-1$
if (array.length == 1)
return array[0].toString();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(array[0]);
for (int i = 1; i < array.length; i++) {
buf.append(separator).append(array[i]);
@ -137,7 +137,7 @@ public class CDataUtil {
if (string.length() == 0)
return EMPTY_STRING_ARRAY;
StringTokenizer t = new StringTokenizer(string, separator);
List<String> list = new ArrayList<String>(t.countTokens());
List<String> list = new ArrayList<>(t.countTokens());
while (t.hasMoreElements()) {
list.add(t.nextToken());
}
@ -148,7 +148,7 @@ public class CDataUtil {
if (entries.length == 0)
return entries;
ArrayList<ICSettingEntry> out = new ArrayList<ICSettingEntry>(entries.length);
ArrayList<ICSettingEntry> out = new ArrayList<>(entries.length);
ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
for (int i = 0; i < entries.length; i++) {
@ -466,7 +466,7 @@ public class CDataUtil {
if (type != null)
exts = getContentTypeFileSpecs(project, type);
} else {
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
for (int i = 0; i < typeIds.length; i++) {
type = manager.getContentType(typeIds[i]);
if (type != null) {
@ -558,7 +558,7 @@ public class CDataUtil {
}
public static Map<IPath, CResourceData> createPathRcDataMap(CConfigurationData data) {
Map<IPath, CResourceData> map = new HashMap<IPath, CResourceData>();
Map<IPath, CResourceData> map = new HashMap<>();
CResourceData[] rcDatas = data.getResourceDatas();
CResourceData rcData;
for (int i = 0; i < rcDatas.length; i++) {
@ -617,7 +617,7 @@ public class CDataUtil {
CResourceData[] rcDatas = cfg.getResourceDatas();
for (int i = 0; i < rcDatas.length; i++) {
if (rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER) {
adjustFolderData(cfg, (CFolderData)rcDatas[i], factory, dess, new HashMap<String, ILanguageDescriptor[]>(map));
adjustFolderData(cfg, (CFolderData)rcDatas[i], factory, dess, new HashMap<>(map));
}
}
@ -626,7 +626,7 @@ public class CDataUtil {
private static void adjustFolderData(CConfigurationData cfgData, CFolderData data, CDataFactory factory, ILanguageDescriptor dess[], HashMap<String, ILanguageDescriptor[]> map) {
Map<String, ILanguageDescriptor> langMap = new HashMap<String, ILanguageDescriptor>();
Map<String, ILanguageDescriptor> langMap = new HashMap<>();
for (int i = 0; i < dess.length; i++) {
langMap.put(dess[i].getId(), dess[i]);
}
@ -664,11 +664,11 @@ public class CDataUtil {
String [] cTypeIds = des.getContentTypeIds();
String srcIds[] = lData.getSourceContentTypeIds();
Set<String> landTypes = new HashSet<String>(Arrays.asList(cTypeIds));
Set<String> landTypes = new HashSet<>(Arrays.asList(cTypeIds));
landTypes.removeAll(Arrays.asList(srcIds));
if (landTypes.size() != 0) {
List<String> srcList = new ArrayList<String>();
List<String> srcList = new ArrayList<>();
srcList.addAll(landTypes);
lData.setSourceContentTypeIds(srcList.toArray(new String[srcList.size()]));
}
@ -680,7 +680,7 @@ public class CDataUtil {
}
private static void addLangs(CConfigurationData cfgData, CFolderData data, CDataFactory factory, Map<String, ILanguageDescriptor> langMap, Map<String, ILanguageDescriptor[]> cTypeToLangMap) {
List<ILanguageDescriptor> list = new ArrayList<ILanguageDescriptor>(langMap.values());
List<ILanguageDescriptor> list = new ArrayList<>(langMap.values());
ILanguageDescriptor des;
while(list.size() != 0) {
des = list.remove(list.size() - 1);
@ -761,8 +761,10 @@ public class CDataUtil {
* @return - true if they are equal
*/
public static boolean isEqual(ICSourceEntry[] ein, ICSourceEntry[] aus) {
if (ein == null || aus == null) return (ein == null && aus == null);
if (ein.length != aus.length) return false;
if (ein == null || aus == null)
return (ein == null && aus == null);
if (ein.length != aus.length)
return false;
for (int i= 0; i < ein.length; i++) {
boolean found = false;
for (int j=0; j<aus.length; j++) {
@ -801,8 +803,8 @@ public class CDataUtil {
ICSourceEntry[] newEntries;
if (excluded) {
List<ICSourceEntry> includeList = new ArrayList<ICSourceEntry>(entries.length);
List<ICSourceEntry> excludeList = new ArrayList<ICSourceEntry>(entries.length);
List<ICSourceEntry> includeList = new ArrayList<>(entries.length);
List<ICSourceEntry> excludeList = new ArrayList<>(entries.length);
sortEntries(path, false, entries, includeList, excludeList);
@ -817,8 +819,8 @@ public class CDataUtil {
newEntries = excludeList.toArray(new ICSourceEntry[excludeList.size()]);
} else {
List<ICSourceEntry> includeList = new ArrayList<ICSourceEntry>(entries.length + 1);
List<ICSourceEntry> excludeList = new ArrayList<ICSourceEntry>(entries.length);
List<ICSourceEntry> includeList = new ArrayList<>(entries.length + 1);
List<ICSourceEntry> excludeList = new ArrayList<>(entries.length);
sortIncludingExcludingEntries(path, entries, includeList, excludeList);
boolean included = false;
@ -878,12 +880,13 @@ public class CDataUtil {
private static void sortIncludingExcludingEntries(IPath path, ICSourceEntry[] entries, List<ICSourceEntry> including, List<ICSourceEntry> excluding) {
for (int i = 0; i < entries.length; i++) {
IPath entryPath = new Path(entries[i].getName());
if(entryPath.isPrefixOf(path))
if (entryPath.isPrefixOf(path)) {
including.add(entries[i]);
else
} else {
excluding.add(entries[i]);
}
}
}
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[]) {
return adjustEntries(entries, false, null);
@ -892,10 +895,11 @@ public class CDataUtil {
private static ICSourceEntry[] getDefaultSourceEntries(boolean absolute, IProject project) {
ICSourceEntry entry;
if (absolute) {
if(project != null)
if (project != null) {
entry = new CSourceEntry(project.getFullPath(), null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
else
} else {
entry = new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
}
} else {
entry = new CSourceEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
}
@ -905,10 +909,11 @@ public class CDataUtil {
private static ICOutputEntry[] getDefaultOutputEntries(boolean absolute, IProject project) {
ICOutputEntry entry;
if (absolute) {
if(project != null)
if (project != null) {
entry = new COutputEntry(project.getFullPath(), null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
else
} else {
entry = new COutputEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
}
} else {
entry = new COutputEntry(Path.EMPTY, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED);
}
@ -927,7 +932,7 @@ public class CDataUtil {
return getDefaultSourceEntries(makeAbsolute, project);
ICSourceEntry ei, ej;
LinkedHashMap<ICSourceEntry, List<IPath>> map = new LinkedHashMap<ICSourceEntry, List<IPath>>();
LinkedHashMap<ICSourceEntry, List<IPath>> map = new LinkedHashMap<>();
for (int i = 0; i < entries.length; i++) {
ei = entries[i];
List<IPath> list = null;
@ -939,20 +944,20 @@ public class CDataUtil {
IPath ejPath = new Path(ej.getName());
if (!isExcluded(ejPath, ei)) {
if (list == null)
list = new ArrayList<IPath>();
list = new ArrayList<>();
list.add(ejPath);
}
}
map.put(ei, list);
}
List<ICSourceEntry> resultList = new ArrayList<ICSourceEntry>(entries.length);
List<ICSourceEntry> resultList = new ArrayList<>(entries.length);
for (Iterator<Map.Entry<ICSourceEntry, List<IPath>>> iter = map.entrySet().iterator(); iter.hasNext();) {
Map.Entry<ICSourceEntry, List<IPath>> entry = iter.next();
List<IPath> list = entry.getValue();
if(list == null)
if (list == null) {
resultList.add(entry.getKey());
else {
} else {
ICSourceEntry se = entry.getKey();
se = addExcludePaths(se, list, true);
if (se != null)
@ -1030,7 +1035,7 @@ public class CDataUtil {
private static Collection<IPath> removePrefix(IPath prefix, Collection<IPath> paths, Collection<IPath> result) {
if (result == null)
result = new ArrayList<IPath>(paths.size());
result = new ArrayList<>(paths.size());
for (Iterator<IPath> iter = paths.iterator(); iter.hasNext(); ) {
IPath path = iter.next();
if (prefix.isPrefixOf(path))
@ -1045,7 +1050,7 @@ public class CDataUtil {
IPath entryPath = new Path(entry.getName());
IPath[] oldExclusions = entry.getExclusionPatterns();
// List newExList = new ArrayList(oldExclusions.length + paths.size());
LinkedHashSet<IPath> newSet = new LinkedHashSet<IPath>();
LinkedHashSet<IPath> newSet = new LinkedHashSet<>();
if (removePrefix) {
removePrefix(entryPath, paths, newSet);
} else {
@ -1078,7 +1083,7 @@ public class CDataUtil {
public static Map<EntryNameKey, ICSettingEntry> fillEntriesMapByNameKey(Map<EntryNameKey, ICSettingEntry> map, ICSettingEntry[] entries) {
if (map == null)
map = new LinkedHashMap<EntryNameKey, ICSettingEntry>();
map = new LinkedHashMap<>();
for (int i = 0; i < entries.length; i++) {
ICSettingEntry entry = entries[i];
@ -1089,7 +1094,7 @@ public class CDataUtil {
public static Map<EntryContentsKey, ICSettingEntry> fillEntriesMapByContentsKey(Map<EntryContentsKey, ICSettingEntry> map, ICSettingEntry[] entries) {
if (map == null)
map = new LinkedHashMap<EntryContentsKey, ICSettingEntry>();
map = new LinkedHashMap<>();
for (int i = 0; i < entries.length; i++) {
ICSettingEntry entry = entries[i];
@ -1140,12 +1145,13 @@ public class CDataUtil {
}
private static Set<IPath> mergeRemovingDups(IPath[] o1, IPath[] o2, boolean add) {
LinkedHashSet<IPath> set = new LinkedHashSet<IPath>();
LinkedHashSet<IPath> set = new LinkedHashSet<>();
set.addAll(Arrays.asList(o1));
if(add)
if (add) {
set.addAll(Arrays.asList(o2));
else
} else {
set.removeAll(Arrays.asList(o2));
}
return set;
}
@ -1157,7 +1163,7 @@ public class CDataUtil {
IPath projPath = project.getFullPath();
if (!path.isAbsolute() || (force && !projPath.isPrefixOf(path))) {
path = projPath.append(path).makeAbsolute();
return (ICExclusionPatternPathEntry)CDataUtil.createEntry(entry.getKind(), path.toString(), null, entry.getExclusionPatterns(), entry.getFlags());
return (ICExclusionPatternPathEntry) createEntry(entry.getKind(), path.toString(), null, entry.getExclusionPatterns(), entry.getFlags());
}
return entry;
}
@ -1170,11 +1176,12 @@ public class CDataUtil {
IPath projPath = project.getFullPath();
if (path.isAbsolute()) {
if(projPath.isPrefixOf(path))
if (projPath.isPrefixOf(path)) {
path = path.removeFirstSegments(projPath.segmentCount()).makeRelative();
else if (force)
} else if (force) {
path = path.makeRelative();
return (ICExclusionPatternPathEntry)CDataUtil.createEntry(entry.getKind(), path.toString(), null, entry.getExclusionPatterns(), entry.getFlags());
}
return (ICExclusionPatternPathEntry) createEntry(entry.getKind(), path.toString(), null, entry.getExclusionPatterns(), entry.getFlags());
}
return entry;
}

View file

@ -33,8 +33,7 @@ public interface IPDOMIndexer {
public ICProject getProject();
/**
* Return the unique ID of type of this indexer
* @return the unique ID of type of this indexer
* Returns the unique ID of type of this indexer
*/
public String getID();

View file

@ -18,29 +18,23 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTComment extends IASTNode {
/**
* @since 5.4
*/
/** @since 5.4 */
public final IASTComment[] EMPTY_COMMENT_ARRAY = {};
/**
* Set the comment.
* Sets the comment.
*
* @param comment
* @param comment the text of the comment
*/
public void setComment(char[] comment);
/**
* Return a char array representation of the comment.
*
* @return char array representation of the comment
* Returns a char array representation of the comment.
*/
public char[] getComment();
/**
* Return true if this is a blockcomment.
*
* @return true if this is a blockcomment
* Returns true if this is a block comment.
*/
public boolean isBlockComment();
}

View file

@ -320,7 +320,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
if (fLocationResolver != null) {
return fLocationResolver.getComments();
}
return new IASTComment[0];
return IASTComment.EMPTY_COMMENT_ARRAY;
}
@Override

View file

@ -104,7 +104,7 @@ public class CIndex implements IIndex {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findBindings(patterns, isFullyQualified, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
for (ILinkage linkage : linkages) {
if (filter.acceptLinkage(linkage)) {
@ -134,7 +134,7 @@ public class CIndex implements IIndex {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findMacroContainers(pattern, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
for (ILinkage linkage : linkages) {
if (filter.acceptLinkage(linkage)) {
@ -160,14 +160,14 @@ public class CIndex implements IIndex {
@Override
public IIndexName[] findNames(IBinding binding, int flags) throws CoreException {
ArrayList<IIndexFragmentName> result= new ArrayList<IIndexFragmentName>();
ArrayList<IIndexFragmentName> result= new ArrayList<>();
if (binding instanceof ICPPUsingDeclaration) {
IBinding[] bindings= ((ICPPUsingDeclaration) binding).getDelegates();
if (bindings == null || bindings.length == 0) {
return new IIndexName[0];
return IIndexName.EMPTY_ARRAY;
}
if (bindings.length > 1) {
ArrayList<IIndexName> multi= new ArrayList<IIndexName>();
ArrayList<IIndexName> multi= new ArrayList<>();
for (IBinding b : bindings) {
multi.addAll(Arrays.asList(findNames(b, flags)));
}
@ -182,7 +182,7 @@ public class CIndex implements IIndex {
// Read only fragments can be superseded by what the indexer writes into
// a writable fragment. Therefore names from a read-only fragment are
// ignored if there is a match in a writable fragment.
HashSet<NameKey> encounteredNames = new HashSet<NameKey>();
HashSet<NameKey> encounteredNames = new HashSet<>();
for (IIndexFragment fragment : fFragments) {
if (fragment instanceof IWritableIndexFragment) {
final IIndexFragmentName[] names = fragment.findNames(binding, flags);
@ -250,8 +250,8 @@ public class CIndex implements IIndex {
if (location == null) {
return IIndexFile.EMPTY_FILE_ARRAY;
}
Set<ISignificantMacros> handled = new HashSet<ISignificantMacros>();
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
Set<ISignificantMacros> handled = new HashSet<>();
ArrayList<IIndexFragmentFile> result= new ArrayList<>();
for (IIndexFragment fragment : fFragments) {
IIndexFragmentFile[] candidates= fragment.getFiles(linkageID, location);
for (IIndexFragmentFile candidate : candidates) {
@ -274,8 +274,8 @@ public class CIndex implements IIndex {
if (location == null) {
return IIndexFile.EMPTY_FILE_ARRAY;
}
Set<FileContentKey> keys = new HashSet<FileContentKey>();
ArrayList<IIndexFragmentFile> result= new ArrayList<IIndexFragmentFile>();
Set<FileContentKey> keys = new HashSet<>();
ArrayList<IIndexFragmentFile> result= new ArrayList<>();
for (IIndexFragment fragment : fFragments) {
IIndexFragmentFile[] candidates= fragment.getFiles(location);
for (IIndexFragmentFile candidate : candidates) {
@ -313,7 +313,7 @@ public class CIndex implements IIndex {
@Override
public IIndexInclude[] findIncludedBy(IIndexFile file, int depth) throws CoreException {
List<IIndexInclude> result= new ArrayList<IIndexInclude>();
List<IIndexInclude> result= new ArrayList<>();
findIncludedBy(file.getLinkageID(), Collections.singletonList(file), result, depth,
new HashSet<FileContentKey>());
return result.toArray(new IIndexInclude[result.size()]);
@ -354,8 +354,8 @@ public class CIndex implements IIndex {
@Override
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
List<IIndexInclude> result= new ArrayList<IIndexInclude>();
findIncludes(Collections.singletonList(file), result, depth, new HashSet<Object>());
List<IIndexInclude> result= new ArrayList<>();
findIncludes(Collections.singletonList(file), result, depth, new HashSet<>());
return result.toArray(new IIndexInclude[result.size()]);
}
@ -454,7 +454,7 @@ public class CIndex implements IIndex {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length * linkages.length);
for (ILinkage linkage : linkages) {
@ -529,7 +529,7 @@ public class CIndex implements IIndex {
}
public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
List<IIndexFragmentBinding> result = new ArrayList<IIndexFragmentBinding>();
List<IIndexFragmentBinding> result = new ArrayList<>();
for (IIndexFragment fragment : fFragments) {
IIndexFragmentBinding adapted = fragment.adaptBinding(binding);
if (adapted != null) {
@ -583,7 +583,7 @@ public class CIndex implements IIndex {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findBindingsForPrefix(prefix, filescope, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
for (ILinkage linkage : linkages) {
if (filter.acceptLinkage(linkage)) {
@ -613,7 +613,7 @@ public class CIndex implements IIndex {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findBindingsForContentAssist(prefix, filescope, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
for (ILinkage linkage : linkages) {
if (filter.acceptLinkage(linkage)) {
@ -643,7 +643,7 @@ public class CIndex implements IIndex {
if (SPECIALCASE_SINGLES && fFragments.length == 1) {
return fFragments[0].findBindings(name, filescope, filter, monitor);
} else {
List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
List<IIndexBinding[]> result = new ArrayList<>();
ILinkage[] linkages = Linkage.getIndexerLinkages();
for (ILinkage linkage : linkages) {
if (filter.acceptLinkage(linkage)) {
@ -685,11 +685,11 @@ public class CIndex implements IIndex {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
List<IIndexMacro> result = new ArrayList<IIndexMacro>();
HashSet<IIndexFileLocation> handledIFLs= new HashSet<IIndexFileLocation>();
List<IIndexMacro> result = new ArrayList<>();
HashSet<IIndexFileLocation> handledIFLs= new HashSet<>();
monitor.beginTask(Messages.CIndex_FindBindingsTask_label, fFragments.length);
for (IIndexFragment fragment : fFragments) {
HashSet<IIndexFile> allowedFiles= new HashSet<IIndexFile>();
HashSet<IIndexFile> allowedFiles= new HashSet<>();
try {
IIndexMacro[] macros= fragment.findMacros(name, isPrefix, caseSensitive, filter,
new SubProgressMonitor(monitor, 1));
@ -747,7 +747,7 @@ public class CIndex implements IIndex {
@Override
public IIndexFile[] getAllFiles() throws CoreException {
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<IIndexFileLocation, IIndexFile>();
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<>();
for (IIndexFragment fragment : fFragments) {
for (IIndexFragmentFile file : fragment.getAllFiles()) {
if (file.hasContent()) {
@ -760,7 +760,7 @@ public class CIndex implements IIndex {
@Override
public IIndexFile[] getDefectiveFiles() throws CoreException {
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<IIndexFileLocation, IIndexFile>();
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<>();
for (IIndexFragment fragment : fFragments) {
for (IIndexFragmentFile file : fragment.getDefectiveFiles()) {
if (file.hasContent()) {
@ -773,7 +773,7 @@ public class CIndex implements IIndex {
@Override
public IIndexFile[] getFilesWithUnresolvedIncludes() throws CoreException {
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<IIndexFileLocation, IIndexFile>();
HashMap<IIndexFileLocation, IIndexFile> result= new HashMap<>();
for (IIndexFragment fragment : fFragments) {
for (IIndexFragmentFile file : fragment.getFilesWithUnresolvedIncludes()) {
if (file.hasContent()) {

View file

@ -40,19 +40,19 @@ public interface IIndexFragmentFile extends IIndexFile {
/**
* Returns the hash-code computed by combining the file size and the file encoding.
* @return hashcode a hash-code or <code>0</code> if it is unknown.
* @return a hash-code or {@code 0} if it is unknown.
*/
int getSizeAndEncodingHashcode() throws CoreException;
/**
* Sets the hash-code computed by combining the file size and the file encoding.
* @param hashcode a hash-code or <code>0</code> if it is unknown.
* @param hashcode a hash-code or {@code 0} if it is unknown.
*/
void setSizeAndEncodingHashcode(int hashcode) throws CoreException;
/**
* Sets the flag that determines whether the file is a header with #pragma once statement
* or an include guard, or it is a source file and parsed only once because of that.
* Sets the flag that determines whether the file is a header with {@code #pragma once}
* statement or an include guard, or it is a source file and parsed only once because of that.
*/
void setPragmaOnceSemantics(boolean value) throws CoreException;
@ -85,5 +85,4 @@ public interface IIndexFragmentFile extends IIndexFile {
* The file 'source' must belong to the same fragment as this file.
*/
void transferContext(IIndexFragmentFile source) throws CoreException;
}

View file

@ -1057,16 +1057,12 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm);
resultCacheCleared = true; // The cache was cleared while writing to the index.
}
} catch (CoreException e) {
th= e;
} catch (RuntimeException e) {
final Throwable cause = e.getCause();
if (cause instanceof DependsOnOutdatedFileException)
return (DependsOnOutdatedFileException) cause;
th= e;
} catch (StackOverflowError e) {
th= e;
} catch (AssertionError e) {
} catch (StackOverflowError | CoreException | AssertionError e) {
th= e;
} catch (OutOfMemoryError e) {
if (--fSwallowOutOfMemoryError < 0)
@ -1247,16 +1243,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
if (storageLinkageID != ILinkage.NO_LINKAGE_ID)
addSymbols(data, storageLinkageID, ctx, fTodoTaskUpdater, pm);
}
} catch (CoreException e) {
} catch (CoreException | RuntimeException | Error e) {
// Avoid parsing files again, that caused an exception to be thrown.
withdrawRequests(linkageID, fileKeys);
throw e;
} catch (RuntimeException e) {
withdrawRequests(linkageID, fileKeys);
throw e;
} catch (Error e) {
withdrawRequests(linkageID, fileKeys);
throw e;
}
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import org.eclipse.cdt.core.dom.ast.IASTComment;

View file

@ -135,27 +135,28 @@ abstract public class PDOMWriter implements IPDOMASTProcessor {
public static int SKIP_NO_REFERENCES= 0;
private static class Symbols {
final ArrayList<IASTName[]> fNames= new ArrayList<IASTName[]>();
final ArrayList<IASTPreprocessorStatement> fMacros= new ArrayList<IASTPreprocessorStatement>();
final ArrayList<IASTPreprocessorIncludeStatement> fIncludes= new ArrayList<IASTPreprocessorIncludeStatement>();
final ArrayList<IASTName[]> fNames= new ArrayList<>();
final ArrayList<IASTPreprocessorStatement> fMacros= new ArrayList<>();
final ArrayList<IASTPreprocessorIncludeStatement> fIncludes= new ArrayList<>();
}
protected static class Data implements IIndexSymbols {
final IASTTranslationUnit fAST;
final FileInAST[] fSelectedFiles;
final IWritableIndex fIndex;
final Map<IASTPreprocessorIncludeStatement, Symbols> fSymbolMap = new HashMap<IASTPreprocessorIncludeStatement, Symbols>();
final Set<IASTPreprocessorIncludeStatement> fContextIncludes = new HashSet<IASTPreprocessorIncludeStatement>();
final List<IStatus> fStati= new ArrayList<IStatus>();
final Map<IASTPreprocessorIncludeStatement, Symbols> fSymbolMap = new HashMap<>();
final Set<IASTPreprocessorIncludeStatement> fContextIncludes = new HashSet<>();
final List<IStatus> fStatuses= new ArrayList<>();
public Data(IASTTranslationUnit ast, FileInAST[] selectedFiles, IWritableIndex index) {
fAST= ast;
fSelectedFiles= selectedFiles;
fIndex= index;
for(FileInAST file : selectedFiles)
for (FileInAST file : selectedFiles) {
fSymbolMap.put(file.includeStatement, new Symbols());
}
}
@Override
public boolean isEmpty() {
@ -272,14 +273,14 @@ abstract public class PDOMWriter implements IPDOMASTProcessor {
// Tasks update.
if (taskUpdater != null) {
Set<IIndexFileLocation> locations= new HashSet<IIndexFileLocation>();
Set<IIndexFileLocation> locations= new HashSet<>();
for (FileInAST file : data.fSelectedFiles) {
locations.add(file.fileContentKey.getLocation());
}
taskUpdater.updateTasks(data.fAST.getComments(), locations.toArray(new IIndexFileLocation[locations.size()]));
}
if (!data.fStati.isEmpty()) {
List<IStatus> stati = data.fStati;
if (!data.fStatuses.isEmpty()) {
List<IStatus> stati = data.fStatuses;
String path= null;
if (data.fSelectedFiles.length > 0) {
path= data.fSelectedFiles[data.fSelectedFiles.length - 1].fileContentKey.getLocation().getURI().getPath();
@ -352,7 +353,7 @@ abstract public class PDOMWriter implements IPDOMASTProcessor {
lock.release();
}
if (th != null) {
data.fStati.add(createStatus(NLS.bind(Messages.PDOMWriter_errorWhileParsing,
data.fStatuses.add(createStatus(NLS.bind(Messages.PDOMWriter_errorWhileParsing,
fileInAST.fileContentKey.getLocation().getURI().getPath()), th));
}
fStatistics.fAddToIndexTime += lock.getCumulativeLockTime();
@ -414,7 +415,7 @@ abstract public class PDOMWriter implements IPDOMASTProcessor {
}
if (th != null) {
if (!reported) {
data.fStati.add(CCorePlugin.createStatus(NLS.bind(Messages.PDOMWriter_errorResolvingName,
data.fStatuses.add(CCorePlugin.createStatus(NLS.bind(Messages.PDOMWriter_errorResolvingName,
name.toString(), file.fileContentKey.getLocation().getURI().getPath()), th));
}
reported= true;
@ -593,7 +594,7 @@ abstract public class PDOMWriter implements IPDOMASTProcessor {
}
}
List<IncludeInformation> includeInfos= new ArrayList<IncludeInformation>();
List<IncludeInformation> includeInfos= new ArrayList<>();
for (int i= 0; i < lists.fIncludes.size(); i++) {
final IASTPreprocessorIncludeStatement stmt = lists.fIncludes.get(i);
if (!stmt.isResolved()) {

View file

@ -48,14 +48,15 @@ import com.ibm.icu.text.NumberFormat;
* Configures the abstract indexer task suitable for indexing projects.
*/
public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPDOMIndexerTask {
private static final String TRUE = "true"; //$NON-NLS-1$
private static final String TRUE = Boolean.TRUE.toString();
private AbstractPDOMIndexer fIndexer;
private boolean fWriteInfoToLog;
protected PDOMIndexerTask(ITranslationUnit[] forceFiles, ITranslationUnit[] updateFiles,
ITranslationUnit[] removeFiles, AbstractPDOMIndexer indexer, boolean isFastIndexer) {
super(concat(forceFiles, updateFiles), removeFiles, new ProjectIndexerInputAdapter(indexer.getProject()), isFastIndexer);
super(concat(forceFiles, updateFiles), removeFiles, new ProjectIndexerInputAdapter(indexer.getProject()),
isFastIndexer);
fIndexer= indexer;
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
setShowInclusionProblems(checkDebugOption(TRACE_INCLUSION_PROBLEMS, TRUE));
@ -105,7 +106,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
}
private static ITranslationUnit[] concat(ITranslationUnit[] added, ITranslationUnit[] changed) {
HashSet<ITranslationUnit> union = new HashSet<ITranslationUnit>(added.length + changed.length);
HashSet<ITranslationUnit> union = new HashSet<>(added.length + changed.length);
union.addAll(Arrays.asList(added));
union.addAll(Arrays.asList(changed));
final ITranslationUnit[] result = union.toArray(new ITranslationUnit[union.size()]);
@ -166,7 +167,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
private Set<String> getStringSet(String key) {
String prefSetting = getIndexer().getProperty(key);
if (prefSetting != null && !prefSetting.isEmpty()) {
return new HashSet<String>(Arrays.asList(prefSetting.split(","))); //$NON-NLS-1$
return new HashSet<>(Arrays.asList(prefSetting.split(","))); //$NON-NLS-1$
}
return Collections.emptySet();
@ -249,7 +250,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
// tracing
if (checkDebugOption(IPDOMIndexerTask.TRACE_STATISTICS, TRUE)) {
String ident= " "; //$NON-NLS-1$
String indent= " "; //$NON-NLS-1$
final long totalTime = System.currentTimeMillis() - start;
final IndexerProgress info= getProgressInformation();
final int sum= fStatistics.fDeclarationCount + fStatistics.fReferenceCount + fStatistics.fProblemBindingCount;
@ -265,7 +266,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
boolean skipImplRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES);
boolean skipTypeRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES);
boolean skipMacroRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES);
System.out.println(ident + " Options: " //$NON-NLS-1$
System.out.println(indent + " Options: " //$NON-NLS-1$
+ "indexer='" + kind //$NON-NLS-1$
+ "', parseAllFiles=" + indexFilesWithoutConfiguration() //$NON-NLS-1$
+ ", unusedHeaders=" + getIndexHeadersWithoutContext() //$NON-NLS-1$
@ -274,25 +275,25 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
+ ", skipTypeReferences=" + skipTypeRefs //$NON-NLS-1$
+ ", skipMacroReferences=" + skipMacroRefs //$NON-NLS-1$
+ "."); //$NON-NLS-1$
System.out.println(ident + " Database: " + dbSize + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(ident + " Timings: " //$NON-NLS-1$
System.out.println(indent + " Database: " + dbSize + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(indent + " Timings: " //$NON-NLS-1$
+ totalTime + " total, " //$NON-NLS-1$
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
+ fStatistics.fResolutionTime + " resolution, " //$NON-NLS-1$
+ fStatistics.fAddToIndexTime + " index update."); //$NON-NLS-1$
System.out.println(ident + " Errors: " //$NON-NLS-1$
System.out.println(indent + " Errors: " //$NON-NLS-1$
+ fStatistics.fErrorCount + " internal, " //$NON-NLS-1$
+ fStatistics.fUnresolvedIncludesCount + " include, " //$NON-NLS-1$
+ fStatistics.fPreprocessorProblemCount + " scanner, " //$NON-NLS-1$
+ fStatistics.fSyntaxProblemsCount + " syntax errors."); //$NON-NLS-1$
if (fStatistics.fTooManyTokensCount > 0)
System.out.println(ident + " Tokens: " //$NON-NLS-1$
System.out.println(indent + " Tokens: " //$NON-NLS-1$
+ fStatistics.fTooManyTokensCount + " TUs with too many tokens."); //$NON-NLS-1$
NumberFormat nfPercent= NumberFormat.getPercentInstance();
nfPercent.setMaximumFractionDigits(2);
nfPercent.setMinimumFractionDigits(2);
System.out.println(ident + " Names: " //$NON-NLS-1$
System.out.println(indent + " Names: " //$NON-NLS-1$
+ fStatistics.fDeclarationCount + " declarations, " //$NON-NLS-1$
+ fStatistics.fReferenceCount + " references, " //$NON-NLS-1$
+ fStatistics.fProblemBindingCount + "(" + nfPercent.format(problemPct) + ") unresolved."); //$NON-NLS-1$ //$NON-NLS-2$
@ -301,7 +302,7 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
long hits= index.getCacheHits();
long tries= misses + hits;
double missPct= tries == 0 ? 0.0 : (double) misses / (double) tries;
System.out.println(ident + " Cache[" //$NON-NLS-1$
System.out.println(indent + " Cache[" //$NON-NLS-1$
+ ChunkCache.getSharedInstance().getMaxSize() / 1024 / 1024 + "MB]: " + //$NON-NLS-1$
+ hits + " hits, " //$NON-NLS-1$
+ misses + "(" + nfPercent.format(missPct) + ") misses."); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -37,7 +37,7 @@ import org.eclipse.osgi.util.NLS;
*/
public class PDOMRebuildTask implements IPDOMIndexerTask {
protected static final String TRUE= String.valueOf(true);
protected static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
protected static final ITranslationUnit[] NO_TUS = {};
private final IPDOMIndexer fIndexer;
private final IndexerProgress fProgress;
@ -78,7 +78,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
createDelegate(cproject, monitor);
}
}
// remove task-tags.
// Remove task-tags.
TodoTaskUpdater.removeTasksFor(project);
} catch (CoreException e) {
CCorePlugin.log(NLS.bind(Messages.PDOMRebuildTask_0, cproject.getElementName() ), e);
@ -112,7 +112,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
boolean allFiles =
TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) ||
TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
List<ITranslationUnit> sources= new ArrayList<ITranslationUnit>();
List<ITranslationUnit> sources= new ArrayList<>();
List<ITranslationUnit> headers= allFiles ? sources : null;
TranslationUnitCollector collector= new TranslationUnitCollector(sources, headers, monitor);
project.accept(collector);

View file

@ -75,8 +75,7 @@ public class TodoTaskParser {
return tasks.toArray(new Task[tasks.size()]);
}
private void parse(char[] comment, String filename, int offset, int lineNumber,
List<Task> tasks) {
private void parse(char[] comment, String filename, int offset, int lineNumber, List<Task> tasks) {
int commentLength = comment.length;
int foundTaskIndex = tasks.size();

View file

@ -9,7 +9,6 @@
* Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer;
import java.util.ArrayList;
@ -100,12 +99,14 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
class TaskList {
IFile fFile;
List<Task> fTasks;
public TaskList(IFile file) {
fFile= file;
}
public void add(Task task) {
if (fTasks == null) {
fTasks= new ArrayList<Task>();
fTasks= new ArrayList<>();
}
fTasks.add(task);
}
@ -113,9 +114,9 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
// first collect all valid file-locations
final Map<IPath, TaskList> pathToTaskList= new HashMap<IPath, TaskList>();
final Set<IProject> projects= new HashSet<IProject>();
// First collect all valid file-locations.
final Map<IPath, TaskList> pathToTaskList= new HashMap<>();
final Set<IProject> projects= new HashSet<>();
for (final IIndexFileLocation indexFileLocation : filesToUpdate) {
final String filepath = indexFileLocation.getFullPath();
if (filepath != null) {
@ -137,7 +138,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
}
}
// run this in a job in order not to block the indexer (bug 210730).
// Update markers in a job in order not to block the indexer (bug 210730).
if (!pathToTaskList.isEmpty()) {
WorkspaceJob job= new WorkspaceJob(Messages.TodoTaskUpdater_UpdateJob) {
@Override
@ -174,8 +175,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
private void applyTask(Task task, IResource resource) throws CoreException {
IMarker marker = resource.createMarker(ICModelMarker.TASK_MARKER);
String description = NLS.bind(Messages.TodoTaskUpdater_taskFormat,
task.getTag(), task.getMessage());
String description = NLS.bind(Messages.TodoTaskUpdater_taskFormat, task.getTag(), task.getMessage());
marker.setAttributes(
TASK_MARKER_ATTRIBUTE_NAMES,
new Object[] {
@ -203,7 +203,7 @@ public class TodoTaskUpdater implements ITodoTaskUpdater {
return;
}
// run this in a job in order not to block the indexer (bug 210730).
// Delete markers in a job in order not to block the indexer (bug 210730).
WorkspaceJob job= new WorkspaceJob(Messages.TodoTaskUpdater_DeleteJob) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

View file

@ -64,7 +64,7 @@ public abstract class IncludesTestBase extends BaseTestCase {
protected TestSourceFile selectedFile;
private StringBuilder[] testData;
private boolean cpp = true;
private final Set<TestSourceFile> testFiles = new LinkedHashSet<TestSourceFile>();
private final Set<TestSourceFile> testFiles = new LinkedHashSet<>();
protected IncludesTestBase() {
super();

View file

@ -107,7 +107,7 @@ public class HeaderSubstitutor {
IncludeInfo includeInfo = fContext.getIncludeForHeaderFile(path);
if (includeInfo == null)
return path;
List<IncludeInfo> candidates = new ArrayList<IncludeInfo>();
List<IncludeInfo> candidates = new ArrayList<>();
candidates.add(includeInfo);
IncludeMap[] maps = fIncludeMaps;
for (IncludeMap map : maps) {
@ -150,8 +150,8 @@ public class HeaderSubstitutor {
public IPath getPreferredRepresentativeHeaderByHeuristic(InclusionRequest request) {
Set<IIndexFile> indexFiles = request.getDeclaringFiles().keySet();
String symbolName = request.getBinding().getName();
ArrayDeque<IIndexFile> front = new ArrayDeque<IIndexFile>();
HashSet<IIndexFile> processed = new HashSet<IIndexFile>();
ArrayDeque<IIndexFile> front = new ArrayDeque<>();
HashSet<IIndexFile> processed = new HashSet<>();
try {
// Look for headers without an extension and a matching name.

View file

@ -42,9 +42,9 @@ public class IncludeCreationContext extends InclusionContext {
public IncludeCreationContext(ITranslationUnit tu, IIndex index) {
super(tu);
fIndex = index;
fHeadersToInclude = new HashSet<IPath>();
fHeadersAlreadyIncluded = new HashSet<IPath>();
fHeadersIncludedPreviously = new HashSet<IPath>();
fHeadersToInclude = new HashSet<>();
fHeadersAlreadyIncluded = new HashSet<>();
fHeadersIncludedPreviously = new HashSet<>();
}
public String getSourceContents() {
@ -67,7 +67,7 @@ public class IncludeCreationContext extends InclusionContext {
*/
public void removeExportedHeaders() throws CoreException {
// Index files keyed by their absolute paths.
Map<IPath, IIndexFile> filesByPath = new HashMap<IPath, IIndexFile>();
Map<IPath, IIndexFile> filesByPath = new HashMap<>();
for (IIndexFile file : fIndex.getAllFiles()) {
IPath path = getPath(file);
filesByPath.put(path, file);
@ -79,12 +79,12 @@ public class IncludeCreationContext extends InclusionContext {
private void removeExportedHeaders(Set<IPath> exportingHeaders,
Map<IPath, IIndexFile> filesByPath) throws CoreException {
Set<IPath> exportedHeaders = new HashSet<IPath>();
Set<IPath> exportedHeaders = new HashSet<>();
for (IPath path : exportingHeaders) {
if (!exportedHeaders.contains(path)) {
IIndexFile file = filesByPath.get(path);
if (file != null) { // file can be null if the header was not indexed.
ArrayDeque<IIndexFile> queue = new ArrayDeque<IIndexFile>();
ArrayDeque<IIndexFile> queue = new ArrayDeque<>();
queue.add(file);
while ((file = queue.pollFirst()) != null) {
for (IIndexInclude include : file.getIncludes()) {

View file

@ -39,7 +39,7 @@ public class IncludeMap {
public IncludeMap(boolean unconditionalSubstitution) {
this.unconditionalSubstitution = unconditionalSubstitution;
this.map = new LinkedHashMap<IncludeInfo, List<IncludeInfo>>();
this.map = new LinkedHashMap<>();
}
/**
@ -51,7 +51,7 @@ public class IncludeMap {
if (keysAndValues.length % 2 != 0)
throw new IllegalArgumentException("More keys than values"); //$NON-NLS-1$
this.unconditionalSubstitution = unconditionalSubstitution;
this.map = new LinkedHashMap<IncludeInfo, List<IncludeInfo>>(keysAndValues.length / 2);
this.map = new LinkedHashMap<>(keysAndValues.length / 2);
for (int i = 0; i < keysAndValues.length;) {
String key = keysAndValues[i++];
addMapping(key, keysAndValues[i++]);
@ -60,7 +60,7 @@ public class IncludeMap {
public IncludeMap(IncludeMap other) {
this.unconditionalSubstitution = other.unconditionalSubstitution;
this.map = new LinkedHashMap<IncludeInfo, List<IncludeInfo>>(other.map.size());
this.map = new LinkedHashMap<>(other.map.size());
addAllMappings(other);
}
@ -75,7 +75,7 @@ public class IncludeMap {
return; // Don't allow mapping to itself.
List<IncludeInfo> list = map.get(from);
if (list == null) {
list = new ArrayList<IncludeInfo>(2);
list = new ArrayList<>(2);
map.put(from, list);
}
list.add(to);
@ -158,7 +158,7 @@ public class IncludeMap {
* Writes the map to a memento. The {@link #isUnconditionalSubstitution()} flag is not written.
*/
public void saveToMemento(IMemento memento) {
List<IncludeInfo> keys = new ArrayList<IncludeInfo>(map.keySet());
List<IncludeInfo> keys = new ArrayList<>(map.keySet());
Collections.sort(keys);
for (IncludeInfo key : keys) {
for (IncludeInfo value : map.get(key)) {
@ -189,7 +189,7 @@ public class IncludeMap {
List<IncludeInfo> otherTargets = entry.getValue();
List<IncludeInfo> targets = map.get(source);
if (targets == null) {
targets = new ArrayList<IncludeInfo>(otherTargets);
targets = new ArrayList<>(otherTargets);
map.put(source, targets);
} else {
targets.addAll(otherTargets);
@ -201,12 +201,12 @@ public class IncludeMap {
for (Entry<IncludeInfo, List<IncludeInfo>> entry : map.entrySet()) {
IncludeInfo source = entry.getKey();
List<IncludeInfo> targets = entry.getValue();
ArrayDeque<IncludeInfo> queue = new ArrayDeque<IncludeInfo>(targets);
ArrayDeque<IncludeInfo> queue = new ArrayDeque<>(targets);
targets.clear();
HashSet<IncludeInfo> processed = new HashSet<IncludeInfo>();
HashSet<IncludeInfo> processed = new HashSet<>();
if (!unconditionalSubstitution)
processed.add(source); // Don't allow mapping to itself.
HashSet<IncludeInfo> seenTargets = new HashSet<IncludeInfo>();
HashSet<IncludeInfo> seenTargets = new HashSet<>();
IncludeInfo target;
queueLoop: while ((target = queue.pollFirst()) != null) {
if (processed.contains(target))
@ -263,7 +263,7 @@ public class IncludeMap {
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append("upconditionalSubstitution = ").append(unconditionalSubstitution); //$NON-NLS-1$
ArrayList<IncludeInfo> sources = new ArrayList<IncludeInfo>(map.keySet());
ArrayList<IncludeInfo> sources = new ArrayList<>(map.keySet());
Collections.sort(sources);
for (IncludeInfo source : sources) {
buf.append('\n');