1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-02-27 12:25:14 -08:00
parent 96a4a227aa
commit ba6c3f6316
20 changed files with 94 additions and 98 deletions

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.pdom.tests;
import java.io.File;

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.pdom.tests;
import java.io.File;

View file

@ -8,24 +8,24 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point. The implementation is
* responsible for populating the tag's data using a given input binding.
* Implementations are contributed with the org.eclipse.cdt.core.tagger extension-point.
* The implementation is responsible for populating the tag's data using a given input binding.
*
* @see #process(ITagWriter, IBinding, IASTName)
* @since 5.5
*/
public interface IBindingTagger {
/**
* Examines the given input binding to decide if a tag should be created. Use the given tagWriter to
* create data if needed. Return the tag if one was created and null otherwise. A tagger (as identified by
* it's unique id string) is allowed to create only one tag for each binding.
* Examines the given input binding to decide if a tag should be created. Use the given
* tagWriter to create data if needed. Return the tag if one was created and null otherwise.
* A tagger (as identified by it's unique id string) is allowed to create only one tag for each
* binding.
*
* @param tagWriter
* the writer to use for creating new tags

View file

@ -8,13 +8,13 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
* Tags are used to annotate {@link ITagReader}'s with extra information. They are created by implementations
* of {@link IBindingTagger} which are contributed using the org.eclipse.cdt.core.tagger extension point. The
* base tag interface is read-only, it is extended by the writable {@link IWritableTag}.
* Tags are used to annotate {@link ITagReader}'s with extra information. They are created by
* implementations of {@link IBindingTagger} which are contributed using
* the org.eclipse.cdt.core.tagger extension point. The base tag interface is read-only, it is
* extended by the writable {@link IWritableTag}.
*
* @see IBindingTagger
* @see ITagReader
@ -25,20 +25,21 @@ public interface ITag {
/** A constant that is returned to indicate a read failure. */
public static final int FAIL = -1;
/** Return the number of bytes in the tag's data payload. */
/** Returns the number of bytes in the tag's data payload. */
public int getDataLen();
/** Return the globally unique id of the tagger that created the receiver. */
/** Returns the globally unique id of the tagger that created the receiver. */
public String getTaggerId();
/** Return the byte from the specified offset or {@link #FAIL} on failure. */
/** Returns the byte from the specified offset or {@link #FAIL} on failure. */
public int getByte(int offset);
/**
* Return the specified number of bytes from the specified offset. Specify len of -1 to read all bytes
* from the specified offset to the end of the payload. Return null if the given range is not valid. This
* would be expected if the version of the contributor has changed in a way that changes the structure of
* the data that it stores. Contributors must be able to deal with that case.
* Returns the specified number of bytes from the specified offset. Specify {@code len} of -1
* to read all bytes from the specified offset to the end of the payload. Returns null if
* the given range is not valid. This would be expected if the version of the contributor has
* changed in a way that changes the structure of the data that it stores. Contributors must be
* able to deal with that case.
*/
public byte[] getBytes(int offset, int len);
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
@ -20,16 +19,17 @@ package org.eclipse.cdt.core.dom.ast.tag;
*/
public interface ITagReader {
/**
* Look for a tag for the receiver, returns null if there is no such tag.
* Looks for a tag for the receiver, returns null if there is no such tag.
*
* @param id
* A string that uniquely identifies the tag to be returned. This value was provided by the
* contributor when the tag was created (see {@link ITagWriter#createTag(String, int)}).
* A string that uniquely identifies the tag to be returned. This value was provided
* by the contributor when the tag was created
* (see {@link ITagWriter#createTag(String, int)}).
*/
public ITag getTag(String id);
/**
* Return all tags known to the receiver. Does not return null.
* Returns all tags known to the receiver. Does not return null.
*/
public Iterable<ITag> getTags();
}

View file

@ -8,14 +8,13 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding;
/**
* Provides ITagReaders for specific bindings. The kind of the reader will vary based on the kind of the input
* binding.
* Provides ITagReaders for specific bindings. The kind of the reader will vary based on the kind
* of the input binding.
*
* @see ITag
* @see ITagReader
@ -23,8 +22,8 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
*/
public interface ITagService {
/**
* Finds or creates a tag reader for the specified binding or null if a reader cannot be associated with
* this binding.
* Finds or creates a tag reader for the specified binding or null if a reader cannot be
* associated with this binding.
*
* @param binding
* could be null

View file

@ -20,20 +20,20 @@ package org.eclipse.cdt.core.dom.ast.tag;
*/
public interface ITagWriter {
/**
* Create and return a new tag for the receiver. E.g., if this writer is associated with a persistent
* binding, then returned tag will read and write from the PDOM database.
* Creates and returns a new tag for the receiver. E.g., if this writer is associated with
* a persistent binding, then returned tag will read and write from the PDOM database.
*
* @param id
* A string that uniquely identifies the tag to be returned. This value will be used by the
* contributor when to find the tag (see {@link ITagReader#getTag(String)}).
* A string that uniquely identifies the tag to be returned. This value will be used
* by the contributor when to find the tag (see {@link ITagReader#getTag(String)}).
* @param len
* The number of bytes that should be allocated to store the tag's data.
*/
public IWritableTag createTag(String id, int len);
/**
* Sets the receiver's tags to only the ones provided. Deletes existing tags that are not in the argument
* list.
* Sets the receiver's tags to only the ones provided. Deletes existing tags that are not in
* the argument list.
*/
public boolean setTags(Iterable<ITag> tags);
}

View file

@ -8,12 +8,12 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.core.dom.ast.tag;
/**
* Tags are used to annotate {@link ITagWriter}'s with extra information. They are created by implementations
* of {@link IBindingTagger} which are contributed using the org.eclipse.cdt.core.tagger extension point.
* Tags are used to annotate {@link ITagWriter}'s with extra information. They are created by
* implementations of {@link IBindingTagger} which are contributed using
* the org.eclipse.cdt.core.tagger extension point.
*
* @see IBindingTagger
* @see ITagReader
@ -21,13 +21,13 @@ package org.eclipse.cdt.core.dom.ast.tag;
* @since 5.5
*/
public interface IWritableTag extends ITag {
/** Write the given byte to the given offset in the tag. Return true if successful and false otherwise. */
/** Writes the given byte to the given offset in the tag. Returns {@code true} if successful. */
public boolean putByte(int offset, byte data);
/**
* Write the argument buffer into the receiver's payload starting at the specified offset. Write the
* specified number of bytes or the full buffer when len is -1. Return true if successful and false
* otherwise.
* Writes the argument buffer into the receiver's payload starting at the specified offset.
* Writes the specified number of bytes or the full buffer when {@code len} is -1. Returns
* {@code true} if successful.
*/
public boolean putBytes(int offset, byte data[], int len);
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -47,7 +46,7 @@ public class NonCachedTaggable implements ITagReader, ITagWriter {
@Override
public boolean setTags(Iterable<ITag> tags) {
// this non-caching implementation has nothing to set, the tags will be regenerated
// This non-caching implementation has nothing to set, the tags will be regenerated
// when they are queried
return true;
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.tag.ITag;

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import java.util.HashMap;
@ -29,6 +28,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
public class TagManager {
private static final String EXTENSION_POINT = "tagger"; //$NON-NLS-1$
private static TagManager INSTANCE;
private Map<String, TaggerDescriptor> taggers;
@ -43,14 +43,12 @@ public class TagManager {
taggers = loadExtensions();
}
private static final String ExtensionPoint = "tagger"; //$NON-NLS-1$
private static Map<String, TaggerDescriptor> loadExtensions() {
Map<String, TaggerDescriptor> taggers = new HashMap<String, TaggerDescriptor>();
// load the extensions
// Load the extensions
IConfigurationElement[] elements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(CCorePlugin.PLUGIN_ID, ExtensionPoint);
.getConfigurationElementsFor(CCorePlugin.PLUGIN_ID, EXTENSION_POINT);
for (IConfigurationElement element : elements) {
TaggerDescriptor desc = new TaggerDescriptor(element);
taggers.put(desc.getId(), desc);
@ -60,8 +58,8 @@ public class TagManager {
}
/**
* Provide an opportunity for the specified tagger to process the given values. The tagger will only run
* if its enablement expression returns true for the arguments.
* Provides an opportunity for the specified tagger to process the given values. The tagger will
* only run if its enablement expression returns true for the arguments.
*/
public ITag process(String taggerId, ITagWriter tagWriter, IBinding binding, IASTName ast) {
TaggerDescriptor desc = taggers.get(taggerId);
@ -72,7 +70,7 @@ public class TagManager {
return tagger == null ? null : tagger.process(tagWriter, binding, ast);
}
/** Provide an opportunity for all enabled taggers to process the given values. */
/** Provides an opportunity for all enabled taggers to process the given values. */
public Iterable<ITag> process(ITagWriter tagWriter, IBinding binding, IASTName ast) {
List<ITag> tags = new LinkedList<ITag>();
for (TaggerDescriptor desc : taggers.values()) {
@ -87,7 +85,7 @@ public class TagManager {
return tags;
}
/** Add or remove tags from the destination to ensure that it has the same tag information as the source. */
/** Adds or removes tags from the destination to ensure that it has the same tag information as the source. */
public void syncTags(IPDOMBinding dst, IBinding src) {
// don't try to copy any tags when there are no contributors to this extension point
if (dst == null || taggers.isEmpty())

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding;
@ -17,16 +16,17 @@ import org.eclipse.cdt.core.dom.ast.tag.ITagService;
public class TagService implements ITagService {
/**
* First gives the IBinding instance a chance to convert itself, by calling IAdaptable#getAdapter(
* ITagReader.class ) on the binding. If the binding doesn't provide an implementation then a simple,
* in-memory, non-cached implementation is created and returned.
* First gives the IBinding instance a chance to convert itself, by calling
* IAdaptable#getAdapter(ITagReader.class) on the binding. If the binding doesn't provide
* an implementation then a simple, in-memory, non-cached implementation is created and
* returned.
*/
@Override
public ITagReader findTagReader(IBinding binding) {
if (binding == null)
return null;
// let the binding adapt to its own tag reader
// Let the binding adapt to its own tag reader
ITagReader tagReader = (ITagReader) binding.getAdapter(ITagReader.class);
if (tagReader != null)
return tagReader;

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.dom.ast.tag;
import java.util.Arrays;
@ -33,9 +32,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
/**
* Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of the tagger is
* instantiated only after checking the enablement expression (if present) for the specified binding. This
* avoids activating the contributing plugin until it is actually needed.
* Internal container for extensions of org.eclipse.cdt.core.tagger. The implementation of
* the tagger is instantiated only after checking the enablement expression (if present) for
* the specified binding. This avoids activating the contributing plugin until it is actually
* needed.
*/
public class TaggerDescriptor {
private static final String Attr_LocalId = "local-id"; //$NON-NLS-1$
@ -52,10 +52,10 @@ public class TaggerDescriptor {
private static final String VAR_LANGUAGEID = "languageId"; //$NON-NLS-1$
/**
* An empty implementation of the tagger used as a placeholder in descriptors that are unable to load the
* contributed class.
* An empty implementation of the tagger used as a placeholder in descriptors that are unable
* to load the contributed class.
*/
private static final IBindingTagger NullTagger = new IBindingTagger() {
private static final IBindingTagger NULL_TAGGER = new IBindingTagger() {
@Override
public ITag process(ITagWriter tagWriter, IBinding binding, IASTName ast) {
return null;
@ -97,8 +97,8 @@ public class TaggerDescriptor {
// there must be a valid local id
if (localId == null) {
String extId = element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin
.log("Invalid extension " + globalId + '.' + extId + " must provide tagger's local-id"); //$NON-NLS-1$ //$NON-NLS-2$
CCorePlugin.log("Invalid extension " + globalId + '.' + extId //$NON-NLS-1$
+ " must provide tagger's local-id"); //$NON-NLS-1$
return null;
}
@ -109,8 +109,8 @@ public class TaggerDescriptor {
// make sure the local id has real content
if (localId.isEmpty()) {
String extId = element.getDeclaringExtension().getSimpleIdentifier();
CCorePlugin
.log("Invalid extension " + globalId + '.' + extId + " must provide value for tagger's local-id"); //$NON-NLS-1$ //$NON-NLS-2$
CCorePlugin.log("Invalid extension " + globalId + '.' + extId //$NON-NLS-1$
+ " must provide value for tagger's local-id"); //$NON-NLS-1$
return null;
}
@ -121,12 +121,12 @@ public class TaggerDescriptor {
}
private boolean matches(ITranslationUnit tu) {
// if the enablement expression is missing or structurally invalid, then return immediately
// If the enablement expression is missing or structurally invalid, then return immediately
if (fStatus != null)
return fStatus.booleanValue();
// if there is no tu, then the enablement expression cannot be evaluated, assume that all taggers
// are needed
// If there is no tu, then the enablement expression cannot be evaluated, assume that all
// taggers are needed
if (tu == null)
return true;
@ -171,7 +171,7 @@ public class TaggerDescriptor {
CCorePlugin.log("Error in class attribute of " + id, e); //$NON-NLS-1$
// mark the tagger with an empty implementation to prevent future load attempts
tagger = NullTagger;
tagger = NULL_TAGGER;
}
}
}

View file

@ -344,7 +344,7 @@ public class CPPVisitor extends ASTQueries {
if (inScope == null)
return false;
IBinding pb= names[names.length-2].resolvePreBinding();
IBinding pb= names[names.length - 2].resolvePreBinding();
if (pb instanceof IProblemBinding)
return false;
@ -930,11 +930,11 @@ public class CPPVisitor extends ASTQueries {
if (name instanceof ICPPASTQualifiedName) {
IASTName[] names = ((ICPPASTQualifiedName) name).getNames();
if (names.length >= 2) {
IBinding b= names[names.length-2].resolvePreBinding();
IBinding b= names[names.length - 2].resolvePreBinding();
if (b instanceof IType) {
IType classType= getNestedType((IType) b, TDEF);
if (classType instanceof ICPPClassType) {
final char[] dtorName = names[names.length-1].getLookupKey();
final char[] dtorName = names[names.length - 1].getLookupKey();
final char[] className = ((ICPPClassType) classType).getNameCharArray();
return CharArrayUtils.equals(dtorName, className);
}
@ -1303,7 +1303,7 @@ public class CPPVisitor extends ASTQueries {
IASTName name = findInnermostDeclarator(fnDeclarator).getName();
if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();
name = ns[ns.length -1];
name = ns[ns.length - 1];
}
return getContainingScope(name);
}

View file

@ -1006,9 +1006,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm);
fStatistics.fParsingTime += System.currentTimeMillis() - start;
if (ast != null) {
// Give the new AST-TU a chance to recognize its translation unit before it is written
// Give the new AST a chance to recognize its translation unit before it is written
// to the index.
((ASTTranslationUnit)ast).setOriginatingTranslationUnit((ITranslationUnit)tu);
((ASTTranslationUnit) ast).setOriginatingTranslationUnit((ITranslationUnit) tu);
writeToIndex(lang.getLinkageID(), ast, codeReader, ctx, pm);
}
} catch (CoreException e) {

View file

@ -69,13 +69,14 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IPDOMBinding
if (adapter.isAssignableFrom(PDOMBinding.class))
return this;
// Any PDOMBinding can have a persistent tag. These tags should be deleted when the PDOMBinding
// is deleted. However, PDOMBinding's don't get deleted, so there is no way to trigger deleting
// of the tags. If the implementation is changed so that PDOMBindings do get deleted, then call:
// PDOMTagIndex.setTags( getPDOM(), pdomBinding.record, Collections.<ITag>emptyList() );
// Any PDOMBinding can have a persistent tag. These tags should be deleted when
// the PDOMBinding is deleted. However, PDOMBinding's don't get deleted, so there is no way
// to trigger deleting of the tags. If the implementation is changed so that PDOMBindings
// do get deleted, then it should call:
// PDOMTagIndex.setTags(getPDOM(), pdomBinding.record, Collections.<ITag>emptyList());
// to clear out all tags for the binding.
if (adapter.isAssignableFrom(ITagReader.class))
return new PDOMTaggable( getPDOM(), getRecord() );
return new PDOMTaggable(getPDOM(), getRecord());
return null;
}

View file

@ -99,9 +99,9 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
getPDOM().putCachedResult(inputBinding, pdomBinding);
}
// Synchronize the tags associated with the persistent binding to match the set that is
// associated with the input binding.
TagManager.getInstance().syncTags( pdomBinding, inputBinding );
// Synchronize the tags associated with the persistent binding to match the set that
// is associated with the input binding.
TagManager.getInstance().syncTags(pdomBinding, inputBinding);
return pdomBinding;
}
@ -114,9 +114,10 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
pdomBinding.update(this, fromBinding);
// Update the tags based on the tags from the new binding. This was in PDOMBinding.update, but
// I found that not all subclasses (e.g., PDOMCPPFunction) call the parent implementation.
TagManager.getInstance().syncTags( pdomBinding, fromBinding );
// Update the tags based on the tags from the new binding. This cannot be done in
// PDOMBinding.update, because not all subclasses (e.g., PDOMCPPFunction) call
// the superclass implementation.
TagManager.getInstance().syncTags(pdomBinding, fromBinding);
}
return pdomBinding;
}

View file

@ -362,9 +362,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
}
// Synchronize the tags associated with the persistent binding to match the set that is
// associated with the input binding.
TagManager.getInstance().syncTags( pdomBinding, inputBinding );
// Synchronize the tags associated with the persistent binding to match
// the set that is associated with the input binding.
TagManager.getInstance().syncTags(pdomBinding, inputBinding);
}
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
@ -378,8 +378,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
pdomBinding.update(this, fromBinding);
// Update the tags based on the tags from the new binding. This was in PDOMBinding.update, but
// I found that not all subclasses (e.g., PDOMCPPFunction) call the parent implementation.
// Update the tags based on the tags from the new binding. This cannot be done in
// PDOMBinding.update, because not all subclasses (e.g., PDOMCPPFunction) call
// the superclass implementation.
TagManager.getInstance().syncTags(pdomBinding, fromBinding);
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Andrew Eidsness - Initial implementation
*/
package org.eclipse.cdt.internal.core.pdom.tag;
import java.util.Collections;

View file

@ -208,7 +208,7 @@ public class CCorePlugin extends Plugin {
/**
* @noreference This field is not intended to be referenced by clients.
*/
public CDTLogWriter cdtLog = null;
public CDTLogWriter cdtLog;
private volatile CProjectDescriptionManager fNewCProjectDescriptionManager;