1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 09:55:29 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-10-21 20:01:16 -07:00
parent 8aa01dbdfc
commit cc3695ca21
8 changed files with 96 additions and 81 deletions

View file

@ -14,8 +14,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.index;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -23,6 +21,8 @@ import org.eclipse.cdt.core.parser.ISignificantMacros;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import java.util.regex.Pattern;
/**
* Interface for accessing the index for one or more projects.
*
@ -60,7 +60,7 @@ public interface IIndex {
final int FIND_REFERENCES = 0x4;
/**
* Constant to search for occurrences across language boundaries.
* You can use it to find the occurrences of a c++-function declared with 'extern "C"' within
* Can be used to find the occurrences of a C++-function declared with 'extern "C"' within
* the c-linkage.
*/
final int SEARCH_ACROSS_LANGUAGE_BOUNDARIES= 0x8;
@ -149,7 +149,7 @@ public interface IIndex {
/**
* Returns the file for the given location, linkage, and significant macros
* May return {@code null}, if no such file exists.
*
*
* @param linkageID the id of the linkage in which the file has been parsed.
* @param location the IIndexFileLocation representing the location of the file
* @param macroDictionary The names and definitions of the macros used to disambiguate between
@ -168,7 +168,7 @@ public interface IIndex {
* for different sets of macro definitions.
* This method may only return files that are actually managed by this fragment.
* This method returns files without content, also.
*
*
* @param linkageID the id of the linkage in which the file has been parsed.
* @param location the IIndexFileLocation representing the location of the file
* @return the files for the location and the linkage.
@ -246,7 +246,8 @@ public interface IIndex {
* @throws CoreException
* @since 4.0.2
*/
public IIndexMacro[] findMacros(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexMacro[] findMacros(char[] name, IndexFilter filter, IProgressMonitor monitor)
throws CoreException;
/**
* Searches for all macros with names that start with the given prefix.
@ -258,11 +259,13 @@ public interface IIndex {
* @throws CoreException
* @since 4.0.2
*/
public IIndexMacro[] findMacrosForPrefix(char[] prefix, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexMacro[] findMacrosForPrefix(char[] prefix, IndexFilter filter,
IProgressMonitor monitor) throws CoreException;
/**
* Searches for the binding of a name. The name may be originated by
* an AST or by a search in an index. May return {@code null}.
*
* @param name a name to find the binding for
* @return the binding or {@code null}
* @throws CoreException
@ -274,50 +277,55 @@ public interface IIndex {
* exists in multiple projects, no duplicate bindings are returned.
* This is fully equivalent to
* <pre>
* findBindings(new Pattern[]{pattern}, isFullyQualified, filter, monitor);
* findBindings(new Pattern[] {pattern}, isFullyQualified, filter, monitor);
* </pre>
* @param pattern the pattern the name of the binding has to match.
* @param isFullyQualified if <code>true</code>, binding must be in global scope
* @param isFullyQualified if {@code true}, binding must be in global scope
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindings(Pattern pattern, boolean isFullyQualified, IndexFilter filter,
IProgressMonitor monitor) throws CoreException;
/**
* Searches for all bindings with qualified names that seen as an array of simple names match
* the given array of patterns. In case a binding exists in multiple projects, no duplicate
* bindings are returned. You can search with an array of patterns that specifies a partial
* qualification only.
* @param patterns an array of patterns the names of the qualified name of the bindings
*
* @param patterns an array of patterns the components of the qualified name of the bindings
* have to match.
* @param isFullyQualified if <code>true</code>, the array of pattern specifies the fully
* @param isFullyQualified if {@code true}, the array of pattern specifies the fully
* qualified name
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be {@code null}.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindings(Pattern[] patterns, boolean isFullyQualified,
IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all macro containers (one for macros with the same name) with names that
* match the given pattern. In case a binding exists in multiple projects, no duplicate
* bindings are returned.
*
* @param pattern a pattern the name of the bindings have to match.
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be {@code null}
* @return an array of bindings matching the pattern
* @throws CoreException
*/
IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
IIndexBinding[] findMacroContainers(Pattern pattern, IndexFilter filter, IProgressMonitor monitor)
throws CoreException;
/**
* Searches for all bindings in global scope with a given name. In case a binding exists in
* multiple projects, no duplicate bindings are returned. This method makes use of the BTree
* and is faster than the methods using patterns.
* <p>
*
* @param names an array of names, which has to be matched by the qualified name of
* the bindings.
* @param filter a filter that allows for skipping parts of the index
@ -325,7 +333,8 @@ public interface IIndex {
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindings(char[][] names, IndexFilter filter, IProgressMonitor monitor)
throws CoreException;
/**
* Searches the global scope for all bindings with a given name.
@ -342,7 +351,8 @@ public interface IIndex {
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor)
throws CoreException;
/**
* Searches the global scope and optionally all other scopes for bindings with a given name.
@ -356,10 +366,12 @@ public interface IIndex {
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(char[] name, boolean fileScopeOnly, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindings(char[] name, boolean fileScopeOnly, IndexFilter filter,
IProgressMonitor monitor) throws CoreException;
/**
* Searches for all bindings with names that start with the given prefix.
*
* @param prefix the prefix with which all returned bindings must start
* @param fileScopeOnly if true, only bindings at file scope are returned
* @param filter a filter that allows for skipping parts of the index
@ -367,16 +379,19 @@ public interface IIndex {
* @return an array of bindings with the prefix
* @throws CoreException
*/
public IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean fileScopeOnly, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindingsForPrefix(char[] prefix, boolean fileScopeOnly,
IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* @noreference This method is not intended to be referenced by clients.
*/
public IIndexBinding[] findBindingsForContentAssist(char[] prefix, boolean fileScopeOnly, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
public IIndexBinding[] findBindingsForContentAssist(char[] prefix, boolean fileScopeOnly,
IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches for all names that resolve to the given binding. You can limit the result to references, declarations
* or definitions, or a combination of those.
* Searches for all names that resolve to the given binding. The search can be limited to
* references, declarations or definitions, or a combination of those.
*
* @param binding a binding for which names are searched for
* @param flags a combination of {@link #FIND_DECLARATIONS}, {@link #FIND_DEFINITIONS},
* {@link #FIND_REFERENCES} and {@link #SEARCH_ACROSS_LANGUAGE_BOUNDARIES}.
@ -422,23 +437,24 @@ public interface IIndex {
public IIndexName[] findDefinitions(IBinding binding) throws CoreException;
/**
* Returns an IIndexBinding for this IIndex that is equivalent to the specified binding,
* Returns an {@link IIndexBinding} for this index that is equivalent to the specified binding,
* or null if such a binding does not exist in this index. This is useful for adapting
* bindings obtained from IIndex objects that might have been created for a different scope
* or for IBinding objects obtained directly from the AST.
* @param binding
* @return an IIndexBinding for this IIndex that is equivalent to the specified binding
*
* @param binding an AST or an index binding
* @return an IIndexBinding for this index that is equivalent to the specified binding
*/
public IIndexBinding adaptBinding(IBinding binding);
/**
* Creates a file-set that can be used with this index as long as you hold a read-lock.
* Creates a file-set that can be used with this index as long as the caller holds a read-lock.
*/
public IIndexFileSet createFileSet();
/**
* Returns an array of all files that are part of this index. If a file is parsed in two
* linkages, or in multiple fragments only one of the files will be returned.
* linkages or in multiple fragments, only one of the files will be returned.
*/
public IIndexFile[] getAllFiles() throws CoreException;

View file

@ -6,10 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Andrew Ferguson (Symbian)
*******************************************************************************/
* Markus Schorn - initial API and implementation
* Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import org.eclipse.cdt.core.dom.ILinkage;
@ -17,8 +16,8 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.core.runtime.CoreException;
public interface IIndexFragmentBinding extends IIndexBinding {
IIndexFragmentBinding[] EMPTY_INDEX_BINDING_ARRAY= new IIndexFragmentBinding[0];
IIndexFragmentBinding[] EMPTY_INDEX_BINDING_ARRAY= {};
/**
* Returns the owner of the binding.
*/
@ -29,7 +28,7 @@ public interface IIndexFragmentBinding extends IIndexBinding {
*/
@Override
ILinkage getLinkage();
/**
* Returns whether this binding has any definitions associated with it
* in its associated fragment.
@ -37,22 +36,22 @@ public interface IIndexFragmentBinding extends IIndexBinding {
boolean hasDefinition() throws CoreException;
/**
* Returns whether this binding has a declaration or definition associated with
* Returns whether this binding has a declaration or definition associated with
* it in its associated fragment.
*/
boolean hasDeclaration() throws CoreException;
/**
* Returns the constant identifying the type of binding stored in the index
*/
int getBindingConstant();
/**
* Returns the scope that contains this binding, or <code>null</code> for bindings in global scope.
* Returns the scope that contains this binding, or {@code null} for bindings in global scope.
*/
@Override
IIndexScope getScope();
/**
* {@inheritDoc}
* @since 5.1
@ -61,7 +60,8 @@ public interface IIndexFragmentBinding extends IIndexBinding {
IIndexFragmentBinding getOwner();
/**
* Returns a unique id for the binding within the fragment, or <code>null</code> for unknown bindings.
* Returns a unique id for the binding within the fragment, or {@code null} for unknown
* bindings.
* @since 5.1
*/
long getBindingID();

View file

@ -6,14 +6,15 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
*******************************************************************************/
* Markus Schorn - initial API and implementation
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
import org.eclipse.cdt.core.index.IIndexExtension;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.parser.ISignificantMacros;
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
@ -21,18 +22,18 @@ import org.eclipse.cdt.internal.core.pdom.YieldableIndexLock;
import org.eclipse.core.runtime.CoreException;
public class WritableCIndex extends CIndex implements IWritableIndex {
private boolean fIsWriteLocked= false;
private boolean fIsWriteLocked;
private Object fThread;
public WritableCIndex(IWritableIndexFragment writable) {
super(new IWritableIndexFragment[] {writable});
super(new IWritableIndexFragment[] { writable }, IIndexExtension.EMPTY_ARRAY);
}
@Override
public IWritableIndexFragment getWritableFragment() {
return (IWritableIndexFragment) getFragments()[0];
}
@Override
public IIndexFragmentFile getWritableFile(int linkageID, IIndexFileLocation location,
ISignificantMacros macroDictionary) throws CoreException {
@ -116,7 +117,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
public void acquireWriteLock() throws InterruptedException {
checkThread();
assert !fIsWriteLocked: "Multiple write locks is not allowed"; //$NON-NLS-1$
getWritableFragment().acquireWriteLock(getReadLockCount());
fIsWriteLocked= true;
}
@ -130,7 +131,6 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
public void releaseWriteLock(boolean flush) {
checkThread();
assert fIsWriteLocked: "No write lock to be released"; //$NON-NLS-1$
// Bug 297641: Result cache of read only providers needs to be cleared.
int establishReadlockCount = getReadLockCount();
@ -140,7 +140,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
fIsWriteLocked= false;
getWritableFragment().releaseWriteLock(establishReadlockCount, flush);
if (establishReadlockCount == 0) {
fThread= null;
}
@ -153,7 +153,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
throw new IllegalArgumentException("A writable index must not be used from multiple threads."); //$NON-NLS-1$
}
}
@Override
public void clearResultCache() {
assert fIsWriteLocked: "Need to hold a write lock to clear result caches"; //$NON-NLS-1$
@ -179,7 +179,7 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
return;
target.transferIncluders(source);
}
@Override
public void transferContext(IIndexFragmentFile source, IIndexFragmentFile target) throws CoreException {
if (source == null || target == null)

View file

@ -12,13 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.provider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.index.provider.IIndexProvider;
@ -45,6 +38,13 @@ import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* The IndexProviderManager is responsible for maintaining the set of index
* fragments contributed via the CIndex extension point.
@ -68,7 +68,7 @@ public final class IndexProviderManager implements IElementChangedListener {
private static final String ELEMENT_RO_INDEX_FRAGMENT_PROVIDER= "ReadOnlyIndexFragmentProvider"; //$NON-NLS-1$
private static final String ELEMENT_PROVIDER_USAGE= "FragmentProviderUsage"; //$NON-NLS-1$
@SuppressWarnings("nls")
private static final String
private static final String
ATTRIBUTE_CLASS = "class",
ATTRIBUTE_NAVIGATION = "navigation",
ATTRIBUTE_CONTENT_ASSIST = "content_assist",
@ -124,7 +124,7 @@ public final class IndexProviderManager implements IElementChangedListener {
providers.add(new ReadOnlyPDOMProviderBridge((IReadOnlyPDOMProvider) provider));
usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE));
} else {
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_InvalidIndexProvider,
extension.getContributor().getName()));
}
} else if (ELEMENT_RO_INDEX_FRAGMENT_PROVIDER.equals(element.getName())) {
@ -134,10 +134,10 @@ public final class IndexProviderManager implements IElementChangedListener {
providers.add((IIndexFragmentProvider) provider);
usageSpecifications.add(element.getChildren(ELEMENT_PROVIDER_USAGE));
} else {
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_0,
CCorePlugin.log(NLS.bind(Messages.IndexProviderManager_InvalidIndexProvider,
extension.getContributor().getName()));
}
}
}
}
} catch (CoreException e) {
CCorePlugin.log(e);
@ -173,7 +173,7 @@ public final class IndexProviderManager implements IElementChangedListener {
result |= getOption(elem, ATTRIBUTE_SEARCH, IIndexManager.ADD_EXTENSION_FRAGMENTS_SEARCH);
result |= getOption(elem, ATTRIBUTE_TYPE_HIERARCHY, IIndexManager.ADD_EXTENSION_FRAGMENTS_TYPE_HIERARCHY);
result |= getOption(elem, ATTRIBUTE_EDITOR, IIndexManager.ADD_EXTENSION_FRAGMENTS_EDITOR);
return result;
}
@ -264,7 +264,7 @@ public final class IndexProviderManager implements IElementChangedListener {
}
} catch (Exception e) {
// No logging, we are generating a msg for the log.
}
}
}
}
} catch (CoreException e) {
@ -361,7 +361,7 @@ public final class IndexProviderManager implements IElementChangedListener {
}
final int length = fragmentProviders.length;
IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length + 1];
System.arraycopy(fragmentProviders, 0, newProviders, 0, length);
newProviders[length] = (IIndexFragmentProvider) provider;
@ -386,12 +386,12 @@ public final class IndexProviderManager implements IElementChangedListener {
final int length = fragmentProviders.length;
IIndexFragmentProvider[] newProviders = new IIndexFragmentProvider[length - 1];
System.arraycopy(fragmentProviders, 0, newProviders, 0, i);
System.arraycopy(fragmentProviders, i+1, newProviders, i, length-i-1);
System.arraycopy(fragmentProviders, i + 1, newProviders, i, length - i - 1);
fragmentProviders = newProviders;
int[] newFilters = new int[length - 1];
System.arraycopy(fragmentProviderUsage, 0, newFilters, 0, i);
System.arraycopy(fragmentProviderUsage, i+1, newFilters, i, length-i-1);
System.arraycopy(fragmentProviderUsage, i + 1, newFilters, i, length - i - 1);
fragmentProviderUsage = newFilters;
return;
}

View file

@ -15,11 +15,11 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.index.provider.messages"; //$NON-NLS-1$
public static String IndexProviderManager_0;
public static String IndexProviderManager_InvalidIndexProvider;
public static String IndexProviderManager_NoCompatibleFragmentsAvailable;
static {
// initialize resource bundle
// Initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

View file

@ -8,5 +8,5 @@
# Contributors:
# Symbian Software Limited - initial API and implementation
###############################################################################
IndexProviderManager_0=Ignoring unrecognized implementation of IIndexProvider contributed by {0}
IndexProviderManager_InvalidIndexProvider=Ignoring unrecognized implementation of IIndexProvider contributed by {0}
IndexProviderManager_NoCompatibleFragmentsAvailable=No compatible index fragment found for fragment id: {0}, found versions {1}.

View file

@ -112,14 +112,14 @@ PDOMProviderName=PDOM Provider
fastIndexer.name=Fast Indexer
# built-in languages
# Built-in languages
language.name.gcc= GNU C
language.name.gpp= GNU C++
language.name.asm= Assembly
CConfigurationDataProvider.name = CConfigurationData provider
projectConverter.name = project converter
CIndex.name = CIndex
projectConverter.name = Project converter
CIndex.name = C/C++ Index
externalSettingsProvider.name = External Settings provider
tagger.name = Parser Node Tagger Extension Point
GeneratePDOMApplication.name = GeneratePDOM
@ -128,10 +128,10 @@ templatesExtensionPoint.name = Templates Extension point
templateProcessTypes.name = Process Types Extension point
templateAssociations.name = Template Associations
CProjectDescriptionStorage.name = Project Description Storage Extension point
CProjectStorageType.singlefile.name = Xml Storage (single file)
CProjectStorageType.separatefile.name = Xml Storage (Separate Files)
CProjectStorageType.singlefile.name = XML Storage (single file)
CProjectStorageType.separatefile.name = XML Storage (Separate Files)
scannerInfoProvider2.name = Scanner Info Provider
efsExtensionProvider.name = EFSExtensionProvider
efsExtensionProvider.name = EFS Extension Provider
refreshExclusionFactory.name = Refresh Exclusion Factory
uncPathConverter.name = UNC Path Converter
ScannerInfoExtensionLanguageSettingsProvider.name=Contributed ScannerInfo Entries

View file

@ -10,7 +10,6 @@
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.indexview;
import org.eclipse.core.runtime.CoreException;
@ -35,13 +34,13 @@ import org.eclipse.cdt.internal.ui.search.CSearchQuery;
* This is the search query to be used for searching the PDOM.
*/
public class IndexViewSearchQuery extends CSearchQuery {
private IIndexBinding fBinding;
private long fLastWrite;
private String fName;
private ICProject fProject;
public IndexViewSearchQuery(ICElement[] scope, ICProject project, long pdomLastWrite, IIndexBinding binding, String name, int flags) {
public IndexViewSearchQuery(ICElement[] scope, ICProject project, long pdomLastWrite,
IIndexBinding binding, String name, int flags) {
super(scope, flags);
fProject= project;
fBinding = binding;
@ -57,7 +56,7 @@ public class IndexViewSearchQuery extends CSearchQuery {
}
return Status.OK_STATUS;
} catch (CoreException e) {
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e);
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, e.getLocalizedMessage(), e);
}
}