mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge branch 'master' into sd90
This commit is contained in:
commit
f02dc2e531
25 changed files with 413 additions and 196 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2011 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
|
||||
|
@ -69,6 +69,7 @@ public class CModelElementsTests extends TestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
monitor = new NullProgressMonitor();
|
||||
fCProject= CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||
|
@ -93,6 +94,7 @@ public class CModelElementsTests extends TestCase {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
|
@ -133,6 +135,7 @@ public class CModelElementsTests extends TestCase {
|
|||
checkArrays(tu);
|
||||
|
||||
checkBug180815(tu);
|
||||
checkBug352350(tu);
|
||||
}
|
||||
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=180815
|
||||
|
@ -144,6 +147,18 @@ public class CModelElementsTests extends TestCase {
|
|||
assertEquals(2, struct.getChildren().length);
|
||||
}
|
||||
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
|
||||
private void checkBug352350(IParent parent) throws CModelException {
|
||||
List namespaces = parent.getChildrenOfType(ICElement.C_NAMESPACE);
|
||||
assertEquals(2, namespaces.size());
|
||||
for (Object o : namespaces) {
|
||||
INamespace namespace = (INamespace)o;
|
||||
if (namespace.getElementName().length() == 0) {
|
||||
assertTrue(namespace.equals(namespace));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkInclude(IParent tu) throws CModelException{
|
||||
List tuIncludes = tu.getChildrenOfType(ICElement.C_INCLUDE);
|
||||
IInclude inc1 = (IInclude) tuIncludes.get(0);
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -367,8 +368,8 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
|
||||
// struct X {
|
||||
// ~X();
|
||||
// void operator delete();
|
||||
// void operator delete[]();
|
||||
// void operator delete(void *);
|
||||
// void operator delete[](void *);
|
||||
// };
|
||||
//
|
||||
// int test(X* x) {
|
||||
|
@ -393,11 +394,38 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
|
||||
names = ba.getImplicitNames("delete[] x;", 6);
|
||||
assertEquals(1, names.length);
|
||||
assertSame(col.getName(3).resolveBinding(), names[0].resolveBinding());
|
||||
assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding());
|
||||
|
||||
ba.assertNoImplicitName("delete 1;", 6);
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// void operator delete(void * a);
|
||||
// };
|
||||
// struct B {};
|
||||
// void operator delete(void * b);
|
||||
//
|
||||
// void test() {
|
||||
// A *a = new A;
|
||||
// delete a;
|
||||
//
|
||||
// B* b = new B;
|
||||
// delete b;
|
||||
// }
|
||||
public void testOverloadedDelete_Bug351547() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IBinding m= bh.assertNonProblem("operator delete(void * a)", 15);
|
||||
IBinding f= bh.assertNonProblem("operator delete(void * b)", 15);
|
||||
|
||||
IASTImplicitName[] names = bh.getImplicitNames("delete a;", 6);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(m, names[1].resolveBinding());
|
||||
|
||||
names = bh.getImplicitNames("delete b;", 6);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(f, names[1].resolveBinding());
|
||||
}
|
||||
|
||||
// struct X {}
|
||||
// int test(X* x) {
|
||||
// X* xs = new X[5];
|
||||
|
|
|
@ -5402,4 +5402,41 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testAddressOfMethodForInstantiation_Bug344310() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename Arg> struct Callback {
|
||||
// Callback(void (*function)(Arg arg)) {}
|
||||
// };
|
||||
//
|
||||
// void Subscribe(const Callback<const int>& callback){}
|
||||
// void CallMe(const int){}
|
||||
//
|
||||
// int test() {
|
||||
// Subscribe(Callback<const int>(&CallMe)); // invalid arguments, symbol not
|
||||
// }
|
||||
public void testParameterAdjustementInInstantiatedFunctionType_351609() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T> struct CT {
|
||||
// int g;
|
||||
// };
|
||||
// template<typename T> struct CT<T&> {
|
||||
// int ref;
|
||||
// };
|
||||
// template<typename T> struct CT<T&&> {
|
||||
// int rref;
|
||||
// };
|
||||
// void test() {
|
||||
// CT<int>::g;
|
||||
// CT<int&>::ref;
|
||||
// CT<int&&>::rref;
|
||||
// }
|
||||
public void testRRefVsRef_351927() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename = int> class A {};
|
||||
public void testTemplateParameterWithoutName_352266() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,3 +139,8 @@ namespace MyPackage
|
|||
struct bug180815 {
|
||||
int i,j;
|
||||
} bug180815_var0, bug180815_var1;
|
||||
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352350
|
||||
namespace {
|
||||
int bug352350;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2011 QNX 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
|
||||
|
@ -40,11 +40,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* TLETODO Document CElement.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public abstract class CElement extends PlatformObject implements ICElement {
|
||||
|
||||
public static final char CEM_ESCAPE = '\\';
|
||||
|
@ -270,12 +265,15 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
}
|
||||
|
||||
public static boolean equals(ICElement lhs, ICElement rhs) {
|
||||
if (lhs == rhs) {
|
||||
return true;
|
||||
}
|
||||
if (lhs.getElementType() != rhs.getElementType()) {
|
||||
return false;
|
||||
}
|
||||
String lhsName= lhs.getElementName();
|
||||
String rhsName= rhs.getElementName();
|
||||
if( lhsName == null || rhsName == null || lhsName.length() == 0 ||
|
||||
if( lhsName == null || rhsName == null || lhsName.length() != rhsName.length() ||
|
||||
!lhsName.equals(rhsName)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2097,16 +2097,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (LT(1) == IToken.tIDENTIFIER) { // optional identifier
|
||||
identifierName = identifier();
|
||||
endOffset = calculateEndOffset(identifierName);
|
||||
if (LT(1) == IToken.tASSIGN) { // optional = type-id
|
||||
if (parameterPack)
|
||||
throw backtrack;
|
||||
consume();
|
||||
defaultValue = typeId(DeclarationOptions.TYPEID); // type-id
|
||||
endOffset = calculateEndOffset(defaultValue);
|
||||
}
|
||||
} else {
|
||||
identifierName = nodeFactory.newName();
|
||||
}
|
||||
if (LT(1) == IToken.tASSIGN) { // optional = type-id
|
||||
if (parameterPack)
|
||||
throw backtrack;
|
||||
consume();
|
||||
defaultValue = typeId(DeclarationOptions.TYPEID); // type-id
|
||||
endOffset = calculateEndOffset(defaultValue);
|
||||
}
|
||||
|
||||
// Check if followed by comma
|
||||
switch (LT(1)) {
|
||||
|
|
|
@ -2962,14 +2962,14 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
IASTInitializerClause[] argArray = args.toArray(new IASTInitializerClause[args.size()]);
|
||||
return findOverloadedOperator(exp, argArray, type, op, LookupMode.ALL_GLOBALS);
|
||||
return findOverloadedOperator(exp, argArray, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
||||
}
|
||||
|
||||
public static ICPPFunction findOverloadedOperator(ICPPASTDeleteExpression exp) {
|
||||
OverloadableOperator op = OverloadableOperator.fromDeleteExpression(exp);
|
||||
IType classType = getNestedClassType(exp);
|
||||
IASTExpression[] args = new IASTExpression[] {createArgForType(exp, classType)};
|
||||
return findOverloadedOperator(exp, args, classType, op, LookupMode.ALL_GLOBALS);
|
||||
IASTExpression[] args = new IASTExpression[] {createArgForType(exp, classType), exp.getOperand()};
|
||||
return findOverloadedOperator(exp, args, classType, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
|
||||
}
|
||||
|
||||
private static ICPPClassType getNestedClassType(ICPPASTDeleteExpression exp) {
|
||||
|
@ -3228,7 +3228,7 @@ public class CPPSemantics {
|
|||
return findOverloadedOperator(fieldRef, new IASTExpression[] {arg}, classType, OverloadableOperator.ARROW, LookupMode.NO_GLOBALS);
|
||||
}
|
||||
|
||||
private static enum LookupMode {NO_GLOBALS, LIMITED_GLOBALS, ALL_GLOBALS}
|
||||
private static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
|
||||
private static ICPPFunction findOverloadedOperator(IASTExpression parent, IASTInitializerClause[] args, IType methodLookupType,
|
||||
OverloadableOperator operator, LookupMode mode) {
|
||||
ICPPClassType callToObjectOfClassType= null;
|
||||
|
@ -3281,43 +3281,64 @@ public class CPPSemantics {
|
|||
funcName.setParent(parent);
|
||||
funcName.setPropertyInParent(STRING_LOOKUP_PROPERTY);
|
||||
LookupData funcData = new LookupData(funcName);
|
||||
if (operator == OverloadableOperator.DELETE || operator == OverloadableOperator.DELETE_ARRAY) {
|
||||
args= ArrayUtil.removeFirst(args);
|
||||
}
|
||||
funcData.setFunctionArguments(true, args);
|
||||
funcData.ignoreMembers = true; // (13.3.1.2.3)
|
||||
if (mode != LookupMode.NO_GLOBALS || callToObjectOfClassType != null) {
|
||||
boolean haveMembers= methodData != null && methodData.hasResults();
|
||||
if (mode == LookupMode.ALL_GLOBALS || mode == LookupMode.LIMITED_GLOBALS
|
||||
|| (mode == LookupMode.GLOBALS_IF_NO_MEMBERS && !haveMembers)) {
|
||||
try {
|
||||
if (mode != LookupMode.NO_GLOBALS) {
|
||||
IScope scope = CPPVisitor.getContainingScope(parent);
|
||||
if (scope == null)
|
||||
return null;
|
||||
lookup(funcData, scope);
|
||||
try {
|
||||
doKoenigLookup(funcData);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
// Filter with file-set
|
||||
IASTTranslationUnit tu= parent.getTranslationUnit();
|
||||
if (tu != null && funcData.foundItems instanceof Object[]) {
|
||||
final IIndexFileSet fileSet = tu.getIndexFileSet();
|
||||
if (fileSet != null) {
|
||||
int j=0;
|
||||
final Object[] items= (Object[]) funcData.foundItems;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Object item = items[i];
|
||||
items[i]= null;
|
||||
if (item instanceof IIndexBinding) {
|
||||
if (!fileSet.containsDeclaration((IIndexBinding) item)) {
|
||||
continue;
|
||||
}
|
||||
IScope scope = CPPVisitor.getContainingScope(parent);
|
||||
if (scope == null)
|
||||
return null;
|
||||
lookup(funcData, scope);
|
||||
try {
|
||||
doKoenigLookup(funcData);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
// Filter with file-set
|
||||
IASTTranslationUnit tu= parent.getTranslationUnit();
|
||||
if (tu != null && funcData.foundItems instanceof Object[]) {
|
||||
final IIndexFileSet fileSet = tu.getIndexFileSet();
|
||||
if (fileSet != null) {
|
||||
int j=0;
|
||||
final Object[] items= (Object[]) funcData.foundItems;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Object item = items[i];
|
||||
items[i]= null;
|
||||
if (item instanceof IIndexBinding) {
|
||||
if (!fileSet.containsDeclaration((IIndexBinding) item)) {
|
||||
continue;
|
||||
}
|
||||
items[j++]= item;
|
||||
}
|
||||
items[j++]= item;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (operator == OverloadableOperator.NEW || operator == OverloadableOperator.DELETE
|
||||
|| operator == OverloadableOperator.NEW_ARRAY || operator == OverloadableOperator.DELETE_ARRAY) {
|
||||
|
||||
// Those operators replace the built-in operator
|
||||
Object[] items= (Object[]) funcData.foundItems;
|
||||
int j= 0;
|
||||
for (Object object : items) {
|
||||
if (object instanceof ICPPFunction) {
|
||||
ICPPFunction func= (ICPPFunction) object;
|
||||
if (!(func instanceof CPPImplicitFunction))
|
||||
items[j++]= func;
|
||||
}
|
||||
}
|
||||
if (j>0) {
|
||||
while (j < items.length)
|
||||
items[j++]= null;
|
||||
}
|
||||
}
|
||||
// 13.3.1.2.3
|
||||
// However, if no operand type has class type, only those non-member functions ...
|
||||
if (mode == LookupMode.LIMITED_GLOBALS) {
|
||||
|
@ -3348,31 +3369,31 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (callToObjectOfClassType != null) {
|
||||
try {
|
||||
// 13.3.1.1.2 call to object of class type
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType);
|
||||
for (ICPPMethod op : ops) {
|
||||
if (op.isExplicit())
|
||||
continue;
|
||||
IFunctionType ft= op.getType();
|
||||
if (ft != null) {
|
||||
IType rt= SemanticUtil.getNestedType(ft.getReturnType(), SemanticUtil.TDEF);
|
||||
if (rt instanceof IPointerType) {
|
||||
IType ptt= SemanticUtil.getNestedType(((IPointerType) rt).getType(), SemanticUtil.TDEF);
|
||||
if (ptt instanceof IFunctionType) {
|
||||
IFunctionType ft2= (IFunctionType) ptt;
|
||||
IBinding sf= createSurrogateCallFunction(parent.getTranslationUnit().getScope(), ft2.getReturnType(), rt, ft2.getParameterTypes());
|
||||
mergeResults(funcData, sf, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (callToObjectOfClassType != null) {
|
||||
try {
|
||||
// 13.3.1.1.2 call to object of class type
|
||||
ICPPMethod[] ops = SemanticUtil.getConversionOperators(callToObjectOfClassType);
|
||||
for (ICPPMethod op : ops) {
|
||||
if (op.isExplicit())
|
||||
continue;
|
||||
IFunctionType ft= op.getType();
|
||||
if (ft != null) {
|
||||
IType rt= SemanticUtil.getNestedType(ft.getReturnType(), SemanticUtil.TDEF);
|
||||
if (rt instanceof IPointerType) {
|
||||
IType ptt= SemanticUtil.getNestedType(((IPointerType) rt).getType(), SemanticUtil.TDEF);
|
||||
if (ptt instanceof IFunctionType) {
|
||||
IFunctionType ft2= (IFunctionType) ptt;
|
||||
IBinding sf= createSurrogateCallFunction(parent.getTranslationUnit().getScope(), ft2.getReturnType(), rt, ft2.getParameterTypes());
|
||||
mergeResults(funcData, sf, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (methodLookupType instanceof ICPPClassType || type2 instanceof ICPPClassType) {
|
||||
|
|
|
@ -1054,6 +1054,13 @@ public class CPPTemplates {
|
|||
if (ret == r && params == ps) {
|
||||
return type;
|
||||
}
|
||||
// The parameter types need to be adjusted.
|
||||
for (int i=0; i<params.length; i++) {
|
||||
IType p= params[i];
|
||||
if (!isDependentType(p)) {
|
||||
params[i]= CPPVisitor.adjustParameterType(p, true);
|
||||
}
|
||||
}
|
||||
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
|
||||
}
|
||||
|
||||
|
|
|
@ -1723,7 +1723,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
* Adjusts the parameter type according to 8.3.5-3:
|
||||
* cv-qualifiers are deleted, arrays and function types are converted to pointers.
|
||||
*/
|
||||
private static IType adjustParameterType(final IType pt, boolean forFunctionType) {
|
||||
static IType adjustParameterType(final IType pt, boolean forFunctionType) {
|
||||
// bug 239975
|
||||
IType t= SemanticUtil.getNestedType(pt, TDEF);
|
||||
if (t instanceof IArrayType) {
|
||||
|
|
|
@ -678,8 +678,12 @@ public class TemplateArgumentDeduction {
|
|||
if (!(a instanceof ICPPReferenceType)) {
|
||||
return false;
|
||||
}
|
||||
p = ((ICPPReferenceType) p).getType();
|
||||
a = ((ICPPReferenceType) a).getType();
|
||||
final ICPPReferenceType rp = (ICPPReferenceType) p;
|
||||
final ICPPReferenceType ra = (ICPPReferenceType) a;
|
||||
if (ra.isRValueReference() != rp.isRValueReference())
|
||||
return false;
|
||||
p = rp.getType();
|
||||
a = ra.getType();
|
||||
} else if (p instanceof IArrayType) {
|
||||
if (!(a instanceof IArrayType)) {
|
||||
return false;
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Marc-Andre Laperle 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Marc-Andre Laperle - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.tests.refactoring.utils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterNameGenerator;
|
||||
|
||||
public class AccessorNameGeneratorTest extends TestCase {
|
||||
|
||||
public void testTrimFieldName() {
|
||||
assertEquals("f", GetterSetterNameGenerator.trimFieldName("f_"));
|
||||
assertEquals("F", GetterSetterNameGenerator.trimFieldName("F_"));
|
||||
assertEquals("oo", GetterSetterNameGenerator.trimFieldName("F_oo"));
|
||||
assertEquals("o", GetterSetterNameGenerator.trimFieldName("f_o"));
|
||||
|
||||
assertEquals("M", GetterSetterNameGenerator.trimFieldName("a_M_"));
|
||||
assertEquals("bs", GetterSetterNameGenerator.trimFieldName("a_bs_"));
|
||||
assertEquals("foo_bar", GetterSetterNameGenerator.trimFieldName("foo_bar"));
|
||||
assertEquals("foo_bar", GetterSetterNameGenerator.trimFieldName("foo_bar_"));
|
||||
|
||||
assertEquals("foo_b", GetterSetterNameGenerator.trimFieldName("foo_b_"));
|
||||
|
||||
assertEquals("foo", GetterSetterNameGenerator.trimFieldName("foo"));
|
||||
assertEquals("foo", GetterSetterNameGenerator.trimFieldName("_foo"));
|
||||
assertEquals("bar", GetterSetterNameGenerator.trimFieldName("_f_bar"));
|
||||
|
||||
assertEquals("f", GetterSetterNameGenerator.trimFieldName("f__"));
|
||||
assertEquals("f", GetterSetterNameGenerator.trimFieldName("__f"));
|
||||
assertEquals("O__b", GetterSetterNameGenerator.trimFieldName("fO__b"));
|
||||
assertEquals("Oo", GetterSetterNameGenerator.trimFieldName("fOo"));
|
||||
assertEquals("O", GetterSetterNameGenerator.trimFieldName("fO"));
|
||||
assertEquals("MyStatic", GetterSetterNameGenerator.trimFieldName("sMyStatic"));
|
||||
assertEquals("MyMember", GetterSetterNameGenerator.trimFieldName("mMyMember"));
|
||||
|
||||
assertEquals("8", GetterSetterNameGenerator.trimFieldName("_8"));
|
||||
|
||||
assertEquals("8bar", GetterSetterNameGenerator.trimFieldName("_8bar_"));
|
||||
assertEquals("8bar_8", GetterSetterNameGenerator.trimFieldName("_8bar_8"));
|
||||
assertEquals("8bAr", GetterSetterNameGenerator.trimFieldName("_8bAr"));
|
||||
assertEquals("b8Ar", GetterSetterNameGenerator.trimFieldName("_b8Ar"));
|
||||
|
||||
assertEquals("Id", GetterSetterNameGenerator.trimFieldName("Id"));
|
||||
assertEquals("ID", GetterSetterNameGenerator.trimFieldName("ID"));
|
||||
assertEquals("IDS", GetterSetterNameGenerator.trimFieldName("IDS"));
|
||||
assertEquals("ID", GetterSetterNameGenerator.trimFieldName("bID"));
|
||||
assertEquals("Id", GetterSetterNameGenerator.trimFieldName("MId"));
|
||||
assertEquals("IdA", GetterSetterNameGenerator.trimFieldName("IdA"));
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ public class IdentifierHelperTest extends TestSuite {
|
|||
suite.addTest(new EmptyCaseTest());
|
||||
suite.addTest(new IllegalCharCaseTest());
|
||||
suite.addTest(new KeywordCaseTest());
|
||||
suite.addTestSuite(AccessorNameGeneratorTest.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class NameComposerTest extends TestCase {
|
|||
private static final int CAPITALIZATION_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE;
|
||||
private static final int CAPITALIZATION_LOWER_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE;
|
||||
|
||||
public void testTrimFieldName() {
|
||||
public void testCompose() {
|
||||
NameComposer composer = new NameComposer(CAPITALIZATION_ORIGINAL, "", "", ".h");
|
||||
assertEquals("MyClass.h", composer.compose("MyClass"));
|
||||
composer = new NameComposer(CAPITALIZATION_LOWER_CASE, "-", "", ".cc");
|
||||
|
@ -44,4 +44,44 @@ public class NameComposerTest extends TestCase {
|
|||
composer = new NameComposer(CAPITALIZATION_ORIGINAL, "_", "", "");
|
||||
assertEquals("RGB_Value", composer.compose("RGBValue"));
|
||||
}
|
||||
|
||||
public void testTrimFieldName() {
|
||||
assertEquals("f", NameComposer.trimFieldName("f_"));
|
||||
assertEquals("F", NameComposer.trimFieldName("F_"));
|
||||
assertEquals("oo", NameComposer.trimFieldName("F_oo"));
|
||||
assertEquals("o", NameComposer.trimFieldName("f_o"));
|
||||
|
||||
assertEquals("M", NameComposer.trimFieldName("a_M_"));
|
||||
assertEquals("bs", NameComposer.trimFieldName("a_bs_"));
|
||||
assertEquals("foo_bar", NameComposer.trimFieldName("foo_bar"));
|
||||
assertEquals("foo_bar", NameComposer.trimFieldName("foo_bar_"));
|
||||
|
||||
assertEquals("foo_b", NameComposer.trimFieldName("foo_b_"));
|
||||
|
||||
assertEquals("foo", NameComposer.trimFieldName("foo"));
|
||||
assertEquals("foo", NameComposer.trimFieldName("_foo"));
|
||||
assertEquals("bar", NameComposer.trimFieldName("_f_bar"));
|
||||
|
||||
assertEquals("f", NameComposer.trimFieldName("f__"));
|
||||
assertEquals("f", NameComposer.trimFieldName("__f"));
|
||||
assertEquals("O__b", NameComposer.trimFieldName("fO__b"));
|
||||
assertEquals("Oo", NameComposer.trimFieldName("fOo"));
|
||||
assertEquals("O", NameComposer.trimFieldName("fO"));
|
||||
assertEquals("MyStatic", NameComposer.trimFieldName("sMyStatic"));
|
||||
assertEquals("MyMember", NameComposer.trimFieldName("mMyMember"));
|
||||
|
||||
assertEquals("8", NameComposer.trimFieldName("_8"));
|
||||
|
||||
assertEquals("8bar", NameComposer.trimFieldName("_8bar_"));
|
||||
assertEquals("8bar_8", NameComposer.trimFieldName("_8bar_8"));
|
||||
assertEquals("8bAr", NameComposer.trimFieldName("_8bAr"));
|
||||
assertEquals("b8Ar", NameComposer.trimFieldName("_b8Ar"));
|
||||
|
||||
assertEquals("Id", NameComposer.trimFieldName("Id"));
|
||||
assertEquals("ID", NameComposer.trimFieldName("ID"));
|
||||
assertEquals("IDS", NameComposer.trimFieldName("IDS"));
|
||||
assertEquals("ID", NameComposer.trimFieldName("bID"));
|
||||
assertEquals("Id", NameComposer.trimFieldName("MId"));
|
||||
assertEquals("IdA", NameComposer.trimFieldName("IdA"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2011 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
|
||||
|
@ -1296,6 +1296,23 @@ public class CPartitionerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testRawString_Bug352544() {
|
||||
try {
|
||||
|
||||
fDocument.replace(0, fDocument.getLength(), "BAR\"(\";");
|
||||
ITypedRegion[] result= fDocument.computePartitioning(0, fDocument.getLength());
|
||||
TypedRegion[] expectation= {
|
||||
new TypedRegion(0, 3, IDocument.DEFAULT_CONTENT_TYPE),
|
||||
new TypedRegion(3, 3, ICPartitions.C_STRING),
|
||||
new TypedRegion(6, 1, IDocument.DEFAULT_CONTENT_TYPE),
|
||||
};
|
||||
checkPartitioning(expectation, result);
|
||||
|
||||
} catch (BadLocationException x) {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void testEditingRawString1() {
|
||||
try {
|
||||
|
||||
|
|
|
@ -191,7 +191,8 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
.setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN)
|
||||
.setSuffixKey(KEY_GETTER_SUFFIX)
|
||||
.setSeedNameGenerator(fieldCategory)
|
||||
.setNameValidator(IDENTIFIER_VALIDATOR);
|
||||
.setNameValidator(IDENTIFIER_VALIDATOR)
|
||||
.setTrimFieldName(true);
|
||||
new Category(PreferencesMessages.NameStyleBlock_setter_node,
|
||||
PreferencesMessages.NameStyleBlock_setter_node_description, EXAMPLE_FIELD_NAME,
|
||||
codeCategory)
|
||||
|
@ -200,7 +201,8 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
.setPrefixKey(KEY_SETTER_PREFIX)
|
||||
.setSuffixKey(KEY_SETTER_SUFFIX)
|
||||
.setSeedNameGenerator(fieldCategory)
|
||||
.setNameValidator(IDENTIFIER_VALIDATOR);
|
||||
.setNameValidator(IDENTIFIER_VALIDATOR)
|
||||
.setTrimFieldName(true);
|
||||
Category fileCategory = new Category(PreferencesMessages.NameStyleBlock_files_node);
|
||||
new Category(PreferencesMessages.NameStyleBlock_cpp_header_node,
|
||||
PreferencesMessages.NameStyleBlock_cpp_header_node_description, EXAMPLE_CLASS_NAME,
|
||||
|
@ -444,6 +446,7 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
|
||||
private Text previewText;
|
||||
private Composite editorArea;
|
||||
private boolean trimFieldName = false;
|
||||
|
||||
Category(String name, String description, String seedName, Category parent) {
|
||||
this.name = name;
|
||||
|
@ -568,8 +571,15 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
|
||||
String name = seedNameGenerator != null ?
|
||||
seedNameGenerator.composeExampleName(settings) : seedName;
|
||||
if (trimFieldName) {
|
||||
name = NameComposer.trimFieldName(name);
|
||||
}
|
||||
return composer.compose(name);
|
||||
}
|
||||
|
||||
void setTrimFieldName(boolean trimSeedName) {
|
||||
this.trimFieldName = trimSeedName;
|
||||
}
|
||||
}
|
||||
|
||||
private abstract static class NameValidator {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Copyright (c) 2008, 2011 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
|
||||
|
@ -14,6 +14,10 @@ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
|
|||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
|
||||
|
@ -25,12 +29,17 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Link;
|
||||
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
|
||||
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage;
|
||||
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext.FieldWrapper;
|
||||
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind;
|
||||
|
||||
public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
|
||||
public class GenerateGettersAndSettersInputPage extends UserInputWizardPage implements IPreferenceChangeListener {
|
||||
private GetterSetterContext context;
|
||||
private ContainerCheckedTreeViewer variableSelectionView;
|
||||
private GetterSetterLabelProvider labelProvider;
|
||||
|
@ -38,6 +47,9 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
|
|||
public GenerateGettersAndSettersInputPage(GetterSetterContext context) {
|
||||
super(Messages.GettersAndSetters_Name);
|
||||
this.context = context;
|
||||
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
|
||||
// We are listening for changes in the Name Style preferences
|
||||
node.addPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
|
@ -59,6 +71,8 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
|
|||
final Button placeImplemetation = new Button(comp, SWT.CHECK);
|
||||
placeImplemetation.setText(Messages.GenerateGettersAndSettersInputPage_PlaceImplHeader);
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
gd.heightHint = 40;
|
||||
placeImplemetation.setLayoutData(gd);
|
||||
placeImplemetation.setSelection(context.isImplementationInHeader());
|
||||
placeImplemetation.addSelectionListener(new SelectionAdapter() {
|
||||
|
@ -68,6 +82,21 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
|
|||
}
|
||||
});
|
||||
|
||||
Link link= new Link(comp, SWT.WRAP);
|
||||
link.setText(Messages.GenerateGettersAndSettersInputPage_LinkDescription);
|
||||
link.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
String id = NameStylePreferencePage.PREF_ID;
|
||||
PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String [] { id }, null).open();
|
||||
}
|
||||
});
|
||||
link.setToolTipText(Messages.GenerateGettersAndSettersInputPage_LinkTooltip);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
gd.grabExcessHorizontalSpace = true;
|
||||
link.setLayoutData(gd);
|
||||
|
||||
setControl(comp);
|
||||
}
|
||||
|
||||
|
@ -189,4 +218,15 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void preferenceChange(PreferenceChangeEvent event) {
|
||||
if (variableSelectionView.getTree().isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetterSetterNameGenerator.getGenerateGetterSettersPreferenceKeys().contains(event.getKey())) {
|
||||
context.refresh();
|
||||
variableSelectionView.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,17 @@ public class GetterSetterContext implements ITreeContentProvider {
|
|||
public Object[] getElements(Object inputElement) {
|
||||
return getWrappedFields().toArray();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
// We only recreate the function declarations instead of recreating GetterSetterInsertEditProviders.
|
||||
// That way, selectedFunctions is still valid. 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 (GetterSetterInsertEditProvider provider : wrapper.childNodes) {
|
||||
provider.createFunctionDeclaration();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
|
|
@ -36,7 +36,15 @@ public class GetterSetterInsertEditProvider implements Comparable<GetterSetterIn
|
|||
|
||||
public GetterSetterInsertEditProvider(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration,
|
||||
AccessorKind kind) {
|
||||
switch (kind) {
|
||||
this.kind = kind;
|
||||
this.fieldName = fieldName;
|
||||
this.fieldDeclaration = fieldDeclaration;
|
||||
|
||||
createFunctionDeclaration();
|
||||
}
|
||||
|
||||
public void createFunctionDeclaration() {
|
||||
switch (this.kind) {
|
||||
case GETTER:
|
||||
this.functionDeclaration = FunctionFactory.createGetterDeclaration(fieldName, fieldDeclaration);
|
||||
break;
|
||||
|
@ -44,10 +52,6 @@ public class GetterSetterInsertEditProvider implements Comparable<GetterSetterIn
|
|||
this.functionDeclaration = FunctionFactory.createSetterDeclaration(fieldName, fieldDeclaration);
|
||||
break;
|
||||
}
|
||||
|
||||
this.kind = kind;
|
||||
this.fieldName = fieldName;
|
||||
this.fieldDeclaration = fieldDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.IPreferencesService;
|
||||
|
||||
import com.ibm.icu.text.BreakIterator;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -24,7 +26,6 @@ import org.eclipse.cdt.ui.PreferenceConstants;
|
|||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.CBreakIterator;
|
||||
import org.eclipse.cdt.internal.ui.util.NameComposer;
|
||||
|
||||
public class GetterSetterNameGenerator {
|
||||
|
@ -32,7 +33,28 @@ public class GetterSetterNameGenerator {
|
|||
// Do not instantiate.
|
||||
private GetterSetterNameGenerator() {
|
||||
}
|
||||
|
||||
private static Set<String> generateGetterSettersPreferenceKeys = new HashSet<String>();
|
||||
static {
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_SUFFIX);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_PREFIX);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_SUFFIX);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX);
|
||||
generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX);
|
||||
}
|
||||
|
||||
public static Set<String> getGenerateGetterSettersPreferenceKeys() {
|
||||
return generateGetterSettersPreferenceKeys;
|
||||
}
|
||||
|
||||
public static String generateGetterName(IASTName fieldName) {
|
||||
IPreferencesService preferences = Platform.getPreferencesService();
|
||||
int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
|
||||
|
@ -48,7 +70,7 @@ public class GetterSetterNameGenerator {
|
|||
String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_GETTER_SUFFIX, "", null); //$NON-NLS-1$
|
||||
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
|
||||
String name = GetterSetterNameGenerator.trimFieldName(fieldName.toString());
|
||||
String name = NameComposer.trimFieldName(fieldName.toString());
|
||||
return composer.compose(name);
|
||||
}
|
||||
|
||||
|
@ -75,7 +97,7 @@ public class GetterSetterNameGenerator {
|
|||
String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_SETTER_SUFFIX, "", null); //$NON-NLS-1$
|
||||
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
|
||||
String name = GetterSetterNameGenerator.trimFieldName(fieldName.toString());
|
||||
String name = NameComposer.trimFieldName(fieldName.toString());
|
||||
return composer.compose(name);
|
||||
}
|
||||
|
||||
|
@ -91,49 +113,7 @@ public class GetterSetterNameGenerator {
|
|||
String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
|
||||
PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
|
||||
NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
|
||||
String name = GetterSetterNameGenerator.trimFieldName(fieldName.toString());
|
||||
String name = NameComposer.trimFieldName(fieldName.toString());
|
||||
return composer.compose(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the trimmed field name. Leading and trailing non-alphanumeric characters are trimmed.
|
||||
* If the first word of the name consists of a single letter and the name contains more than
|
||||
* one word, the first word is removed.
|
||||
*
|
||||
* @param fieldName a field name to trim
|
||||
* @return the trimmed field name
|
||||
*/
|
||||
public static String trimFieldName(String fieldName){
|
||||
CBreakIterator iterator = new CBreakIterator();
|
||||
iterator.setText(fieldName);
|
||||
int firstWordStart = -1;
|
||||
int firstWordEnd = -1;
|
||||
int secondWordStart = -1;
|
||||
int lastWordEnd = -1;
|
||||
int end;
|
||||
for (int start = iterator.first(); (end = iterator.next()) != BreakIterator.DONE; start = end) {
|
||||
if (Character.isLetterOrDigit(fieldName.charAt(start))) {
|
||||
int pos = end;
|
||||
while (--pos >= start && !Character.isLetterOrDigit(fieldName.charAt(pos))) {
|
||||
}
|
||||
lastWordEnd = pos + 1;
|
||||
if (firstWordStart < 0) {
|
||||
firstWordStart = start;
|
||||
firstWordEnd = lastWordEnd;
|
||||
} else if (secondWordStart < 0) {
|
||||
secondWordStart = start;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Skip the first word if it consists of a single letter and the name contains more than
|
||||
// one word.
|
||||
if (firstWordStart >= 0 && firstWordStart + 1 == firstWordEnd && secondWordStart >= 0) {
|
||||
firstWordStart = secondWordStart;
|
||||
}
|
||||
if (firstWordStart < 0) {
|
||||
return fieldName;
|
||||
} else {
|
||||
return fieldName.substring(firstWordStart, lastWordEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ public final class Messages extends NLS {
|
|||
public static String GenerateGettersAndSettersInputPage_SelectAll;
|
||||
public static String GenerateGettersAndSettersInputPage_SelectGetters;
|
||||
public static String GenerateGettersAndSettersInputPage_SelectSetters;
|
||||
public static String GenerateGettersAndSettersInputPage_LinkDescription;
|
||||
public static String GenerateGettersAndSettersInputPage_LinkTooltip;
|
||||
public static String GenerateGettersAndSettersRefactoring_NoCassDefFound;
|
||||
public static String GenerateGettersAndSettersRefactoring_NoFields;
|
||||
public static String GenerateGettersAndSettersRefactoring_NoImplFile;
|
||||
|
|
|
@ -16,6 +16,8 @@ GenerateGettersAndSettersInputPage_PlaceImplHeader=Place implementation in heade
|
|||
GenerateGettersAndSettersInputPage_SelectAll=Select All
|
||||
GenerateGettersAndSettersInputPage_SelectGetters=Select Getters
|
||||
GenerateGettersAndSettersInputPage_SelectSetters=Select Setters
|
||||
GenerateGettersAndSettersInputPage_LinkDescription=The names of getters and setters may be configured on the <a>Name Style</a> preference page.
|
||||
GenerateGettersAndSettersInputPage_LinkTooltip=Show the name style preferences.
|
||||
GenerateGettersAndSettersRefactoring_NoCassDefFound=No class definition found
|
||||
GenerateGettersAndSettersRefactoring_NoFields=The class does not contain any fields.
|
||||
GenerateGettersAndSettersRefactoring_NoImplFile=No implementation file found. Inserting definition into the header file.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2011 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
|
||||
|
@ -388,7 +388,7 @@ public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPa
|
|||
consume();
|
||||
break;
|
||||
default:
|
||||
if ('a' <= ch && ch <= 'z' || 'A' <= ch && 'Z' <= ch || ch =='_') {
|
||||
if ('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch =='_') {
|
||||
fLast = IDENT;
|
||||
fTokenOffset++;
|
||||
} else if ('0' <= ch && ch <= '9' && fLast == IDENT) {
|
||||
|
|
|
@ -146,4 +146,46 @@ public class NameComposer {
|
|||
Character.toUpperCase(word.charAt(i)) : Character.toLowerCase(word.charAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the trimmed field name. Leading and trailing non-alphanumeric characters are trimmed.
|
||||
* If the first word of the name consists of a single letter and the name contains more than
|
||||
* one word, the first word is removed.
|
||||
*
|
||||
* @param fieldName a field name to trim
|
||||
* @return the trimmed field name
|
||||
*/
|
||||
public static String trimFieldName(String fieldName){
|
||||
CBreakIterator iterator = new CBreakIterator();
|
||||
iterator.setText(fieldName);
|
||||
int firstWordStart = -1;
|
||||
int firstWordEnd = -1;
|
||||
int secondWordStart = -1;
|
||||
int lastWordEnd = -1;
|
||||
int end;
|
||||
for (int start = iterator.first(); (end = iterator.next()) != BreakIterator.DONE; start = end) {
|
||||
if (Character.isLetterOrDigit(fieldName.charAt(start))) {
|
||||
int pos = end;
|
||||
while (--pos >= start && !Character.isLetterOrDigit(fieldName.charAt(pos))) {
|
||||
}
|
||||
lastWordEnd = pos + 1;
|
||||
if (firstWordStart < 0) {
|
||||
firstWordStart = start;
|
||||
firstWordEnd = lastWordEnd;
|
||||
} else if (secondWordStart < 0) {
|
||||
secondWordStart = start;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Skip the first word if it consists of a single letter and the name contains more than
|
||||
// one word.
|
||||
if (firstWordStart >= 0 && firstWordStart + 1 == firstWordEnd && secondWordStart >= 0) {
|
||||
firstWordStart = secondWordStart;
|
||||
}
|
||||
if (firstWordStart < 0) {
|
||||
return fieldName;
|
||||
} else {
|
||||
return fieldName.substring(firstWordStart, lastWordEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ TracepointActions_Evaluate_Name=Evaluate Action
|
|||
TracepointActions_WhileStepping_Name=While-Stepping Action
|
||||
# START NON-TRANSLATABLE
|
||||
TracepointActions_Collect_text=collect {0}
|
||||
TracepointActions_Evaluate_text=eval {0}
|
||||
TracepointActions_Evaluate_text=teval {0}
|
||||
TracepointActions_WhileStepping_text=while-stepping {0} {1}
|
||||
# END NON-TRANSLATABLE
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
|
|||
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.cdt.dsf.debug.service.ICachingService;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
|
@ -503,6 +504,18 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
|
|||
getSession().dispatchEvent(new TracingStartedEvent(context), getProperties());
|
||||
rm.done();
|
||||
}
|
||||
@Override
|
||||
protected void handleError() {
|
||||
// Send an event to cause a refresh of the button states
|
||||
IDMEvent<ITraceTargetDMContext> event;
|
||||
if (fIsTracingActive) {
|
||||
event = new TracingStartedEvent(context);
|
||||
} else {
|
||||
event = new TracingStoppedEvent(context);
|
||||
}
|
||||
getSession().dispatchEvent(event, getProperties());
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue