1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-27 19:05:38 +02:00

@Override annotations.

This commit is contained in:
Sergey Prigogin 2011-12-28 17:21:02 -08:00
parent cfc0eec3f1
commit 302e64aebc
4 changed files with 81 additions and 45 deletions

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.IName;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IASTName extends IASTNode, IName { public interface IASTName extends IASTNode, IName {
/** /**
* Constant sentinel. * Constant sentinel.
*/ */
@ -32,12 +31,14 @@ public interface IASTName extends IASTNode, IName {
/** /**
* Returns the name including qualification and template arguments. * Returns the name including qualification and template arguments.
*/ */
@Override
public char[] toCharArray(); public char[] toCharArray();
/** /**
* Same as {@link #toCharArray()}. * Same as {@link #toCharArray()}.
* @since 5.1 * @since 5.1
*/ */
@Override
public String toString(); public String toString();
/** /**
@ -101,11 +102,13 @@ public interface IASTName extends IASTNode, IName {
/** /**
* @since 5.1 * @since 5.1
*/ */
@Override
public IASTName copy(); public IASTName copy();
/** /**
* @since 5.3 * @since 5.3
*/ */
@Override
public IASTName copy(CopyStyle style); public IASTName copy(CopyStyle style);
/** /**

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation * Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Mike Kucera (IBM) * Mike Kucera (IBM)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.parser; package org.eclipse.cdt.core.dom.parser;
@ -106,14 +106,15 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
protected abstract ParserLanguage getParserLanguage(); protected abstract ParserLanguage getParserLanguage();
@Deprecated @Deprecated
@Override
public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index,
IParserLogService log) throws CoreException { IParserLogService log) throws CoreException {
return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log); return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log);
} }
@Override
@Deprecated @Deprecated
@Override
public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory,
IIndex index, int options, IParserLogService log) throws CoreException { IIndex index, int options, IParserLogService log) throws CoreException {
@ -136,6 +137,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
if (log instanceof ICanceler) { if (log instanceof ICanceler) {
canceler= (ICanceler) log; canceler= (ICanceler) log;
canceler.setCancelable(new ICancelable() { canceler.setCancelable(new ICancelable() {
@Override
public void cancel() { public void cancel() {
scanner.cancel(); scanner.cancel();
parser.cancel(); parser.cancel();
@ -155,6 +157,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
} }
@Deprecated @Deprecated
@Override
public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader, public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index,
IParserLogService log, int offset) throws CoreException { IParserLogService log, int offset) throws CoreException {
@ -189,12 +192,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
*/ */
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) { protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) {
ParserMode mode; ParserMode mode;
if (forCompletion) if (forCompletion) {
mode= ParserMode.COMPLETION_PARSE; mode= ParserMode.COMPLETION_PARSE;
else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) } else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) {
mode= ParserMode.STRUCTURAL_PARSE; mode= ParserMode.STRUCTURAL_PARSE;
else } else {
mode= ParserMode.COMPLETE_PARSE; mode= ParserMode.COMPLETE_PARSE;
}
ISourceCodeParser parser= createParser(scanner, mode, log, index); ISourceCodeParser parser= createParser(scanner, mode, log, index);
if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) { if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
@ -224,6 +228,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return new CPreprocessor(content, scanInfo, getParserLanguage(), log, getScannerExtensionConfiguration(scanInfo), fcp); return new CPreprocessor(content, scanInfo, getParserLanguage(), log, getScannerExtensionConfiguration(scanInfo), fcp);
} }
@Override
@Deprecated @Deprecated
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
IASTNode selectedNode= ast.getNodeSelector(null).findNode(start, length); IASTNode selectedNode= ast.getNodeSelector(null).findNode(start, length);
@ -243,12 +248,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return collector.getNames(); return collector.getNames();
} }
@Override
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
// use default model builder // use default model builder
return null; return null;
} }
private ICLanguageKeywords cLanguageKeywords = null; private ICLanguageKeywords cLanguageKeywords;
private synchronized ICLanguageKeywords getCLanguageKeywords() { private synchronized ICLanguageKeywords getCLanguageKeywords() {
if (cLanguageKeywords == null) if (cLanguageKeywords == null)
@ -265,15 +271,18 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }
// for backwards compatibility // For backwards compatibility
@Override
public String[] getBuiltinTypes() { public String[] getBuiltinTypes() {
return getCLanguageKeywords().getBuiltinTypes(); return getCLanguageKeywords().getBuiltinTypes();
} }
@Override
public String[] getKeywords() { public String[] getKeywords() {
return getCLanguageKeywords().getKeywords(); return getCLanguageKeywords().getKeywords();
} }
@Override
public String[] getPreprocessorKeywords() { public String[] getPreprocessorKeywords() {
return getCLanguageKeywords().getPreprocessorKeywords(); return getCLanguageKeywords().getPreprocessorKeywords();
} }

View file

@ -6,10 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation * John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research) * Yuan Zhang / Beth Tibbitts (IBM Research)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; package org.eclipse.cdt.internal.core.dom.parser.c;
@ -31,14 +31,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
* Implementation for names in C translation units. * Implementation for names in C translation units.
*/ */
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext { public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
private final char[] name; private final char[] name;
private static final char[] EMPTY_CHAR_ARRAY = {}; private static final char[] EMPTY_CHAR_ARRAY = {};
private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding = null; private IBinding binding;
public CASTName(char[] name) { public CASTName(char[] name) {
this.name = name; this.name = name;
@ -48,10 +46,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
name = EMPTY_CHAR_ARRAY; name = EMPTY_CHAR_ARRAY;
} }
public CASTName copy() { @Override
public CASTName copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public CASTName copy(CopyStyle style) { public CASTName copy(CopyStyle style) {
CASTName copy = new CASTName(name == null ? null : name.clone()); CASTName copy = new CASTName(name == null ? null : name.clone());
copy.setOffsetAndLength(this); copy.setOffsetAndLength(this);
@ -61,7 +61,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return copy; return copy;
} }
public IBinding resolveBinding() { @Override
public IBinding resolveBinding() {
if (binding == null) { if (binding == null) {
CVisitor.createBinding(this); CVisitor.createBinding(this);
} }
@ -69,19 +70,23 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return binding; return binding;
} }
public IBinding resolvePreBinding() { @Override
public IBinding resolvePreBinding() {
return resolveBinding(); return resolveBinding();
} }
public IBinding getBinding() { @Override
public IBinding getBinding() {
return binding; return binding;
} }
public IBinding getPreBinding() { @Override
public IBinding getPreBinding() {
return binding; return binding;
} }
public IASTCompletionContext getCompletionContext() { @Override
public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent(); IASTNode node = getParent();
while (node != null) { while (node != null) {
if (node instanceof IASTCompletionContext) { if (node instanceof IASTCompletionContext) {
@ -95,7 +100,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return null; return null;
} }
public void setBinding(IBinding binding) { @Override
public void setBinding(IBinding binding) {
this.binding = binding; this.binding = binding;
} }
@ -107,14 +113,17 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return new String(name); return new String(name);
} }
public char[] toCharArray() { @Override
public char[] toCharArray() {
return name; return name;
} }
@Override
public char[] getSimpleID() { public char[] getSimpleID() {
return name; return name;
} }
@Override
public char[] getLookupKey() { public char[] getLookupKey() {
return name; return name;
} }
@ -146,6 +155,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
} }
@Override
public int getRoleOfName(boolean allowResolution) { public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) { if (parent instanceof IASTInternalNameOwner) {
@ -157,7 +167,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return IASTNameOwner.r_unclear; return IASTNameOwner.r_unclear;
} }
public boolean isDeclaration() { @Override
public boolean isDeclaration() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -172,8 +183,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false; return false;
} }
@Override
public boolean isReference() { public boolean isReference() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -187,7 +198,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false; return false;
} }
public boolean isDefinition() { @Override
public boolean isDefinition() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -201,10 +213,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false; return false;
} }
@Override
public ILinkage getLinkage() { public ILinkage getLinkage() {
return Linkage.C_LINKAGE; return Linkage.C_LINKAGE;
} }
@Override
public IBinding[] findBindings(IASTName n, boolean isPrefix) { public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTElaboratedTypeSpecifier) { if (parent instanceof IASTElaboratedTypeSpecifier) {
@ -247,6 +261,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings); return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
} }
@Override
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -46,9 +46,9 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
} }
} }
private IBinding fBinding = null; private IBinding fBinding;
private byte fResolutionDepth = 0; private byte fResolutionDepth;
private boolean fIsFinal= false; private boolean fIsFinal;
public final void incResolutionDepth() { public final void incResolutionDepth() {
if (fBinding == null && ++fResolutionDepth > MAX_RESOLUTION_DEPTH) { if (fBinding == null && ++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
@ -66,6 +66,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Resolves the name at least up to the intermediate binding and returns it. * Resolves the name at least up to the intermediate binding and returns it.
* @see ICPPTwoPhaseBinding * @see ICPPTwoPhaseBinding
*/ */
@Override
public IBinding resolvePreBinding() { public IBinding resolvePreBinding() {
if (fBinding == null) { if (fBinding == null) {
if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
@ -77,7 +78,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return fBinding; return fBinding;
} }
public IBinding resolveBinding() { @Override
public IBinding resolveBinding() {
if (fBinding == null) { if (fBinding == null) {
if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
setBinding(new RecursionResolvingBinding(this)); setBinding(new RecursionResolvingBinding(this));
@ -105,7 +107,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Otherwise the intermediate or final binding for this name is returned. * Otherwise the intermediate or final binding for this name is returned.
* @see ICPPTwoPhaseBinding * @see ICPPTwoPhaseBinding
*/ */
public IBinding getPreBinding() { @Override
public IBinding getPreBinding() {
return fBinding; return fBinding;
} }
@ -114,7 +117,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Otherwise the final binding for this name is returned. * Otherwise the final binding for this name is returned.
* @see ICPPTwoPhaseBinding * @see ICPPTwoPhaseBinding
*/ */
public IBinding getBinding() { @Override
public IBinding getBinding() {
final IBinding cand= fBinding; final IBinding cand= fBinding;
if (cand == null) if (cand == null)
return null; return null;
@ -137,11 +141,13 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
fIsFinal= true; fIsFinal= true;
} }
@Override
public void setBinding(IBinding binding) { public void setBinding(IBinding binding) {
fBinding= binding; fBinding= binding;
fResolutionDepth= 0; fResolutionDepth= 0;
} }
@Override
public IASTName getLastName() { public IASTName getLastName() {
return this; return this;
} }
@ -151,6 +157,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return new String(toCharArray()); return new String(toCharArray());
} }
@Override
public IASTCompletionContext getCompletionContext() { public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent(); IASTNode node = getParent();
while (node != null) { while (node != null) {
@ -163,6 +170,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return null; return null;
} }
@Override
public int getRoleOfName(boolean allowResolution) { public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) { if (parent instanceof IASTInternalNameOwner) {
@ -174,7 +182,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return IASTNameOwner.r_unclear; return IASTNameOwner.r_unclear;
} }
public boolean isDeclaration() { @Override
public boolean isDeclaration() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -189,7 +198,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false; return false;
} }
public boolean isReference() { @Override
public boolean isReference() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -198,7 +208,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false; return false;
} }
public boolean isDefinition() { @Override
public boolean isDefinition() {
IASTNode parent = getParent(); IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) { if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this); int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -207,9 +218,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false; return false;
} }
/* (non-Javadoc) @Override
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
*/
public ILinkage getLinkage() { public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE; return Linkage.CPP_LINKAGE;
} }