From d8d335dbf8d31205be5cfbcbedf1bc049f0eed21 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 31 Oct 2011 19:17:31 -0700 Subject: [PATCH] Added missing @Override annotations. --- .../core/dom/rewrite/ASTLiteralNode.java | 22 ++++- .../core/dom/rewrite/TrackedNodePosition.java | 8 +- .../dom/rewrite/astwriter/ContainerNode.java | 17 ++-- .../astwriter/ProblemRuntimeException.java | 10 +-- .../formatter/CodeFormatterVisitor.java | 13 ++- .../refactoring/CTextFileChangeFactory.java | 3 +- .../ui/refactoring/DocumentAdapter.java | 82 +++++++++++++------ 7 files changed, 104 insertions(+), 51 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java index 638108f78a5..7d7b5b74e5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite; @@ -31,10 +31,12 @@ public class ASTLiteralNode implements IASTNode { fCode= code; } + @Override public String getRawSignature() { return fCode; } + @Override public boolean accept(ASTVisitor visitor) { if (visitor instanceof ASTWriterVisitor) { ((ASTWriterVisitor) visitor).visit(this); @@ -42,72 +44,90 @@ public class ASTLiteralNode implements IASTNode { return true; } + @Override public boolean contains(IASTNode node) { return false; } + @Override public String getContainingFilename() { return null; } + @Override public IASTFileLocation getFileLocation() { return null; } + @Override public IASTNodeLocation[] getNodeLocations() { return null; } + @Override public IASTNode getParent() { return null; } + @Override public IASTNode[] getChildren() { return IASTNode.EMPTY_NODE_ARRAY; } + @Override public ASTNodeProperty getPropertyInParent() { return null; } + @Override public IASTTranslationUnit getTranslationUnit() { return null; } + @Override public boolean isPartOfTranslationUnitFile() { return false; } + @Override public void setParent(IASTNode node) { } + @Override public void setPropertyInParent(ASTNodeProperty property) { } + @Override public IToken getSyntax() { throw new UnsupportedOperationException(); } + @Override public IToken getLeadingSyntax() { throw new UnsupportedOperationException(); } + @Override public IToken getTrailingSyntax() { throw new UnsupportedOperationException(); } + @Override public boolean isFrozen() { return false; } + @Override public IASTNode copy() { throw new UnsupportedOperationException(); } + @Override public IASTNode copy(CopyStyle style) { throw new UnsupportedOperationException(); } + @Override public boolean isActive() { return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java index d31331325c4..d92ade75747 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/TrackedNodePosition.java @@ -30,9 +30,7 @@ public class TrackedNodePosition implements ITrackedNodePosition { this.node= node; } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getStartPosition() - */ + @Override public int getStartPosition() { if (this.group.isEmpty()) { return this.node.getOffset(); @@ -44,9 +42,7 @@ public class TrackedNodePosition implements ITrackedNodePosition { return coverage.getOffset(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getLength() - */ + @Override public int getLength() { if (this.group.isEmpty()) { return this.node.getLength(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java index a9cfdeee41b..f32f3a57262 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ContainerNode.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; @@ -20,18 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; - /** - * - * This class serves as a container to pass several nodes to the - * ASTWriter. This container is used if source code for several sibling nodes but - * for their common parent node should be generated. + * This class serves as a container to pass several nodes to the ASTWriter. + * This container is used if source code for several sibling nodes but for their common parent + * node should be generated. * * @author Emanuel Graf IFS - * */ public class ContainerNode extends ASTNode { - private final IASTTranslationUnit tu = null; private final ArrayList nodes = new ArrayList(); @@ -42,10 +38,12 @@ public class ContainerNode extends ASTNode { } } + @Override public ContainerNode copy() { return copy(CopyStyle.withoutLocations); } + @Override public ContainerNode copy(CopyStyle style) { ContainerNode copy = new ContainerNode(); for (IASTNode node : getNodes()) @@ -59,7 +57,7 @@ public class ContainerNode extends ASTNode { public void addNode(IASTNode node) { nodes.add(node); - if(node.getParent() == null) { + if (node.getParent() == null) { node.setParent(tu); } } @@ -80,5 +78,4 @@ public class ContainerNode extends ASTNode { public List getNodes(){ return Collections.unmodifiableList(nodes); } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java index 1dbddc51c45..11a47db433c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ProblemRuntimeException.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; @@ -15,16 +15,13 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTProblemHolder; /** - * - * This exception is thrown if a problem nod is passed to the astwriter. The Exception + * This exception is thrown if a problem node is passed to the ASTWriter. The exception * contains the IASTProblemHolder that was passed to the writer. * * @see IASTProblem * @author Emanuel Graf IFS - * */ public class ProblemRuntimeException extends RuntimeException { - private static final long serialVersionUID = -3661425564246498786L; private IASTProblemHolder problem; @@ -32,8 +29,7 @@ public class ProblemRuntimeException extends RuntimeException { problem = statement; } - public IASTProblemHolder getProblem(){ + public IASTProblemHolder getProblem() { return problem; } - } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index b6808425482..4f103f5d5af 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -187,7 +187,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats a given token at a given position. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -211,6 +211,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, spaceBeforeToken, spaceAfterToken); } + @Override public void run() { int offset = scribe.scanner.getCurrentPosition(); if (tokenPosition < 0 || offset > tokenPosition) @@ -229,7 +230,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats a trailing semicolon. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -242,7 +243,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } - /* + /** * Formats the part of a function declaration following the parameter list. * @see #formatList(List, ListOptions, boolean, boolean, Runnable) */ @@ -256,6 +257,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, this.continuationFormatter = tailFormatter; } + @Override public void run() { boolean needSpace = skipConstVolatileRestrict(); int token = peekNextToken(); @@ -303,6 +305,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } } + /** + * Formats a trailing semicolon. + * @see #formatList(List, ListOptions, boolean, boolean, Runnable) + */ private class ClosingParensesisTailFormatter implements Runnable { private final boolean spaceBeforeClosingParen; private final Runnable continuationFormatter; @@ -315,6 +321,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, this.parenPosition = scribe.findToken(Token.tRPAREN); } + @Override public void run() { int offset = scribe.scanner.getCurrentPosition(); if (parenPosition >= 0 && offset <= parenPosition) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java index 41868e1e6f6..2341aa2c35e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ICTextFileChangeFactory; */ public class CTextFileChangeFactory implements ICTextFileChangeFactory { + @Override public TextFileChange createCTextFileChange(IFile file) { return new CTextFileChange(file.getName(), file); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java index 12e40b4b9fb..bf623992367 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java @@ -6,12 +6,11 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; - import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -50,7 +49,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.core.model.IBufferFactory; - /** * Adapts IDocument to IBuffer. Uses the * same algorithm as the text widget to determine the buffer's line delimiter. @@ -60,14 +58,13 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory; * This class is similar to the JDT DocumentAdapter class. */ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { - /** * Executes a document set content call in the ui thread. */ protected class DocumentSetCommand implements Runnable { - private String fContents; + @Override public void run() { fDocument.set(fContents); } @@ -82,11 +79,11 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { * Executes a document replace call in the ui thread. */ protected class DocumentReplaceCommand implements Runnable { - private int fOffset; private int fLength; private String fText; + @Override public void run() { try { fDocument.replace(fOffset, fLength, fText); @@ -104,31 +101,52 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { } private static final boolean DEBUG_LINE_DELIMITERS= true; - public static final IBuffer NULL_BUFFER = new IBuffer(){ + public static final IBuffer NULL_BUFFER = new IBuffer() { + @Override public void addBufferChangedListener(IBufferChangedListener listener) {} + @Override public void append(char[] text) {} + @Override public void append(String text) {} + @Override public void close() {} - public char getChar(int position) {return 0;} - public char[] getCharacters() {return new char[0];} - public String getContents() {return "";} //$NON-NLS-1$ - public int getLength() {return 0;} + @Override + public char getChar(int position) { return 0; } + @Override + public char[] getCharacters() { return new char[0]; } + @Override + public String getContents() { return ""; } //$NON-NLS-1$ + @Override + public int getLength() { return 0; } + @Override public IOpenable getOwner() {return null;} - public String getText(int offset, int length) {return "";} //$NON-NLS-1$ - public IResource getUnderlyingResource() {return null;} - public boolean hasUnsavedChanges() {return false;} - public boolean isClosed() {return false;} - public boolean isReadOnly() {return true;} + @Override + public String getText(int offset, int length) { return ""; } //$NON-NLS-1$ + @Override + public IResource getUnderlyingResource() { return null; } + @Override + public boolean hasUnsavedChanges() { return false; } + @Override + public boolean isClosed() { return false; } + @Override + public boolean isReadOnly() { return true; } + @Override public void removeBufferChangedListener(IBufferChangedListener listener) {} + @Override public void replace(int position, int length, char[] text) {} + @Override public void replace(int position, int length, String text) {} + @Override public void save(IProgressMonitor progress, boolean force) throws CModelException {} + @Override public void setContents(char[] contents) {} + @Override public void setContents(String contents) {} }; public static IBufferFactory FACTORY= new IBufferFactory() { - public IBuffer createBuffer(IOpenable owner) { + @Override + public IBuffer createBuffer(IOpenable owner) { if (owner instanceof IWorkingCopy) { IWorkingCopy wc= (IWorkingCopy) owner; ITranslationUnit tu= wc.getOriginalElement(); @@ -206,6 +224,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IBuffer#addBufferChangedListener(IBufferChangedListener) */ + @Override public void addBufferChangedListener(IBufferChangedListener listener) { Assert.isNotNull(listener); if (!fBufferListeners.contains(listener)) @@ -215,6 +234,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IBuffer#removeBufferChangedListener(IBufferChangedListener) */ + @Override public void removeBufferChangedListener(IBufferChangedListener listener) { Assert.isNotNull(listener); fBufferListeners.remove(listener); @@ -224,6 +244,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#append(char[]) */ + @Override public void append(char[] text) { append(new String(text)); } @@ -231,6 +252,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String) */ + @Override public void append(String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); @@ -242,8 +264,8 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#close() */ + @Override public void close() { - if (isClosed()) return; @@ -268,6 +290,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getChar(int) */ + @Override public char getChar(int position) { try { return fDocument.getChar(position); @@ -279,6 +302,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getCharacters() */ + @Override public char[] getCharacters() { String content= getContents(); return content == null ? null : content.toCharArray(); @@ -287,6 +311,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getContents() */ + @Override public String getContents() { return fDocument.get(); } @@ -294,6 +319,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getLength() */ + @Override public int getLength() { return fDocument.getLength(); } @@ -301,6 +327,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getOwner() */ + @Override public IOpenable getOwner() { return fOwner; } @@ -308,6 +335,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int) */ + @Override public String getText(int offset, int length) { try { return fDocument.get(offset, length); @@ -319,6 +347,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource() */ + @Override public IResource getUnderlyingResource() { return fFile; } @@ -326,6 +355,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges() */ + @Override public boolean hasUnsavedChanges() { return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false; } @@ -333,6 +363,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#isClosed() */ + @Override public boolean isClosed() { return fDocument == null; } @@ -340,6 +371,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly() */ + @Override public boolean isReadOnly() { IResource resource= getUnderlyingResource(); if (resource != null) { @@ -354,6 +386,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[]) */ + @Override public void replace(int position, int length, char[] text) { replace(position, length, new String(text)); } @@ -361,6 +394,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String) */ + @Override public void replace(int position, int length, String text) { if (DEBUG_LINE_DELIMITERS) { validateLineDelimiters(text); @@ -371,6 +405,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean) */ + @Override public void save(IProgressMonitor progress, boolean force) throws CModelException { try { if (fTextFileBuffer != null) @@ -383,6 +418,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) */ + @Override public void setContents(char[] contents) { setContents(new String(contents)); } @@ -390,14 +426,13 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /** * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String) */ + @Override public void setContents(String contents) { int oldLength= fDocument.getLength(); if (contents == null) { - if (oldLength != 0) fSetCmd.set(""); //$NON-NLS-1$ - } else { // set only if different if (DEBUG_LINE_DELIMITERS) { @@ -407,12 +442,10 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { int newLength= contents.length(); if (oldLength != newLength || !contents.equals(fDocument.get())) fSetCmd.set(contents); - } } private void validateLineDelimiters(String contents) { - if (fLegalLineDelimiters == null) { // collect all line delimiters in the document HashSet existingDelimiters= new HashSet(); @@ -460,6 +493,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent event) { // there is nothing to do here } @@ -467,6 +501,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { /* * @see IDocumentListener#documentChanged(DocumentEvent) */ + @Override public void documentChanged(DocumentEvent event) { fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText())); } @@ -483,6 +518,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { return fTextFileBuffer; } + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Class adapter) { if (adapter.isAssignableFrom(ITextFileBuffer.class)) {