mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
d44a0b76f7
commit
99cdc84b19
3 changed files with 37 additions and 49 deletions
|
@ -41,8 +41,8 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
|
|||
|
||||
public class FunctionFactory {
|
||||
|
||||
public static IASTFunctionDefinition createGetterDefinition(String varName, IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
|
||||
|
||||
public static IASTFunctionDefinition createGetterDefinition(String varName,
|
||||
IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
|
||||
IASTFunctionDefinition getter = new CPPASTFunctionDefinition();
|
||||
|
||||
getter.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations));
|
||||
|
@ -52,9 +52,7 @@ public class FunctionFactory {
|
|||
getterDeclarator = getterDeclarator.getNestedDeclarator();
|
||||
}
|
||||
getter.setDeclarator((IASTFunctionDeclarator) getterDeclarator);
|
||||
|
||||
getter.setBody(getGetterBody(varName));
|
||||
|
||||
return getter;
|
||||
}
|
||||
|
||||
|
@ -72,7 +70,6 @@ public class FunctionFactory {
|
|||
|
||||
private static IASTDeclarator getGetterDeclarator(String varName,
|
||||
IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
|
||||
|
||||
CPPASTName getterName = new CPPASTName();
|
||||
String varPartOfGetterName = NameHelper.makeFirstCharUpper(NameHelper.trimFieldName(varName));
|
||||
getterName.setName("get".concat(varPartOfGetterName).toCharArray()); //$NON-NLS-1$
|
||||
|
@ -107,18 +104,15 @@ public class FunctionFactory {
|
|||
IASTDeclarator parent = (IASTDeclarator) innermost.getParent();
|
||||
parent.setNestedDeclarator(functionDeclarator);
|
||||
return topDeclarator;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static IASTFunctionDefinition createSetterDefinition(String varName, IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
|
||||
|
||||
public static IASTFunctionDefinition createSetterDefinition(String varName,
|
||||
IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
|
||||
IASTFunctionDefinition setter = new CPPASTFunctionDefinition();
|
||||
|
||||
setter.setDeclSpecifier(getVoidDeclSpec());
|
||||
setter.setDeclarator(getSetterDeclarator(varName, fieldDeclaration, name));
|
||||
setter.setBody(getSetterBody(fieldDeclaration));
|
||||
|
||||
return setter;
|
||||
}
|
||||
|
||||
|
@ -160,8 +154,7 @@ public class FunctionFactory {
|
|||
declarator.setName(setterName);
|
||||
}
|
||||
CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration();
|
||||
parameterDeclaration
|
||||
.setDeclarator(fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations));
|
||||
parameterDeclaration.setDeclarator(fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations));
|
||||
parameterDeclaration.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(
|
||||
CopyStyle.withLocations));
|
||||
declarator.addParameterDeclaration(parameterDeclaration.copy(CopyStyle.withLocations));
|
||||
|
@ -190,5 +183,4 @@ public class FunctionFactory {
|
|||
setter.addDeclarator(getSetterDeclarator(name, fieldDeclaration, null));
|
||||
return setter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ public class GetterSetterInsertEditProvider implements Comparable<GetterSetterIn
|
|||
public GetterSetterInsertEditProvider(String name, IASTSimpleDeclaration fieldDeclaration, Type type) {
|
||||
switch (type) {
|
||||
case getter:
|
||||
|
||||
this.functionDeclaration = FunctionFactory.createGetterDeclaration(name, fieldDeclaration);
|
||||
break;
|
||||
case setter:
|
||||
|
|
|
@ -34,10 +34,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
|||
/**
|
||||
* Helper class to find Namespace informations.
|
||||
* @author Mirko Stocker
|
||||
*
|
||||
*/
|
||||
public class NamespaceHelper {
|
||||
|
||||
/**
|
||||
* Returns the qualified name of all namespaces that are defined at the specified file and offset.
|
||||
*
|
||||
|
@ -46,12 +44,11 @@ public class NamespaceHelper {
|
|||
* @return ICPPASTQualifiedName with the names of all namespaces
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static ICPPASTQualifiedName getSurroundingNamespace(final IFile insertFile, final int offset) throws CoreException {
|
||||
|
||||
public static ICPPASTQualifiedName getSurroundingNamespace(final IFile insertFile, final int offset)
|
||||
throws CoreException {
|
||||
final CPPASTQualifiedName qualifiedName = new CPPASTQualifiedName();
|
||||
|
||||
TranslationUnitHelper.loadTranslationUnit(insertFile, false).accept(new CPPASTAllVisitor() {
|
||||
|
||||
@Override
|
||||
public int visit(IASTDeclSpecifier declSpec) {
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier && checkFileNameAndLocation(insertFile, offset, declSpec)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue