k_class
C++ introduces the class concept for composite
- * types.
+ * k_class
C++ introduces the class concept for composite types.
*/
public static final int k_class = IASTCompositeTypeSpecifier.k_last + 1;
@@ -52,15 +50,14 @@ public interface ICPPASTCompositeTypeSpecifier extends IASTCompositeTypeSpecifie
*
* @noimplement This interface is not intended to be implemented by clients.
*/
- public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner, ICPPASTPackExpandable {
- public static final ICPPASTBaseSpecifier[] EMPTY_BASESPECIFIER_ARRAY = new ICPPASTBaseSpecifier[0];
+ public static interface ICPPASTBaseSpecifier extends IASTNode, IASTNameOwner, ICPPASTPackExpandable {
+ public static final ICPPASTBaseSpecifier[] EMPTY_BASESPECIFIER_ARRAY = {};
/**
* Relation between base specifier and its name.
*/
public static final ASTNodeProperty NAME = new ASTNodeProperty(
"ICPPASTBaseSpecifier.NAME - Name of base class"); //$NON-NLS-1$
-
public static final int v_public = 1;
public static final int v_protected = 2;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java
index 6e4ece7cb26..23ba2025a7c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTVisibilityLabel.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * John Camelon (IBM) - Initial API and implementation
+ * John Camelon (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTVisibilityLabel extends IASTDeclaration {
-
/**
* v_public
== public:
*/
@@ -37,28 +36,28 @@ public interface ICPPASTVisibilityLabel extends IASTDeclaration {
public static final int v_private = 3;
/**
- * Get the visibility.
+ * Returns the visibility.
*
* @return int
*/
public int getVisibility();
/**
- * Set visibility.
+ * Sets visibility.
*
- * @param visibility
- * int
+ * @param visibility one of v_public, v_protected, v_private
*/
public void setVisibility(int visibility);
-
/**
* @since 5.1
*/
+ @Override
public ICPPASTVisibilityLabel copy();
/**
* @since 5.3
*/
+ @Override
public ICPPASTVisibilityLabel copy(CopyStyle style);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java
index 158a3edfe78..dba54022524 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTCompositeTypeSpecifier.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * John Camelon (IBM Rational Software) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * John Camelon (IBM Rational Software) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Yuan Zhang / Beth Tibbitts (IBM Research)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@@ -27,13 +27,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
*/
public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
ICASTCompositeTypeSpecifier, IASTAmbiguityParent {
-
private int fKey;
private IASTName fName;
- private IASTDeclaration[] fActiveDeclarations= null;
- private IASTDeclaration [] fAllDeclarations = null;
- private int fDeclarationsPos=-1;
- private IScope fScope = null;
+ private IASTDeclaration[] fActiveDeclarations;
+ private IASTDeclaration[] fAllDeclarations;
+ private int fDeclarationsPos = -1;
+ private IScope fScope;
public CASTCompositeTypeSpecifier() {
}
@@ -43,10 +42,12 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
setName(name);
}
+ @Override
public CASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
+ @Override
public CASTCompositeTypeSpecifier copy(CopyStyle style) {
CASTCompositeTypeSpecifier copy = new CASTCompositeTypeSpecifier();
copyCompositeTypeSpecifier(copy, style);
@@ -60,24 +61,28 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
copyBaseDeclSpec(copy);
copy.setKey(fKey);
copy.setName(fName == null ? null : fName.copy(style));
- for(IASTDeclaration member : getMembers())
+ for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
}
- public int getKey() {
+ @Override
+ public int getKey() {
return fKey;
}
- public void setKey(int key) {
+ @Override
+ public void setKey(int key) {
assertNotFrozen();
this.fKey = key;
}
- public IASTName getName() {
+ @Override
+ public IASTName getName() {
return fName;
}
- public void setName(IASTName name) {
+ @Override
+ public void setName(IASTName name) {
assertNotFrozen();
this.fName = name;
if (name != null) {
@@ -86,51 +91,57 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
}
}
+ @Override
public IASTDeclaration[] getMembers() {
IASTDeclaration[] active= fActiveDeclarations;
if (active == null) {
- active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos+1);
+ active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos + 1);
fActiveDeclarations= active;
}
return active;
}
+ @Override
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
if (includeInactive) {
- fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class, fAllDeclarations, fDeclarationsPos);
+ fAllDeclarations= ArrayUtil.trimAt(IASTDeclaration.class, fAllDeclarations,
+ fDeclarationsPos);
return fAllDeclarations;
}
return getMembers();
}
- public void addMemberDeclaration(IASTDeclaration declaration) {
+ @Override
+ public void addMemberDeclaration(IASTDeclaration declaration) {
assertNotFrozen();
if (declaration != null) {
declaration.setParent(this);
declaration.setPropertyInParent(MEMBER_DECLARATION);
- fAllDeclarations = (IASTDeclaration[]) ArrayUtil.append(IASTDeclaration.class, fAllDeclarations,
+ fAllDeclarations = ArrayUtil.appendAt(IASTDeclaration.class, fAllDeclarations,
++fDeclarationsPos, declaration);
fActiveDeclarations= null;
}
}
- public void addDeclaration(IASTDeclaration declaration) {
+ @Override
+ public void addDeclaration(IASTDeclaration declaration) {
addMemberDeclaration(declaration);
}
-
- public IScope getScope() {
- if( fScope == null )
- fScope = new CCompositeTypeScope( this );
+
+ @Override
+ public IScope getScope() {
+ if (fScope == null)
+ fScope = new CCompositeTypeScope(this);
return fScope;
}
@Override
- public boolean accept( ASTVisitor action ){
+ public boolean accept(ASTVisitor action){
if (action.shouldVisitDeclSpecifiers) {
switch (action.visit(this)) {
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
if (fName != null && !fName.accept(action))
@@ -138,7 +149,8 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
IASTDeclaration[] decls= getDeclarations(action.includeInactiveNodes);
for (int i = 0; i < decls.length; i++) {
- if (!decls[i].accept(action)) return false;
+ if (!decls[i].accept(action))
+ return false;
}
if (action.shouldVisitDeclSpecifiers) {
@@ -151,13 +163,15 @@ public class CASTCompositeTypeSpecifier extends CASTBaseDeclSpecifier implements
return true;
}
+ @Override
public int getRoleForName(IASTName n) {
- if( n == this.fName )
+ if (n == this.fName)
return r_definition;
return r_unclear;
}
- public void replace(IASTNode child, IASTNode other) {
+ @Override
+ public void replace(IASTNode child, IASTNode other) {
assert child.isActive() == other.isActive();
for (int i = 0; i <= fDeclarationsPos; ++i) {
if (fAllDeclarations[i] == child) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java
index c7752367055..20ef93b2382 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCompositeTypeSpecifier.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * John Camelon (IBM) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * John Camelon (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -27,17 +27,15 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
*/
public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
implements ICPPASTCompositeTypeSpecifier, IASTAmbiguityParent {
-
private int fKey;
private IASTName fName;
private CPPClassScope fScope;
private IASTDeclaration[] fAllDeclarations;
private IASTDeclaration[] fActiveDeclarations;
- private int fDeclarationsPos=-1;
- private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs = null;
+ private int fDeclarationsPos = -1;
+ private ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier[] baseSpecs;
private int baseSpecsPos = -1;
- private boolean fAmbiguitiesResolved= false;
-
+ private boolean fAmbiguitiesResolved;
public CPPASTCompositeTypeSpecifier() {
}
@@ -54,13 +52,15 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
fAmbiguitiesResolved= true;
}
+ @Override
public CPPASTCompositeTypeSpecifier copy() {
return copy(CopyStyle.withoutLocations);
}
+ @Override
public CPPASTCompositeTypeSpecifier copy(CopyStyle style) {
- CPPASTCompositeTypeSpecifier copy = new CPPASTCompositeTypeSpecifier(fKey, fName == null
- ? null : fName.copy(style));
+ CPPASTCompositeTypeSpecifier copy =
+ new CPPASTCompositeTypeSpecifier(fKey, fName == null ? null : fName.copy(style));
copyBaseDeclSpec(copy);
for (IASTDeclaration member : getMembers())
copy.addMemberDeclaration(member == null ? null : member.copy(style));
@@ -73,35 +73,43 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return copy;
}
- public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
- if( baseSpecs == null ) return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
- baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.removeNullsAfter( ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos );
+ @Override
+ public ICPPASTBaseSpecifier[] getBaseSpecifiers() {
+ if (baseSpecs == null)
+ return ICPPASTBaseSpecifier.EMPTY_BASESPECIFIER_ARRAY;
+ baseSpecs = ArrayUtil.trimAt(ICPPASTBaseSpecifier.class, baseSpecs, baseSpecsPos);
return baseSpecs;
}
- public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
+ @Override
+ public void addBaseSpecifier(ICPPASTBaseSpecifier baseSpec) {
assertNotFrozen();
if (baseSpec != null) {
baseSpec.setParent(this);
baseSpec.setPropertyInParent(BASE_SPECIFIER);
- baseSpecs = (ICPPASTBaseSpecifier[]) ArrayUtil.append( ICPPASTBaseSpecifier.class, baseSpecs, ++baseSpecsPos, baseSpec );
+ baseSpecs = ArrayUtil.appendAt(ICPPASTBaseSpecifier.class, baseSpecs, ++baseSpecsPos,
+ baseSpec);
}
}
- public int getKey() {
+ @Override
+ public int getKey() {
return fKey;
}
- public void setKey(int key) {
+ @Override
+ public void setKey(int key) {
assertNotFrozen();
fKey = key;
}
- public IASTName getName() {
+ @Override
+ public IASTName getName() {
return fName;
}
- public void setName(IASTName name) {
+ @Override
+ public void setName(IASTName name) {
assertNotFrozen();
this.fName = name;
if (name != null) {
@@ -110,23 +118,27 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
}
}
+ @Override
public IASTDeclaration[] getMembers() {
IASTDeclaration[] active= fActiveDeclarations;
if (active == null) {
- active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos+1);
+ active = ASTQueries.extractActiveDeclarations(fAllDeclarations, fDeclarationsPos + 1);
fActiveDeclarations= active;
}
return active;
}
+ @Override
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
if (includeInactive) {
- fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class, fAllDeclarations, fDeclarationsPos);
+ fAllDeclarations= ArrayUtil.trimAt(IASTDeclaration.class, fAllDeclarations,
+ fDeclarationsPos);
return fAllDeclarations;
}
return getMembers();
}
+ @Override
public void addMemberDeclaration(IASTDeclaration decl) {
if (decl == null)
return;
@@ -138,15 +150,17 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
assertNotFrozen();
decl.setParent(this);
decl.setPropertyInParent(decl instanceof ICPPASTVisibilityLabel ? VISIBILITY_LABEL : MEMBER_DECLARATION);
- fAllDeclarations = (IASTDeclaration[]) ArrayUtil.append(IASTDeclaration.class, fAllDeclarations,
+ fAllDeclarations = ArrayUtil.appendAt(IASTDeclaration.class, fAllDeclarations,
++fDeclarationsPos, decl);
fActiveDeclarations= null;
}
- public final void addDeclaration(IASTDeclaration decl) {
+ @Override
+ public final void addDeclaration(IASTDeclaration decl) {
addMemberDeclaration(decl);
}
+ @Override
public ICPPClassScope getScope() {
if (fScope == null) {
fScope = new CPPClassScope(this);
@@ -172,12 +186,14 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
ICPPASTBaseSpecifier[] bases = getBaseSpecifiers();
for (int i = 0; i < bases.length; i++) {
- if (!bases[i].accept(action)) return false;
+ if (!bases[i].accept(action))
+ return false;
}
IASTDeclaration[] decls = getDeclarations(action.includeInactiveNodes);
for (int i = 0; i < decls.length; i++) {
- if (!decls[i].accept(action)) return false;
+ if (!decls[i].accept(action))
+ return false;
}
if (action.shouldVisitDeclSpecifiers && action.leave(this) == ASTVisitor.PROCESS_ABORT)
@@ -186,12 +202,14 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
return true;
}
+ @Override
public int getRoleForName(IASTName name) {
- if( name == this.fName )
+ if (name == this.fName)
return r_definition;
return r_unclear;
}
+ @Override
public void replace(IASTNode child, IASTNode other) {
assert child.isActive() == other.isActive();
for (int i = 0; i <= fDeclarationsPos; ++i) {
diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts
index a402270781e..8099b078d57 100644
--- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts
+++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractConstant.rts
@@ -397,7 +397,6 @@ public:
};
#endif /*A_H_*/
-
//=
#ifndef A_H_
#define A_H_
@@ -413,7 +412,6 @@ private:
};
#endif /*A_H_*/
-
//@A.cpp
#include "A.h"
@@ -426,7 +424,6 @@ A::~A() {
int A::foo() {
return /*$*/42/*$$*/;
}
-
//=
#include "A.h"
@@ -439,8 +436,7 @@ A::~A() {
int A::foo() {
return theAnswer;
}
-
-//!Bug 246062 [Refactoring] NPE extracting a constant from an inlined method
+//!Bug 246062 - Extracting a constant from an inlined method
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
//@.config
filename=A.h
@@ -450,18 +446,17 @@ class X {
int a = /*$*/42/*$$*/;
}
};
-
//=
class X {
+public:
+ static const int theAnswer = 42;
+
+private:
void method() {
int a = theAnswer;
}
-
-public:
- static const int theAnswer = 42;
};
-
-//!ExtractConstantString
+//!Extract constant string
//#org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefactoringTest
//@.config
visibility=private
diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts
index 513d9d6d58d..368414c0540 100644
--- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts
+++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractMethod.rts
@@ -1480,7 +1480,6 @@ private:
};
#endif /*A_H_*/
-
//=
#ifndef A_H_
#define A_H_
@@ -1491,15 +1490,14 @@ public:
virtual ~A();
int foo();
-private:
- int help();
-
protected:
void exp(int& i);
+
+private:
+ int help();
};
#endif /*A_H_*/
-
//@A.cpp
#include "A.h"
@@ -1519,7 +1517,6 @@ int A::foo() {
int A::help() {
return 42;
}
-
//=
#include "A.h"
@@ -1543,7 +1540,6 @@ int A::foo() {
int A::help() {
return 42;
}
-
//@.config
filename=A.cpp
methodname=exp
diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts
index 9d55f345d59..a270920614c 100644
--- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts
+++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts
@@ -71,10 +71,6 @@ public:
int GetUniqueId();
- char* getName() const {
- return name;
- }
-
int getSystemId() {
return systemId;
}
@@ -82,6 +78,10 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ char* getName() const {
+ return name;
+ }
};
int gooo = 1;
@@ -176,10 +176,6 @@ public:
int GetUniqueId();
- char* getName() const {
- return name;
- }
-
int getSystemId() {
return systemId;
}
@@ -187,6 +183,10 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ char* getName() const {
+ return name;
+ }
};
}
@@ -246,7 +246,6 @@ public:
}
};
-
int gooo = 1;
#endif /* A_H_ */
@@ -278,10 +277,6 @@ public:
int GetUniqueId();
- void setName(char* name) {
- this->name = name;
- }
-
int getSystemId() {
return systemId;
}
@@ -289,8 +284,11 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
-};
+ void setName(char* name) {
+ this->name = name;
+ }
+};
int gooo = 1;
@@ -379,14 +377,6 @@ public:
int GetUniqueId();
- char* getName() const {
- return name;
- }
-
- void setName(char* name) {
- this->name = name;
- }
-
int getSystemId() {
return systemId;
}
@@ -394,6 +384,14 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ char* getName() const {
+ return name;
+ }
+
+ void setName(char* name) {
+ this->name = name;
+ }
};
int gooo = 1;
@@ -463,6 +461,18 @@ public:
Person myFriend;
+ Person(int socSecNo); // constructor
+
+ ~Person(); // destructor
+
+ char* Name();
+
+ void Print();
+
+ int SocSecNo();
+
+ int GetUniqueId();
+
char* getName() const {
return name;
}
@@ -478,18 +488,6 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
-
- Person(int socSecNo); // constructor
-
- ~Person(); // destructor
-
- char* Name();
-
- void Print();
-
- int SocSecNo();
-
- int GetUniqueId();
};
int gooo = 1;
@@ -567,7 +565,7 @@ GaS::Getters() {
GaS::~Getters() {
}
-//!Generate Getters and Setters no Methods
+//!Generate Getters and Setters no methods
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
filename=A.h
@@ -588,9 +586,6 @@ private:
#define A_H_
class Person {
-private:
- int id;
-
public:
int getId() const {
return id;
@@ -599,15 +594,19 @@ public:
void setId(int id) {
this->id = id;
}
+
+private:
+ int id;
};
#endif /* A_H_ */
-//!Generate Getters and Setters no Methods
+//!Generate Getters and Setters no methods ascending visibility order
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
filename=A.h
getters=i
setters=i
+ascendingVisibilityOrder=true
//@A.h
/*
* test.h
@@ -624,7 +623,6 @@ class test {
};
#endif /* TEST_H_ */
-
//=
/*
* test.h
@@ -650,8 +648,7 @@ public:
};
#endif /* TEST_H_ */
-
-//!Generate Getters and Setters no Fields
+//!Generate Getters and Setters no fields
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
filename=A.h
@@ -759,8 +756,6 @@ public:
Person myFriend;
- const FullName& getName() const;
- void setName(const FullName& name);
Person(int socSecNo); // constructor
~Person(); // destructor
@@ -776,6 +771,8 @@ public:
int getSystemId();
void setSystemId(int systemId);
+ const FullName& getName() const;
+ void setName(const FullName& name);
};
int gooo = 1;
@@ -886,7 +883,6 @@ public:
int SocSecNo();
int GetUniqueId();
- char* getName() const;
int getSystemId() {
return systemId;
@@ -895,6 +891,8 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ char* getName() const;
};
}
@@ -1005,7 +1003,6 @@ public:
int SocSecNo();
int GetUniqueId();
- void setName(char* name);
int getSystemId() {
return systemId;
@@ -1014,6 +1011,8 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ void setName(char* name);
};
int gooo = 1;
@@ -1115,8 +1114,6 @@ public:
int SocSecNo();
int GetUniqueId();
- char* getName() const;
- void setName(char* name);
int getSystemId() {
return systemId;
@@ -1125,6 +1122,9 @@ public:
void setSystemId(int systemId) {
this->systemId = systemId;
}
+
+ char* getName() const;
+ void setName(char* name);
};
int gooo = 1;
@@ -1178,12 +1178,12 @@ private:
#define A_H_
class Person {
-private:
- int id;
-
public:
int getId() const;
void setId(int id);
+
+private:
+ int id;
};
inline int Person::getId() const {
@@ -1228,13 +1228,14 @@ class test {
//comment1
class test {
- int i; //comment2
- char* b;
- //comment3
-
public:
int getI() const;
void setI(int i);
+
+private:
+ int i; //comment2
+ char* b;
+ //comment3
};
inline int test::getI() const {
@@ -1275,12 +1276,13 @@ class Test {
namespace foo {
class Test {
- int testField;
- void foo();
-
public:
int getTestField() const;
void setTestField(int testField);
+
+private:
+ int testField;
+ void foo();
};
} // namespace foo
@@ -1334,11 +1336,12 @@ class Test {
#define TEST_H_
class Test {
- int testField;
-
public:
int getTestField() const;
void setTestField(int testField);
+
+private:
+ int testField;
};
#endif
@@ -1374,11 +1377,12 @@ class Test {
#define TEST_H_
class Test {
- int testField;
-
public:
int getTestField() const;
void setTestField(int testField);
+
+private:
+ int testField;
};
#endif
@@ -1464,13 +1468,13 @@ private:
#define A_H_
class A {
-private:
- int a[2];
-
public:
const int* getA() const {
return a;
}
+
+private:
+ int a[2];
};
#endif /* A_H_ */
//!Bug 352258 - Avoiding reserved names
@@ -1493,9 +1497,6 @@ private:
#define A_H_
class getClass {
-private:
- int mClass;
-
public:
int getClass1() const {
return mClass;
@@ -1504,5 +1505,8 @@ public:
void setClass(int _class) {
mClass = _class;
}
+
+private:
+ int mClass;
};
#endif /* A_H_ */
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java
index 6b9cbf91d44..2cdeca22683 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java
@@ -18,11 +18,14 @@ import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile;
@@ -41,6 +44,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
private String[] selectedSetters;
private GenerateGettersAndSettersRefactoring refactoring;
private boolean definitionSeparate;
+ private String ascendingVisibilityOrder;
/**
* @param name
@@ -52,21 +56,30 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
@Override
protected void runTest() throws Throwable {
- IFile file = project.getFile(fileName);
- ICElement element = CoreModel.getDefault().create(file);
- refactoring = new GenerateGettersAndSettersRefactoring(element, selection, cproject, astCache);
- RefactoringStatus initialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
-
- if (fatalError) {
- assertConditionsFatalError(initialConditions);
- return;
- } else {
- assertConditionsOk(initialConditions);
- executeRefactoring();
+ try {
+ IFile file = project.getFile(fileName);
+ ICElement element = CoreModel.getDefault().create(file);
+ refactoring = new GenerateGettersAndSettersRefactoring(element, selection, cproject, astCache);
+ RefactoringStatus initialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR);
+
+ if (fatalError) {
+ assertConditionsFatalError(initialConditions);
+ return;
+ } else {
+ assertConditionsOk(initialConditions);
+ executeRefactoring();
+ }
+ } finally {
+ IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ store.setToDefault(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER);
}
}
private void executeRefactoring() throws CoreException, Exception {
+ if (ascendingVisibilityOrder != null) {
+ IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+ store.setValue(PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER, ascendingVisibilityOrder);
+ }
selectFields();
refactoring.getContext().setDefinitionSeparate(definitionSeparate);
RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
@@ -102,6 +115,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
String getters = refactoringProperties.getProperty("getters", ""); //$NON-NLS-1$ //$NON-NLS-2$
String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$
definitionSeparate = Boolean.valueOf(refactoringProperties.getProperty("definitionSeparate", "false"));
+ ascendingVisibilityOrder = refactoringProperties.getProperty("ascendingVisibilityOrder", null);
selectedGetters = getters.split(",");
selectedSetters = setters.split(",");
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java
deleted file mode 100644
index 0fa86ca0b49..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Institute for Software, HSR Hochschule fuer Technik
- * Rapperswil, University of applied sciences and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Institute for Software - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.text.edits.TextEditGroup;
-
-import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
-import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
-
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTVisibilityLabel;
-
-import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
-
-/**
- * Adds a declaration to an existing class via the ModificationCollector. It automatically searches
- * the correct insertion point for the desired visibility.
- *
- * @author Mirko Stocker
- */
-public class AddDeclarationNodeToClassChange {
- private final ICPPASTCompositeTypeSpecifier classNode;
- private final VisibilityEnum visibility;
- private List
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
* Value is of type Boolean
.
*
+ * Value is of type Boolean
. The true
value means that private members
+ * are before public ones. The default is to put public members before private ones.
+ *
+ * @since 5.4
+ */
+ public static final String CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER = "class_member_ascending_visibility_order"; //$NON-NLS-1$
+
+
/**
* Returns the CDT-UI preference store.
*
@@ -2089,9 +2108,9 @@ public class PreferenceConstants {
/**
* Returns the node in the preference in the given context.
* @param key The preference key.
- * @param project The current context or null
if no context is available and the
- * workspace setting should be taken. Note that passing null
should
- * be avoided.
+ * @param project The current context or null
if no context is available and
+ * the workspace setting should be taken. Note that passing null
should
+ * be avoided.
* @return Returns the node matching the given context.
*/
private static IEclipsePreferences getPreferenceNode(String key, ICProject project) {
@@ -2108,15 +2127,20 @@ public class PreferenceConstants {
return node;
}
+ node = ConfigurationScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
+ if (node.get(key, null) != null) {
+ return node;
+ }
+
return DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
}
/**
* Returns the string value for the given key in the given context.
* @param key The preference key
- * @param project The current context or null
if no context is available and the
- * workspace setting should be taken. Note that passing null
should
- * be avoided.
+ * @param project The current context or null
if no context is available and
+ * the workspace setting should be taken. Note that passing null
should
+ * be avoided.
* @return Returns the current value for the string.
* @since 5.0
*/
@@ -2127,9 +2151,9 @@ public class PreferenceConstants {
/**
* Returns the integer value for the given key in the given context.
* @param key The preference key
- * @param project The current context or null
if no context is available and the
- * workspace setting should be taken. Note that passing null
should
- * be avoided.
+ * @param project The current context or null
if no context is available and
+ * the workspace setting should be taken. Note that passing null
should
+ * be avoided.
* @param defaultValue The default value if not specified in the preferences.
* @return Returns the current value for the string.
* @since 5.1
@@ -2141,9 +2165,9 @@ public class PreferenceConstants {
/**
* Returns the boolean value for the given key in the given context.
* @param key The preference key
- * @param project The current context or null
if no context is available and the
- * workspace setting should be taken. Note that passing null
should
- * be avoided.
+ * @param project The current context or null
if no context is available and
+ * the workspace setting should be taken. Note that passing null
should
+ * be avoided.
* @param defaultValue The default value if not specified in the preferences.
* @return Returns the current value for the string.
* @since 5.1
@@ -2152,4 +2176,16 @@ public class PreferenceConstants {
return getPreferenceNode(key, project).getBoolean(key, defaultValue);
}
+ /**
+ * Returns the scopes for preference lookup.
+ *
+ * @param project a project or null
+ * @return the scopes for preference lookup.
+ * @since 5.4
+ */
+ public static IScopeContext[] getPreferenceScopes(IProject project) {
+ return project != null ?
+ new IScopeContext[] { new ProjectScope(project), InstanceScope.INSTANCE, ConfigurationScope.INSTANCE, DefaultScope.INSTANCE } :
+ new IScopeContext[] { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE, DefaultScope.INSTANCE };
+ }
}