1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-02-03 14:20:09 -08:00
parent 60214efa55
commit 0d4d66ec6e
12 changed files with 67 additions and 125 deletions

View file

@ -63,13 +63,13 @@ public abstract class ChangeGeneratorTest extends BaseTestFramework {
assertTrue("The indexing operation of the test CProject has not finished jet. This should not happen...", joined);
IASTTranslationUnit unit = CoreModelUtil.findTranslationUnit(testFile).getAST();
final ChangeGenerator changegenartor = new ChangeGenerator(modStore,
final ChangeGenerator changeGenerator = new ChangeGenerator(modStore,
ASTCommenter.getCommentedNodeMap(unit));
unit.accept(visitor);
changegenartor.generateChange(unit);
changeGenerator.generateChange(unit);
Document doc = new Document(source);
for (Change curChange : ((CompositeChange) changegenartor.getChange()).getChildren()) {
for (Change curChange : ((CompositeChange) changeGenerator.getChange()).getChildren()) {
if (curChange instanceof TextFileChange) {
TextFileChange textChange = (TextFileChange) curChange;
textChange.getEdit().apply(doc);

View file

@ -24,7 +24,7 @@ public interface IName {
/**
* @since 5.2
*/
IName[] EMPTY_ARRAY= {};
public static final IName[] EMPTY_ARRAY= {};
/**
* Returns the name without qualification and without template arguments.

View file

@ -26,7 +26,7 @@ public interface IASTName extends IASTNode, IName {
/**
* Constant sentinel.
*/
public static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
public static final IASTName[] EMPTY_NAME_ARRAY = {};
/**
* Returns the name including qualification and template arguments.

View file

@ -24,7 +24,6 @@ import org.eclipse.cdt.core.parser.IToken;
* @noextend This interface is not intended to be extended by clients.
*/
public interface IASTNode {
/**
* @since 5.3
*/
@ -42,7 +41,7 @@ public interface IASTNode {
withLocations
}
public static final IASTNode[] EMPTY_NODE_ARRAY = new IASTNode[0];
public static final IASTNode[] EMPTY_NODE_ARRAY = {};
/**
* Get the translation unit (master) node that is the ancestor of all nodes

View file

@ -1207,14 +1207,15 @@ public class CVisitor extends ASTQueries {
node = node.getParent();
}
if (node instanceof IASTParameterDeclaration)
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
else if (node instanceof IASTSimpleDeclaration)
if (node instanceof IASTSimpleDeclaration) {
declSpec = ((IASTSimpleDeclaration) node).getDeclSpecifier();
else if (node instanceof IASTFunctionDefinition)
} else if (node instanceof IASTParameterDeclaration) {
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
} else if (node instanceof IASTFunctionDefinition) {
declSpec = ((IASTFunctionDefinition) node).getDeclSpecifier();
else if (node instanceof IASTTypeId)
} else if (node instanceof IASTTypeId) {
declSpec = ((IASTTypeId) node).getDeclSpecifier();
}
boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator);

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software (IFS)- initial API and implementation
* Institute for Software (IFS)- initial API and implementation
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring;
@ -18,10 +18,8 @@ import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
/**
* @author Emanuel Graf IFS
*
*/
public class CCompositeChange extends CompositeChange {
private RefactoringChangeDescriptor desc;
public CCompositeChange(String name, Change[] children) {
@ -38,12 +36,9 @@ public class CCompositeChange extends CompositeChange {
@Override
public ChangeDescriptor getDescriptor() {
if(desc == null) {
return super.getDescriptor();
}else {
if (desc != null) {
return desc;
}
return super.getDescriptor();
}
}

View file

@ -22,14 +22,12 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
/**
* 3 radio buttons in a group, labeled according to the corresponding visibility name (public, private, protected).
* Three radio buttons in a group, labeled according to the corresponding visibility name
* (public, private, protected).
*
* @author Thomas Corbat
*
*/
public class VisibilitySelectionPanel extends Composite {
private Button publicAccessRadioButton;
private Button protectedAccessRadioButton;
private Button privateAccessRadioButton;
@ -46,12 +44,10 @@ public class VisibilitySelectionPanel extends Composite {
createAccessModifierComposite(this);
setSelected(defaultVisibility);
}
private void createAccessModifierComposite(Composite control) {
accessModifierGroup = new Group(this, SWT.SHADOW_NONE );
accessModifierGroup = new Group(this, SWT.SHADOW_NONE);
RowLayout groupLayout = new RowLayout(SWT.HORIZONTAL);
groupLayout.fill = true;
accessModifierGroup.setLayout(groupLayout);
@ -65,11 +61,10 @@ public class VisibilitySelectionPanel extends Composite {
privateAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
privateAccessRadioButton.setText(VisibilityEnum.v_private.toString());
}
private void setSelected(VisibilityEnum defaultVisibility) {
switch (defaultVisibility){
switch (defaultVisibility) {
case v_public:
publicAccessRadioButton.setSelection(true);
break;
@ -87,12 +82,11 @@ public class VisibilitySelectionPanel extends Composite {
}
@Override
public void setEnabled(boolean enabled){
public void setEnabled(boolean enabled) {
accessModifierGroup.setEnabled(enabled);
publicAccessRadioButton.setEnabled(enabled);
protectedAccessRadioButton.setEnabled(enabled);
privateAccessRadioButton.setEnabled(enabled);
super.setEnabled(enabled);
}
}

View file

@ -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.ui.refactoring.implementmethod;
@ -21,16 +21,15 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
/**
* @author Lukas Felber
*
*/
public class ParameterInfo {
private IASTParameterDeclaration parameter;
private boolean hasNewName;
private String parameterName;
public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean HasNewName) {
public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean hasNewName) {
this.parameter = parameter;
this.hasNewName = HasNewName;
this.hasNewName = hasNewName;
this.parameterName = parameterName;
}

View file

@ -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.ui.refactoring.utils;
@ -78,7 +78,8 @@ public class ASTHelper {
return null;
}
public static boolean samePointers(IASTPointerOperator[] pointerOperators1, IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
public static boolean samePointers(IASTPointerOperator[] pointerOperators1,
IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
if (pointerOperators2.length == pointerOperators1.length) {
for (int i = 0; i < pointerOperators2.length; i++) {
IASTPointerOperator operator1 = pointerOperators1[i];
@ -110,7 +111,7 @@ public class ASTHelper {
for (IASTNode aktNode = node; aktNode != null; aktNode = aktNode.getParent()) {
if (aktNode instanceof ICPPASTNamespaceDefinition) {
namespaces.add(0, (ICPPASTNamespaceDefinition) aktNode);
} else if(aktNode instanceof ICPPASTQualifiedName) {
} else if (aktNode instanceof ICPPASTQualifiedName) {
namespaces.addAll(getNamespaces((ICPPASTQualifiedName) aktNode));
}
}
@ -119,10 +120,10 @@ public class ASTHelper {
public static ArrayList<ICPPASTNamespaceDefinition> getNamespaces(ICPPASTQualifiedName qualifiedName) {
ArrayList<ICPPASTNamespaceDefinition> namespaces = new ArrayList<ICPPASTNamespaceDefinition>();
for(IASTName aktQualifiedPartName : qualifiedName.getNames()) {
for (IASTName aktQualifiedPartName : qualifiedName.getNames()) {
IBinding binding = aktQualifiedPartName.resolveBinding();
for(IASTName aktResolvedName : qualifiedName.getTranslationUnit().getDefinitionsInAST(binding)) {
if(aktResolvedName.getParent() instanceof ICPPASTNamespaceDefinition) {
for (IASTName aktResolvedName : qualifiedName.getTranslationUnit().getDefinitionsInAST(binding)) {
if (aktResolvedName.getParent() instanceof ICPPASTNamespaceDefinition) {
namespaces.add((ICPPASTNamespaceDefinition) aktResolvedName.getParent());
break;
}
@ -146,10 +147,11 @@ public class ASTHelper {
return specifiers;
}
public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(IASTTranslationUnit unit, String aktFileName) {
public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(
IASTTranslationUnit unit, String aktFileName) {
Collection<IASTPreprocessorStatement> statements = new ArrayList<IASTPreprocessorStatement>();
for(IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
if(aktStatement.getFileLocation() == null) {
for (IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
if (aktStatement.getFileLocation() == null) {
continue;
} else if (aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
statements.add(aktStatement);
@ -160,10 +162,10 @@ public class ASTHelper {
public static Collection<IASTDeclaration> getAllInFileDeclarations(IASTTranslationUnit unit, String aktFileName) {
Collection<IASTDeclaration> decls = new ArrayList<IASTDeclaration>();
for(IASTDeclaration aktDecl: unit.getDeclarations()) {
if(aktDecl.getFileLocation() == null) {
for (IASTDeclaration aktDecl: unit.getDeclarations()) {
if (aktDecl.getFileLocation() == null) {
continue;
} else if(aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
} else if (aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
decls.add(aktDecl);
}
}
@ -172,11 +174,11 @@ public class ASTHelper {
public static ICPPASTUsingDirective getActiveUsingDirecitveForNode(IASTNode node, IASTTranslationUnit unit) {
ICPPASTUsingDirective activeDirective = null;
for(IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
if(aktDeclaration.getFileLocation().getNodeOffset() >= node.getFileLocation().getNodeOffset()) {
for (IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
if (aktDeclaration.getFileLocation().getNodeOffset() >= node.getFileLocation().getNodeOffset()) {
break;
}
if(aktDeclaration instanceof ICPPASTUsingDirective) {
if (aktDeclaration instanceof ICPPASTUsingDirective) {
activeDirective = (ICPPASTUsingDirective) aktDeclaration;
}
}
@ -185,7 +187,7 @@ public class ASTHelper {
public static Collection<ICPPASTUsingDeclaration> getUsingDeclarations(IASTTranslationUnit unit) {
Collection<ICPPASTUsingDeclaration> usingDecls = new ArrayList<ICPPASTUsingDeclaration>();
for(IASTDeclaration aktDecl : unit.getDeclarations()) {
for (IASTDeclaration aktDecl : unit.getDeclarations()) {
if (aktDecl instanceof ICPPASTUsingDeclaration) {
usingDecls.add((ICPPASTUsingDeclaration) aktDecl);
}
@ -193,33 +195,10 @@ public class ASTHelper {
return usingDecls;
}
public static boolean isClassDefinitionName(IASTName name) {
try {
if(!(name.getParent().getParent().getParent() instanceof IASTFunctionDefinition)) {
return false;
}
ICPPASTQualifiedName qName = (ICPPASTQualifiedName) name.getParent();
IASTName secondLastName = qName.getNames()[qName.getNames().length-2];
if(!(name.equals(secondLastName))) {
return false;
}
IBinding binding = name.resolveBinding();
for(IASTName aktName : name.getTranslationUnit().getDeclarationsInAST(binding)) {
if(!isClassDeclarationName(aktName)) {
return false;
}
}
} catch (NullPointerException e) {
return false;
}
return true;
}
public static IASTCompositeTypeSpecifier getCompositeTypeSpecifierForName(IASTName name) {
IBinding binding = name.resolveBinding();
for(IASTName aktName : name.getTranslationUnit().getDefinitionsInAST(binding)) {
if(aktName.getParent() instanceof IASTCompositeTypeSpecifier) {
for (IASTName aktName : name.getTranslationUnit().getDefinitionsInAST(binding)) {
if (aktName.getParent() instanceof IASTCompositeTypeSpecifier) {
return (IASTCompositeTypeSpecifier) aktName.getParent();
}
}
@ -228,10 +207,10 @@ public class ASTHelper {
public static Collection<IASTFunctionDeclarator> getFunctionDeclaratorsForClass(IASTCompositeTypeSpecifier klass) {
Collection<IASTFunctionDeclarator> declarators = new ArrayList<IASTFunctionDeclarator>();
for(IASTDeclaration aktDeclaration : klass.getMembers()) {
if(aktDeclaration instanceof IASTSimpleDeclaration) {
for(IASTDeclarator aktDeclarator : ((IASTSimpleDeclaration) aktDeclaration).getDeclarators()) {
if(aktDeclarator instanceof IASTFunctionDeclarator) {
for (IASTDeclaration aktDeclaration : klass.getMembers()) {
if (aktDeclaration instanceof IASTSimpleDeclaration) {
for (IASTDeclarator aktDeclarator : ((IASTSimpleDeclaration) aktDeclaration).getDeclarators()) {
if (aktDeclarator instanceof IASTFunctionDeclarator) {
declarators.add((IASTFunctionDeclarator) aktDeclarator);
}
}
@ -242,10 +221,10 @@ public class ASTHelper {
public static Collection<IASTFunctionDefinition> getFunctionDefinitionsForClass(IASTCompositeTypeSpecifier klass) {
Collection<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
for(IASTFunctionDeclarator aktDeclarator : getFunctionDeclaratorsForClass(klass)) {
for (IASTFunctionDeclarator aktDeclarator : getFunctionDeclaratorsForClass(klass)) {
IBinding binding = aktDeclarator.getName().resolveBinding();
for(IASTName aktName : aktDeclarator.getTranslationUnit().getDefinitionsInAST(binding)) {
if(aktName.getParent().getParent().getParent() instanceof IASTFunctionDefinition) {
for (IASTName aktName : aktDeclarator.getTranslationUnit().getDefinitionsInAST(binding)) {
if (aktName.getParent().getParent().getParent() instanceof IASTFunctionDefinition) {
definitions.add((IASTFunctionDefinition) aktName.getParent().getParent().getParent());
}
}

View file

@ -10,15 +10,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards.classwizard;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
public final class BaseClassesLabelProvider implements ITableLabelProvider {
private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label;
private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label;
private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label;
@ -34,7 +33,7 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
return ACCESS_PRIVATE;
if (access == ASTAccessVisibility.PROTECTED)
return ACCESS_PROTECTED;
return ACCESS_PUBLIC;
return ACCESS_PUBLIC;
}
private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
@ -59,42 +58,30 @@ public final class BaseClassesLabelProvider implements ITableLabelProvider {
IBaseClassInfo info = (IBaseClassInfo) element;
switch (columnIndex) {
case 0:
return fTypeInfoLabelProvider.getText(info.getType());
case 1:
return getAccessText(info.getAccess());
case 2:
return getYesNoText(info.isVirtual());
default:
return null;
case 0:
return fTypeInfoLabelProvider.getText(info.getType());
case 1:
return getAccessText(info.getAccess());
case 2:
return getYesNoText(info.isVirtual());
default:
return null;
}
}
/*
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
*/
@Override
public void addListener(ILabelProviderListener listener) {
}
/*
* @see IBaseLabelProvider#dispose()
*/
@Override
public void dispose() {
}
/*
* @see IBaseLabelProvider#isLabelProperty(Object, String)
*/
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
/*
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
*/
@Override
public void removeListener(ILabelProviderListener listener) {
}

View file

@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
public class MethodStubsListDialogField extends CheckedListDialogField<IMethodStub> {
// column properties
private static final String CP_NAME = "name"; //$NON-NLS-1$
private static final String CP_ACCESS = "access"; //$NON-NLS-1$
@ -154,7 +153,7 @@ public class MethodStubsListDialogField extends CheckedListDialogField<IMethodSt
new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label;
}
}
);

View file

@ -65,10 +65,6 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
fUncheckAllButtonIndex= uncheckButtonIndex;
}
/*
* @see ListDialogField#createTableViewer
*/
@Override
protected TableViewer createTableViewer(Composite parent) {
Table table= new Table(parent, SWT.CHECK + getListStyle());
@ -82,10 +78,6 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
return tableViewer;
}
/*
* @see ListDialogField#getListControl
*/
@Override
public Control getListControl(Composite parent) {
Control control= super.getListControl(parent);
@ -110,7 +102,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
}
private void checkStateChanged() {
//call super and do not update check model
// Call super and do not update check model
super.dialogFieldChanged();
}
@ -166,7 +158,7 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
fCheckElements.remove(object);
}
if (fTable != null) {
((CheckboxTableViewer)fTable).setChecked(object, state);
((CheckboxTableViewer) fTable).setChecked(object, state);
}
}
@ -196,9 +188,6 @@ public class CheckedListDialogField<T> extends ListDialogField<T> {
checkStateChanged();
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
*/
@Override
public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
boolean wasChecked= isChecked(oldElement);