diff options
author | Thomas Corbat | 2015-04-23 06:34:26 +0000 |
---|---|---|
committer | Thomas Corbat | 2015-06-12 14:35:39 +0000 |
commit | ed3e9cf973d25a4e96a7b6b65ecaa2b597c173b9 (patch) | |
tree | 2a10d23c06d9772d3bc7a97e39ded098a55249d0 /core/org.eclipse.cdt.core/parser/org | |
parent | d997a7c313290dfcdcab5ff382435950ff620e03 (diff) | |
download | org.eclipse.cdt-ed3e9cf973d25a4e96a7b6b65ecaa2b597c173b9.tar.gz org.eclipse.cdt-ed3e9cf973d25a4e96a7b6b65ecaa2b597c173b9.tar.xz org.eclipse.cdt-ed3e9cf973d25a4e96a7b6b65ecaa2b597c173b9.zip |
Bug 399931 - Fix for toggling functions with return type from context.
Change-Id: I188d851500c4464d12977c82805679eee31663f2
Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org')
5 files changed, 55 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java index 4c72cb15a98..e41a6a58a6e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/INodeFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2015 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 @@ -156,7 +156,10 @@ public interface INodeFactory { public IASTName newName(); public IASTName newName(char[] name); - + + /** @since 5.11 */ + public IASTName newName(String name); + public IASTNullStatement newNullStatement(); public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java index 8553b66df25..091b13eeb19 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2015 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 @@ -279,6 +279,14 @@ public interface ICPPNodeFactory extends INodeFactory { public ICPPASTQualifiedName newQualifiedName(); /** + * Creates an {@link ICPPASTQualifiedName} and adds name qualifiers for the + * elements of {@code nameQualifiers}. {@code nameQualifiers} cannot contain decltype specifiers + * for creation of {@link ICPPASTDecltypeSpecifier}. + * @since 5.11 + */ + public ICPPASTQualifiedName newQualifiedName(String[] nameQualifiers, String name); + + /** * @since 5.9 */ @Override @@ -291,6 +299,11 @@ public interface ICPPNodeFactory extends INodeFactory { public ICPPASTName newName(char[] name); /** + * @since 5.11 + */ + public ICPPASTNamedTypeSpecifier newNamedTypeSpecifier(IASTName name); + + /** * Creates a range based for statement. * @since 5.3 */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java index f4f35db2f56..681a1f30e98 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2015 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 @@ -364,7 +364,12 @@ public class CNodeFactory extends NodeFactory implements ICNodeFactory { public IASTName newName(char[] name) { return new CASTName(name); } - + + @Override + public IASTName newName(String name) { + return newName(name.toCharArray()); + } + @Override public IASTNullStatement newNullStatement() { return new CASTNullStatement(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java index 1c70b6c7f9f..34a62ea0b5f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2015 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 @@ -520,6 +520,16 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { } @Override + public ICPPASTName newName(String name) { + return newName(name.toCharArray()); + } + + @Override + public ICPPASTNamedTypeSpecifier newNamedTypeSpecifier(IASTName name) { + return new CPPASTNamedTypeSpecifier(name); + } + + @Override public ICPPASTNamespaceAlias newNamespaceAlias(IASTName alias, IASTName qualifiedName) { return new CPPASTNamespaceAlias(alias, qualifiedName); } @@ -622,6 +632,15 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory { } @Override + public ICPPASTQualifiedName newQualifiedName(String[] nameQualifiers, String name) { + ICPPASTQualifiedName qualifiedName = newQualifiedName(newName(name)); + for (String qualifier : nameQualifiers) { + qualifiedName.addNameSpecifier(newName(qualifier)); + } + return qualifiedName; + } + + @Override public ICPPASTRangeBasedForStatement newRangeBasedForStatement() { return new CPPASTRangeBasedForStatement(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java index f66d337c4c4..a8a86aa5d5a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/NameWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik + * Copyright (c) 2008, 2015 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 @@ -8,9 +8,11 @@ * * Contributors: * Institute for Software - initial API and implementation + * Thomas Corbat (IFS) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -80,11 +82,15 @@ public class NameWriter extends NodeWriter { private boolean needsTemplateQualifier(ICPPASTTemplateId templId){ if (templId.getParent() instanceof ICPPASTQualifiedName) { ICPPASTQualifiedName qName = (ICPPASTQualifiedName) templId.getParent(); - return isDependentName(qName, templId); + return !isPartOfFunctionDeclarator(qName) && isDependentName(qName, templId); } return false; } - + + private boolean isPartOfFunctionDeclarator(ICPPASTQualifiedName qName) { + return qName.getParent() instanceof IASTFunctionDeclarator; + } + private boolean isDependentName(ICPPASTQualifiedName qname, ICPPASTTemplateId tempId) { ICPPASTNameSpecifier[] segments = qname.getAllSegments(); for (int i = 0; i < segments.length; ++i){ |