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

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-01-23 10:05:51 -08:00
parent 815d32990c
commit 6878112781
9 changed files with 443 additions and 495 deletions

View file

@ -8,10 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* Created on Sept 28, 2004
*/
package org.eclipse.cdt.core.parser.tests;
import java.io.ByteArrayInputStream;
@ -41,7 +37,7 @@ public class FileBasePluginTest extends TestCase {
static IWorkspace workspace;
static IProject project;
static FileManager fileManager;
static int numProjects = 0;
static int numProjects;
static Class className;
static ICProject cPrj;
@ -69,7 +65,7 @@ public class FileBasePluginTest extends TestCase {
numProjects++;
}
} catch (CoreException e) {
/*boo*/
// Ignore
}
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
@ -79,8 +75,7 @@ public class FileBasePluginTest extends TestCase {
}
}
public FileBasePluginTest(String name, Class className)
{
public FileBasePluginTest(String name, Class className) {
super(name);
initialize(className);
}
@ -94,7 +89,7 @@ public class FileBasePluginTest extends TestCase {
project = null;
}
} catch (Throwable e) {
/*boo*/
// Ignore
}
}
@ -112,29 +107,11 @@ public class FileBasePluginTest extends TestCase {
try {
members[i].delete(false, monitor);
} catch (Throwable e) {
/*boo*/
// Ignore
}
}
}
// below can be used to work with large files (too large for memory)
// protected IFile importFile(String fileName) throws Exception {
// IFile file = cPrj.getProject().getFile(fileName);
// if (!file.exists()) {
// try{
// FileInputStream fileIn = new FileInputStream(
// CTestPlugin.getDefault().getFileInPlugin(new Path("resources/parser/" + fileName)));
// file.create(fileIn,false, monitor);
// } catch (CoreException e) {
// e.printStackTrace();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// }
//
// return file;
// }
protected IFolder importFolder(String folderName) throws Exception {
IFolder folder = project.getProject().getFolder(folderName);
@ -144,16 +121,18 @@ public class FileBasePluginTest extends TestCase {
return folder;
}
public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if( file.exists() )
if (file.exists()) {
file.setContents(stream, false, false, monitor);
else
} else {
file.create(stream, false, monitor);
}
fileManager.addFile(file);

View file

@ -8,10 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* Created on Sept 28, 2004
*/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.io.ByteArrayInputStream;
@ -44,7 +40,7 @@ public class AST2FileBasePluginTest extends TestCase {
static IWorkspace workspace;
static IProject project;
static FileManager fileManager;
static int numProjects = 0;
static int numProjects;
static Class className;
static ICProject cPrj;
@ -73,7 +69,7 @@ public class AST2FileBasePluginTest extends TestCase {
numProjects++;
}
} catch (CoreException e) {
/*boo*/
// Ignore
}
if (project == null)
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
@ -83,8 +79,7 @@ public class AST2FileBasePluginTest extends TestCase {
}
}
public AST2FileBasePluginTest(String name, Class className)
{
public AST2FileBasePluginTest(String name, Class className) {
super(name);
initialize(className);
}
@ -98,7 +93,7 @@ public class AST2FileBasePluginTest extends TestCase {
project = null;
}
} catch (Throwable e) {
/*boo*/
// Ignore
}
}
@ -116,7 +111,7 @@ public class AST2FileBasePluginTest extends TestCase {
try {
members[i].delete(false, monitor);
} catch (Throwable e) {
/*boo*/
// Ignore
}
}
}
@ -130,16 +125,18 @@ public class AST2FileBasePluginTest extends TestCase {
return folder;
}
public IFile importFile(String fileName, String contents) throws Exception {
// Obtain file handle
IFile file = project.getProject().getFile(fileName);
InputStream stream = new ByteArrayInputStream(contents.getBytes());
// Create file input stream
if( file.exists() )
if (file.exists()) {
file.setContents(stream, false, false, monitor);
else
} else {
file.create(stream, false, monitor);
}
fileManager.addFile(file);
@ -150,5 +147,4 @@ public class AST2FileBasePluginTest extends TestCase {
return TestSourceReader.getContentsForTest(
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
}
}

View file

@ -6685,7 +6685,8 @@ public class AST2TemplateTests extends AST2BaseTest {
BindingAssertionHelper assertionHelper = getAssertionHelper();
ICPPAliasTemplateInstance AliasInt = assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
ICPPAliasTemplateInstance AliasInt =
assertionHelper.assertNonProblem("Alias<int> intAlias;", "Alias<int>", ICPPAliasTemplateInstance.class);
assertEquals("Alias<int>", AliasInt.getName());
assertEquals("NS", AliasInt.getQualifiedName()[0]);
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);

View file

@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.core.resources.IFile;
@ -58,8 +57,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
super(name, DOMSelectionParseTest.class);
}
public void testBaseCase_VariableReference() throws Exception
{
public void testBaseCase_VariableReference() throws Exception {
String code = "void f() { int x; x=3; }"; //$NON-NLS-1$
int offset1 = code.indexOf( "x=" ); //$NON-NLS-1$
int offset2 = code.indexOf( '=');
@ -74,8 +72,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1);
}
public void testBaseCase_FunctionReference() throws Exception
{
public void testBaseCase_FunctionReference() throws Exception {
String code = "int x(){x( );}"; //$NON-NLS-1$
int offset1 = code.indexOf( "x( " ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
@ -90,16 +87,14 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1);
}
public void testBaseCase_Error() throws Exception
{
public void testBaseCase_Error() throws Exception {
String code = "int x() { y( ) }"; //$NON-NLS-1$
int offset1 = code.indexOf( "y( " ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
assertNull( parse( code, offset1, offset2, false ));
}
public void testBaseCase_FunctionDeclaration() throws Exception
{
public void testBaseCase_FunctionDeclaration() throws Exception {
String code = "int x(); void test() {x( );}"; //$NON-NLS-1$
int offset1 = code.indexOf( "x( )" ); //$NON-NLS-1$
int offset2 = code.indexOf( "( )"); //$NON-NLS-1$
@ -114,8 +109,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1);
}
public void testBaseCase_FunctionDeclaration2() throws Exception
{
public void testBaseCase_FunctionDeclaration2() throws Exception {
String code = "int printf( const char *, ... ); "; //$NON-NLS-1$
int offset1 = code.indexOf( "printf" ); //$NON-NLS-1$
int offset2 = code.indexOf( "( const"); //$NON-NLS-1$
@ -125,8 +119,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "printf" ); //$NON-NLS-1$
}
public void testBaseCase_VariableDeclaration() throws Exception
{
public void testBaseCase_VariableDeclaration() throws Exception {
String code = "int x = 3;"; //$NON-NLS-1$
int offset1 = code.indexOf( "x" ); //$NON-NLS-1$
int offset2 = code.indexOf( " ="); //$NON-NLS-1$
@ -137,8 +130,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "x" ); //$NON-NLS-1$
}
public void testBaseCase_Parameter() throws Exception
{
public void testBaseCase_Parameter() throws Exception {
String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$
int offset1 = code.indexOf( "argc;" ); //$NON-NLS-1$
int offset2 = code.indexOf( ";" ); //$NON-NLS-1$
@ -154,8 +146,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 4);
}
public void testBug57898() throws Exception
{
public void testBug57898() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Gonzo { public: void playHorn(); };\n" ); //$NON-NLS-1$
writer.write( "void Gonzo::playHorn() { return; }\n" ); //$NON-NLS-1$
@ -190,8 +181,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
}
}
public void testConstructorDestructorDeclaration() throws Exception
{
public void testConstructorDestructorDeclaration() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$
String code = writer.toString();
@ -209,8 +199,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "~Gonzo" ); //$NON-NLS-1$
}
public void testBug60264() throws Exception
{
public void testBug60264() throws Exception {
Writer writer = new StringWriter();
writer.write( "namespace Muppets { int i; }\n" ); //$NON-NLS-1$
writer.write( "int main(int argc, char **argv) { Muppets::i = 1; }\n" ); //$NON-NLS-1$
@ -239,8 +228,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 7);
}
public void testBug61613() throws Exception
{
public void testBug61613() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Foo { // ** (A) **\n" ); //$NON-NLS-1$
writer.write( " public:\n" ); //$NON-NLS-1$
@ -263,8 +251,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 3);
}
public void testBug60038() throws Exception
{
public void testBug60038() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Gonzo {\n"); //$NON-NLS-1$
writer.write( "public:\n"); //$NON-NLS-1$
@ -339,8 +326,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
}
}
public void testMethodReference() throws Exception
{
public void testMethodReference() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Sample { public:\n"); //$NON-NLS-1$
writer.write( " int getAnswer() const;\n"); //$NON-NLS-1$
@ -362,8 +348,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 9);
}
public void testConstructorDefinition() throws Exception
{
public void testConstructorDefinition() throws Exception {
String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$
int startIndex = code.indexOf( "::ABC") + 2; //$NON-NLS-1$
IASTNode node = parse( code, startIndex, startIndex + 3 );
@ -377,8 +362,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 3);
}
public void testBug63966() throws Exception
{
public void testBug63966() throws Exception {
Writer writer = new StringWriter();
writer.write( "void foo(int a) {}\n" ); //$NON-NLS-1$
writer.write( "void foo(long a) {}\n" ); //$NON-NLS-1$
@ -389,8 +373,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + 3 );
}
public void testBug66744() throws Exception
{
public void testBug66744() throws Exception {
Writer writer = new StringWriter();
writer.write( "enum EColours { RED, GREEN, BLUE }; \n" ); //$NON-NLS-1$
writer.write( "void foo() { EColours color = GREEN; } \n" ); //$NON-NLS-1$
@ -402,8 +385,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
public void testBug68527() throws Exception
{
public void testBug68527() throws Exception {
Writer writer = new StringWriter();
writer.write("struct X;\n"); //$NON-NLS-1$
writer.write("struct X anA;"); //$NON-NLS-1$
@ -412,8 +394,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + 1 );
}
public void testBug60407() throws Exception
{
public void testBug60407() throws Exception {
Writer writer = new StringWriter();
writer.write( "struct ZZZ { int x, y, z; };\n" ); //$NON-NLS-1$
writer.write( "typedef struct ZZZ _FILE;\n" ); //$NON-NLS-1$
@ -429,8 +410,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
parse( code, startIndex, startIndex + "static_function".length() ); //$NON-NLS-1$
}
public void testBug61800() throws Exception
{
public void testBug61800() throws Exception {
Writer writer = new StringWriter();
writer.write( "class B {};\n"); //$NON-NLS-1$
writer.write( "class ABCDEF {\n"); //$NON-NLS-1$
@ -450,8 +430,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 5);
}
public void testBug68739() throws Exception
{
public void testBug68739() throws Exception {
Writer writer = new StringWriter();
writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$
writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$
@ -468,8 +447,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((IASTName)node).toString(), "fprintf" ); //$NON-NLS-1$
}
public void testBug72818() throws Exception
{
public void testBug72818() throws Exception {
Writer writer = new StringWriter();
writer.write( "union Squaw { int x; double u; };\n" ); //$NON-NLS-1$
writer.write( "int main(int argc, char **argv) {\n" ); //$NON-NLS-1$
@ -489,8 +467,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 5);
}
public void test72220() throws Exception
{
public void test72220() throws Exception {
Writer writer = new StringWriter();
writer.write( "const int FOUND_ME = 1;\n" ); //$NON-NLS-1$
writer.write( "class Test{\n" ); //$NON-NLS-1$
@ -671,8 +648,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
// assertEquals( ((ASTNode)decls[0]).getLength(), 3);
}
public void testBug72710() throws Exception
{
public void testBug72710() throws Exception {
Writer writer = new StringWriter();
writer.write( "class Card{\n" ); //$NON-NLS-1$
writer.write( " Card( int rank );\n" ); //$NON-NLS-1$
@ -1643,8 +1619,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 1);
}
public void testBug64181() throws Exception
{
public void testBug64181() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("namespace Foo { // ** (A) **\n"); //$NON-NLS-1$
buffer.append("int bar;\n"); //$NON-NLS-1$
@ -1673,8 +1648,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[1]).getLength(), 3);
}
public void testBug80823() throws Exception
{
public void testBug80823() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("class MyEggImpl {}; // line A\n"); //$NON-NLS-1$
buffer.append("#define MyChicken MyEggImpl\n"); //$NON-NLS-1$
@ -1694,8 +1668,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals( ((ASTNode)decls[0]).getLength(), 9);
}
public void testBug86993() throws Exception
{
public void testBug86993() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("#define _BEGIN_STD_C extern \"C\" {\n"); //$NON-NLS-1$
buffer.append("#define _END_STD_C }\n"); //$NON-NLS-1$
@ -1736,4 +1709,3 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
assertEquals(length, loc.getNodeLength());
}
}