mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fixed compiler warnings.
This commit is contained in:
parent
3715cdbbe8
commit
dafa751ccf
10 changed files with 50 additions and 58 deletions
|
@ -1,4 +1,4 @@
|
|||
#Sat May 15 15:21:20 EDT 2010
|
||||
#Sat Feb 19 16:35:59 PST 2011
|
||||
eclipse.preferences.version=1
|
||||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
|
||||
sp_cleanup.add_default_serial_version_id=true
|
||||
|
@ -16,7 +16,7 @@ sp_cleanup.always_use_this_for_non_static_field_access=false
|
|||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code=false
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
sp_cleanup.make_local_variable_final=false
|
||||
sp_cleanup.make_parameters_final=false
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 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
|
||||
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.codan.core.internal.checkers.AssignmentInConditionCheckerTest;
|
||||
|
@ -30,11 +31,11 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
|||
public AutomatedIntegrationSuite() {
|
||||
}
|
||||
|
||||
public AutomatedIntegrationSuite(Class theClass, String name) {
|
||||
public AutomatedIntegrationSuite(Class<? extends TestCase> theClass, String name) {
|
||||
super(theClass, name);
|
||||
}
|
||||
|
||||
public AutomatedIntegrationSuite(Class theClass) {
|
||||
public AutomatedIntegrationSuite(Class<? extends TestCase> theClass) {
|
||||
super(theClass);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* @author Alena
|
||||
*
|
||||
* @author Alena Laskavaia
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class CheckerTestCase extends CodanTestCase {
|
||||
protected IMarker[] markers;
|
||||
|
||||
|
|
|
@ -17,13 +17,12 @@ import org.osgi.framework.BundleContext;
|
|||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class CodanCoreTestActivator extends Plugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core.test";
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core.test"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static CodanCoreTestActivator plugin;
|
||||
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
|
@ -34,6 +33,7 @@ public class CodanCoreTestActivator extends Plugin {
|
|||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
|
@ -43,6 +43,7 @@ public class CodanCoreTestActivator extends Plugin {
|
|||
* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
|
@ -56,5 +57,4 @@ public class CodanCoreTestActivator extends Plugin {
|
|||
public static CodanCoreTestActivator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009,2010 QNX Software Systems
|
||||
* Copyright (c) 2009,2011 QNX Software Systems
|
||||
* 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:
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
* QNX Software Systems (Alena Laskavaia) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
|
@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
/**
|
||||
* TODO: add description
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
@SuppressWarnings({ "nls", "restriction" })
|
||||
public abstract class CodanFastCxxAstTestCase extends TestCase {
|
||||
protected IASTTranslationUnit tu;
|
||||
|
||||
|
@ -58,7 +58,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
try {
|
||||
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
|
||||
return TestSourceReader.getContentsForTest(plugin == null ? null
|
||||
: plugin.getBundle(), "src", getClass(), getName(), //$NON-NLS-1$
|
||||
: plugin.getBundle(), "src", getClass(), getName(),
|
||||
sections);
|
||||
} catch (IOException e) {
|
||||
fail(e.getMessage());
|
||||
|
@ -73,18 +73,15 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
|
||||
/**
|
||||
* @return
|
||||
*
|
||||
*
|
||||
*/
|
||||
public IASTTranslationUnit parse(String code) {
|
||||
return parse(code, isCpp() ? ParserLanguage.CPP : ParserLanguage.C,
|
||||
true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang,
|
||||
boolean gcc) {
|
||||
FileContent codeReader = FileContent.create("code.c", //$NON-NLS-1$
|
||||
code.toCharArray());
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) {
|
||||
FileContent codeReader = FileContent.create("code.c", code.toCharArray());
|
||||
IScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, lang,
|
||||
ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
@ -103,12 +100,11 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
config = new GCCParserExtensionConfiguration();
|
||||
else
|
||||
config = new ANSICParserExtensionConfiguration();
|
||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||
NULL_LOG, config);
|
||||
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
|
||||
}
|
||||
IASTTranslationUnit tu = parser2.parse();
|
||||
if (parser2.encounteredError() && !hasCodeErrors())
|
||||
fail("PARSE FAILURE"); //$NON-NLS-1$
|
||||
fail("PARSE FAILURE");
|
||||
if (!hasCodeErrors()) {
|
||||
if (lang == ParserLanguage.C) {
|
||||
IASTProblem[] problems = CVisitor.getProblems(tu);
|
||||
|
@ -125,7 +121,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
/**
|
||||
* Override if any of code that test tried to parse has errors, otherwise
|
||||
* parse method would assert
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected boolean hasCodeErrors() {
|
||||
|
@ -156,11 +152,9 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
}
|
||||
|
||||
void runCodan(IASTTranslationUnit tu) {
|
||||
IProblemReporter problemReporter = CodanRuntime.getInstance()
|
||||
.getProblemReporter();
|
||||
IProblemReporter problemReporter = CodanRuntime.getInstance() .getProblemReporter();
|
||||
CodanRuntime.getInstance().setProblemReporter(new IProblemReporter() {
|
||||
public void reportProblem(String problemId, IProblemLocation loc,
|
||||
Object... args) {
|
||||
public void reportProblem(String problemId, IProblemLocation loc, Object... args) {
|
||||
codanproblems.add(new ProblemInstance(problemId, loc, args));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 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
|
||||
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.codan.core.cfg.ControlFlowGraphTest;
|
||||
|
@ -24,11 +25,11 @@ public class CodanFastTestSuite extends TestSuite {
|
|||
public CodanFastTestSuite() {
|
||||
}
|
||||
|
||||
public CodanFastTestSuite(Class theClass, String name) {
|
||||
public CodanFastTestSuite(Class<? extends TestCase> theClass, String name) {
|
||||
super(theClass, name);
|
||||
}
|
||||
|
||||
public CodanFastTestSuite(Class theClass) {
|
||||
public CodanFastTestSuite(Class<? extends TestCase> theClass) {
|
||||
super(theClass);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Alena Laskavaia
|
||||
* Copyright (c) 2009, 2011 Alena Laskavaia
|
||||
* 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:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.eclipse.core.runtime.Path;
|
|||
/**
|
||||
* TODO: add description
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class CodanTestCase extends BaseTestCase {
|
||||
ArrayList<File> tempFiles = new ArrayList<File>();
|
||||
protected File tmpDir;
|
||||
|
@ -47,7 +48,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
protected IFile currentIFile;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public CodanTestCase() {
|
||||
super();
|
||||
|
@ -62,7 +63,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
|
||||
/**
|
||||
* Override for c++ (i.e. at least one c++ test)
|
||||
*
|
||||
*
|
||||
* @return is c++ tests
|
||||
*/
|
||||
public boolean isCpp() {
|
||||
|
@ -82,8 +83,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
if (cproject != null) {
|
||||
try {
|
||||
cproject.getProject().delete(
|
||||
IResource.FORCE
|
||||
| IResource.ALWAYS_DELETE_PROJECT_CONTENT,
|
||||
IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
|
||||
new NullProgressMonitor());
|
||||
} catch (CoreException e) {
|
||||
throw e;
|
||||
|
@ -100,8 +100,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
for (int i = 0; i < projects.length; i++) {
|
||||
IProject p = projects[i];
|
||||
if (p.getName().startsWith("Codan")) {
|
||||
p.delete(IResource.FORCE
|
||||
| IResource.ALWAYS_DELETE_PROJECT_CONTENT,
|
||||
p.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
|
||||
new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +111,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
ModelJoiner mj = new ModelJoiner();
|
||||
try {
|
||||
// Create the cproject
|
||||
final String projectName = "CodanProjTest_"
|
||||
+ System.currentTimeMillis();
|
||||
final String projectName = "CodanProjTest_" + System.currentTimeMillis();
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
|
@ -189,7 +187,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
}
|
||||
|
||||
public File loadcode(String code, boolean cpp) {
|
||||
String fileKey = "@file:"; //$NON-NLS-1$
|
||||
String fileKey = "@file:";
|
||||
int indf = code.indexOf(fileKey);
|
||||
if (indf >= 0) {
|
||||
int sep = code.indexOf('\n');
|
||||
|
@ -201,7 +199,7 @@ public class CodanTestCase extends BaseTestCase {
|
|||
return loadcode(code, new File(tmpDir, fileName));
|
||||
}
|
||||
}
|
||||
String ext = cpp ? ".cpp" : ".c"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String ext = cpp ? ".cpp" : ".c";
|
||||
File testFile = null;
|
||||
try {
|
||||
testFile = File.createTempFile("test", ext, tmpDir); //$NON-NLS-1$
|
||||
|
@ -229,15 +227,14 @@ public class CodanTestCase extends BaseTestCase {
|
|||
// hmm
|
||||
fail(e.getMessage());
|
||||
}
|
||||
currentCElem = cproject
|
||||
.findElement(new Path(currentFile.toString()));
|
||||
currentCElem = cproject.findElement(new Path(currentFile.toString()));
|
||||
currentIFile = (IFile) currentCElem.getResource();
|
||||
return testFile;
|
||||
} catch (IOException e) {
|
||||
fail("Cannot save test: " + testFile + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fail("Cannot save test: " + testFile + ": " + e.getMessage());
|
||||
return null;
|
||||
} catch (CModelException e) {
|
||||
fail("Cannot find file: " + testFile + ": " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
fail("Cannot find file: " + testFile + ": " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Alena Laskavaia
|
||||
* Copyright (c) 2009, 2011 Alena Laskavaia
|
||||
* 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:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
|
@ -22,6 +22,7 @@ import java.net.URL;
|
|||
/**
|
||||
* TODO: add description
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
public class TestUtils {
|
||||
public static File saveFile(InputStream st, File testFile)
|
||||
throws FileNotFoundException, IOException {
|
||||
|
@ -54,15 +55,13 @@ public class TestUtils {
|
|||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static InputStream getJavaFileText(String srcRoot, Class clazz)
|
||||
throws IOException {
|
||||
public static InputStream getJavaFileText(String srcRoot, Class<?> clazz) throws IOException {
|
||||
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
|
||||
String classFile = clazz.getName().replaceAll("\\.", "/");
|
||||
classFile += ".java";
|
||||
InputStream st = null;
|
||||
if (plugin != null) {
|
||||
URL resource = plugin.getBundle().getResource(
|
||||
srcRoot + "/" + classFile);
|
||||
URL resource = plugin.getBundle().getResource(srcRoot + "/" + classFile);
|
||||
st = resource.openStream();
|
||||
} else {
|
||||
st = clazz.getResourceAsStream("/" + classFile);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Sat May 15 15:20:42 EDT 2010
|
||||
#Sat Feb 19 14:21:09 PST 2011
|
||||
eclipse.preferences.version=1
|
||||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
|
||||
sp_cleanup.add_default_serial_version_id=true
|
||||
|
@ -16,7 +16,7 @@ sp_cleanup.always_use_this_for_non_static_field_access=false
|
|||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code=false
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
sp_cleanup.make_local_variable_final=false
|
||||
sp_cleanup.make_parameters_final=false
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Sat May 15 20:01:30 EDT 2010
|
||||
#Sat Feb 19 16:19:49 PST 2011
|
||||
eclipse.preferences.version=1
|
||||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
|
||||
sp_cleanup.add_default_serial_version_id=true
|
||||
|
@ -16,7 +16,7 @@ sp_cleanup.always_use_this_for_non_static_field_access=false
|
|||
sp_cleanup.always_use_this_for_non_static_method_access=false
|
||||
sp_cleanup.convert_to_enhanced_for_loop=false
|
||||
sp_cleanup.correct_indentation=false
|
||||
sp_cleanup.format_source_code=true
|
||||
sp_cleanup.format_source_code=false
|
||||
sp_cleanup.format_source_code_changes_only=false
|
||||
sp_cleanup.make_local_variable_final=false
|
||||
sp_cleanup.make_parameters_final=false
|
||||
|
|
Loading…
Add table
Reference in a new issue