1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 02:05:39 +02:00

Cosmetics.

This commit is contained in:
sprigogin 2012-02-29 14:21:04 -08:00
parent 84e82daec5
commit 5337c7707b
25 changed files with 423 additions and 470 deletions

View file

@ -11,14 +11,12 @@
package org.eclipse.cdt.core.model;
/**
* IDeclaration is a base interface for any C Model element that could be
* considered a declaration.
* Base interface for any C Model element that could be considered a declaration.
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference {
/**
* Checks if the declaration is static
* Returns true if the declaration is static, false otherwise.
@ -29,7 +27,7 @@ public interface IDeclaration extends ICElement, ISourceManipulation, ISourceRef
/**
* Checks if the declaration is constant.
* Returns true if the decalration is constant, false otherwise.
* Returns true if the declaration is constant, false otherwise.
* @return boolean
* @throws CModelException
*/

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.model;
/**
* Represents a function
*
@ -18,7 +17,6 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IFunctionDeclaration extends IDeclaration {
/**
* Returns the type signatures of the exceptions this method throws,
* in the order declared in the source. Returns an empty array

View file

@ -17,5 +17,4 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IMethod extends IMethodDeclaration {
}

View file

@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.model;
/**
* Represents the declaration method of a class
*
@ -18,7 +17,6 @@ package org.eclipse.cdt.core.model;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
/**
* Returns whether this method is a constructor.
*
@ -78,5 +76,4 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* return true if the member is a friend.
*/
public boolean isFriend() throws CModelException;
}

View file

@ -20,11 +20,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor;
/**
* Generic visitor for ast-nodes.
* Generic visitor for AST nodes.
* <p> Clients may subclass. </p>
* @since 5.1
*/
public abstract class ASTGenericVisitor extends ASTVisitor implements ICPPASTVisitor, ICASTVisitor {
public ASTGenericVisitor(boolean visitNodes) {
super(visitNodes);
}

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
/**
* Abstract base class for all visitors to traverse ast nodes. <br>
* Abstract base class for all visitors to traverse AST nodes. <br>
* visit() methods implement a top-down traversal, and <br>
* leave() methods implement a bottom-up traversal. <br>
*
@ -142,7 +142,6 @@ public abstract class ASTVisitor {
*/
public boolean shouldVisitAmbiguousNodes = false;
/**
* Implicit names are created to allow implicit bindings to be resolved,
* normally they are not visited, set this flag to true to visit them.
@ -150,7 +149,6 @@ public abstract class ASTVisitor {
*/
public boolean shouldVisitImplicitNames = false;
/**
* Sometimes more than one implicit name is created for a binding,
* set this flag to true to visit more than one name for an implicit binding.
@ -158,7 +156,6 @@ public abstract class ASTVisitor {
*/
public boolean shouldVisitImplicitNameAlternates = false;
/**
* Creates a visitor that does not visit any kind of node per default.
*/
@ -329,6 +326,7 @@ public abstract class ASTVisitor {
public int leave(IASTArrayModifier arrayModifier) {
return PROCESS_CONTINUE;
}
/**
* @since 5.1
*/
@ -398,6 +396,7 @@ public abstract class ASTVisitor {
public int visit( IASTComment comment){
return PROCESS_CONTINUE;
}
/**
* @deprecated use {@link IASTTranslationUnit#getComments()}, instead.
*/

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTBreakStatement extends IASTStatement {
/**
* @since 5.1
*/

View file

@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTCaseStatement extends IASTStatement {
/**
* <code>ASTNodeProperty</code> that represents the relationship between a
* case statement and the expression it contains.
@ -30,7 +29,6 @@ public interface IASTCaseStatement extends IASTStatement {
/**
* The expression that determines whether this case should be taken.
*
*/
public IASTExpression getExpression();

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTContinueStatement extends IASTStatement {
/**
* @since 5.1
*/

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTDeclarationStatement extends IASTStatement {
/**
* <code>DECLARATION</code> represents the relationship between a
* declaration statement and the declaration it wraps.
@ -50,5 +49,4 @@ public interface IASTDeclarationStatement extends IASTStatement {
*/
@Override
public IASTDeclarationStatement copy(CopyStyle style);
}

View file

@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTDefaultStatement extends IASTStatement {
/**
* @since 5.1
*/

View file

@ -17,13 +17,13 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTDoStatement extends IASTStatement {
/**
* <code>BODY</code> represents the relationship between a
* <code>IASTDoStatement</code> and its nested body
* <code>IASTStatement</code>.
*/
public static final ASTNodeProperty BODY = new ASTNodeProperty("IASTDoStatement.BODY - nested body for IASTDoStatement"); //$NON-NLS-1$
public static final ASTNodeProperty BODY =
new ASTNodeProperty("IASTDoStatement.BODY - nested body for IASTDoStatement"); //$NON-NLS-1$
/**
* <code>CONDITION</code> represents the relationship between a
@ -74,5 +74,4 @@ public interface IASTDoStatement extends IASTStatement {
*/
@Override
public IASTDoStatement copy(CopyStyle style);
}

View file

@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTNameOwner {
/**
* Role of name in this context is a declaration.
*/
@ -45,5 +44,4 @@ public interface IASTNameOwner {
* @return r_definition, r_declaration, r_reference or r_unclear.
*/
public int getRoleForName(IASTName name);
}

View file

@ -33,5 +33,4 @@ public interface IASTStatement extends IASTNode {
*/
@Override
public IASTStatement copy(CopyStyle style);
}

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTSwitchStatement extends IASTStatement {
/**
* <code>CONTROLLER_EXP</code> represents the relationship between an
* <code>IASTSwitchStatement</code> and it's nested

View file

@ -21,7 +21,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* Each IASTName segment has property being <code>SEGMENT_NAME</code>.
*/
@ -31,8 +30,7 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* Add a subname.
*
* @param name
* <code>IASTName</code>
* @param name <code>IASTName</code>
*/
public void addName(IASTName name);
@ -45,7 +43,6 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* The last name is often semantically significant.
*
*/
@Override
public IASTName getLastName();
@ -60,15 +57,13 @@ public interface ICPPASTQualifiedName extends IASTName, IASTNameOwner {
/**
* Set this name to be fully qualified or not (true/false).
*
* @param value
* boolean
* @param value boolean
*/
public void setFullyQualified(boolean value);
/**
* This is used to check if the ICPPASTQualifiedName's last segment is
* an ICPPASTConversionName or an ICPPASTOperatorName.
*
*/
public boolean isConversionOrOperator();

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
@ -33,7 +32,6 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic
public static final ASTNodeProperty BODY = new ASTNodeProperty(
"ICPPASTRangeBasedForStatement.BODY [IASTStatement]"); //$NON-NLS-1$
/**
* Returns the for-range-declaration
*/
@ -60,7 +58,6 @@ public interface ICPPASTRangeBasedForStatement extends IASTStatement, IASTImplic
@Override
public ICPPASTRangeBasedForStatement copy(CopyStyle style);
/**
* Not allowed on frozen AST.
*/

View file

@ -8,7 +8,7 @@
* Contributors:
* John Camelon - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigoin (Google)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;

View file

@ -23,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
* @since 5.0
*/
public class ASTNodeSpecification<T extends IASTNode> {
public enum Relation {FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING}
public enum Relation { FIRST_CONTAINED, EXACT_MATCH, ENCLOSING, STRICTLY_ENCLOSING }
private final Class<T> fClass;
private final Relation fRelation;
@ -87,6 +87,7 @@ public class ASTNodeSpecification<T extends IASTNode> {
}
}
}
@SuppressWarnings("unchecked")
public void visit(ASTNode astNode, IASTImageLocation imageLocation) {
if (isAcceptableNode(astNode) && imageLocation != null) {

View file

@ -18,24 +18,22 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
* @author jcamelon
*/
public class CPPASTBreakStatement extends ASTNode implements IASTBreakStatement {
@Override
public boolean accept( ASTVisitor action ){
if( action.shouldVisitStatements ){
switch( action.visit( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
public boolean accept(ASTVisitor action) {
if (action.shouldVisitStatements) {
switch (action.visit(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
if( action.shouldVisitStatements ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
if (action.shouldVisitStatements) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
return true;
}

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatement, IASTAmbiguityParent {
private IASTInitializerClause retValue;
public CPPASTReturnStatement() {
@ -37,8 +36,8 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
@Override
public CPPASTReturnStatement copy(CopyStyle style) {
CPPASTReturnStatement copy = new CPPASTReturnStatement(retValue == null ? null
: retValue.copy(style));
CPPASTReturnStatement copy =
new CPPASTReturnStatement(retValue == null ? null : retValue.copy(style));
copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);
@ -59,7 +58,6 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
return null;
}
@Override
public void setReturnValue(IASTExpression returnValue) {
setReturnArgument(returnValue);
@ -90,11 +88,11 @@ public class CPPASTReturnStatement extends ASTNode implements IASTReturnStatemen
if (retValue != null && !retValue.accept(action))
return false;
if( action.shouldVisitStatements ){
switch( action.leave( this ) ){
case ASTVisitor.PROCESS_ABORT : return false;
case ASTVisitor.PROCESS_SKIP : return true;
default : break;
if (action.shouldVisitStatements) {
switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true;
default: break;
}
}
return true;

View file

@ -19,13 +19,6 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.cdt.core.dom.ast.ASTGenericVisitor;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -199,6 +192,13 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Collection of methods to extract information from a C++ translation unit.
*/
@ -1397,7 +1397,7 @@ public class CPPVisitor extends ASTQueries {
if (bname.length() > 0 && !bname.startsWith("operator")) { //$NON-NLS-1$
requiredName= bname.toCharArray();
}
this.bindings = new IBinding[] {binding};
this.bindings = new IBinding[] { binding };
if (binding instanceof ICPPUsingDeclaration) {
this.bindings= ((ICPPUsingDeclaration) binding).getDelegates();
kind= KIND_COMPOSITE;

View file

@ -19,7 +19,6 @@ import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
@ -106,10 +105,9 @@ public class NodeContainer {
names.add(nameInfo);
}
} catch (DOMException e) {
ILog logger = CUIPlugin.getDefault().getLog();
IStatus status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
e.getMessage(), e);
logger.log(status);
CUIPlugin.log(status);
}
} else if (binding instanceof IVariable) {
NameInformation nameInformation = new NameInformation(name);
@ -129,8 +127,8 @@ public class NodeContainer {
for (NameInformation nameInfo : names) {
IASTName name = nameInfo.getName();
IASTTranslationUnit unit = name.getTranslationUnit();
IASTName[] nameDeclarations = unit.getDeclarationsInAST(name.resolveBinding());
IASTTranslationUnit ast = name.getTranslationUnit();
IASTName[] nameDeclarations = ast.getDeclarationsInAST(name.resolveBinding());
if (nameDeclarations.length != 0) {
nameInfo.setDeclarationName(nameDeclarations[nameDeclarations.length - 1]);
}

View file

@ -30,7 +30,6 @@ import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@ -39,6 +38,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
* A collection of helper methods to interact with the workbench's IDocuments and IFiles
*/
public class EclipseObjects {
static public IWorkbenchPage getActivePage() {
return getActiveWindow().getActivePage();
}
@ -47,16 +47,13 @@ public class EclipseObjects {
* @return the active, visible TextEditor
*/
static public IEditorPart getActiveEditor() {
IEditorPart editor = null;
IWorkbenchPage page = getActivePage();
if (page.isEditorAreaVisible()
&& page.getActiveEditor() != null
&& page.getActiveEditor() instanceof TextEditor) {
editor = page.getActiveEditor();
IEditorPart activeEditor = page.getActiveEditor();
if (page.isEditorAreaVisible() && activeEditor instanceof TextEditor) {
return activeEditor;
}
return editor;
return null;
}
/**
@ -71,10 +68,10 @@ public class EclipseObjects {
for (IEditorReference editor2 : editors) {
IEditorPart editor = editor2.getEditor(false);
if (editor instanceof CEditor) {
CEditor edi = ((CEditor)editor);
CEditor edi = ((CEditor) editor);
IResource resource = edi.getInputCElement().getResource();
if (resource instanceof IFile) {
if( (( IFile )resource).equals(file) ){
if (((IFile) resource).equals(file)) {
return editor;
}
}
@ -87,29 +84,28 @@ public class EclipseObjects {
/**
* @return the file from the active editor
*/
static public IFile getActiveFile(){
static public IFile getActiveFile() {
IEditorInput editorInput = getActiveEditor().getEditorInput();
IFile aFile = null;
if(editorInput instanceof IFileEditorInput){
aFile = ((IFileEditorInput)editorInput).getFile();
if (editorInput instanceof IFileEditorInput) {
return ((IFileEditorInput) editorInput).getFile();
}
return aFile;
return null;
}
/**
* @return the document from the currently active editor
*/
static public IDocument getActiveDocument() {
return getDocument( getActiveEditor() );
return getDocument(getActiveEditor());
}
/**
* @return the document opened in the editor
*/
static public IDocument getDocument(IEditorPart editor) {
ITextEditor txtEditor = ((ITextEditor)editor);
ITextEditor txtEditor = ((ITextEditor) editor);
IDocumentProvider prov = txtEditor.getDocumentProvider();
return prov.getDocument(txtEditor.getEditorInput());
}
@ -132,41 +128,31 @@ public class EclipseObjects {
*/
static public IFile getFile(ISelection selection) {
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
IFile file = getFile((IStructuredSelection)selection);
IFile file = getFile((IStructuredSelection) selection);
return file;
}
return EclipseObjects.getActiveFile();
return getActiveFile();
}
static private IFile getFile(IStructuredSelection selection) {
IFile file = null;
Object o = selection.getFirstElement();
if (o instanceof ICElement) {
ICElement e= (ICElement) o;
IResource r= e.getUnderlyingResource();
if (r instanceof IFile) {
file= (IFile) r;
return (IFile) r;
}
}
return file;
return null;
}
/**
* @return the file at the specified path string
*/
public static IFile getFileForPathString(String path) {
IPath ipath = new Path(path);
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath);
}
/**
* @return the file containing the node
*/
public static IFile getFile(IASTNode node){
if(node == null)
return null;
return getFileForPathString(node.getFileLocation().getFileName());
public static IFile getFileForPathString(String filePath) {
IPath path = new Path(filePath);
return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
}
}