1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 438384 - "syntax error" for class method ref qualifiers

This commit is contained in:
Sergey Prigogin 2014-08-26 17:50:09 -07:00
parent 33b70bb10c
commit 1eabfa5241
17 changed files with 187 additions and 83 deletions

View file

@ -2242,6 +2242,31 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
//class A {
// void a() & {}
// void b() && {}
//
// void c() const& {}
// void d() const&& {}
//
// void e() volatile & {}
// void f() volatile && {}
//
// void g() volatile const& {}
// void h() volatile const&& {}
//};
public void test8s4() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// void print(int a, int)
// {
// //printf("a = %d",a);
// }
public void test8_4s5() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// int a;
// struct X {
// static int a;
@ -5717,7 +5742,7 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
// template <class T> int f(T[5]);
// int I = f<int>(0);
// int j = f<void>(0); // invalid array // also no error with gcc
// int j = f<void>(0); // invalid array
public void _test14_8_2s8b() throws Exception {
final String content= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
@ -6593,14 +6618,6 @@ public class AST2CPPSpecTest extends AST2SpecTestBase {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
// void print(int a, int)
// {
// //printf("a = %d",a);
// }
public void test8_4s5() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// int a;
// const int b = a;
// int c = b;

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
Bundle-Version: 5.8.0.qualifier
Bundle-Version: 5.9.0.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -59,6 +59,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDecltypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
@ -314,6 +315,17 @@ public class ASTStringUtil {
if (cppFunctionDecl.isVolatile()) {
buffer.append(Keywords.VOLATILE).append(' ');
}
RefQualifier refQualifier = cppFunctionDecl.getRefQualifier();
if (refQualifier != null) {
switch (refQualifier) {
case LVALUE:
buffer.append(Keywords.cpAMPER).append(' ');
break;
case RVALUE:
buffer.append(Keywords.cpAND).append(' ');
break;
}
}
if (cppFunctionDecl.isPureVirtual()) {
buffer.append("=0 "); //$NON-NLS-1$
}

View file

@ -398,6 +398,9 @@ public class ASTTypeUtil {
if (type instanceof ICPPFunctionType) {
ICPPFunctionType ft= (ICPPFunctionType) type;
needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile(), false);
if (ft.hasRefQualifier()) {
appendRefQualifier(result, needSpace, ft.isRValueReference()); needSpace = true;
}
}
} else if (type instanceof IPointerType) {
if (type instanceof ICPPPointerToMemberType) {
@ -466,6 +469,14 @@ public class ASTTypeUtil {
return needSpace;
}
private static void appendRefQualifier(StringBuilder target, boolean needSpace,
boolean isRValueReference) {
if (needSpace) {
target.append(SPACE);
}
target.append(isRValueReference ? Keywords.cpAND : Keywords.cpAMPER);
}
/**
* Returns the normalized string representation of the type.
* @see #getType(IType, boolean)

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others.
* Copyright (c) 2004, 2014 IBM Corporation 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
@ -26,6 +26,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
* @noextend This interface is not intended to be extended by clients.
*/
public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarator, ICPPASTDeclarator {
/**
* @since 5.9
*/
public enum RefQualifier { LVALUE, RVALUE }
/**
* Used as return value for {@link #getExceptionSpecification()}.
* @since 5.1
@ -99,6 +104,18 @@ public interface ICPPASTFunctionDeclarator extends IASTStandardFunctionDeclarato
*/
public void setPureVirtual(boolean isPureVirtual);
/**
* Returns the ref-qualifier.
* @since 5.9
*/
public RefQualifier getRefQualifier();
/**
* Sets the ref-qualifier.
* @since 5.9
*/
public void setRefQualifier(RefQualifier value);
/**
* @since 5.2
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005-2009 IBM Corporation and others.
* Copyright (c) 2005, 2014 IBM Corporation 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
@ -30,6 +30,18 @@ public interface ICPPFunctionType extends IFunctionType {
*/
public boolean isVolatile();
/**
* Returns {@code true} for a method declared with a ref-qualifier.
* @since 5.9
*/
public boolean hasRefQualifier();
/**
* Returns {@code true} if the type of the implicit object parameter is an rvalue reference.
* @since 5.9
*/
public boolean isRValueReference();
/**
* Whether the function type takes variable number of arguments.
* @since 5.2

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others.
* Copyright (c) 2004, 2014 IBM Corporation 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
@ -44,6 +44,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
private boolean isVolatile;
private boolean isConst;
private boolean isMutable;
private RefQualifier refQualifier;
private ICPPFunctionScope scope;
@ -67,6 +68,7 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
copy.isVolatile = isVolatile;
copy.isConst = isConst;
copy.isMutable = isMutable;
copy.refQualifier = refQualifier;
for (IASTParameterDeclaration param : getParameters()) {
copy.addParameterDeclaration(param == null ? null : param.copy(style));
@ -212,6 +214,17 @@ public class CPPASTFunctionDeclarator extends CPPASTDeclarator implements ICPPAS
this.pureVirtual = isPureVirtual;
}
@Override
public RefQualifier getRefQualifier() {
return refQualifier;
}
@Override
public void setRefQualifier(RefQualifier value) {
assertNotFrozen();
refQualifier = value;
}
@Override
@Deprecated
public org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer[] getConstructorChain() {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2013 Wind River Systems, Inc. and others.
* Copyright (c) 2010, 2014 Wind River Systems, Inc. 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
@ -102,7 +102,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
// Function call operator
final IType returnType= getReturnType();
final IType[] parameterTypes= getParameterTypes();
ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false);
ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false, false, false);
ICPPParameter[] params = new ICPPParameter[parameterTypes.length];
for (int i = 0; i < params.length; i++) {
@ -117,7 +117,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
// Conversion operator
if (needConversionOperator) {
final CPPFunctionType conversionTarget = new CPPFunctionType(returnType, parameterTypes);
ft= new CPPFunctionType(conversionTarget, IType.EMPTY_TYPE_ARRAY, true, false, false);
ft= new CPPFunctionType(conversionTarget, IType.EMPTY_TYPE_ARRAY, true, false, false, false, false);
m= new CPPImplicitMethod(scope, CPPASTConversionName.createName(conversionTarget, null), ft, params);
result[5]= m;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2012 IBM Corporation and others.
* Copyright (c) 2004, 2014 IBM Corporation 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
@ -31,18 +31,22 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
private final IType returnType;
private final boolean isConst;
private final boolean isVolatile;
private final boolean hasRefQualifier;
private final boolean isRValueReference;
private final boolean takesVarargs;
public CPPFunctionType(IType returnType, IType[] types) {
this(returnType, types, false, false, false);
this(returnType, types, false, false, false, false, false);
}
public CPPFunctionType(IType returnType, IType[] types, boolean isConst, boolean isVolatile,
boolean takesVarargs) {
boolean hasRefQualifier, boolean isRValueReference, boolean takesVarargs) {
this.returnType = returnType;
this.parameters = types;
this.isConst = isConst;
this.isVolatile= isVolatile;
this.hasRefQualifier = hasRefQualifier;
this.isRValueReference = isRValueReference;
this.takesVarargs= takesVarargs;
}
@ -52,7 +56,10 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return o.isSameType(this);
if (o instanceof ICPPFunctionType) {
ICPPFunctionType ft = (ICPPFunctionType) o;
if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile() || takesVarArgs() != ft.takesVarArgs()) {
if (isConst() != ft.isConst() || isVolatile() != ft.isVolatile()
|| hasRefQualifier() != ft.hasRefQualifier()
|| isRValueReference() != ft.isRValueReference()
|| takesVarArgs() != ft.takesVarArgs()) {
return false;
}
@ -118,6 +125,16 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return isVolatile;
}
@Override
public boolean hasRefQualifier() {
return hasRefQualifier;
}
@Override
public boolean isRValueReference() {
return isRValueReference;
}
@Override
public boolean takesVarArgs() {
return takesVarargs;
@ -131,9 +148,11 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
short firstBytes= ITypeMarshalBuffer.FUNCTION_TYPE;
if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (takesVarArgs()) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG3;
if (isConst) firstBytes |= ITypeMarshalBuffer.FLAG1;
if (takesVarargs) firstBytes |= ITypeMarshalBuffer.FLAG2;
if (isVolatile) firstBytes |= ITypeMarshalBuffer.FLAG3;
if (hasRefQualifier) firstBytes |= ITypeMarshalBuffer.FLAG4;
if (isRValueReference) firstBytes |= ITypeMarshalBuffer.FLAG5;
buffer.putShort(firstBytes);
buffer.putInt(parameters.length);
@ -154,6 +173,8 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
return new CPPFunctionType(rt, pars,
(firstBytes & ITypeMarshalBuffer.FLAG1) != 0, // const
(firstBytes & ITypeMarshalBuffer.FLAG3) != 0, // volatile
(firstBytes & ITypeMarshalBuffer.FLAG5) != 0, // has ref-qualifier
(firstBytes & ITypeMarshalBuffer.FLAG4) != 0, // rvalue reference
(firstBytes & ITypeMarshalBuffer.FLAG2) != 0); // takes varargs
}
}

View file

@ -74,6 +74,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttribute;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
@ -91,13 +92,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTForStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression.CaptureDefault;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
@ -4240,6 +4241,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
}
// ref-qualifiers
switch (LT(1)) {
case IToken.tAMPER:
fc.setRefQualifier(RefQualifier.LVALUE);
endOffset= consume().getEndOffset();
break;
case IToken.tAND:
fc.setRefQualifier(RefQualifier.RVALUE);
endOffset= consume().getEndOffset();
break;
default:
break;
}
// throws clause
if (LT(1) == IToken.t_throw) {
fc.setEmptyExceptionSpecification();

View file

@ -864,6 +864,7 @@ public class CPPTemplates {
if (i < parameters.length) {
par = parameters[i];
} // else reuse last parameter (which should be a pack)
@SuppressWarnings("null")
IValue defaultValue = par.getDefaultValue();
IValue specializedValue = CPPTemplates.instantiateValue(defaultValue, tpMap,
packOffset, within, maxdepth, point);
@ -1325,7 +1326,8 @@ public class CPPTemplates {
params[i]= CPPVisitor.adjustParameterType(p, true);
}
}
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(),
ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs());
}
if (type instanceof ICPPTemplateParameter) {
@ -2227,10 +2229,11 @@ public class CPPTemplates {
}
}
ICPPFunctionType originalType = function.getType();
if (i == parameters.length) // no parameters with default arguments
if (i == parameters.length) // No parameters with default arguments.
return originalType;
return new CPPFunctionType(originalType.getReturnType(), ArrayUtil.trim(parameterTypes),
originalType.isConst(), originalType.isVolatile(), originalType.takesVarArgs());
originalType.isConst(), originalType.isVolatile(), originalType.hasRefQualifier(),
originalType.isRValueReference(), originalType.takesVarArgs());
}
private static int compareSpecialization(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode, IASTNode point) throws DOMException {

View file

@ -112,6 +112,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
@ -1830,7 +1831,7 @@ public class CPPVisitor extends ASTQueries {
pTypes[i] = pt;
}
return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false);
return new CPPFunctionType(returnType, pTypes, isConst, isVolatile, false, false, false);
}
/**
@ -1869,7 +1870,9 @@ public class CPPVisitor extends ASTQueries {
returnType = getPointerTypes(returnType, fnDtor);
}
CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile(),
RefQualifier refQualifier = fnDtor.getRefQualifier();
CPPFunctionType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(),
fnDtor.isVolatile(), refQualifier != null, refQualifier == RefQualifier.RVALUE,
fnDtor.takesVarArgs());
final IASTDeclarator nested = fnDtor.getNestedDeclarator();
if (nested != null) {

View file

@ -355,7 +355,8 @@ public class SemanticUtil {
if (ret == r && params == ps) {
return type;
}
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(),
ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs());
}
if (type instanceof ITypedef) {
@ -499,7 +500,8 @@ public class SemanticUtil {
if (ret == r) {
return type;
}
return new CPPFunctionType(ret, ft.getParameterTypes(), ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
return new CPPFunctionType(ret, ft.getParameterTypes(), ft.isConst(), ft.isVolatile(),
ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs());
}
if (type instanceof ITypeContainer) {
final ITypeContainer tc = (ITypeContainer) type;

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator.RefQualifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
@ -142,6 +143,17 @@ public class DeclaratorWriter extends NodeWriter {
scribe.printSpace();
scribe.print(Keywords.VOLATILE);
}
RefQualifier refQualifier = funcDec.getRefQualifier();
if (refQualifier != null) {
switch (refQualifier) {
case LVALUE:
scribe.print(Keywords.cpAMPER);
break;
case RVALUE:
scribe.print(Keywords.cpAND);
break;
}
}
if (funcDec.isMutable()) {
scribe.printSpace();
scribe.print(Keywords.MUTABLE);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2013 Symbian Software Systems and others.
* Copyright (c) 2007, 2014 Symbian Software Systems 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
@ -157,7 +157,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
IType[] p= ft.getParameterTypes();
IType[] p2= getCompositeTypes(p);
if (r != r2 || p != p2) {
return new CPPFunctionType(r2, p2, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
return new CPPFunctionType(r2, p2, ft.isConst(), ft.isVolatile(),
ft.hasRefQualifier(), ft.isRValueReference(), ft.takesVarArgs());
}
return ft;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2013 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 Wind River Systems, Inc. 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
@ -289,6 +289,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
public void run() {
boolean needSpace = skipConstVolatileRestrict();
int token = peekNextToken();
// Ref-qualifier.
if (token == Token.tAMPER || token == Token.tAND) {
scribe.printNextToken(token, true);
token = peekNextToken();
needSpace = true;
}
if (token == Token.t_throw || token == Token.tIDENTIFIER) {
if (node instanceof ICPPASTFunctionDeclarator) {
final IASTTypeId[] exceptionSpecification=
@ -1417,48 +1423,6 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
formatList(parameters, options, true, node.takesVarArgs(),
new FunctionDeclaratorTailFormatter(node, tailFormatter));
// IASTFileLocation fileLocation= node.getFileLocation();
// if (fileLocation != null &&
// scribe.scanner.getCurrentPosition() < fileLocation.getNodeOffset() + fileLocation.getNodeLength()) {
// skipConstVolatileRestrict();
//
// int token = peekNextToken();
// if (token == Token.t_throw || token == Token.tIDENTIFIER) {
// final IASTTypeId[] exceptionSpecification= node.getExceptionSpecification();
// if (exceptionSpecification != null && token == Token.t_throw)
// formatExceptionSpecification(exceptionSpecification);
// if (peekNextToken() == Token.tIDENTIFIER) {
// Alignment alignment = scribe.createAlignment(
// Alignment.TRAILING_TEXT,
// Alignment.M_COMPACT_SPLIT,
// 1,
// scribe.scanner.getCurrentPosition());
//
// scribe.enterAlignment(alignment);
// boolean ok = false;
// do {
// try {
// scribe.alignFragment(alignment, 0);
// // Skip the rest of the declarator.
// scribe.printTrailingComment();
// scribe.space();
// if (tailFormatter != null)
// tailFormatter.run();
// skipNode(node);
// ok = true;
// } catch (AlignmentException e) {
// scribe.redoAlignment(e);
// }
// } while (!ok);
// scribe.exitAlignment(alignment, true);
// }
// } else {
// // Skip the rest (=0)
// scribe.printTrailingComment();
// scribe.space();
// skipNode(node);
// }
// }
return PROCESS_SKIP;
}

View file

@ -38,11 +38,11 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
@ -264,6 +264,7 @@ public class ImplementMethodRefactoring extends CRefactoring {
createdMethodDeclarator = nodeFactory.newFunctionDeclarator(qName);
createdMethodDeclarator.setConst(functionDeclarator.isConst());
createdMethodDeclarator.setRefQualifier(functionDeclarator.getRefQualifier());
for (IASTPointerOperator pop : functionDeclarator.getPointerOperators()) {
createdMethodDeclarator.addPointerOperator(pop.copy(CopyStyle.withLocations));
}