1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fixed compiler warnings.

This commit is contained in:
Sergey Prigogin 2011-02-20 00:49:47 +00:00
parent 3715cdbbe8
commit dafa751ccf
10 changed files with 50 additions and 58 deletions

View file

@ -1,4 +1,4 @@
#Sat May 15 15:21:20 EDT 2010 #Sat Feb 19 16:35:59 PST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
sp_cleanup.add_default_serial_version_id=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.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=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.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false sp_cleanup.make_parameters_final=false

View file

@ -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 * 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
@ -12,6 +12,7 @@
package org.eclipse.cdt.codan.core.test; package org.eclipse.cdt.codan.core.test;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.codan.core.internal.checkers.AssignmentInConditionCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.AssignmentInConditionCheckerTest;
@ -30,11 +31,11 @@ public class AutomatedIntegrationSuite extends TestSuite {
public AutomatedIntegrationSuite() { public AutomatedIntegrationSuite() {
} }
public AutomatedIntegrationSuite(Class theClass, String name) { public AutomatedIntegrationSuite(Class<? extends TestCase> theClass, String name) {
super(theClass, name); super(theClass, name);
} }
public AutomatedIntegrationSuite(Class theClass) { public AutomatedIntegrationSuite(Class<? extends TestCase> theClass) {
super(theClass); super(theClass);
} }

View file

@ -26,9 +26,9 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
/** /**
* @author Alena * @author Alena Laskavaia
*
*/ */
@SuppressWarnings("nls")
public class CheckerTestCase extends CodanTestCase { public class CheckerTestCase extends CodanTestCase {
protected IMarker[] markers; protected IMarker[] markers;

View file

@ -17,9 +17,8 @@ import org.osgi.framework.BundleContext;
* The activator class controls the plug-in life cycle * The activator class controls the plug-in life cycle
*/ */
public class CodanCoreTestActivator extends Plugin { public class CodanCoreTestActivator extends Plugin {
// The plug-in ID // 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 // The shared instance
private static CodanCoreTestActivator plugin; private static CodanCoreTestActivator plugin;
@ -34,6 +33,7 @@ public class CodanCoreTestActivator extends Plugin {
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/ */
@Override
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); super.start(context);
plugin = this; plugin = this;
@ -43,6 +43,7 @@ public class CodanCoreTestActivator extends Plugin {
* (non-Javadoc) * (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/ */
@Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
plugin = null; plugin = null;
super.stop(context); super.stop(context);
@ -56,5 +57,4 @@ public class CodanCoreTestActivator extends Plugin {
public static CodanCoreTestActivator getDefault() { public static CodanCoreTestActivator getDefault() {
return plugin; return plugin;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009,2010 QNX Software Systems * Copyright (c) 2009,2011 QNX Software Systems
* 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
@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* TODO: add description * TODO: add description
*/ */
@SuppressWarnings("restriction") @SuppressWarnings({ "nls", "restriction" })
public abstract class CodanFastCxxAstTestCase extends TestCase { public abstract class CodanFastCxxAstTestCase extends TestCase {
protected IASTTranslationUnit tu; protected IASTTranslationUnit tu;
@ -58,7 +58,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
try { try {
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault(); CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
return TestSourceReader.getContentsForTest(plugin == null ? null return TestSourceReader.getContentsForTest(plugin == null ? null
: plugin.getBundle(), "src", getClass(), getName(), //$NON-NLS-1$ : plugin.getBundle(), "src", getClass(), getName(),
sections); sections);
} catch (IOException e) { } catch (IOException e) {
fail(e.getMessage()); fail(e.getMessage());
@ -80,11 +80,8 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
true); true);
} }
@SuppressWarnings("restriction") protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean gcc) {
protected IASTTranslationUnit parse(String code, ParserLanguage lang, FileContent codeReader = FileContent.create("code.c", code.toCharArray());
boolean gcc) {
FileContent codeReader = FileContent.create("code.c", //$NON-NLS-1$
code.toCharArray());
IScannerInfo scannerInfo = new ScannerInfo(); IScannerInfo scannerInfo = new ScannerInfo();
IScanner scanner = AST2BaseTest.createScanner(codeReader, lang, IScanner scanner = AST2BaseTest.createScanner(codeReader, lang,
ParserMode.COMPLETE_PARSE, scannerInfo); ParserMode.COMPLETE_PARSE, scannerInfo);
@ -103,12 +100,11 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
config = new GCCParserExtensionConfiguration(); config = new GCCParserExtensionConfiguration();
else else
config = new ANSICParserExtensionConfiguration(); config = new ANSICParserExtensionConfiguration();
parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, parser2 = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config);
NULL_LOG, config);
} }
IASTTranslationUnit tu = parser2.parse(); IASTTranslationUnit tu = parser2.parse();
if (parser2.encounteredError() && !hasCodeErrors()) if (parser2.encounteredError() && !hasCodeErrors())
fail("PARSE FAILURE"); //$NON-NLS-1$ fail("PARSE FAILURE");
if (!hasCodeErrors()) { if (!hasCodeErrors()) {
if (lang == ParserLanguage.C) { if (lang == ParserLanguage.C) {
IASTProblem[] problems = CVisitor.getProblems(tu); IASTProblem[] problems = CVisitor.getProblems(tu);
@ -156,11 +152,9 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
} }
void runCodan(IASTTranslationUnit tu) { void runCodan(IASTTranslationUnit tu) {
IProblemReporter problemReporter = CodanRuntime.getInstance() IProblemReporter problemReporter = CodanRuntime.getInstance() .getProblemReporter();
.getProblemReporter();
CodanRuntime.getInstance().setProblemReporter(new IProblemReporter() { CodanRuntime.getInstance().setProblemReporter(new IProblemReporter() {
public void reportProblem(String problemId, IProblemLocation loc, public void reportProblem(String problemId, IProblemLocation loc, Object... args) {
Object... args) {
codanproblems.add(new ProblemInstance(problemId, loc, args)); codanproblems.add(new ProblemInstance(problemId, loc, args));
} }
}); });

View file

@ -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 * 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
@ -12,6 +12,7 @@
package org.eclipse.cdt.codan.core.test; package org.eclipse.cdt.codan.core.test;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.cdt.codan.core.cfg.ControlFlowGraphTest; import org.eclipse.cdt.codan.core.cfg.ControlFlowGraphTest;
@ -24,11 +25,11 @@ public class CodanFastTestSuite extends TestSuite {
public CodanFastTestSuite() { public CodanFastTestSuite() {
} }
public CodanFastTestSuite(Class theClass, String name) { public CodanFastTestSuite(Class<? extends TestCase> theClass, String name) {
super(theClass, name); super(theClass, name);
} }
public CodanFastTestSuite(Class theClass) { public CodanFastTestSuite(Class<? extends TestCase> theClass) {
super(theClass); super(theClass);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia * Copyright (c) 2009, 2011 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
@ -38,6 +38,7 @@ import org.eclipse.core.runtime.Path;
/** /**
* TODO: add description * TODO: add description
*/ */
@SuppressWarnings("nls")
public class CodanTestCase extends BaseTestCase { public class CodanTestCase extends BaseTestCase {
ArrayList<File> tempFiles = new ArrayList<File>(); ArrayList<File> tempFiles = new ArrayList<File>();
protected File tmpDir; protected File tmpDir;
@ -82,8 +83,7 @@ public class CodanTestCase extends BaseTestCase {
if (cproject != null) { if (cproject != null) {
try { try {
cproject.getProject().delete( cproject.getProject().delete(
IResource.FORCE IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
| IResource.ALWAYS_DELETE_PROJECT_CONTENT,
new NullProgressMonitor()); new NullProgressMonitor());
} catch (CoreException e) { } catch (CoreException e) {
throw e; throw e;
@ -100,8 +100,7 @@ public class CodanTestCase extends BaseTestCase {
for (int i = 0; i < projects.length; i++) { for (int i = 0; i < projects.length; i++) {
IProject p = projects[i]; IProject p = projects[i];
if (p.getName().startsWith("Codan")) { if (p.getName().startsWith("Codan")) {
p.delete(IResource.FORCE p.delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT,
| IResource.ALWAYS_DELETE_PROJECT_CONTENT,
new NullProgressMonitor()); new NullProgressMonitor());
} }
} }
@ -112,8 +111,7 @@ public class CodanTestCase extends BaseTestCase {
ModelJoiner mj = new ModelJoiner(); ModelJoiner mj = new ModelJoiner();
try { try {
// Create the cproject // Create the cproject
final String projectName = "CodanProjTest_" final String projectName = "CodanProjTest_" + System.currentTimeMillis();
+ System.currentTimeMillis();
final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.run(new IWorkspaceRunnable() { workspace.run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException { public void run(IProgressMonitor monitor) throws CoreException {
@ -189,7 +187,7 @@ public class CodanTestCase extends BaseTestCase {
} }
public File loadcode(String code, boolean cpp) { public File loadcode(String code, boolean cpp) {
String fileKey = "@file:"; //$NON-NLS-1$ String fileKey = "@file:";
int indf = code.indexOf(fileKey); int indf = code.indexOf(fileKey);
if (indf >= 0) { if (indf >= 0) {
int sep = code.indexOf('\n'); int sep = code.indexOf('\n');
@ -201,7 +199,7 @@ public class CodanTestCase extends BaseTestCase {
return loadcode(code, new File(tmpDir, fileName)); 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; File testFile = null;
try { try {
testFile = File.createTempFile("test", ext, tmpDir); //$NON-NLS-1$ testFile = File.createTempFile("test", ext, tmpDir); //$NON-NLS-1$
@ -229,15 +227,14 @@ public class CodanTestCase extends BaseTestCase {
// hmm // hmm
fail(e.getMessage()); fail(e.getMessage());
} }
currentCElem = cproject currentCElem = cproject.findElement(new Path(currentFile.toString()));
.findElement(new Path(currentFile.toString()));
currentIFile = (IFile) currentCElem.getResource(); currentIFile = (IFile) currentCElem.getResource();
return testFile; return testFile;
} catch (IOException e) { } 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; return null;
} catch (CModelException e) { } 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; return null;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2010 Alena Laskavaia * Copyright (c) 2009, 2011 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
@ -22,6 +22,7 @@ import java.net.URL;
/** /**
* TODO: add description * TODO: add description
*/ */
@SuppressWarnings("nls")
public class TestUtils { public class TestUtils {
public static File saveFile(InputStream st, File testFile) public static File saveFile(InputStream st, File testFile)
throws FileNotFoundException, IOException { throws FileNotFoundException, IOException {
@ -54,15 +55,13 @@ public class TestUtils {
* @return * @return
* @throws IOException * @throws IOException
*/ */
public static InputStream getJavaFileText(String srcRoot, Class clazz) public static InputStream getJavaFileText(String srcRoot, Class<?> clazz) throws IOException {
throws IOException {
CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault(); CodanCoreTestActivator plugin = CodanCoreTestActivator.getDefault();
String classFile = clazz.getName().replaceAll("\\.", "/"); String classFile = clazz.getName().replaceAll("\\.", "/");
classFile += ".java"; classFile += ".java";
InputStream st = null; InputStream st = null;
if (plugin != null) { if (plugin != null) {
URL resource = plugin.getBundle().getResource( URL resource = plugin.getBundle().getResource(srcRoot + "/" + classFile);
srcRoot + "/" + classFile);
st = resource.openStream(); st = resource.openStream();
} else { } else {
st = clazz.getResourceAsStream("/" + classFile); st = clazz.getResourceAsStream("/" + classFile);

View file

@ -1,4 +1,4 @@
#Sat May 15 15:20:42 EDT 2010 #Sat Feb 19 14:21:09 PST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
sp_cleanup.add_default_serial_version_id=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.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=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.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false sp_cleanup.make_parameters_final=false

View file

@ -1,4 +1,4 @@
#Sat May 15 20:01:30 EDT 2010 #Sat Feb 19 16:19:49 PST 2011
eclipse.preferences.version=1 eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
sp_cleanup.add_default_serial_version_id=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.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=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.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false sp_cleanup.make_parameters_final=false