1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Added missing @Override annotations.

This commit is contained in:
Sergey Prigogin 2011-10-31 19:17:31 -07:00
parent 8da748eb55
commit d8d335dbf8
7 changed files with 104 additions and 51 deletions

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.rewrite; package org.eclipse.cdt.internal.core.dom.rewrite;
@ -31,10 +31,12 @@ public class ASTLiteralNode implements IASTNode {
fCode= code; fCode= code;
} }
@Override
public String getRawSignature() { public String getRawSignature() {
return fCode; return fCode;
} }
@Override
public boolean accept(ASTVisitor visitor) { public boolean accept(ASTVisitor visitor) {
if (visitor instanceof ASTWriterVisitor) { if (visitor instanceof ASTWriterVisitor) {
((ASTWriterVisitor) visitor).visit(this); ((ASTWriterVisitor) visitor).visit(this);
@ -42,72 +44,90 @@ public class ASTLiteralNode implements IASTNode {
return true; return true;
} }
@Override
public boolean contains(IASTNode node) { public boolean contains(IASTNode node) {
return false; return false;
} }
@Override
public String getContainingFilename() { public String getContainingFilename() {
return null; return null;
} }
@Override
public IASTFileLocation getFileLocation() { public IASTFileLocation getFileLocation() {
return null; return null;
} }
@Override
public IASTNodeLocation[] getNodeLocations() { public IASTNodeLocation[] getNodeLocations() {
return null; return null;
} }
@Override
public IASTNode getParent() { public IASTNode getParent() {
return null; return null;
} }
@Override
public IASTNode[] getChildren() { public IASTNode[] getChildren() {
return IASTNode.EMPTY_NODE_ARRAY; return IASTNode.EMPTY_NODE_ARRAY;
} }
@Override
public ASTNodeProperty getPropertyInParent() { public ASTNodeProperty getPropertyInParent() {
return null; return null;
} }
@Override
public IASTTranslationUnit getTranslationUnit() { public IASTTranslationUnit getTranslationUnit() {
return null; return null;
} }
@Override
public boolean isPartOfTranslationUnitFile() { public boolean isPartOfTranslationUnitFile() {
return false; return false;
} }
@Override
public void setParent(IASTNode node) { public void setParent(IASTNode node) {
} }
@Override
public void setPropertyInParent(ASTNodeProperty property) { public void setPropertyInParent(ASTNodeProperty property) {
} }
@Override
public IToken getSyntax() { public IToken getSyntax() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public IToken getLeadingSyntax() { public IToken getLeadingSyntax() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public IToken getTrailingSyntax() { public IToken getTrailingSyntax() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean isFrozen() { public boolean isFrozen() {
return false; return false;
} }
@Override
public IASTNode copy() { public IASTNode copy() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public IASTNode copy(CopyStyle style) { public IASTNode copy(CopyStyle style) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override
public boolean isActive() { public boolean isActive() {
return true; return true;
} }

View file

@ -30,9 +30,7 @@ public class TrackedNodePosition implements ITrackedNodePosition {
this.node= node; this.node= node;
} }
/* (non-Javadoc) @Override
* @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getStartPosition()
*/
public int getStartPosition() { public int getStartPosition() {
if (this.group.isEmpty()) { if (this.group.isEmpty()) {
return this.node.getOffset(); return this.node.getOffset();
@ -44,9 +42,7 @@ public class TrackedNodePosition implements ITrackedNodePosition {
return coverage.getOffset(); return coverage.getOffset();
} }
/* (non-Javadoc) @Override
* @see org.eclipse.cdt.internal.corext.dom.ITrackedNodePosition#getLength()
*/
public int getLength() { public int getLength() {
if (this.group.isEmpty()) { if (this.group.isEmpty()) {
return this.node.getLength(); return this.node.getLength();

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; 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.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/** /**
* * This class serves as a container to pass several nodes to the <code>ASTWriter</code>.
* This class serves as a container to pass several nodes to the * This container is used if source code for several sibling nodes but for their common parent
* <code>ASTWriter</code>. This container is used if source code for several sibling nodes but * node should be generated.
* for their common parent node should be generated.
* *
* @author Emanuel Graf IFS * @author Emanuel Graf IFS
*
*/ */
public class ContainerNode extends ASTNode { public class ContainerNode extends ASTNode {
private final IASTTranslationUnit tu = null; private final IASTTranslationUnit tu = null;
private final ArrayList<IASTNode> nodes = new ArrayList<IASTNode>(); private final ArrayList<IASTNode> nodes = new ArrayList<IASTNode>();
@ -42,10 +38,12 @@ public class ContainerNode extends ASTNode {
} }
} }
@Override
public ContainerNode copy() { public ContainerNode copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);
} }
@Override
public ContainerNode copy(CopyStyle style) { public ContainerNode copy(CopyStyle style) {
ContainerNode copy = new ContainerNode(); ContainerNode copy = new ContainerNode();
for (IASTNode node : getNodes()) for (IASTNode node : getNodes())
@ -59,7 +57,7 @@ public class ContainerNode extends ASTNode {
public void addNode(IASTNode node) { public void addNode(IASTNode node) {
nodes.add(node); nodes.add(node);
if(node.getParent() == null) { if (node.getParent() == null) {
node.setParent(tu); node.setParent(tu);
} }
} }
@ -80,5 +78,4 @@ public class ContainerNode extends ASTNode {
public List<IASTNode> getNodes(){ public List<IASTNode> getNodes(){
return Collections.unmodifiableList(nodes); return Collections.unmodifiableList(nodes);
} }
} }

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; 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; import org.eclipse.cdt.core.dom.ast.IASTProblemHolder;
/** /**
* * This exception is thrown if a problem node is passed to the ASTWriter. The exception
* This exception is thrown if a problem nod is passed to the astwriter. The Exception
* contains the <code>IASTProblemHolder</code> that was passed to the writer. * contains the <code>IASTProblemHolder</code> that was passed to the writer.
* *
* @see IASTProblem * @see IASTProblem
* @author Emanuel Graf IFS * @author Emanuel Graf IFS
*
*/ */
public class ProblemRuntimeException extends RuntimeException { public class ProblemRuntimeException extends RuntimeException {
private static final long serialVersionUID = -3661425564246498786L; private static final long serialVersionUID = -3661425564246498786L;
private IASTProblemHolder problem; private IASTProblemHolder problem;
@ -32,8 +29,7 @@ public class ProblemRuntimeException extends RuntimeException {
problem = statement; problem = statement;
} }
public IASTProblemHolder getProblem(){ public IASTProblemHolder getProblem() {
return problem; return problem;
} }
} }

View file

@ -187,7 +187,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} }
} }
/* /**
* Formats a given token at a given position. * Formats a given token at a given position.
* @see #formatList(List, ListOptions, boolean, boolean, Runnable) * @see #formatList(List, ListOptions, boolean, boolean, Runnable)
*/ */
@ -211,6 +211,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
spaceBeforeToken, spaceAfterToken); spaceBeforeToken, spaceAfterToken);
} }
@Override
public void run() { public void run() {
int offset = scribe.scanner.getCurrentPosition(); int offset = scribe.scanner.getCurrentPosition();
if (tokenPosition < 0 || offset > tokenPosition) if (tokenPosition < 0 || offset > tokenPosition)
@ -229,7 +230,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} }
} }
/* /**
* Formats a trailing semicolon. * Formats a trailing semicolon.
* @see #formatList(List, ListOptions, boolean, boolean, Runnable) * @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. * Formats the part of a function declaration following the parameter list.
* @see #formatList(List, ListOptions, boolean, boolean, Runnable) * @see #formatList(List, ListOptions, boolean, boolean, Runnable)
*/ */
@ -256,6 +257,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
this.continuationFormatter = tailFormatter; this.continuationFormatter = tailFormatter;
} }
@Override
public void run() { public void run() {
boolean needSpace = skipConstVolatileRestrict(); boolean needSpace = skipConstVolatileRestrict();
int token = peekNextToken(); 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 class ClosingParensesisTailFormatter implements Runnable {
private final boolean spaceBeforeClosingParen; private final boolean spaceBeforeClosingParen;
private final Runnable continuationFormatter; private final Runnable continuationFormatter;
@ -315,6 +321,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
this.parenPosition = scribe.findToken(Token.tRPAREN); this.parenPosition = scribe.findToken(Token.tRPAREN);
} }
@Override
public void run() { public void run() {
int offset = scribe.scanner.getCurrentPosition(); int offset = scribe.scanner.getCurrentPosition();
if (parenPosition >= 0 && offset <= parenPosition) { if (parenPosition >= 0 && offset <= parenPosition) {

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.ui.refactoring; 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 { public class CTextFileChangeFactory implements ICTextFileChangeFactory {
@Override
public TextFileChange createCTextFileChange(IFile file) { public TextFileChange createCTextFileChange(IFile file) {
return new CTextFileChange(file.getName(), file); return new CTextFileChange(file.getName(), file);
} }

View file

@ -6,12 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring; package org.eclipse.cdt.internal.ui.refactoring;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -50,7 +49,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IBufferFactory;
/** /**
* Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
* same algorithm as the text widget to determine the buffer's line delimiter. * 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. * This class is similar to the JDT DocumentAdapter class.
*/ */
public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener { public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* Executes a document set content call in the ui thread. * Executes a document set content call in the ui thread.
*/ */
protected class DocumentSetCommand implements Runnable { protected class DocumentSetCommand implements Runnable {
private String fContents; private String fContents;
@Override
public void run() { public void run() {
fDocument.set(fContents); fDocument.set(fContents);
} }
@ -82,11 +79,11 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
* Executes a document replace call in the ui thread. * Executes a document replace call in the ui thread.
*/ */
protected class DocumentReplaceCommand implements Runnable { protected class DocumentReplaceCommand implements Runnable {
private int fOffset; private int fOffset;
private int fLength; private int fLength;
private String fText; private String fText;
@Override
public void run() { public void run() {
try { try {
fDocument.replace(fOffset, fLength, fText); fDocument.replace(fOffset, fLength, fText);
@ -104,31 +101,52 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
} }
private static final boolean DEBUG_LINE_DELIMITERS= true; 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) {} public void addBufferChangedListener(IBufferChangedListener listener) {}
@Override
public void append(char[] text) {} public void append(char[] text) {}
@Override
public void append(String text) {} public void append(String text) {}
@Override
public void close() {} public void close() {}
public char getChar(int position) {return 0;} @Override
public char[] getCharacters() {return new char[0];} public char getChar(int position) { return 0; }
public String getContents() {return "";} //$NON-NLS-1$ @Override
public int getLength() {return 0;} 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 IOpenable getOwner() {return null;}
public String getText(int offset, int length) {return "";} //$NON-NLS-1$ @Override
public IResource getUnderlyingResource() {return null;} public String getText(int offset, int length) { return ""; } //$NON-NLS-1$
public boolean hasUnsavedChanges() {return false;} @Override
public boolean isClosed() {return false;} public IResource getUnderlyingResource() { return null; }
public boolean isReadOnly() {return true;} @Override
public boolean hasUnsavedChanges() { return false; }
@Override
public boolean isClosed() { return false; }
@Override
public boolean isReadOnly() { return true; }
@Override
public void removeBufferChangedListener(IBufferChangedListener listener) {} public void removeBufferChangedListener(IBufferChangedListener listener) {}
@Override
public void replace(int position, int length, char[] text) {} public void replace(int position, int length, char[] text) {}
@Override
public void replace(int position, int length, String text) {} public void replace(int position, int length, String text) {}
@Override
public void save(IProgressMonitor progress, boolean force) throws CModelException {} public void save(IProgressMonitor progress, boolean force) throws CModelException {}
@Override
public void setContents(char[] contents) {} public void setContents(char[] contents) {}
@Override
public void setContents(String contents) {} public void setContents(String contents) {}
}; };
public static IBufferFactory FACTORY= new IBufferFactory() { public static IBufferFactory FACTORY= new IBufferFactory() {
public IBuffer createBuffer(IOpenable owner) { @Override
public IBuffer createBuffer(IOpenable owner) {
if (owner instanceof IWorkingCopy) { if (owner instanceof IWorkingCopy) {
IWorkingCopy wc= (IWorkingCopy) owner; IWorkingCopy wc= (IWorkingCopy) owner;
ITranslationUnit tu= wc.getOriginalElement(); ITranslationUnit tu= wc.getOriginalElement();
@ -206,6 +224,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/* /*
* @see IBuffer#addBufferChangedListener(IBufferChangedListener) * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
*/ */
@Override
public void addBufferChangedListener(IBufferChangedListener listener) { public void addBufferChangedListener(IBufferChangedListener listener) {
Assert.isNotNull(listener); Assert.isNotNull(listener);
if (!fBufferListeners.contains(listener)) if (!fBufferListeners.contains(listener))
@ -215,6 +234,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/* /*
* @see IBuffer#removeBufferChangedListener(IBufferChangedListener) * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
*/ */
@Override
public void removeBufferChangedListener(IBufferChangedListener listener) { public void removeBufferChangedListener(IBufferChangedListener listener) {
Assert.isNotNull(listener); Assert.isNotNull(listener);
fBufferListeners.remove(listener); fBufferListeners.remove(listener);
@ -224,6 +244,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#append(char[]) * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/ */
@Override
public void append(char[] text) { public void append(char[] text) {
append(new String(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) * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
*/ */
@Override
public void append(String text) { public void append(String text) {
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(text); validateLineDelimiters(text);
@ -242,8 +264,8 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#close() * @see org.eclipse.cdt.core.model.IBuffer#close()
*/ */
@Override
public void close() { public void close() {
if (isClosed()) if (isClosed())
return; return;
@ -268,6 +290,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getChar(int) * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
*/ */
@Override
public char getChar(int position) { public char getChar(int position) {
try { try {
return fDocument.getChar(position); return fDocument.getChar(position);
@ -279,6 +302,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getCharacters() * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
*/ */
@Override
public char[] getCharacters() { public char[] getCharacters() {
String content= getContents(); String content= getContents();
return content == null ? null : content.toCharArray(); 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() * @see org.eclipse.cdt.core.model.IBuffer#getContents()
*/ */
@Override
public String getContents() { public String getContents() {
return fDocument.get(); return fDocument.get();
} }
@ -294,6 +319,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getLength() * @see org.eclipse.cdt.core.model.IBuffer#getLength()
*/ */
@Override
public int getLength() { public int getLength() {
return fDocument.getLength(); return fDocument.getLength();
} }
@ -301,6 +327,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getOwner() * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
*/ */
@Override
public IOpenable getOwner() { public IOpenable getOwner() {
return fOwner; return fOwner;
} }
@ -308,6 +335,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getText(int, int) * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
*/ */
@Override
public String getText(int offset, int length) { public String getText(int offset, int length) {
try { try {
return fDocument.get(offset, length); return fDocument.get(offset, length);
@ -319,6 +347,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource() * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
*/ */
@Override
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
return fFile; return fFile;
} }
@ -326,6 +355,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges() * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
*/ */
@Override
public boolean hasUnsavedChanges() { public boolean hasUnsavedChanges() {
return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false; 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() * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
*/ */
@Override
public boolean isClosed() { public boolean isClosed() {
return fDocument == null; return fDocument == null;
} }
@ -340,6 +371,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#isReadOnly() * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
*/ */
@Override
public boolean isReadOnly() { public boolean isReadOnly() {
IResource resource= getUnderlyingResource(); IResource resource= getUnderlyingResource();
if (resource != null) { 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[]) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
*/ */
@Override
public void replace(int position, int length, char[] text) { public void replace(int position, int length, char[] text) {
replace(position, length, new String(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) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
*/ */
@Override
public void replace(int position, int length, String text) { public void replace(int position, int length, String text) {
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(text); 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) * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
*/ */
@Override
public void save(IProgressMonitor progress, boolean force) throws CModelException { public void save(IProgressMonitor progress, boolean force) throws CModelException {
try { try {
if (fTextFileBuffer != null) if (fTextFileBuffer != null)
@ -383,6 +418,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
*/ */
@Override
public void setContents(char[] contents) { public void setContents(char[] contents) {
setContents(new String(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) * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
*/ */
@Override
public void setContents(String contents) { public void setContents(String contents) {
int oldLength= fDocument.getLength(); int oldLength= fDocument.getLength();
if (contents == null) { if (contents == null) {
if (oldLength != 0) if (oldLength != 0)
fSetCmd.set(""); //$NON-NLS-1$ fSetCmd.set(""); //$NON-NLS-1$
} else { } else {
// set only if different // set only if different
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
@ -407,12 +442,10 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
int newLength= contents.length(); int newLength= contents.length();
if (oldLength != newLength || !contents.equals(fDocument.get())) if (oldLength != newLength || !contents.equals(fDocument.get()))
fSetCmd.set(contents); fSetCmd.set(contents);
} }
} }
private void validateLineDelimiters(String contents) { private void validateLineDelimiters(String contents) {
if (fLegalLineDelimiters == null) { if (fLegalLineDelimiters == null) {
// collect all line delimiters in the document // collect all line delimiters in the document
HashSet<String> existingDelimiters= new HashSet<String>(); HashSet<String> existingDelimiters= new HashSet<String>();
@ -460,6 +493,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/* /*
* @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
*/ */
@Override
public void documentAboutToBeChanged(DocumentEvent event) { public void documentAboutToBeChanged(DocumentEvent event) {
// there is nothing to do here // there is nothing to do here
} }
@ -467,6 +501,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
/* /*
* @see IDocumentListener#documentChanged(DocumentEvent) * @see IDocumentListener#documentChanged(DocumentEvent)
*/ */
@Override
public void documentChanged(DocumentEvent event) { public void documentChanged(DocumentEvent event) {
fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText())); fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
} }
@ -483,6 +518,7 @@ public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
return fTextFileBuffer; return fTextFileBuffer;
} }
@Override
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
if (adapter.isAssignableFrom(ITextFileBuffer.class)) { if (adapter.isAssignableFrom(ITextFileBuffer.class)) {