1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +02:00

Bug 372009 - Wrong class name in NonVirtualDestructor warning

This commit is contained in:
Marc-Andre Laperle 2012-03-05 01:31:48 -05:00
parent 4af78ed0b2
commit e912eb6f32
3 changed files with 27 additions and 5 deletions

View file

@ -9,6 +9,7 @@
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
* Patrick Hofer [bug 315528] * Patrick Hofer [bug 315528]
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Marc-Andre Laperle
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers; package org.eclipse.cdt.codan.internal.checkers;
@ -117,7 +118,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
node = decls[0]; node = decls[0];
} }
} }
reportProblem(PROBLEM_ID, node, className.getSimpleID().toString(), reportProblem(PROBLEM_ID, node, new String(className.getSimpleID()),
virtualMethod.getName()); virtualMethod.getName());
return PROCESS_SKIP; return PROCESS_SKIP;
} }

View file

@ -195,4 +195,12 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment()); loadCodeAndRun(getAboveComment());
checkNoErrors(); checkNoErrors();
} }
// class Foo {
// virtual void bar();
// };
public void testBug372009_wrongClassNameInMessage() throws Exception {
loadCodeAndRun(getAboveComment());
assertMessageContains("Foo", markers[0]);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2011 Alena Laskavaia * Copyright (c) 2009, 2012 Alena Laskavaia
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
* Marc-Andre Laperle
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.test; package org.eclipse.cdt.codan.core.test;
@ -186,9 +187,21 @@ public class CheckerTestCase extends CodanTestCase {
*/ */
public void assertMessageMatch(String pattern, IMarker m) { public void assertMessageMatch(String pattern, IMarker m) {
try { try {
String attribute = (String) m.getAttribute(IMarker.MESSAGE); String message = (String) m.getAttribute(IMarker.MESSAGE);
if (attribute.matches(pattern)) { if (message.matches(pattern)) {
fail("Expected " + attribute + " to match with /" + pattern //$NON-NLS-1$ //$NON-NLS-2$ fail("Expected " + message + " to match with /" + pattern //$NON-NLS-1$ //$NON-NLS-2$
+ "/"); //$NON-NLS-1$
}
} catch (CoreException e) {
fail(e.getMessage());
}
}
public void assertMessageContains(CharSequence charSequence, IMarker m) {
try {
String message = (String) m.getAttribute(IMarker.MESSAGE);
if (!message.contains(charSequence)) {
fail("Expected " + message + " to contain /" + charSequence //$NON-NLS-1$ //$NON-NLS-2$
+ "/"); //$NON-NLS-1$ + "/"); //$NON-NLS-1$
} }
} catch (CoreException e) { } catch (CoreException e) {