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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-04-05 04:56:22 +00:00
parent e96f2e9804
commit d44a0b76f7

View file

@ -26,7 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.Type; import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.Type;
import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper; import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
public class GetterAndSetterContext implements ITreeContentProvider{ public class GetterAndSetterContext implements ITreeContentProvider {
public ArrayList<IASTSimpleDeclaration> existingFields = new ArrayList<IASTSimpleDeclaration>(); public ArrayList<IASTSimpleDeclaration> existingFields = new ArrayList<IASTSimpleDeclaration>();
public ArrayList<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>(); public ArrayList<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>();
public ArrayList<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>(); public ArrayList<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>();
@ -41,10 +41,10 @@ public class GetterAndSetterContext implements ITreeContentProvider{
FieldWrapper wrapper = (FieldWrapper) parentElement; FieldWrapper wrapper = (FieldWrapper) parentElement;
if (wrapper.getChildNodes().isEmpty()) { if (wrapper.getChildNodes().isEmpty()) {
if (!wrapper.getter.exists()){ if (!wrapper.getter.exists()) {
wrapper.childNodes.add(createGetterInserter(wrapper.field)); wrapper.childNodes.add(createGetterInserter(wrapper.field));
} }
if (!wrapper.setter.exists() && !wrapper.field.getDeclSpecifier().isConst()){ if (!wrapper.setter.exists() && !wrapper.field.getDeclSpecifier().isConst()) {
wrapper.childNodes.add(createSetterInserter(wrapper.field)); wrapper.childNodes.add(createSetterInserter(wrapper.field));
} }
} }
@ -96,12 +96,12 @@ public class GetterAndSetterContext implements ITreeContentProvider{
private ArrayList<FieldWrapper> getWrappedFields() { private ArrayList<FieldWrapper> getWrappedFields() {
if (wrappedFields == null) { if (wrappedFields == null) {
wrappedFields = new ArrayList<FieldWrapper>(); wrappedFields = new ArrayList<FieldWrapper>();
for (IASTSimpleDeclaration currentField : existingFields){ for (IASTSimpleDeclaration currentField : existingFields) {
FieldWrapper wrapper = new FieldWrapper(); FieldWrapper wrapper = new FieldWrapper();
wrapper.field = currentField; wrapper.field = currentField;
wrapper.getter = getGetterForField(currentField); wrapper.getter = getGetterForField(currentField);
wrapper.setter = getSetterForField(currentField); wrapper.setter = getSetterForField(currentField);
if (wrapper.missingGetterOrSetter()){ if (wrapper.missingGetterOrSetter()) {
wrappedFields.add(wrapper); wrappedFields.add(wrapper);
} }
} }
@ -136,28 +136,27 @@ public class GetterAndSetterContext implements ITreeContentProvider{
} }
private void setFunctionToWrapper(FunctionWrapper wrapper, String getterName) { private void setFunctionToWrapper(FunctionWrapper wrapper, String getterName) {
for (IASTFunctionDefinition currentDefinition : existingFunctionDefinitions){ for (IASTFunctionDefinition currentDefinition : existingFunctionDefinitions) {
if (currentDefinition.getDeclarator().getName().toString().endsWith(getterName)){ if (currentDefinition.getDeclarator().getName().toString().endsWith(getterName)) {
wrapper.functionDefinition = currentDefinition; wrapper.functionDefinition = currentDefinition;
} }
} }
for (IASTSimpleDeclaration currentDeclaration : existingFunctionDeclarations){ for (IASTSimpleDeclaration currentDeclaration : existingFunctionDeclarations) {
if (getFieldDeclarationName(currentDeclaration).toString().endsWith(getterName)){ if (getFieldDeclarationName(currentDeclaration).toString().endsWith(getterName)) {
wrapper.functionDeclaration = currentDeclaration; wrapper.functionDeclaration = currentDeclaration;
} }
} }
} }
protected class FieldWrapper {
protected class FieldWrapper{
protected IASTSimpleDeclaration field; protected IASTSimpleDeclaration field;
protected FunctionWrapper getter; protected FunctionWrapper getter;
protected FunctionWrapper setter; protected FunctionWrapper setter;
protected ArrayList<GetterSetterInsertEditProvider> childNodes = new ArrayList<GetterSetterInsertEditProvider>(2); protected ArrayList<GetterSetterInsertEditProvider> childNodes = new ArrayList<GetterSetterInsertEditProvider>(2);
@Override @Override
public String toString(){ public String toString() {
IASTDeclarator declarator = field.getDeclarators()[0]; IASTDeclarator declarator = field.getDeclarators()[0];
while (declarator.getNestedDeclarator() != null) { while (declarator.getNestedDeclarator() != null) {
declarator = declarator.getNestedDeclarator(); declarator = declarator.getNestedDeclarator();
@ -174,7 +173,7 @@ public class GetterAndSetterContext implements ITreeContentProvider{
} }
} }
protected class FunctionWrapper{ protected class FunctionWrapper {
protected IASTSimpleDeclaration functionDeclaration; protected IASTSimpleDeclaration functionDeclaration;
protected IASTFunctionDefinition functionDefinition; protected IASTFunctionDefinition functionDefinition;