mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
Proper handling of class declarations located in cpp files.
This commit is contained in:
parent
e55eb9ff04
commit
120ba41b08
9 changed files with 71 additions and 61 deletions
|
@ -3,7 +3,6 @@
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=name
|
getters=name
|
||||||
inHeader=true
|
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -104,7 +103,6 @@ int gooo = 1;
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=name
|
getters=name
|
||||||
inHeader=true
|
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -215,7 +213,6 @@ int gooo = 1;
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
setters=name
|
setters=name
|
||||||
inHeader=true
|
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -319,7 +316,6 @@ int gooo = 1;
|
||||||
filename=C.h
|
filename=C.h
|
||||||
setters=name
|
setters=name
|
||||||
getters=name
|
getters=name
|
||||||
inHeader=true
|
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -427,7 +423,6 @@ int gooo = 1;
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=name,systemId
|
getters=name,systemId
|
||||||
setters=name,systemId
|
setters=name,systemId
|
||||||
inHeader=true
|
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -527,7 +522,6 @@ int gooo = 1;
|
||||||
filename=GaS.h
|
filename=GaS.h
|
||||||
getters=i,ok
|
getters=i,ok
|
||||||
setters=i,ok
|
setters=i,ok
|
||||||
inHeader=true
|
|
||||||
//@GaS.cpp
|
//@GaS.cpp
|
||||||
#include "Getters.h"
|
#include "Getters.h"
|
||||||
|
|
||||||
|
@ -593,7 +587,6 @@ private:
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=id
|
getters=id
|
||||||
setters=id
|
setters=id
|
||||||
inHeader=true
|
|
||||||
//@C.h
|
//@C.h
|
||||||
#ifndef C_H_
|
#ifndef C_H_
|
||||||
#define C_H_
|
#define C_H_
|
||||||
|
@ -631,7 +624,6 @@ public:
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=i
|
getters=i
|
||||||
setters=i
|
setters=i
|
||||||
inHeader=true
|
|
||||||
//@C.h
|
//@C.h
|
||||||
/*
|
/*
|
||||||
* test.h
|
* test.h
|
||||||
|
@ -705,19 +697,19 @@ class test {
|
||||||
#define TEST_H_
|
#define TEST_H_
|
||||||
|
|
||||||
//comment1
|
//comment1
|
||||||
class test
|
class test {
|
||||||
{
|
|
||||||
void test();
|
void test();
|
||||||
//comment3
|
//comment3
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TEST_H_ */
|
#endif /* TEST_H_ */
|
||||||
|
|
||||||
//!Generate Getters and Setters One Getter Selection Implementation in CPP
|
//!Generate Getters and Setters One Getter Selection Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=name
|
getters=name
|
||||||
|
definitionSeparate=true
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -815,11 +807,12 @@ public:
|
||||||
int gooo = 1;
|
int gooo = 1;
|
||||||
|
|
||||||
#endif /*C_H_*/
|
#endif /*C_H_*/
|
||||||
//!Generate Getters and Setters One Getter Selection with Namespace Implementation in CPP
|
//!Generate Getters and Setters One Getter Selection with Namespace Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=name
|
getters=name
|
||||||
|
definitionSeparate=true
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -943,11 +936,12 @@ int gooo = 1;
|
||||||
|
|
||||||
#endif /*C_H_*/
|
#endif /*C_H_*/
|
||||||
|
|
||||||
//!Generate Getters and Setters One Setter Selection Implementation in CPP
|
//!Generate Getters and Setters One Setter Selection Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
setters=name
|
setters=name
|
||||||
|
definitionSeparate=true
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -1057,12 +1051,13 @@ public:
|
||||||
int gooo = 1;
|
int gooo = 1;
|
||||||
|
|
||||||
#endif /*C_H_*/
|
#endif /*C_H_*/
|
||||||
//!Getter and Setter Selection Implementation in CPP
|
//!Getter and Setter Selection Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
setters=name
|
setters=name
|
||||||
getters=name
|
getters=name
|
||||||
|
definitionSeparate=true
|
||||||
//@C.cpp
|
//@C.cpp
|
||||||
#include "C.h"
|
#include "C.h"
|
||||||
|
|
||||||
|
@ -1177,13 +1172,13 @@ int gooo = 1;
|
||||||
|
|
||||||
#endif /*C_H_*/
|
#endif /*C_H_*/
|
||||||
|
|
||||||
//!Generate Getters and Setters no Methods Implementation in CPP
|
//!Generate Getters and Setters no Methods Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=id
|
getters=id
|
||||||
setters=id
|
setters=id
|
||||||
infos=1
|
definitionSeparate=true
|
||||||
//@C.h
|
//@C.h
|
||||||
#ifndef C_H_
|
#ifndef C_H_
|
||||||
#define C_H_
|
#define C_H_
|
||||||
|
@ -1208,24 +1203,24 @@ public:
|
||||||
void setId(int id);
|
void setId(int id);
|
||||||
};
|
};
|
||||||
|
|
||||||
int Person::getId() const {
|
inline int Person::getId() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Person::setId(int id) {
|
inline void Person::setId(int id) {
|
||||||
this->id = id;
|
this->id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /*C_H_*/
|
#endif /*C_H_*/
|
||||||
|
|
||||||
//!No Methods Implementation in CPP
|
//!No Methods Separate Definition
|
||||||
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
//@.config
|
//@.config
|
||||||
filename=C.h
|
filename=C.h
|
||||||
getters=i
|
getters=i
|
||||||
setters=i
|
setters=i
|
||||||
infos=1
|
definitionSeparate=true
|
||||||
//@C.h
|
//@C.h
|
||||||
/*
|
/*
|
||||||
* test.h
|
* test.h
|
||||||
|
@ -1262,11 +1257,11 @@ public:
|
||||||
void setI(int i);
|
void setI(int i);
|
||||||
};
|
};
|
||||||
|
|
||||||
int test::getI() const {
|
inline int test::getI() const {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void test::setI(int i) {
|
inline void test::setI(int i) {
|
||||||
this->i = i;
|
this->i = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1279,6 +1274,7 @@ void test::setI(int i) {
|
||||||
filename=Test.h
|
filename=Test.h
|
||||||
getters=testField
|
getters=testField
|
||||||
setters=testField
|
setters=testField
|
||||||
|
definitionSeparate=true
|
||||||
|
|
||||||
//@Test.h
|
//@Test.h
|
||||||
#ifndef TEST_H_
|
#ifndef TEST_H_
|
||||||
|
@ -1346,6 +1342,7 @@ void Test::foo() {
|
||||||
filename=Test.h
|
filename=Test.h
|
||||||
getters=testField
|
getters=testField
|
||||||
setters=testField
|
setters=testField
|
||||||
|
definitionSeparate=true
|
||||||
|
|
||||||
//@Test.h
|
//@Test.h
|
||||||
#ifndef TEST_H_
|
#ifndef TEST_H_
|
||||||
|
@ -1386,6 +1383,7 @@ void Test::setTestField(int testField) {
|
||||||
filename=component_b/public_headers/Test.h
|
filename=component_b/public_headers/Test.h
|
||||||
getters=testField
|
getters=testField
|
||||||
setters=testField
|
setters=testField
|
||||||
|
definitionSeparate=true
|
||||||
|
|
||||||
//@component_b/public_headers/Test.h
|
//@component_b/public_headers/Test.h
|
||||||
#ifndef TEST_H_
|
#ifndef TEST_H_
|
||||||
|
|
|
@ -109,7 +109,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest {
|
||||||
|
|
||||||
protected void assertConditionsInfo(RefactoringStatus status, int number) {
|
protected void assertConditionsInfo(RefactoringStatus status, int number) {
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
assertTrue("Info in Condition expected", status.hasInfo()); //$NON-NLS-1$
|
assertTrue("Info in condition expected", status.hasInfo()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
RefactoringStatusEntry[] entries = status.getEntries();
|
RefactoringStatusEntry[] entries = status.getEntries();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -123,7 +123,7 @@ public abstract class RefactoringTest extends RefactoringBaseTest {
|
||||||
|
|
||||||
protected void assertConditionsError(RefactoringStatus status, int number) {
|
protected void assertConditionsError(RefactoringStatus status, int number) {
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
assertTrue("Error in Condition expected", status.hasError()); //$NON-NLS-1$
|
assertTrue("Error in condition expected", status.hasError()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
RefactoringStatusEntry[] entries = status.getEntries();
|
RefactoringStatusEntry[] entries = status.getEntries();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
|
||||||
private List<String> selectedGetters;
|
private List<String> selectedGetters;
|
||||||
private List<String> selectedSetters;
|
private List<String> selectedSetters;
|
||||||
private GenerateGettersAndSettersRefactoring refactoring;
|
private GenerateGettersAndSettersRefactoring refactoring;
|
||||||
private boolean keepInHeader;
|
private boolean definitionSeparate;
|
||||||
private int infos;
|
private int infos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
|
||||||
|
|
||||||
private void executeRefactoring() throws CoreException, Exception {
|
private void executeRefactoring() throws CoreException, Exception {
|
||||||
selectFields();
|
selectFields();
|
||||||
refactoring.getContext().setImplementationInHeader(keepInHeader);
|
refactoring.getContext().setDefinitionSeparate(definitionSeparate);
|
||||||
RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
|
RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR);
|
||||||
Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
|
Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR);
|
||||||
if (warnings > 0) {
|
if (warnings > 0) {
|
||||||
|
@ -109,7 +109,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
|
||||||
infos = new Integer(refactoringProperties.getProperty("infos", "0"));
|
infos = new Integer(refactoringProperties.getProperty("infos", "0"));
|
||||||
String getters = refactoringProperties.getProperty("getters", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
String getters = refactoringProperties.getProperty("getters", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
keepInHeader = Boolean.valueOf(refactoringProperties.getProperty("inHeader", "false"));
|
definitionSeparate = Boolean.valueOf(refactoringProperties.getProperty("definitionSeparate", "false"));
|
||||||
|
|
||||||
selectedGetters = new ArrayList<String>();
|
selectedGetters = new ArrayList<String>();
|
||||||
for (String getterName : getters.split(",")) { //$NON-NLS-1$
|
for (String getterName : getters.split(",")) { //$NON-NLS-1$
|
||||||
|
|
|
@ -68,17 +68,17 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl
|
||||||
gd.verticalAlignment = SWT.TOP;
|
gd.verticalAlignment = SWT.TOP;
|
||||||
btComp.setLayoutData(gd);
|
btComp.setLayoutData(gd);
|
||||||
|
|
||||||
final Button placeImplemetation = new Button(comp, SWT.CHECK);
|
final Button definitionSeparate = new Button(comp, SWT.CHECK);
|
||||||
placeImplemetation.setText(Messages.GenerateGettersAndSettersInputPage_PlaceImplHeader);
|
definitionSeparate.setText(Messages.GenerateGettersAndSettersInputPage_SeparateDefinition);
|
||||||
gd = new GridData();
|
gd = new GridData();
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
gd.heightHint = 40;
|
gd.heightHint = 40;
|
||||||
placeImplemetation.setLayoutData(gd);
|
definitionSeparate.setLayoutData(gd);
|
||||||
placeImplemetation.setSelection(context.isImplementationInHeader());
|
definitionSeparate.setSelection(context.isDefinitionSeparate());
|
||||||
placeImplemetation.addSelectionListener(new SelectionAdapter() {
|
definitionSeparate.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
context.setImplementationInHeader(placeImplemetation.getSelection());
|
context.setDefinitionSeparate(definitionSeparate.getSelection());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -121,9 +121,10 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 {
|
||||||
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
|
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
|
||||||
CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
|
CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
|
||||||
RefactoringStatus result = new RefactoringStatus();
|
RefactoringStatus result = new RefactoringStatus();
|
||||||
if (!context.isImplementationInHeader()) {
|
if (context.isDefinitionSeparate()) {
|
||||||
findDefinitionInsertLocation(pm);
|
findDefinitionInsertLocation(pm);
|
||||||
if (definitionInsertLocation == null || tu.equals(definitionInsertLocation.getTranslationUnit())) {
|
if (definitionInsertLocation == null ||
|
||||||
|
definitionInsertLocation.getTranslationUnit() == null) {
|
||||||
result.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile);
|
result.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,14 +231,19 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 {
|
||||||
List<IASTNode> getterAndSetters = new ArrayList<IASTNode>();
|
List<IASTNode> getterAndSetters = new ArrayList<IASTNode>();
|
||||||
List<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
|
List<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
|
||||||
for (GetterSetterInsertEditProvider currentProvider : context.selectedFunctions) {
|
for (GetterSetterInsertEditProvider currentProvider : context.selectedFunctions) {
|
||||||
if (context.isImplementationInHeader()) {
|
if (context.isDefinitionSeparate()) {
|
||||||
getterAndSetters.add(currentProvider.getFunctionDefinition(false));
|
|
||||||
} else {
|
|
||||||
getterAndSetters.add(currentProvider.getFunctionDeclaration());
|
getterAndSetters.add(currentProvider.getFunctionDeclaration());
|
||||||
definitions.add(currentProvider.getFunctionDefinition(true));
|
IASTFunctionDefinition functionDefinition = currentProvider.getFunctionDefinition(true);
|
||||||
|
// Standalone definitions in a header file have to be declared inline.
|
||||||
|
if (definitionInsertLocation.getTranslationUnit().isHeaderUnit()) {
|
||||||
|
functionDefinition.getDeclSpecifier().setInline(true);
|
||||||
|
}
|
||||||
|
definitions.add(functionDefinition);
|
||||||
|
} else {
|
||||||
|
getterAndSetters.add(currentProvider.getFunctionDefinition(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!context.isImplementationInHeader()) {
|
if (context.isDefinitionSeparate()) {
|
||||||
addDefinition(collector, definitions, pm);
|
addDefinition(collector, definitions, pm);
|
||||||
}
|
}
|
||||||
ICPPASTCompositeTypeSpecifier classDefinition =
|
ICPPASTCompositeTypeSpecifier classDefinition =
|
||||||
|
@ -271,9 +277,9 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTSimpleDeclaration decl = context.existingFields.get(0);
|
IASTSimpleDeclaration decl = context.existingFields.get(0);
|
||||||
MethodDefinitionInsertLocationFinder methodDefinitionInsertLocationFinder = new MethodDefinitionInsertLocationFinder();
|
MethodDefinitionInsertLocationFinder locationFinder = new MethodDefinitionInsertLocationFinder();
|
||||||
InsertLocation location = methodDefinitionInsertLocationFinder.find(
|
InsertLocation location = locationFinder.find(tu, decl.getFileLocation(), decl.getParent(),
|
||||||
tu, decl.getFileLocation(), decl.getParent(), astCache, pm);
|
astCache, pm);
|
||||||
|
|
||||||
if (location.getFile() == null || NodeHelper.isContainedInTemplateDeclaration(decl)) {
|
if (location.getFile() == null || NodeHelper.isContainedInTemplateDeclaration(decl)) {
|
||||||
location.setNodeToInsertAfter(NodeHelper.findTopLevelParent(decl), tu);
|
location.setNodeToInsertAfter(NodeHelper.findTopLevelParent(decl), tu);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class GetterSetterContext implements ITreeContentProvider {
|
||||||
public SortedSet<GetterSetterInsertEditProvider> selectedFunctions = new TreeSet<GetterSetterInsertEditProvider>();
|
public SortedSet<GetterSetterInsertEditProvider> selectedFunctions = new TreeSet<GetterSetterInsertEditProvider>();
|
||||||
public IASTName selectedName;
|
public IASTName selectedName;
|
||||||
private ArrayList<FieldWrapper> wrappedFields;
|
private ArrayList<FieldWrapper> wrappedFields;
|
||||||
private boolean implementationInHeader = false;
|
private boolean definitionSeparate;
|
||||||
|
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
ArrayList<GetterSetterInsertEditProvider> children = new ArrayList<GetterSetterInsertEditProvider>();
|
ArrayList<GetterSetterInsertEditProvider> children = new ArrayList<GetterSetterInsertEditProvider>();
|
||||||
|
@ -80,9 +80,11 @@ public class GetterSetterContext implements ITreeContentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
// We only recreate the function declarations instead of recreating GetterSetterInsertEditProviders.
|
// We only recreate the function declarations instead of recreating
|
||||||
// That way, selectedFunctions is still valid. Also, the objects inside the TreeViewer are still the same
|
// GetterSetterInsertEditProviders. That way, selectedFunctions is still valid.
|
||||||
// which is convenient because that way we don't need to save then restore the collapsed/expanded+checked/unchecked state of the TreeViewer.
|
// Also, the objects inside the TreeViewer are still the same, which is convenient because
|
||||||
|
// that way we don't need to save then restore the collapsed/expanded+checked/unchecked
|
||||||
|
// state of the TreeViewer.
|
||||||
for (FieldWrapper wrapper : wrappedFields) {
|
for (FieldWrapper wrapper : wrappedFields) {
|
||||||
for (GetterSetterInsertEditProvider provider : wrapper.childNodes) {
|
for (GetterSetterInsertEditProvider provider : wrapper.childNodes) {
|
||||||
provider.createFunctionDeclaration();
|
provider.createFunctionDeclaration();
|
||||||
|
@ -96,12 +98,12 @@ public class GetterSetterContext implements ITreeContentProvider {
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isImplementationInHeader() {
|
public boolean isDefinitionSeparate() {
|
||||||
return implementationInHeader;
|
return definitionSeparate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImplementationInHeader(boolean implementationInHeader) {
|
public void setDefinitionSeparate(boolean definitionSeparate) {
|
||||||
this.implementationInHeader = implementationInHeader;
|
this.definitionSeparate = definitionSeparate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<FieldWrapper> getWrappedFields() {
|
private ArrayList<FieldWrapper> getWrappedFields() {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
public final class Messages extends NLS {
|
public final class Messages extends NLS {
|
||||||
public static String GenerateGettersAndSettersInputPage_DeselectAll;
|
public static String GenerateGettersAndSettersInputPage_DeselectAll;
|
||||||
public static String GenerateGettersAndSettersInputPage_header;
|
public static String GenerateGettersAndSettersInputPage_header;
|
||||||
public static String GenerateGettersAndSettersInputPage_PlaceImplHeader;
|
public static String GenerateGettersAndSettersInputPage_SeparateDefinition;
|
||||||
public static String GenerateGettersAndSettersInputPage_SelectAll;
|
public static String GenerateGettersAndSettersInputPage_SelectAll;
|
||||||
public static String GenerateGettersAndSettersInputPage_SelectGetters;
|
public static String GenerateGettersAndSettersInputPage_SelectGetters;
|
||||||
public static String GenerateGettersAndSettersInputPage_SelectSetters;
|
public static String GenerateGettersAndSettersInputPage_SelectSetters;
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
# 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
|
||||||
###############################################################################
|
###############################################################################
|
||||||
GettersAndSetters_Name=Generate getters and setters
|
GettersAndSetters_Name=Generate getters and setters
|
||||||
GenerateGettersAndSettersInputPage_DeselectAll=Deselect All
|
GenerateGettersAndSettersInputPage_DeselectAll=Deselect All
|
||||||
GenerateGettersAndSettersInputPage_header=Select getters and setters to create:
|
GenerateGettersAndSettersInputPage_header=Select getters and setters to create:
|
||||||
GenerateGettersAndSettersInputPage_PlaceImplHeader=Place implementation in header file
|
GenerateGettersAndSettersInputPage_SeparateDefinition=Definition separate from declaration
|
||||||
GenerateGettersAndSettersInputPage_SelectAll=Select All
|
GenerateGettersAndSettersInputPage_SelectAll=Select All
|
||||||
GenerateGettersAndSettersInputPage_SelectGetters=Select Getters
|
GenerateGettersAndSettersInputPage_SelectGetters=Select Getters
|
||||||
GenerateGettersAndSettersInputPage_SelectSetters=Select Setters
|
GenerateGettersAndSettersInputPage_SelectSetters=Select Setters
|
||||||
|
|
|
@ -105,10 +105,14 @@ public class MethodDefinitionInsertLocationFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insertLocation.getTranslationUnit() == null) {
|
if (insertLocation.getTranslationUnit() == null) {
|
||||||
ITranslationUnit partner = SourceHeaderPartnerFinder.getPartnerTranslationUnit(
|
if (declarationTu.isHeaderUnit()) {
|
||||||
declarationTu, astCache);
|
ITranslationUnit partner = SourceHeaderPartnerFinder.getPartnerTranslationUnit(
|
||||||
if (partner != null) {
|
declarationTu, astCache);
|
||||||
insertLocation.setParentNode(astCache.getAST(partner, null), partner);
|
if (partner != null) {
|
||||||
|
insertLocation.setParentNode(astCache.getAST(partner, null), partner);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
insertLocation.setParentNode(parent.getTranslationUnit(), declarationTu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue