1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-05-09 18:35:04 -07:00
parent 720771095c
commit 01ac823ccb
4 changed files with 46 additions and 35 deletions

View file

@ -184,6 +184,7 @@ public interface IIndexManager extends IPDOMManager {
/** /**
* Returns the index for the given project. * Returns the index for the given project.
*
* @param project the project to get the index for * @param project the project to get the index for
* @return an index for the project * @return an index for the project
* @throws CoreException * @throws CoreException
@ -192,6 +193,7 @@ public interface IIndexManager extends IPDOMManager {
/** /**
* Returns the index for the given projects. * Returns the index for the given projects.
*
* @param projects the projects to get the index for * @param projects the projects to get the index for
* @return an index for the projects * @return an index for the projects
* @throws CoreException * @throws CoreException
@ -203,7 +205,7 @@ public interface IIndexManager extends IPDOMManager {
* projects. * projects.
* *
* @param project the project to get the index for * @param project the project to get the index for
* @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and * @param options {@code 0} or a combination of {@link #ADD_DEPENDENCIES} and
* {@link #ADD_DEPENDENT}. * {@link #ADD_DEPENDENT}.
* @return an index for the project * @return an index for the project
* @throws CoreException * @throws CoreException
@ -213,8 +215,9 @@ public interface IIndexManager extends IPDOMManager {
/** /**
* Returns the index for the given projects. You can specify to add dependencies or dependent * Returns the index for the given projects. You can specify to add dependencies or dependent
* projects. * projects.
*
* @param projects the projects to get the index for * @param projects the projects to get the index for
* @param options <code>0</code> or a combination of {@link #ADD_DEPENDENCIES} and * @param options {@code 0} or a combination of {@link #ADD_DEPENDENCIES} and
* {@link #ADD_DEPENDENT}. * {@link #ADD_DEPENDENT}.
* @return an index for the projects * @return an index for the projects
* @throws CoreException * @throws CoreException
@ -223,6 +226,7 @@ public interface IIndexManager extends IPDOMManager {
/** /**
* Registers a listener that will be notified whenever the indexer go idle. * Registers a listener that will be notified whenever the indexer go idle.
*
* @param listener the listener to register. * @param listener the listener to register.
*/ */
void addIndexChangeListener(IIndexChangeListener listener); void addIndexChangeListener(IIndexChangeListener listener);
@ -235,12 +239,14 @@ public interface IIndexManager extends IPDOMManager {
/** /**
* Registers a listener that will be notified whenever the indexer changes its state. * Registers a listener that will be notified whenever the indexer changes its state.
*
* @param listener the listener to register. * @param listener the listener to register.
*/ */
void addIndexerStateListener(IIndexerStateListener listener); void addIndexerStateListener(IIndexerStateListener listener);
/** /**
* Removes a previously registered indexer state listener. * Removes a previously registered indexer state listener.
*
* @param listener the listener to unregister. * @param listener the listener to unregister.
*/ */
void removeIndexerStateListener(IIndexerStateListener listener); void removeIndexerStateListener(IIndexerStateListener listener);
@ -249,15 +255,17 @@ public interface IIndexManager extends IPDOMManager {
* Joins the indexer and reports progress. * Joins the indexer and reports progress.
* @param waitMaxMillis time limit in milliseconds after which the method returns with * @param waitMaxMillis time limit in milliseconds after which the method returns with
* {@code false}, or {@link #FOREVER}. * {@code false}, or {@link #FOREVER}.
*
* @param monitor a monitor to report progress. * @param monitor a monitor to report progress.
* @return <code>true</code>, if the indexer went idle in the given time. * @return {@code true}, if the indexer went idle in the given time.
*/ */
boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor); boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor);
/** /**
* Checks whether the indexer is currently idle. The indexer is idle, when there is currently no request * Checks whether the indexer is currently idle. The indexer is idle, when there is currently
* to update files of an index and no initialization for a project is performed. However, the indexer becomes * no request to update files of an index and no initialization for a project is performed.
* idle, when the setup of a project is postponed (check with {@link #isIndexerSetupPostponed(ICProject)}). * However, the indexer becomes idle, when the setup of a project is postponed
* (check with {@link #isIndexerSetupPostponed(ICProject)}).
*/ */
boolean isIndexerIdle(); boolean isIndexerIdle();
@ -268,8 +276,10 @@ public interface IIndexManager extends IPDOMManager {
boolean isProjectIndexed(ICProject proj); boolean isProjectIndexed(ICProject proj);
/** /**
* Return whether the indexer-setup for a project is currently postponed. Note, * Returns whether the indexer-setup for a project is currently postponed. Note,
* that a postponed setup does not prevent the indexer from becoming idle ({@link #isIndexerIdle()}. * that a postponed setup does not prevent the indexer from becoming idle
* ({@link #isIndexerIdle()}.
* <p>
* The fact that the indexer-setup for a project is no longer postponed, will be reported using * The fact that the indexer-setup for a project is no longer postponed, will be reported using
* {@link IndexerSetupParticipant#onIndexerSetup(ICProject)}. * {@link IndexerSetupParticipant#onIndexerSetup(ICProject)}.
*/ */
@ -296,20 +306,22 @@ public interface IIndexManager extends IPDOMManager {
public void reindex(ICProject project); public void reindex(ICProject project);
/** /**
* Updates the index for the given selection of translation units considering * Updates the index for the given selection of translation units considering the options
* the options supplied. The selection is defined by an array of translation * supplied. The selection is defined by an array of translation units, containers and projects.
* units, containers and projects. For containers and projects all recursively * For containers and projects all recursively nested translation units are considered.
* nested translation units are considered. *
* @param tuSelection the translation units to update. * @param tuSelection the translation units to update.
* @param options one of {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS} optionally * @param options one of {@link #UPDATE_ALL} or {@link #UPDATE_CHECK_TIMESTAMPS} optionally
* combined with {@link #UPDATE_EXTERNAL_FILES_FOR_PROJECT} and {@link #UPDATE_CHECK_CONTENTS_HASH}. * combined with {@link #UPDATE_EXTERNAL_FILES_FOR_PROJECT} and
* {@link #UPDATE_CHECK_CONTENTS_HASH}.
* @throws CoreException * @throws CoreException
* @since 4.0 * @since 4.0
*/ */
public void update(ICElement[] tuSelection, int options) throws CoreException; public void update(ICElement[] tuSelection, int options) throws CoreException;
/** /**
* Export index for usage within a team. * Exports index for usage within a team.
*
* @param project a project for which the PDOM is to be exported. * @param project a project for which the PDOM is to be exported.
* @param location the target location for the database. * @param location the target location for the database.
* @param options currently none are supported. * @param options currently none are supported.

View file

@ -651,7 +651,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
final boolean regularContent = isRequiredInIndex(tu, ifl, isSourceUnit); final boolean regularContent = isRequiredInIndex(tu, ifl, isSourceUnit);
final boolean indexedUnconditionally = fResolver.isIndexedUnconditionally(ifl); final boolean indexedUnconditionally = fResolver.isIndexedUnconditionally(ifl);
if (regularContent || indexedUnconditionally) { if (regularContent || indexedUnconditionally) {
// Headers or sources required with a specific linkage // Headers or sources required with a specific linkage.
final UpdateKind updateKind = isSourceUnit ? UpdateKind.REQUIRED_SOURCE final UpdateKind updateKind = isSourceUnit ? UpdateKind.REQUIRED_SOURCE
: regularContent && both ? UpdateKind.REQUIRED_HEADER : UpdateKind.ONE_LINKAGE_HEADER; : regularContent && both ? UpdateKind.REQUIRED_HEADER : UpdateKind.ONE_LINKAGE_HEADER;
if (regularContent || indexFiles.length == 0) { if (regularContent || indexFiles.length == 0) {

View file

@ -18,7 +18,7 @@ import java.util.HashMap;
* @param <T> Type of the objects contained in the set. * @param <T> Type of the objects contained in the set.
*/ */
public class AtomicMultiSet<T> { public class AtomicMultiSet<T> {
private final HashMap<T, Integer> map = new HashMap<T, Integer>(); private final HashMap<T, Integer> map = new HashMap<>();
/** /**
* Adds object to the set if it was not present, or increments its reference count otherwise. * Adds object to the set if it was not present, or increments its reference count otherwise.

View file

@ -145,26 +145,26 @@ public class PDOMManager implements IWritableIndexManager, IListener {
ILinkage.C_LINKAGE_ID, ILinkage.CPP_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID ILinkage.C_LINKAGE_ID, ILinkage.CPP_LINKAGE_ID, ILinkage.FORTRAN_LINKAGE_ID
}; };
private final ArrayDeque<ICProject> fProjectQueue= new ArrayDeque<ICProject>(); private final ArrayDeque<ICProject> fProjectQueue= new ArrayDeque<>();
private final PDOMSetupJob fSetupJob; private final PDOMSetupJob fSetupJob;
/** /**
* Protects fIndexerJob, fCurrentTask and fTaskQueue. * Protects fIndexerJob, fCurrentTask and fTaskQueue.
*/ */
private final ArrayDeque<IPDOMIndexerTask> fTaskQueue = new ArrayDeque<IPDOMIndexerTask>(); private final ArrayDeque<IPDOMIndexerTask> fTaskQueue = new ArrayDeque<>();
private final PDOMIndexerJob fIndexerJob; private final PDOMIndexerJob fIndexerJob;
private IPDOMIndexerTask fCurrentTask; private IPDOMIndexerTask fCurrentTask;
private int fSourceCount, fHeaderCount, fTickCount; private int fSourceCount, fHeaderCount, fTickCount;
private final ArrayDeque<Runnable> fChangeEvents= new ArrayDeque<Runnable>(); private final ArrayDeque<Runnable> fChangeEvents= new ArrayDeque<>();
private final Job fNotificationJob; private final Job fNotificationJob;
private final AtomicMultiSet<IIndexFileLocation> fFilesIndexedUnconditionlly= new AtomicMultiSet<IIndexFileLocation>(); private final AtomicMultiSet<IIndexFileLocation> fFilesIndexedUnconditionlly= new AtomicMultiSet<>();
/** /**
* Stores mapping from pdom to project, used to serialize creation of new pdoms. * Stores mapping from pdom to project, used to serialize creation of new pdoms.
*/ */
private Map<IProject, IPDOM> fProjectToPDOM= new HashMap<IProject, IPDOM>(); private Map<IProject, IPDOM> fProjectToPDOM= new HashMap<>();
private Map<File, ICProject> fFileToProject= new HashMap<File, ICProject>(); private Map<File, ICProject> fFileToProject= new HashMap<>();
private ListenerList fChangeListeners= new ListenerList(); private ListenerList fChangeListeners= new ListenerList();
private ListenerList fStateListeners= new ListenerList(); private ListenerList fStateListeners= new ListenerList();
@ -185,12 +185,12 @@ public class PDOMManager implements IWritableIndexManager, IListener {
* Serializes creation of new indexer, when acquiring the lock you are * Serializes creation of new indexer, when acquiring the lock you are
* not allowed to hold a lock on fPDOMs. * not allowed to hold a lock on fPDOMs.
*/ */
private Map<ICProject, IndexUpdatePolicy> fUpdatePolicies= new HashMap<ICProject, IndexUpdatePolicy>(); private Map<ICProject, IndexUpdatePolicy> fUpdatePolicies= new HashMap<>();
private Set<String> fClosingProjects= new HashSet<String>(); private Set<String> fClosingProjects= new HashSet<>();
private Map<IProject, PCL> fPrefListeners= new HashMap<IProject, PCL>(); private Map<IProject, PCL> fPrefListeners= new HashMap<>();
private List<IndexerSetupParticipant> fSetupParticipants= new ArrayList<IndexerSetupParticipant>(); private List<IndexerSetupParticipant> fSetupParticipants= new ArrayList<>();
private Set<ICProject> fPostponedProjects= new HashSet<ICProject>(); private Set<ICProject> fPostponedProjects= new HashSet<>();
private int fLastNotifiedState= IndexerStateEvent.STATE_IDLE; private int fLastNotifiedState= IndexerStateEvent.STATE_IDLE;
private boolean fInShutDown; private boolean fInShutDown;
@ -1210,7 +1210,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
@Override @Override
public IIndex getIndex(ICProject project) throws CoreException { public IIndex getIndex(ICProject project) throws CoreException {
return fIndexFactory.getIndex(new ICProject[] {project}, 0); return fIndexFactory.getIndex(new ICProject[] { project }, 0);
} }
@Override @Override
@ -1220,7 +1220,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
@Override @Override
public IIndex getIndex(ICProject project, int options) throws CoreException { public IIndex getIndex(ICProject project, int options) throws CoreException {
return fIndexFactory.getIndex(new ICProject[] {project}, options); return fIndexFactory.getIndex(new ICProject[] { project }, options);
} }
@Override @Override
@ -1245,8 +1245,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
boolean deleted= targetLocation.delete(); boolean deleted= targetLocation.delete();
if (!deleted) { if (!deleted) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
MessageFormat.format(Messages.PDOMManager_ExistingFileCollides, MessageFormat.format(Messages.PDOMManager_ExistingFileCollides, targetLocation));
targetLocation ));
} }
} }
try { try {
@ -1383,17 +1382,17 @@ public class PDOMManager implements IWritableIndexManager, IListener {
* set of folders and files specifying the selection. * set of folders and files specifying the selection.
*/ */
private Map<ICProject, List<ICElement>> splitSelection(ICElement[] tuSelection) { private Map<ICProject, List<ICElement>> splitSelection(ICElement[] tuSelection) {
HashMap<ICProject, List<ICElement>> result= new HashMap<ICProject, List<ICElement>>(); HashMap<ICProject, List<ICElement>> result= new HashMap<>();
allElements: for (int i = 0; i < tuSelection.length; i++) { allElements: for (int i = 0; i < tuSelection.length; i++) {
ICElement element = tuSelection[i]; ICElement element = tuSelection[i];
if (element instanceof ICProject || element instanceof ICContainer || element instanceof ITranslationUnit) { if (element instanceof ICProject || element instanceof ICContainer || element instanceof ITranslationUnit) {
ICProject project= element.getCProject(); ICProject project= element.getCProject();
List<ICElement> set= result.get(project); List<ICElement> set= result.get(project);
if (set == null) { if (set == null) {
set= new ArrayList<ICElement>(); set= new ArrayList<>();
result.put(project, set); result.put(project, set);
} }
for (int j= 0; j<set.size(); j++) { for (int j= 0; j < set.size(); j++) {
ICElement other= set.get(j); ICElement other= set.get(j);
if (contains(other, element)) { if (contains(other, element)) {
continue allElements; continue allElements;
@ -1558,7 +1557,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
if (!"true".equals(IndexerPreferences.get(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, null))) //$NON-NLS-1$ if (!"true".equals(IndexerPreferences.get(cproject.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, null))) //$NON-NLS-1$
return null; // No check is performed in this case return null; // No check is performed in this case
Set<ITranslationUnit> sources= new HashSet<ITranslationUnit>(); Set<ITranslationUnit> sources= new HashSet<>();
cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor())); cproject.accept(new TranslationUnitCollector(sources, null, new NullProgressMonitor()));
IStatus syncStatus = null; IStatus syncStatus = null;