mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 00:05:53 +02:00
Merge branch 'master' into sd90
This commit is contained in:
commit
383cb93e57
122 changed files with 3581 additions and 1483 deletions
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
|
@ -83,7 +83,7 @@ public abstract class CodanFastCxxAstTestCase extends TestCase {
|
|||
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);
|
||||
IScanner scanner = AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
ISourceCodeParser parser2 = null;
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
ICPPParserExtensionConfiguration config = null;
|
||||
|
|
|
@ -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;
|
||||
|
@ -36,127 +32,110 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class FileBasePluginTest extends TestCase {
|
||||
public class FileBasePluginTestCase extends TestCase {
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects = 0;
|
||||
static int numProjects;
|
||||
static Class className;
|
||||
static ICProject cPrj;
|
||||
|
||||
public FileBasePluginTest() {
|
||||
public FileBasePluginTestCase() {
|
||||
}
|
||||
|
||||
public FileBasePluginTest(String name) {
|
||||
public FileBasePluginTestCase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName){
|
||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("ParserTestProject", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
project = cPrj.getProject();
|
||||
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
|
||||
//Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public FileBasePluginTest(String name, Class className)
|
||||
{
|
||||
public FileBasePluginTestCase(String name, Class className) {
|
||||
super(name);
|
||||
initialize(className);
|
||||
}
|
||||
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete( true, false, monitor );
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
// 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);
|
||||
|
||||
//Create file input stream
|
||||
if( !folder.exists() )
|
||||
folder.create( false, false, monitor );
|
||||
|
||||
|
||||
// Create file input stream
|
||||
if (!folder.exists())
|
||||
folder.create(false, false, monitor);
|
||||
|
||||
return folder;
|
||||
}
|
||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
|
||||
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() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
// Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, monitor);
|
||||
} else {
|
||||
file.create(stream, false, monitor);
|
||||
}
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2009, 2013 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Mike Kucera (IBM)
|
||||
* Sergey Prigogin (Google)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -28,19 +29,19 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* Tests for classes implementing IASTImplicitNameOwner interface.
|
||||
*/
|
||||
public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
||||
public class AST2CPPImplicitNameTests extends AST2TestBase {
|
||||
|
||||
public AST2CPPImplicitNameTests() {
|
||||
}
|
||||
|
||||
|
||||
public AST2CPPImplicitNameTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(AST2CPPImplicitNameTests.class);
|
||||
}
|
||||
|
||||
|
||||
public IASTImplicitName[] getImplicitNames(IASTTranslationUnit tu, String contents, String section, int len) {
|
||||
final int offset = contents.indexOf(section);
|
||||
assertTrue(offset >= 0);
|
||||
|
@ -75,25 +76,25 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
IASTImplicitName n;
|
||||
|
||||
|
||||
n = ba.assertImplicitName("+= 5", 2, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(14).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("+ p", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(4).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("- p", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(8).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("* p", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(17).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("/ p", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(23).resolveBinding());
|
||||
|
||||
|
||||
n = ba.assertImplicitName("-p;", 1, ICPPMethod.class);
|
||||
assertSame(n.resolveBinding(), col.getName(12).resolveBinding());
|
||||
|
||||
|
||||
ba.assertNoImplicitName("<< 6", 2);
|
||||
ba.assertNoImplicitName("+p;", 1);
|
||||
}
|
||||
|
@ -136,9 +137,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
ba.assertNoImplicitName("&Y::x;", 1);
|
||||
|
||||
|
||||
IASTImplicitName n = ba.assertImplicitName("&y;", 1, ICPPFunction.class);
|
||||
assertSame(n.resolveBinding(), col.getName(9).resolveBinding());
|
||||
}
|
||||
|
@ -165,20 +166,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// p2->doA();
|
||||
// }
|
||||
public void testArrowOperator() throws Exception {
|
||||
String contents = getAboveComment();
|
||||
String contents = getAboveComment();
|
||||
IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName[] implicits = getImplicitNames(tu, contents, "->doA();", 2);
|
||||
|
||||
|
||||
assertNotNull(implicits);
|
||||
assertEquals(2, implicits.length);
|
||||
|
||||
|
||||
assertSame(implicits[1].getBinding(), col.getName(4).resolveBinding());
|
||||
assertSame(implicits[0].getBinding(), col.getName(12).resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// struct A {
|
||||
// int x;
|
||||
// };
|
||||
|
@ -224,15 +225,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
ba.assertNoImplicitName(", b, c, d); // func", 1);
|
||||
ba.assertNoImplicitName(", c, d); // func", 1);
|
||||
ba.assertNoImplicitName(", d); // func", 1);
|
||||
|
||||
|
||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d; // expr", 1, ICPPFunction.class);
|
||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d; // expr", 1, ICPPFunction.class);
|
||||
ba.assertNoImplicitName(", d; // expr", 1);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
assertSame(opAB.resolveBinding(), col.getName(5).resolveBinding());
|
||||
assertSame(opCC.resolveBinding(), col.getName(11).resolveBinding());
|
||||
}
|
||||
|
@ -255,20 +256,20 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testCommaOperator2() throws Exception {
|
||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||
|
||||
|
||||
IASTImplicitName opAB = ba.assertImplicitName(", b, c, d", 1, ICPPMethod.class);
|
||||
IASTImplicitName opCC = ba.assertImplicitName(", c, d", 1, ICPPFunction.class);
|
||||
IASTImplicitName opDD = ba.assertImplicitName(", d", 1, ICPPMethod.class);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
// 6, 11, 15
|
||||
assertSame(opAB.resolveBinding(), col.getName(6).resolveBinding());
|
||||
assertSame(opCC.resolveBinding(), col.getName(15).resolveBinding());
|
||||
assertSame(opDD.resolveBinding(), col.getName(11).resolveBinding());
|
||||
|
||||
|
||||
ba.assertNonProblem("ee;", 2);
|
||||
}
|
||||
|
||||
|
@ -289,7 +290,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("(b); // 1", 1, ICPPMethod.class);
|
||||
IASTImplicitName n2 = ba.assertImplicitName("); // 1", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
|
@ -298,14 +299,14 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
// there should be no overlap
|
||||
ba.assertNoImplicitName("b); // 1", 1);
|
||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("(); // 2", 1, ICPPMethod.class);
|
||||
n2 = ba.assertImplicitName("); // 2", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
assertFalse(n1.isAlternate());
|
||||
assertTrue(n2.isAlternate());
|
||||
assertSame(col.getName(3).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("(1, 2); // 3", 1, ICPPMethod.class);
|
||||
n2 = ba.assertImplicitName("); // 3", 1, ICPPMethod.class);
|
||||
assertSame(n1.resolveBinding(), n2.resolveBinding());
|
||||
|
@ -348,7 +349,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
IASTImplicitName n1 = ba.assertImplicitName("[0]); //1", 1, ICPPMethod.class);
|
||||
ba.assertNoImplicitName("0]); //1", 1);
|
||||
IASTImplicitName n2 = ba.assertImplicitName("]); //1", 1, ICPPMethod.class);
|
||||
|
@ -356,7 +357,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertFalse(n1.isAlternate());
|
||||
assertTrue(n2.isAlternate());
|
||||
assertSame(col.getName(1).resolveBinding(), n1.resolveBinding());
|
||||
|
||||
|
||||
n1 = ba.assertImplicitName("[q]); //2", 1, ICPPMethod.class);
|
||||
ba.assertNoImplicitName("q]); //2", 1);
|
||||
n2 = ba.assertImplicitName("]); //2", 1, ICPPMethod.class);
|
||||
|
@ -384,21 +385,21 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertEquals(2, names.length);
|
||||
IASTImplicitName destructor = names[0];
|
||||
IASTImplicitName delete = names[1];
|
||||
|
||||
|
||||
IASTTranslationUnit tu = ba.getTranslationUnit();
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
||||
assertSame(col.getName(1).resolveBinding(), destructor.resolveBinding());
|
||||
assertSame(col.getName(2).resolveBinding(), delete.resolveBinding());
|
||||
|
||||
|
||||
names = ba.getImplicitNames("delete[] x;", 6);
|
||||
assertEquals(1, names.length);
|
||||
assertSame(col.getName(4).resolveBinding(), names[0].resolveBinding());
|
||||
|
||||
|
||||
ba.assertNoImplicitName("delete 1;", 6);
|
||||
}
|
||||
|
||||
|
||||
// struct A {
|
||||
// void operator delete(void * a);
|
||||
// };
|
||||
|
@ -416,15 +417,15 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
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);
|
||||
assertEquals(2, names.length);
|
||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||
assertSame(m, names[1].resolveBinding());
|
||||
|
||||
names = bh.getImplicitNames("delete b;", 6);
|
||||
assertTrue(((ICPPMethod) names[0].resolveBinding()).isDestructor());
|
||||
assertEquals(2, names.length);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(f, names[1].resolveBinding());
|
||||
}
|
||||
|
||||
|
@ -443,13 +444,13 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||
IBinding m= bh.assertNonProblem("operator new(size_t a)", 12);
|
||||
IBinding f= bh.assertNonProblem("operator new(size_t b)", 12);
|
||||
|
||||
|
||||
IASTImplicitName[] names = bh.getImplicitNames("new A;", 3);
|
||||
assertEquals(1, names.length);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(m, names[0].resolveBinding());
|
||||
|
||||
names = bh.getImplicitNames("new B;", 3);
|
||||
assertEquals(1, names.length);
|
||||
assertEquals(2, names.length);
|
||||
assertSame(f, names[0].resolveBinding());
|
||||
}
|
||||
|
||||
|
@ -461,9 +462,9 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
public void testImplicitNewAndDelete() throws Exception {
|
||||
BindingAssertionHelper ba = new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertNoImplicitName("new X", 3);
|
||||
ba.assertNoImplicitName("delete[]", 6);
|
||||
ba.assertNoImplicitName("delete[]", 6);
|
||||
}
|
||||
|
||||
|
||||
// typedef long unsigned int size_t
|
||||
// struct nothrow_t {};
|
||||
// extern const nothrow_t nothrow;
|
||||
|
@ -491,7 +492,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
assertSame(col.getName(9).resolveBinding(), n2.resolveBinding());
|
||||
assertSame(col.getName(14).resolveBinding(), n3.resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// int test() {
|
||||
// throw;
|
||||
// }
|
||||
|
@ -551,7 +552,7 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
IASTImplicitName v = ba.assertImplicitName("v(p)", 1, ICPPConstructor.class);
|
||||
assertSame(ctor1, v.resolveBinding());
|
||||
}
|
||||
|
||||
|
||||
// enum A {aa};
|
||||
// struct B{ operator A();};
|
||||
// bool operator==(A, A); // overrides the built-in operator.
|
||||
|
@ -567,5 +568,5 @@ public class AST2CPPImplicitNameTests extends AST2BaseTest {
|
|||
ICPPFunction op = ba.assertNonProblem("operator==", 0);
|
||||
IASTImplicitName a = ba.assertImplicitName("==b", 2, ICPPFunction.class);
|
||||
assertSame(op, a.resolveBinding());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
/**
|
||||
* Examples taken from the c++-specification.
|
||||
*/
|
||||
public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||
public class AST2CPPSpecTest extends AST2SpecTestBase {
|
||||
|
||||
public AST2CPPSpecTest() {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -128,6 +128,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
|
@ -139,7 +140,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
public class AST2CPPTests extends AST2BaseTest {
|
||||
public class AST2CPPTests extends AST2TestBase {
|
||||
|
||||
public AST2CPPTests() {
|
||||
}
|
||||
|
@ -260,7 +261,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(declNames.length, i);
|
||||
assertEquals(defNames.length, j);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void assertSameType(IType first, IType second){
|
||||
assertNotNull(first);
|
||||
|
@ -1201,10 +1202,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testVirtualParentLookup() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPNameCollector collector = new CPPNameCollector(true);
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 15);
|
||||
assertEquals(collector.size(), 16);
|
||||
|
||||
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
|
||||
|
@ -1215,7 +1216,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstances(collector, D, 3);
|
||||
assertInstances(collector, C, 2);
|
||||
assertInstances(collector, B, 2);
|
||||
assertInstances(collector, A, 2);
|
||||
assertInstances(collector, A, 3);
|
||||
assertInstances(collector, ctor, 1);
|
||||
assertInstances(collector, x, 2);
|
||||
}
|
||||
|
@ -1230,10 +1231,10 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testAmbiguousVirtualParentLookup() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPNameCollector collector = new CPPNameCollector(true);
|
||||
tu.accept(collector);
|
||||
|
||||
assertEquals(collector.size(), 15);
|
||||
assertEquals(collector.size(), 16);
|
||||
|
||||
ICPPClassType D = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||
ICPPField x1 = (ICPPField) collector.getName(1).resolveBinding();
|
||||
|
@ -1241,13 +1242,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPClassType B = (ICPPClassType) collector.getName(4).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) collector.getName(6).resolveBinding();
|
||||
ICPPConstructor ctor = A.getConstructors()[0];
|
||||
IProblemBinding x2 = (IProblemBinding) collector.getName(14).resolveBinding();
|
||||
IProblemBinding x2 = (IProblemBinding) collector.getName(15).resolveBinding();
|
||||
assertEquals(x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
|
||||
|
||||
assertInstances(collector, D, 3);
|
||||
assertInstances(collector, C, 2);
|
||||
assertInstances(collector, B, 2);
|
||||
assertInstances(collector, A, 2);
|
||||
assertInstances(collector, A, 3);
|
||||
assertInstances(collector, ctor, 1);
|
||||
assertInstances(collector, x1, 1);
|
||||
}
|
||||
|
@ -1843,7 +1844,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPMethod dtor = (ICPPMethod) col.getName(13).resolveBinding();
|
||||
assertNotNull(dtor);
|
||||
assertEquals(dtor.getName(), "~C"); //$NON-NLS-1$
|
||||
assertInstances(col, C, 6);
|
||||
assertInstances(col, C, 7);
|
||||
|
||||
assertInstances(col, op, 3);
|
||||
assertInstances(col, other, 4);
|
||||
|
@ -1993,7 +1994,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
|
||||
assertInstances(col, pb, 2);
|
||||
assertInstances(col, mutate, 2);
|
||||
assertInstances(col, B, 2);
|
||||
assertInstances(col, B, 3);
|
||||
}
|
||||
|
||||
// struct S { int i; };
|
||||
|
@ -2511,7 +2512,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testBug86267() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
ICPPClassType D1 = (ICPPClassType) col.getName(2).resolveBinding();
|
||||
|
@ -2549,7 +2550,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
ICPPMethod op = (ICPPMethod) col.getName(3).resolveBinding();
|
||||
IParameter other = (IParameter) col.getName(5).resolveBinding();
|
||||
|
||||
assertInstances(col, C, 6);
|
||||
assertInstances(col, C, 7);
|
||||
assertInstances(col, f, 2);
|
||||
assertInstances(col, op, 3);
|
||||
assertInstances(col, other, 4);
|
||||
|
@ -4052,11 +4053,11 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// X x = new X(y);
|
||||
public void testBug90654_1() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
ICPPConstructor ctor1 = (ICPPConstructor) col.getName(1).resolveBinding();
|
||||
ICPPConstructor ctor = (ICPPConstructor) col.getName(11).resolveBinding();
|
||||
ICPPConstructor ctor = (ICPPConstructor) col.getName(12).resolveBinding();
|
||||
assertSame(ctor, ctor1);
|
||||
}
|
||||
|
||||
|
@ -8382,20 +8383,24 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// fH({1}); // H(G(1))
|
||||
// }
|
||||
public void testListInitialization_302412f() throws Exception {
|
||||
ICPPConstructor ctor;
|
||||
IProblemBinding problem;
|
||||
String code= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
bh.assertProblem("f({1,1})", 1);
|
||||
ctor= bh.assertNonProblem("F({1,1})", 1);
|
||||
bh.assertImplicitName("F({1,1})", 1, ICPPConstructor.class);
|
||||
bh.assertNonProblem("fF({1,1})", 2);
|
||||
|
||||
bh.assertNonProblem("fG(1)", 2);
|
||||
bh.assertNonProblem("fG({1})", 2);
|
||||
|
||||
ctor= bh.assertNonProblem("H(1)", 1);
|
||||
problem= bh.assertProblem("H({1})", 1);
|
||||
assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
|
||||
bh.assertImplicitName("H(1)", 1, ICPPConstructor.class);
|
||||
bh.assertNoImplicitName("H({1})", 1);
|
||||
// TODO(nathanridge): Perhaps we should store implicit names even if they
|
||||
// resolve to ProblemBindings. Then we can do the stronger check in the
|
||||
// 3 commented lines below.
|
||||
//IASTImplicitName n= bh.assertImplicitName("H({1})", 1, IProblemBinding.class);
|
||||
//problem= (IProblemBinding) n.resolveBinding();
|
||||
//assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
|
||||
bh.assertProblem("fH(1)", 2);
|
||||
bh.assertNonProblem("fH({1})", 2);
|
||||
}
|
||||
|
@ -9823,7 +9828,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
// struct Base {
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDef(){}
|
||||
// };
|
||||
// struct S : public Base {
|
||||
|
@ -9851,9 +9856,9 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstance(declarator, ICPPASTFunctionDeclarator.class);
|
||||
assertVirtualSpecifiers((ICPPASTFunctionDeclarator)declarator, true, false);
|
||||
}
|
||||
|
||||
|
||||
// struct Base {
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDecl();
|
||||
// virtual void mFuncDef(){}
|
||||
// };
|
||||
// struct S : public Base {
|
||||
|
@ -10025,7 +10030,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
// double vdouble;
|
||||
// long double vlongdouble;
|
||||
// UnscopedEnum vue;
|
||||
//
|
||||
//
|
||||
// // Narrowing conversions
|
||||
// fint({vdouble});
|
||||
// ffloat({vlongdouble});
|
||||
|
@ -10083,7 +10088,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
helper.assertNonProblemOnFirstIdentifier("fint({vbool");
|
||||
helper.assertNonProblemOnFirstIdentifier("fint({vchar");
|
||||
}
|
||||
|
||||
|
||||
// namespace std {
|
||||
// struct string {};
|
||||
// struct exception {};
|
||||
|
@ -10121,4 +10126,64 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// T bar();
|
||||
// struct S {
|
||||
// void waldo();
|
||||
// };
|
||||
// int main() {
|
||||
// auto L = [](S s) { return s; };
|
||||
// typedef decltype(L) lambda_type;
|
||||
// decltype(bar<const lambda_type>()(S())) v;
|
||||
// v.waldo();
|
||||
// }
|
||||
public void testDecltypeWithConstantLambda_397494() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <bool>
|
||||
// struct enable_if {
|
||||
// };
|
||||
// template <>
|
||||
// struct enable_if<true> {
|
||||
// typedef void type;
|
||||
// };
|
||||
// struct base {};
|
||||
// struct derived : base {};
|
||||
// typedef enable_if<__is_base_of(base, derived)>::type T;
|
||||
public void testIsBaseOf_399353() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
// template <bool> struct B{};
|
||||
// template <>
|
||||
// struct B<true> {
|
||||
// void waldo();
|
||||
// };
|
||||
// typedef char& one;
|
||||
// int main() {
|
||||
// B<sizeof(one) == 1> b;
|
||||
// b.waldo();
|
||||
// }
|
||||
public void testSizeofReference_397342() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct A {
|
||||
// char a[100];
|
||||
// };
|
||||
// struct B {
|
||||
// A& b;
|
||||
// };
|
||||
// A* p;
|
||||
public void testSizeofStructWithReferenceField_397342() throws Exception {
|
||||
BindingAssertionHelper bh = getAssertionHelper();
|
||||
IASTName nameB = bh.findName("B");
|
||||
IASTName namep = bh.findName("p");
|
||||
ICPPClassType B = (ICPPClassType) nameB.resolveBinding();
|
||||
IPointerType ptrToA = (IPointerType) ((ICPPVariable) namep.resolveBinding()).getType();
|
||||
long pointerSize = SizeofCalculator.getSizeAndAlignment(ptrToA, namep).size;
|
||||
long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size;
|
||||
assertEquals(pointerSize, BSize);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2CSpecTest extends AST2SpecBaseTest {
|
||||
public class AST2CSpecTest extends AST2SpecTestBase {
|
||||
|
||||
public AST2CSpecTest() {
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -39,116 +35,116 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2FileBasePluginTest extends TestCase {
|
||||
public class AST2FileBasePluginTestCase extends TestCase {
|
||||
static NullProgressMonitor monitor;
|
||||
static IWorkspace workspace;
|
||||
static IProject project;
|
||||
static FileManager fileManager;
|
||||
static int numProjects = 0;
|
||||
static int numProjects;
|
||||
static Class className;
|
||||
static ICProject cPrj;
|
||||
|
||||
public AST2FileBasePluginTest() {
|
||||
public AST2FileBasePluginTestCase() {
|
||||
}
|
||||
|
||||
public AST2FileBasePluginTest(String name) {
|
||||
public AST2FileBasePluginTestCase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private void initialize(Class aClassName){
|
||||
if( CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null){
|
||||
private void initialize(Class aClassName) {
|
||||
if (CCorePlugin.getDefault() != null && CCorePlugin.getDefault().getCoreModel() != null) {
|
||||
//(CCorePlugin.getDefault().getCoreModel().getIndexManager()).reset();
|
||||
monitor = new NullProgressMonitor();
|
||||
|
||||
|
||||
workspace = ResourcesPlugin.getWorkspace();
|
||||
|
||||
|
||||
try {
|
||||
cPrj = CProjectHelper.createCCProject("AST2BasedProjectMofo", "bin", IPDOMManager.ID_NO_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
project = cPrj.getProject();
|
||||
|
||||
|
||||
// ugly
|
||||
if (className == null || !className.equals(aClassName)) {
|
||||
className = aClassName;
|
||||
numProjects++;
|
||||
}
|
||||
} catch ( CoreException e ) {
|
||||
/*boo*/
|
||||
} catch (CoreException e) {
|
||||
// Ignore
|
||||
}
|
||||
if (project == null)
|
||||
throw new NullPointerException("Unable to create project"); //$NON-NLS-1$
|
||||
|
||||
//Create file manager
|
||||
|
||||
// Create file manager
|
||||
fileManager = new FileManager();
|
||||
}
|
||||
}
|
||||
|
||||
public AST2FileBasePluginTest(String name, Class className)
|
||||
{
|
||||
public AST2FileBasePluginTestCase(String name, Class className) {
|
||||
super(name);
|
||||
initialize(className);
|
||||
}
|
||||
|
||||
|
||||
public void cleanupProject() throws Exception {
|
||||
numProjects--;
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
if (numProjects == 0) {
|
||||
project.delete( true, false, monitor );
|
||||
project.delete(true, false, monitor);
|
||||
project = null;
|
||||
}
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if( project == null || !project.exists() )
|
||||
if (project == null || !project.exists())
|
||||
return;
|
||||
|
||||
IResource [] members = project.members();
|
||||
for( int i = 0; i < members.length; i++ ){
|
||||
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
IResource[] members = project.members();
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
if (members[i].getName().equals(".project") || members[i].getName().equals(".cproject")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
continue;
|
||||
if (members[i].getName().equals(".settings"))
|
||||
continue;
|
||||
try{
|
||||
members[i].delete( false, monitor );
|
||||
} catch( Throwable e ){
|
||||
/*boo*/
|
||||
try {
|
||||
members[i].delete(false, monitor);
|
||||
} catch (Throwable e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IFolder importFolder(String folderName) throws Exception {
|
||||
IFolder folder = project.getProject().getFolder(folderName);
|
||||
|
||||
//Create file input stream
|
||||
if( !folder.exists() )
|
||||
folder.create( false, false, monitor );
|
||||
|
||||
|
||||
// Create file input stream
|
||||
if (!folder.exists())
|
||||
folder.create(false, false, monitor);
|
||||
|
||||
return folder;
|
||||
}
|
||||
public IFile importFile(String fileName, String contents ) throws Exception{
|
||||
//Obtain file handle
|
||||
|
||||
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() )
|
||||
file.setContents( stream, false, false, monitor );
|
||||
else
|
||||
file.create( stream, false, monitor );
|
||||
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
// Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, monitor);
|
||||
} else {
|
||||
file.create(stream, false, monitor);
|
||||
}
|
||||
|
||||
fileManager.addFile(file);
|
||||
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected StringBuilder[] getContents(int sections) throws IOException {
|
||||
return TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), sections);
|
||||
}
|
||||
|
||||
}
|
|
@ -59,7 +59,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2KnRTests extends AST2BaseTest {
|
||||
public class AST2KnRTests extends AST2TestBase {
|
||||
|
||||
public AST2KnRTests() {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
@ -46,7 +48,7 @@ import org.eclipse.core.resources.IFile;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
||||
public class AST2SelectionParseTest extends AST2SelectionParseTestBase {
|
||||
|
||||
public AST2SelectionParseTest() {
|
||||
}
|
||||
|
@ -352,9 +354,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
|||
assertTrue(node instanceof IASTTypeId);
|
||||
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "Gonzo"); //$NON-NLS-1$
|
||||
name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
||||
assertNotNull(name.resolveBinding());
|
||||
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
|
||||
assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$
|
||||
name = TestUtil.findImplicitName(name);
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertTrue(binding instanceof ICPPConstructor);
|
||||
assertEquals(((ICPPConstructor)binding).getName(), "Gonzo"); //$NON-NLS-1$
|
||||
break;
|
||||
default:
|
||||
assertTrue(node instanceof IASTName);
|
||||
|
@ -736,9 +739,10 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
|||
assertTrue(node instanceof IASTTypeId);
|
||||
assertEquals(((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName().toString(), "B"); //$NON-NLS-1$
|
||||
IASTName name = ((IASTNamedTypeSpecifier)((IASTTypeId)node).getDeclSpecifier()).getName();
|
||||
assertNotNull(name.resolveBinding());
|
||||
assertTrue(name.resolveBinding() instanceof ICPPConstructor);
|
||||
assertEquals(((ICPPConstructor)name.resolveBinding()).getName(), "B"); //$NON-NLS-1$
|
||||
name = TestUtil.findImplicitName(name);
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertTrue(binding instanceof ICPPConstructor);
|
||||
assertEquals(((ICPPConstructor)binding).getName(), "B"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug72712_2() throws Exception{
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTest;
|
||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.GNUCSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
|
@ -40,18 +40,18 @@ import org.eclipse.core.resources.IFile;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
||||
public class AST2SelectionParseTestBase extends FileBasePluginTestCase {
|
||||
|
||||
public AST2SelectionParseBaseTest() {
|
||||
public AST2SelectionParseTestBase() {
|
||||
}
|
||||
|
||||
public AST2SelectionParseBaseTest(String name) {
|
||||
public AST2SelectionParseTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||
|
||||
public AST2SelectionParseBaseTest(String name, Class className) {
|
||||
public AST2SelectionParseTestBase(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class AST2SelectionParseBaseTest extends FileBasePluginTest {
|
|||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems) throws ParserException {
|
||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
||||
ISourceCodeParser parser2 = null;
|
||||
if (lang == ParserLanguage.CPP) {
|
|
@ -41,12 +41,12 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2SpecBaseTest extends AST2BaseTest {
|
||||
public AST2SpecBaseTest() {
|
||||
public class AST2SpecTestBase extends AST2TestBase {
|
||||
public AST2SpecTestBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AST2SpecBaseTest(String name) {
|
||||
public AST2SpecTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class AST2SpecBaseTest extends AST2BaseTest {
|
|||
boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings,
|
||||
int expectedProblemBindings, String[] problems) throws ParserException {
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
||||
ISourceCodeParser parser2 = null;
|
||||
if (lang == ParserLanguage.CPP) {
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 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
|
||||
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
|
@ -55,6 +56,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
|
@ -101,7 +103,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
public class AST2TemplateTests extends AST2BaseTest {
|
||||
public class AST2TemplateTests extends AST2TestBase {
|
||||
|
||||
public AST2TemplateTests() {
|
||||
}
|
||||
|
@ -2371,11 +2373,11 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testCPPConstructorTemplateSpecialization() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), CPP, true, true);
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
ICPPASTTemplateId tid= (ICPPASTTemplateId) col.getName(20);
|
||||
IASTName cn= col.getName(21);
|
||||
IASTImplicitName tid= (IASTImplicitName) col.getName(20);
|
||||
IASTName cn= col.getName(22);
|
||||
assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6)
|
||||
assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6)
|
||||
assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6)
|
||||
|
@ -3840,7 +3842,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// };
|
||||
public void testNestedTemplates_259872_1() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class);
|
||||
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
|
||||
}
|
||||
|
||||
// template <typename CL, typename T>
|
||||
|
@ -3865,7 +3867,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// };
|
||||
public void testNestedTemplates_259872_2() throws Exception {
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), CPP);
|
||||
bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class);
|
||||
bh.assertNonProblem("A<B, int>", 9, ICPPClassType.class);
|
||||
}
|
||||
|
||||
// template <class T>
|
||||
|
@ -4403,6 +4405,17 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename A>
|
||||
// void foo(A);
|
||||
// template <typename A, typename... B>
|
||||
// void foo(A, B...);
|
||||
// int main() {
|
||||
// foo(0);
|
||||
// }
|
||||
public void testFunctionTemplatePartialOrdering_388805() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T> class CT {};
|
||||
// template<int I> class CTI {};
|
||||
//
|
||||
|
@ -4828,6 +4841,25 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ub= bh.assertNonProblem("f(h(args...) + args...)", 1);
|
||||
}
|
||||
|
||||
// template <typename... Args>
|
||||
// struct contains_waldo;
|
||||
// template <>
|
||||
// struct contains_waldo<> {
|
||||
// static const bool value = false;
|
||||
// };
|
||||
// template <typename First, typename... Rest>
|
||||
// struct contains_waldo<First, Rest...> {
|
||||
// static const bool value = contains_waldo<Rest...>::value;
|
||||
// };
|
||||
// int main() {
|
||||
// bool b1 = contains_waldo<int>::value;
|
||||
// bool b2 = contains_waldo<int, int>::value;
|
||||
// bool b2 = contains_waldo<int, int, int>::value;
|
||||
// }
|
||||
public void testRecursiveVariadicTemplate_397828() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct Test {
|
||||
// void Update() {}
|
||||
// };
|
||||
|
@ -6219,24 +6251,24 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
||||
ICPPClassType S = assertionHelper.assertNonProblem("struct S {", "S", ICPPClassType.class);
|
||||
ICPPField x = assertionHelper.assertNonProblem("int x", "x", ICPPField.class);
|
||||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S", "Alias", ITypedef.class);
|
||||
IFunction foo = assertionHelper.assertNonProblem("void foo() {", "foo", IFunction.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA", "myA", IVariable.class);
|
||||
|
||||
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, x, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertInstances(collector, foo, 1);
|
||||
assertInstances(collector, myA, 2);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T x;
|
||||
|
@ -6248,7 +6280,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6257,7 +6289,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ITypedef Alias = assertionHelper.assertNonProblem("using Alias = S<int>;", "Alias", ITypedef.class);
|
||||
IVariable myA = assertionHelper.assertNonProblem("Alias myA;", "myA", IVariable.class);
|
||||
ICPPSpecialization xRef = assertionHelper.assertNonProblem("myA.x = 42;", "x", ICPPSpecialization.class);
|
||||
|
||||
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
|
@ -6273,13 +6305,13 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasBasicType() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
||||
ICPPAliasTemplate Alias = assertionHelper.assertNonProblem("using Alias = int;", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPAliasTemplateInstance aliasFloatInstance = assertionHelper.assertNonProblem("Alias<float> myA;", "Alias<float>", ICPPAliasTemplateInstance.class);
|
||||
|
||||
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertSameType(aliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
}
|
||||
|
@ -6296,7 +6328,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6334,9 +6366,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t1 = assertionHelper.assertNonProblem("T1 t1;", "t1", ICPPField.class);
|
||||
ICPPField t2 = assertionHelper.assertNonProblem("T2 t2;", "t2", ICPPField.class);
|
||||
ICPPField t3 = assertionHelper.assertNonProblem("T3 t3;", "t3", ICPPField.class);
|
||||
|
@ -6377,9 +6409,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPAliasTemplateInstance TAliasSInt = assertionHelper.assertNonProblem("TAlias<S<int>> myA;", "TAlias<S<int>>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>()", "t", ICPPSpecialization.class);
|
||||
|
@ -6400,9 +6432,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPTemplateInstance STAliasInt = assertionHelper.assertNonProblem("S<TAlias<int>> myA;", "S<TAlias<int>>", ICPPTemplateInstance.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem("myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
|
@ -6423,9 +6455,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("int buff [Size];", "buff", ICPPField.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
||||
|
@ -6446,9 +6478,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasDefaultArguments() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField buff = assertionHelper.assertNonProblem("T buff [Size];", "buff", ICPPField.class);
|
||||
ICPPAliasTemplateInstance myA = assertionHelper.assertNonProblem("TAlias<> myA;", "TAlias<>", ICPPAliasTemplateInstance.class);
|
||||
ICPPSpecialization buffRef = assertionHelper.assertNonProblem("myA.buff[0] = 1;", "buff", ICPPSpecialization.class);
|
||||
|
@ -6470,9 +6502,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasTemplateArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
ICPPSpecialization tRef = assertionHelper.assertNonProblem(" myA.t = S<int>();", "t", ICPPSpecialization.class);
|
||||
ICPPClassSpecialization Sint = assertionHelper.assertNonProblem("myA.t = S<int>();", "S<int>", ICPPClassSpecialization.class);
|
||||
|
@ -6497,9 +6529,9 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(TAlias<int> arg){", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefAlias = assertionHelper.assertNonProblem("bar(myA);", "bar", ICPPFunction.class);
|
||||
ICPPFunction barRefSInt = assertionHelper.assertNonProblem("bar(myS);", "bar", ICPPFunction.class);
|
||||
|
@ -6522,7 +6554,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPFunction bar = assertionHelper.assertNonProblem("void bar(S<int> arg){", "bar", ICPPFunction.class);
|
||||
|
@ -6571,7 +6603,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6596,7 +6628,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasForTemplateReference() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPClassSpecialization SInt = assertionHelper.assertNonProblem("S<int> myS;", "S<int>", ICPPClassSpecialization.class);
|
||||
|
@ -6612,7 +6644,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6632,7 +6664,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
CPPNameCollector collector = getCPPNameCollector(assertionHelper.getTranslationUnit());
|
||||
|
||||
|
@ -6657,7 +6689,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplatedAliasTemplateParameter() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
BindingAssertionHelper assertionHelper = getAssertionHelper();
|
||||
|
||||
ICPPField t = assertionHelper.assertNonProblem("T t;", "t", ICPPField.class);
|
||||
|
@ -6680,10 +6712,11 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// Alias<int> intAlias;
|
||||
public void testAliasDeclarationContext() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
|
||||
|
||||
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]);
|
||||
|
@ -7004,4 +7037,92 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testDependentExpressions_395243d() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// struct B {
|
||||
// enum { value = 1 };
|
||||
// };
|
||||
//
|
||||
// template <typename T>
|
||||
// struct C {
|
||||
// enum { id = B<T>::value };
|
||||
// };
|
||||
//
|
||||
// void test() {
|
||||
// int x = C<bool>::id;
|
||||
// }
|
||||
public void _testDependentEnumValue_389009() throws Exception {
|
||||
BindingAssertionHelper ah = getAssertionHelper();
|
||||
IEnumerator binding = ah.assertNonProblem("C<bool>::id", "id");
|
||||
IValue value = binding.getValue();
|
||||
Long num = value.numericalValue();
|
||||
assertNotNull(num);
|
||||
assertEquals(1, num.longValue());
|
||||
}
|
||||
|
||||
// template <int...> struct A {};
|
||||
// template <int... I> void foo(A<I...>);
|
||||
// int main() {
|
||||
// foo(A<0>());
|
||||
// }
|
||||
public void testVariadicNonTypeTemplateParameter_382074() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <bool...>
|
||||
// struct ice_or {
|
||||
// static const bool value = false;
|
||||
// };
|
||||
// template <typename T>
|
||||
// struct is_foo {
|
||||
// static const bool value = false;
|
||||
// };
|
||||
// template <typename... Args>
|
||||
// struct contains_foo {
|
||||
// static const bool value = ice_or<is_foo<Args>::value...>::value;
|
||||
// };
|
||||
// template <bool>
|
||||
// struct meta;
|
||||
// struct S { void bar(); };
|
||||
// template <>
|
||||
// struct meta<false> {
|
||||
// typedef S type;
|
||||
// };
|
||||
// int main() {
|
||||
// meta<contains_foo<>::value>::type t;
|
||||
// t.bar();
|
||||
// }
|
||||
public void testVariadicNonTypeTemplateParameter_399039() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename...>
|
||||
// struct common_type;
|
||||
// template <typename T>
|
||||
// struct common_type<T> {
|
||||
// typedef int type;
|
||||
// };
|
||||
// template <typename T, typename... U>
|
||||
// struct common_type<T, U...> {
|
||||
// typedef int type;
|
||||
// };
|
||||
// typedef common_type<int>::type type;
|
||||
public void testClassTemplateSpecializationPartialOrdering_398044a() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename>
|
||||
// class A;
|
||||
// template <typename R, typename... Args>
|
||||
// class A<R(*)(Args...)> {
|
||||
// };
|
||||
// template <typename R>
|
||||
// class A<R*> {
|
||||
// };
|
||||
// int main() {
|
||||
// A<bool(*)()> mf;
|
||||
// }
|
||||
public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -95,7 +95,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class AST2BaseTest extends BaseTestCase {
|
||||
public class AST2TestBase extends BaseTestCase {
|
||||
public final static String TEST_CODE = "<testcode>";
|
||||
protected static final IParserLogService NULL_LOG = new NullLogService();
|
||||
protected static boolean sValidateCopy;
|
||||
|
@ -110,6 +110,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
map.put("__SIZEOF_SHORT__", "2");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
map.put("__SIZEOF_LONG__", "8");
|
||||
map.put("__SIZEOF_POINTER__", "8");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -118,17 +119,18 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
map.put("__SIZEOF_SHORT__", "2");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
map.put("__SIZEOF_LONG__", "8");
|
||||
map.put("__SIZEOF_POINTER__", "8");
|
||||
return map;
|
||||
}
|
||||
|
||||
public AST2BaseTest() {
|
||||
public AST2TestBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AST2BaseTest(String name) {
|
||||
|
||||
public AST2TestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
sValidateCopy= true;
|
||||
|
@ -138,7 +140,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
protected IASTTranslationUnit parse(String code, ParserLanguage lang) throws ParserException {
|
||||
return parse(code, lang, false, true);
|
||||
}
|
||||
|
||||
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||
return parse(code, lang, useGNUExtensions, true);
|
||||
}
|
||||
|
@ -147,10 +149,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
boolean expectNoProblems) throws ParserException {
|
||||
return parse(code, lang, useGNUExtensions, expectNoProblems, false);
|
||||
}
|
||||
|
||||
|
||||
protected IASTTranslationUnit parse(String code, ParserLanguage lang, boolean useGNUExtensions,
|
||||
boolean expectNoProblems, boolean skipTrivialInitializers) throws ParserException {
|
||||
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
IScanner scanner = createScanner(FileContent.create(TEST_CODE, code.toCharArray()), lang, ParserMode.COMPLETE_PARSE,
|
||||
createScannerInfo(useGNUExtensions));
|
||||
configureScanner(scanner);
|
||||
AbstractGNUSourceCodeParser parser = null;
|
||||
|
@ -170,12 +172,12 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
} else {
|
||||
config = new ANSICParserExtensionConfiguration();
|
||||
}
|
||||
|
||||
|
||||
parser = new GNUCSourceParser(scanner, ParserMode.COMPLETE_PARSE, NULL_LOG, config, null);
|
||||
}
|
||||
if (skipTrivialInitializers)
|
||||
parser.setSkipTrivialExpressionsInAggregateInitializers(true);
|
||||
|
||||
|
||||
IASTTranslationUnit tu = parser.parse();
|
||||
assertTrue(tu.isFrozen());
|
||||
if (sValidateCopy)
|
||||
|
@ -183,7 +185,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
if (parser.encounteredError() && expectNoProblems)
|
||||
throw new ParserException("FAILURE"); //$NON-NLS-1$
|
||||
|
||||
|
||||
if (lang == ParserLanguage.C && expectNoProblems) {
|
||||
assertEquals(CVisitor.getProblems(tu).length, 0);
|
||||
assertEquals(tu.getPreprocessorProblems().length, 0);
|
||||
|
@ -193,7 +195,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
if (expectNoProblems)
|
||||
assertEquals(0, tu.getPreprocessorProblems().length);
|
||||
|
||||
|
||||
return tu;
|
||||
}
|
||||
|
||||
|
@ -215,7 +217,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
configuration= GPPScannerExtensionConfiguration.getInstance(scannerInfo);
|
||||
}
|
||||
IScanner scanner;
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
scanner= new CPreprocessor(codeReader, scannerInfo, lang, NULL_LOG, configuration,
|
||||
IncludeFileContentProvider.getSavedFilesProvider());
|
||||
return scanner;
|
||||
}
|
||||
|
@ -263,7 +265,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
|
||||
protected void validateSimpleBinaryExpressionC(String code, int operand) throws ParserException {
|
||||
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
||||
IASTBinaryExpression e = (IASTBinaryExpression) getExpressionFromStatementInCode(code, ParserLanguage.C);
|
||||
assertNotNull(e);
|
||||
assertEquals(e.getOperator(), operand);
|
||||
IASTIdExpression x = (IASTIdExpression) e.getOperand1();
|
||||
|
@ -290,8 +292,8 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
ASTComparer.assertCopy(tu, copy);
|
||||
return (T) copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static protected class CNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -309,29 +311,35 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
return null;
|
||||
return nameList.get(idx);
|
||||
}
|
||||
|
||||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertInstances(CNameCollector collector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
|
||||
|
||||
assertNotNull(binding);
|
||||
|
||||
|
||||
for (int i = 0; i < collector.size(); i++) {
|
||||
if (collector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
assertEquals(count, num);
|
||||
}
|
||||
|
||||
static protected class CPPNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
public CPPNameCollector() {
|
||||
this(false); // don't visit implicit names by default
|
||||
}
|
||||
|
||||
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||
this.shouldVisitNames = true;
|
||||
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||
}
|
||||
|
||||
public List<IASTName> nameList = new ArrayList<IASTName>();
|
||||
|
||||
@Override
|
||||
|
@ -349,7 +357,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
|
||||
|
||||
public void dump() {
|
||||
for (int i= 0; i < size(); i++) {
|
||||
IASTName name= getName(i);
|
||||
|
@ -365,7 +373,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
if (collector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
assertEquals(num, count);
|
||||
}
|
||||
|
||||
|
@ -386,42 +394,42 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
String expressionString = ASTStringUtil.getExpressionString(exp);
|
||||
assertEquals(str, expressionString);
|
||||
}
|
||||
|
||||
|
||||
protected void isParameterSignatureEqual(IASTDeclarator decltor, String str) {
|
||||
assertTrue(decltor instanceof IASTFunctionDeclarator);
|
||||
final String[] sigArray = ASTStringUtil.getParameterSignatureArray((IASTFunctionDeclarator) decltor);
|
||||
assertEquals(str, "(" + ASTStringUtil.join(sigArray, ", ") + ")");
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTDeclarator declarator, String expected) {
|
||||
String signature= ASTStringUtil.getSignatureString(declarator);
|
||||
assertEquals(expected, signature);
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTDeclSpecifier declSpec, String str) {
|
||||
assertEquals(str, ASTStringUtil.getSignatureString(declSpec, null));
|
||||
}
|
||||
|
||||
|
||||
protected void isSignatureEqual(IASTTypeId typeId, String str) {
|
||||
assertEquals(str, ASTStringUtil.getSignatureString(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator()));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IASTDeclarator decltor, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(decltor));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IASTTypeId typeId, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(typeId));
|
||||
}
|
||||
|
||||
|
||||
protected void isTypeEqual(IType type, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getType(type));
|
||||
}
|
||||
|
||||
|
||||
protected void isParameterTypeEqual(IFunctionType fType, String str) {
|
||||
assertEquals(str, ASTTypeUtil.getParameterTypeString(fType));
|
||||
}
|
||||
|
||||
|
||||
static protected class CNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -449,9 +457,9 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static protected class CPPNameResolver extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -479,13 +487,13 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
|
||||
public int size() {
|
||||
return nameList.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String getAboveComment() throws IOException {
|
||||
return getContents(1)[0].toString();
|
||||
}
|
||||
|
||||
|
||||
protected CharSequence[] getContents(int sections) throws IOException {
|
||||
CTestPlugin plugin = CTestPlugin.getDefault();
|
||||
if (plugin == null)
|
||||
|
@ -502,14 +510,14 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
return clazz.cast(o);
|
||||
}
|
||||
|
||||
|
||||
protected static void assertField(IBinding binding, String fieldName, String ownerName) {
|
||||
assertInstance(binding, IField.class);
|
||||
assertEquals(fieldName, binding.getName());
|
||||
ICompositeType struct = ((IField) binding).getCompositeTypeOwner();
|
||||
assertEquals(ownerName, struct.getName());
|
||||
}
|
||||
|
||||
|
||||
protected class BindingAssertionHelper {
|
||||
protected IASTTranslationUnit tu;
|
||||
protected String contents;
|
||||
|
@ -562,7 +570,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IBinding binding= binding(section, len);
|
||||
if (binding instanceof IProblemBinding) {
|
||||
IProblemBinding problem= (IProblemBinding) binding;
|
||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||
fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
|
||||
}
|
||||
if (binding == null) {
|
||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||
|
@ -611,12 +619,12 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IASTName name = findImplicitName(section, len);
|
||||
final String selection = section.substring(0, len);
|
||||
assertNotNull("did not find \"" + selection + "\"", name);
|
||||
|
||||
|
||||
assertInstance(name, IASTImplicitName.class);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
assertNotNull(implicits);
|
||||
|
||||
|
||||
if (implicits.length > 1) {
|
||||
boolean found = false;
|
||||
for (IASTImplicitName n : implicits) {
|
||||
|
@ -627,34 +635,34 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
|
||||
|
||||
assertEquals(selection, name.getRawSignature());
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull(binding);
|
||||
assertInstance(binding, bindingClass);
|
||||
return (IASTImplicitName) name;
|
||||
}
|
||||
|
||||
|
||||
public void assertNoImplicitName(String section, int len) {
|
||||
IASTName name = findImplicitName(section, len);
|
||||
final String selection = section.substring(0, len);
|
||||
assertNull("found name \"" + selection + "\"", name);
|
||||
}
|
||||
|
||||
|
||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||
IASTName name = findImplicitName(section, len);
|
||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||
IASTImplicitName[] implicits = owner.getImplicitNames();
|
||||
return implicits;
|
||||
}
|
||||
|
||||
|
||||
public IASTName findName(String section, int len) {
|
||||
final int offset = contents.indexOf(section);
|
||||
assertTrue("Section \"" + section + "\" not found", offset >= 0);
|
||||
IASTNodeSelector selector = tu.getNodeSelector(null);
|
||||
return selector.findName(offset, len);
|
||||
}
|
||||
|
||||
|
||||
public IASTName findName(String context, String name) {
|
||||
if (context == null) {
|
||||
context = contents;
|
||||
|
@ -712,7 +720,7 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
}
|
||||
return "Unknown problem ID";
|
||||
}
|
||||
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class... cs) {
|
||||
if (len <= 0)
|
||||
len += section.length();
|
||||
|
@ -744,10 +752,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
final String selection = section.substring(0, len);
|
||||
assertNotNull("No AST name for \"" + selection + "\"", astName);
|
||||
assertEquals(selection, astName.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = astName.resolveBinding();
|
||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||
|
||||
|
||||
return astName.resolveBinding();
|
||||
}
|
||||
|
||||
|
@ -755,10 +763,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
IASTName astName = findName(context, name);
|
||||
assertNotNull("No AST name for \"" + name + "\"", astName);
|
||||
assertEquals(name, astName.getRawSignature());
|
||||
|
||||
|
||||
IBinding binding = astName.resolveBinding();
|
||||
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||
|
||||
|
||||
return astName.resolveBinding();
|
||||
}
|
||||
}
|
||||
|
@ -770,10 +778,10 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions) throws Exception {
|
||||
return parseAndCheckBindings(code, lang, useGnuExtensions, false);
|
||||
}
|
||||
|
||||
|
||||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang, boolean useGnuExtensions,
|
||||
boolean skipTrivialInitializers) throws Exception {
|
||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||
IASTTranslationUnit tu = parse(code, lang, useGnuExtensions, true, skipTrivialInitializers);
|
||||
CNameCollector col = new CNameCollector();
|
||||
tu.accept(col);
|
||||
assertNoProblemBindings(col);
|
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
public class AST2UtilOldTests extends AST2BaseTest {
|
||||
public class AST2UtilOldTests extends AST2TestBase {
|
||||
public AST2UtilOldTests() {
|
||||
}
|
||||
public AST2UtilOldTests(String name) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class AST2UtilTests extends AST2BaseTest {
|
||||
public class AST2UtilTests extends AST2TestBase {
|
||||
public AST2UtilTests() {
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
public class ASTCPPSpecDefectTests extends AST2BaseTest {
|
||||
public class ASTCPPSpecDefectTests extends AST2TestBase {
|
||||
|
||||
public ASTCPPSpecDefectTests() {
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* Testcases for inactive code in ast.
|
||||
*/
|
||||
public class ASTInactiveCodeTests extends AST2BaseTest {
|
||||
public class ASTInactiveCodeTests extends AST2TestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(ASTInactiveCodeTests.class);
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.ParserMode;
|
|||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
|
||||
public class ASTNodeSelectorTest extends AST2BaseTest {
|
||||
public class ASTNodeSelectorTest extends AST2TestBase {
|
||||
|
||||
static public TestSuite suite() {
|
||||
return suite(ASTNodeSelectorTest.class);
|
||||
|
@ -55,7 +55,7 @@ public class ASTNodeSelectorTest extends AST2BaseTest {
|
|||
fCode= getContents(1)[0].toString();
|
||||
FileContent codeReader = FileContent.create("<test-code>", fCode.toCharArray());
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, ParserLanguage.CPP, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
GNUCPPSourceParser parser= new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE, new NullLogService(), new GPPParserExtensionConfiguration());
|
||||
fTu= parser.parse();
|
||||
fSelector= fTu.getNodeSelector(null);
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
public class AccessControlTests extends AST2BaseTest {
|
||||
public class AccessControlTests extends AST2TestBase {
|
||||
|
||||
protected class AccessAssertionHelper extends BindingAssertionHelper {
|
||||
AccessAssertionHelper(String contents) throws ParserException {
|
||||
|
|
|
@ -13,22 +13,22 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
|||
import org.eclipse.cdt.core.dom.CDOM;
|
||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTest;
|
||||
import org.eclipse.cdt.core.parser.tests.FileBasePluginTestCase;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class CDOMBaseTest extends FileBasePluginTest {
|
||||
public class CDOMTestBase extends FileBasePluginTestCase {
|
||||
|
||||
public CDOMBaseTest() {
|
||||
public CDOMTestBase() {
|
||||
}
|
||||
|
||||
public CDOMBaseTest(String name) {
|
||||
public CDOMTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public CDOMBaseTest(String name, Class className) {
|
||||
public CDOMTestBase(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class CodeReaderCacheTest extends CDOMBaseTest {
|
||||
public class CodeReaderCacheTest extends CDOMTestBase {
|
||||
|
||||
public CodeReaderCacheTest() {
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
* @author Guido Zgraggen
|
||||
*
|
||||
*/
|
||||
public class CommentTests extends AST2BaseTest {
|
||||
public class CommentTests extends AST2TestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(CommentTests.class);
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -102,9 +103,13 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
static private class CPPNameCollector extends ASTVisitor {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
public CPPNameCollector() {
|
||||
this(false); // don't visit implicit names by default
|
||||
}
|
||||
public CPPNameCollector(boolean shouldVisitImplicitNames) {
|
||||
this.shouldVisitNames = true;
|
||||
this.shouldVisitImplicitNames = shouldVisitImplicitNames;
|
||||
}
|
||||
public List nameList = new ArrayList();
|
||||
@Override
|
||||
public int visit(IASTName name){
|
||||
|
@ -141,7 +146,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
|
||||
assertEquals(count, num);
|
||||
assertEquals(num, count);
|
||||
}
|
||||
protected void assertInstances(CNameCollector nameCollector, IBinding binding, int num) throws Exception {
|
||||
int count = 0;
|
||||
|
@ -149,7 +154,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
if (nameCollector.getName(i).resolveBinding() == binding)
|
||||
count++;
|
||||
|
||||
assertEquals(count, num);
|
||||
assertEquals(num, count);
|
||||
}
|
||||
protected IASTTranslationUnit parse(String code, boolean expectedToPass,
|
||||
ParserLanguage lang) throws Exception {
|
||||
|
@ -172,7 +177,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
ISourceCodeParser parser2 = null;
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
ICPPParserExtensionConfiguration config = null;
|
||||
if (gcc)
|
||||
|
@ -750,7 +755,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testConstructorChain() throws Exception {
|
||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||
IASTTranslationUnit tu = parse("int x = 5;\n class A \n{ public : \n int a; \n A() : a(x) { } };");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1053,7 +1058,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testScoping() throws Exception {
|
||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||
IASTTranslationUnit tu = parse("void foo() { int x = 3; if (x == 1) { int x = 4; } else int x = 2; }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1098,7 +1103,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
}
|
||||
|
||||
public void testBug42872() throws Exception {
|
||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||
IASTTranslationUnit tu = parse("struct B {}; struct D : B {}; void foo(D* dp) { B* bp = dynamic_cast<B*>(dp); }");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
|
@ -1112,14 +1117,14 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug43503A() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class SD_01 { void f_SD_01() {}}; int main(){ SD_01 * a = new SD_01(); a->f_SD_01(); } ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 8);
|
||||
assertEquals(col.size(), 9);
|
||||
ICPPClassType SD_01 = (ICPPClassType) col.getName(0).resolveBinding();
|
||||
ICPPMethod f_SD_01 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||
ICPPConstructor ctor = SD_01.getConstructors()[0];
|
||||
assertInstances(col, SD_01, 2);
|
||||
assertInstances(col, SD_01, 3);
|
||||
assertInstances(col, ctor, 1);
|
||||
assertInstances(col, f_SD_01, 2);
|
||||
}
|
||||
|
@ -1204,10 +1209,10 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buff.append("} \n");
|
||||
IASTTranslationUnit tu = parse(buff.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 17);
|
||||
assertEquals(col.size(), 18);
|
||||
ICompositeType SD_02 = (ICompositeType) col.getName(0).resolveBinding();
|
||||
ICPPMethod f_SD_02 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||
ICPPClassType SD_01 = (ICPPClassType) col.getName(2).resolveBinding();
|
||||
|
@ -1217,7 +1222,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
assertInstances(col, SD_02, 2);
|
||||
assertInstances(col, f_SD_02, 2);
|
||||
assertInstances(col, SD_01, 3);
|
||||
assertInstances(col, SD_01, 4);
|
||||
assertInstances(col, ctor, 1);
|
||||
assertInstances(col, next, 2);
|
||||
assertInstances(col, f_SD_01, 4);
|
||||
|
@ -1268,10 +1273,10 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug44342() throws Exception {
|
||||
IASTTranslationUnit tu = parse("class A { void f(){} void f(int){} }; int main(){ A * a = new A(); a->f();} ");
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 10);
|
||||
assertEquals(col.size(), 11);
|
||||
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
||||
ICPPMethod f1 = (ICPPMethod) col.getName(1).resolveBinding();
|
||||
ICPPMethod f2 = (ICPPMethod) col.getName(2).resolveBinding();
|
||||
|
@ -1279,7 +1284,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
ICPPConstructor ctor = A.getConstructors()[0];
|
||||
IVariable a = (IVariable) col.getName(6).resolveBinding();
|
||||
|
||||
assertInstances(col, A, 2);
|
||||
assertInstances(col, A, 3);
|
||||
assertInstances(col, f1, 2);
|
||||
assertInstances(col, f2, 1);
|
||||
assertInstances(col, ctor, 1);
|
||||
|
@ -1288,7 +1293,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testCDesignatedInitializers() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("struct Inner { int a,b,c; };");
|
||||
buffer.append("struct Inner { int a,b,c; };");
|
||||
buffer.append("struct A { int x; int y[]; struct Inner innerArray[]; int z[]; };");
|
||||
buffer.append("struct A myA = { .x = 4, .y[3] = 4, .y[4] = 3, .innerArray[0].a = 3, .innerArray[1].b = 5, .innerArray[2].c=6, .z = { 1,4,5} };");
|
||||
parse(buffer.toString(), true, ParserLanguage.C);
|
||||
|
@ -1314,7 +1319,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
" _Bool b; " +
|
||||
" f(b);" +
|
||||
" f(g((_Bool) 1) );" +
|
||||
"}",
|
||||
"}",
|
||||
true, ParserLanguage.C);
|
||||
}
|
||||
|
||||
|
@ -1337,7 +1342,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug44925() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append("class MyClass { };");
|
||||
buffer.append("class MyClass { };");
|
||||
buffer.append("class MyClass myObj1;");
|
||||
buffer.append("enum MyEnum { Item1 };");
|
||||
buffer.append("enum MyEnum myObj2;");
|
||||
|
@ -1420,23 +1425,23 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
buffer.append("void main() { N::A * a = new N::A(); a->f(); } ");
|
||||
IASTTranslationUnit tu = parse(buffer.toString());
|
||||
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
CPPNameCollector col = new CPPNameCollector(true);
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals(col.size(), 13);
|
||||
assertEquals(col.size(), 14);
|
||||
ICPPNamespace N = (ICPPNamespace) col.getName(0).resolveBinding();
|
||||
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding();
|
||||
|
||||
ICPPConstructor ctor = A.getConstructors()[0];
|
||||
|
||||
IProblemBinding fp = (IProblemBinding) col.getName(12).resolveBinding();
|
||||
IProblemBinding fp = (IProblemBinding) col.getName(13).resolveBinding();
|
||||
assertEquals(fp.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
|
||||
assertInstances(col, N, 3);
|
||||
assertInstances(col, f, 1);
|
||||
assertInstances(col, A, 3);
|
||||
assertInstances(col, ctor, 2);
|
||||
assertInstances(col, A, 5);
|
||||
assertInstances(col, ctor, 1);
|
||||
}
|
||||
|
||||
public void testBug43110() throws Exception {
|
||||
|
@ -1994,7 +1999,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("int main(int argc, char **argv) {\n");
|
||||
writer.write("FILE * file = 0;\n");
|
||||
writer.write("static_function(file);\n");
|
||||
writer.write("return 0;\n");
|
||||
writer.write("return 0;\n");
|
||||
writer.write("}\n");
|
||||
parse(writer.toString());
|
||||
}
|
||||
|
@ -2046,8 +2051,8 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
writer.write("};\n");
|
||||
writer.write("\n");
|
||||
writer.write("template<typename T>\n");
|
||||
writer.write("inline T526026< T >\n");
|
||||
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
||||
writer.write("inline T526026< T >\n");
|
||||
writer.write("operator+(typename T526026<T>::diff d, const T526026<T> & x)\n");
|
||||
writer.write("{ return T526026< T >(); }\n");
|
||||
writer.write("}\n");
|
||||
parse(writer.toString(), false);
|
||||
|
@ -2055,7 +2060,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug71094() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write("using namespace DOESNOTEXIST;\n");
|
||||
writer.write("using namespace DOESNOTEXIST;\n");
|
||||
writer.write("class A { int x; };\n");
|
||||
parse(writer.toString(), false);
|
||||
}
|
||||
|
@ -2223,7 +2228,7 @@ public class CompleteParser2Tests extends BaseTestCase {
|
|||
|
||||
public void testBug74328() throws Exception {
|
||||
Writer writer = new StringWriter();
|
||||
writer.write("int\n");
|
||||
writer.write("int\n");
|
||||
writer.write("main(int argc, char **argv) {\n");
|
||||
writer.write(" char *sign;\n");
|
||||
writer.write("sign = \"\"; // IProblem generated here, syntax error\n");
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseBaseTest {
|
||||
public class DOMGCCSelectionParseExtensionsTest extends DOMSelectionParseTestBase {
|
||||
|
||||
public DOMGCCSelectionParseExtensionsTest() {
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.core.runtime.content.IContentType;
|
|||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
|
||||
public class DOMLocationInclusionTests extends AST2FileBasePluginTestCase {
|
||||
|
||||
public DOMLocationInclusionTests() {
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
public class DOMLocationMacroTests extends AST2BaseTest {
|
||||
public class DOMLocationMacroTests extends AST2TestBase {
|
||||
|
||||
final ParserLanguage[] languages = new ParserLanguage[] { ParserLanguage.C, ParserLanguage.CPP };
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class DOMLocationTests extends AST2BaseTest {
|
||||
public class DOMLocationTests extends AST2TestBase {
|
||||
|
||||
public DOMLocationTests() {
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
* @author Emanuel Graf
|
||||
*
|
||||
*/
|
||||
public class DOMPreprocessorInformationTest extends AST2BaseTest {
|
||||
public class DOMPreprocessorInformationTest extends AST2TestBase {
|
||||
|
||||
public void testPragma() throws Exception {
|
||||
String msg = "GCC poison printf sprintf fprintf";
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,16 +23,16 @@ import org.eclipse.core.resources.IFile;
|
|||
* @author johnc
|
||||
*
|
||||
*/
|
||||
public class DOMSelectionParseBaseTest extends DOMFileBasePluginTest {
|
||||
public class DOMSelectionParseTestBase extends DOMFileBasePluginTest {
|
||||
|
||||
public DOMSelectionParseBaseTest() {
|
||||
public DOMSelectionParseTestBase() {
|
||||
}
|
||||
|
||||
public DOMSelectionParseBaseTest(String name) {
|
||||
public DOMSelectionParseTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public DOMSelectionParseBaseTest(String name, Class className) {
|
||||
public DOMSelectionParseTestBase(String name, Class className) {
|
||||
super(name, className);
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* Testcases related to recovery from invalid syntax.
|
||||
*/
|
||||
public class FaultToleranceTests extends AST2BaseTest {
|
||||
public class FaultToleranceTests extends AST2TestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(FaultToleranceTests.class);
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
|||
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
||||
public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
||||
public class GCCCompleteParseExtensionsTest extends AST2TestBase {
|
||||
|
||||
public GCCCompleteParseExtensionsTest() {
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class GCCTests extends AST2BaseTest {
|
||||
public class GCCTests extends AST2TestBase {
|
||||
|
||||
public GCCTests() {
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class ImageLocationTests extends AST2BaseTest {
|
||||
public class ImageLocationTests extends AST2TestBase {
|
||||
|
||||
private static final int CODE = IASTImageLocation.REGULAR_CODE;
|
||||
private static final int MACRO = IASTImageLocation.MACRO_DEFINITION;
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor;
|
|||
/**
|
||||
* Testcases for non-gnu language extensions.
|
||||
*/
|
||||
public class LanguageExtensionsTest extends AST2BaseTest {
|
||||
public class LanguageExtensionsTest extends AST2TestBase {
|
||||
|
||||
protected static final int SIZEOF_EXTENSION = 0x1;
|
||||
protected static final int FUNCTION_STYLE_ASM = 0x2;
|
||||
|
|
|
@ -1335,7 +1335,7 @@ public class QuickParser2Tests extends TestCase {
|
|||
ParserLanguage lang, boolean gcc) throws Exception {
|
||||
FileContent codeReader = FileContent.create("<test-code>", code.toCharArray());
|
||||
IScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
ISourceCodeParser parser2 = null;
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
ICPPParserExtensionConfiguration config = null;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|||
/**
|
||||
* Directly tests parts of the semantics package
|
||||
*/
|
||||
public class SemanticsTests extends AST2BaseTest {
|
||||
public class SemanticsTests extends AST2TestBase {
|
||||
|
||||
public SemanticsTests() {}
|
||||
public SemanticsTests(String name) { super(name); }
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.TodoTaskParser.Task;
|
||||
|
||||
public class TaskParserTest extends AST2BaseTest {
|
||||
public class TaskParserTest extends AST2TestBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(TaskParserTest.class);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Nathan Ridge.
|
||||
* 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:
|
||||
* Nathan Ridge - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
||||
public class TestUtil {
|
||||
/**
|
||||
* Searches the AST upward from the given starting node to find the
|
||||
* nearest IASTImplicitNameOwner and returns its first implicit name,
|
||||
* or null if it has no implicit names.
|
||||
*/
|
||||
public static IASTName findImplicitName(IASTNode node) {
|
||||
while (node != null) {
|
||||
if (node instanceof IASTImplicitNameOwner) {
|
||||
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) node).getImplicitNames();
|
||||
if (implicitNames != null && implicitNames.length > 0) {
|
||||
return implicitNames[0];
|
||||
}
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
|||
/**
|
||||
* Tests for ClassTypeHelper class.
|
||||
*/
|
||||
public class TypeTraitsTests extends AST2BaseTest {
|
||||
public class TypeTraitsTests extends AST2TestBase {
|
||||
|
||||
public TypeTraitsTests() {
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
|||
/**
|
||||
* Unit tests for CPPVariableReadWriteFlags and CVariableReadWriteFlags classes.
|
||||
*/
|
||||
public class VariableReadWriteFlagsTest extends AST2BaseTest {
|
||||
public class VariableReadWriteFlagsTest extends AST2TestBase {
|
||||
private static final int READ = PDOMName.READ_ACCESS;
|
||||
private static final int WRITE = PDOMName.WRITE_ACCESS;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
|
@ -53,7 +53,7 @@ public class CompletionTestBase extends BaseTestCase {
|
|||
protected IASTCompletionNode getCompletionNode(String code, ParserLanguage lang, boolean useGNUExtensions) throws ParserException {
|
||||
FileContent codeReader = FileContent.create("<test-code>", code.trim().toCharArray());
|
||||
ScannerInfo scannerInfo = new ScannerInfo();
|
||||
IScanner scanner= AST2BaseTest.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner= AST2TestBase.createScanner(codeReader, lang, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
||||
ISourceCodeParser parser = null;
|
||||
if( lang == ParserLanguage.CPP )
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteBaseTest;
|
||||
import org.eclipse.cdt.core.parser.tests.rewrite.TestHelper;
|
||||
import org.eclipse.cdt.core.parser.tests.rewrite.TestSourceFile;
|
||||
|
@ -95,7 +95,7 @@ public class ASTWriterTest extends RewriteBaseTest {
|
|||
ParserLanguage language = getLanguage(testFile);
|
||||
boolean useGNUExtensions = getGNUExtension(testFile);
|
||||
|
||||
IScanner scanner = AST2BaseTest.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
IScanner scanner = AST2TestBase.createScanner(codeReader, language, ParserMode.COMPLETE_PARSE, scannerInfo);
|
||||
|
||||
ISourceCodeParser parser = null;
|
||||
if (language == ParserLanguage.CPP) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2012 Symbian Software Systems and others.
|
||||
* Copyright (c) 2006, 2013 Symbian 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
|
||||
|
@ -10,6 +10,7 @@
|
|||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -83,7 +84,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
protected IASTName findName(String section, int len) {
|
||||
protected IASTName findName(String section, int len, boolean preferImplicitName) {
|
||||
if (len == 0)
|
||||
len= section.length();
|
||||
for (int i = 0; i < strategy.getAstCount(); i++) {
|
||||
|
@ -91,15 +92,27 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||
final int offset = strategy.getAstSource(i).indexOf(section);
|
||||
if (offset >= 0) {
|
||||
IASTName name= nodeSelector.findName(offset, len);
|
||||
if (name == null)
|
||||
name= nodeSelector.findImplicitName(offset, len);
|
||||
return name;
|
||||
if (preferImplicitName) {
|
||||
return nodeSelector.findImplicitName(offset, len);
|
||||
} else {
|
||||
IASTName name= nodeSelector.findName(offset, len);
|
||||
if (name == null)
|
||||
name= nodeSelector.findImplicitName(offset, len);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected IASTName findName(String section, int len) {
|
||||
return findName(section, len, false);
|
||||
}
|
||||
|
||||
protected IASTName findImplicitName(String section, int len) {
|
||||
return findName(section, len, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get an IBinding from the initial specified number of characters
|
||||
|
@ -129,9 +142,37 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
assertInstance(binding, clazz, cs);
|
||||
return clazz.cast(binding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get an IBinding attached to an implicit name from the initial specified
|
||||
* number of characters from the specified code fragment. Fails the test if
|
||||
* <ul>
|
||||
* <li> There is not a unique implicit name with the specified criteria
|
||||
* <li> The binding associated with the implicit name is null or a problem binding
|
||||
* <li> The binding is not an instance of the specified class
|
||||
* </ul>
|
||||
* @param section the code fragment to search for in the AST. The first occurrence of an identical section is used.
|
||||
* @param len the length of the specified section to use as a name
|
||||
* @param clazz an expected class type or interface that the binding should extend/implement
|
||||
* @return the associated implicit name's binding
|
||||
*/
|
||||
protected <T> T getBindingFromImplicitASTName(String section, int len, Class<T> clazz, Class ... cs) {
|
||||
if (len < 1) {
|
||||
len= section.length()+len;
|
||||
}
|
||||
IASTName name= findImplicitName(section, len);
|
||||
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||
assertInstance(binding, clazz, cs);
|
||||
return clazz.cast(binding);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IndexBindingResolutionTestBase#getBindingFromASTName(Class, String, int)
|
||||
* @see IndexBindingResolutionTestBase#getBindingFromASTName(String, int, Class<T>, Class ...)
|
||||
*/
|
||||
protected <T extends IBinding> T getBindingFromASTName(String section, int len) {
|
||||
if (len <= 0)
|
||||
|
@ -146,6 +187,23 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||
return (T) binding;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IndexBindingResolutionTestBase#getBindingFromImplicitASTName(String, int, Class<T>, Class ...)
|
||||
*/
|
||||
protected <T extends IBinding> T getBindingFromImplicitASTName(String section, int len) {
|
||||
if (len <= 0)
|
||||
len += section.length();
|
||||
|
||||
IASTName name= findImplicitName(section, len);
|
||||
assertNotNull("Name not found for \"" + section + "\"", name);
|
||||
assertEquals(section.substring(0, len), name.getRawSignature());
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||
assertFalse("Binding is a ProblemBinding for name \"" + name.getRawSignature() + "\"", IProblemBinding.class.isAssignableFrom(name.resolveBinding().getClass()));
|
||||
return (T) binding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to verify that the resolved binding for a name is a problem binding.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -42,20 +43,20 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
public ProjectWithDepProj() { setStrategy(new ReferencedProject(false)); }
|
||||
public static TestSuite suite() { return suite(ProjectWithDepProj.class); }
|
||||
}
|
||||
|
||||
public static void addTests(TestSuite suite) {
|
||||
|
||||
public static void addTests(TestSuite suite) {
|
||||
suite.addTest(SingleProject.suite());
|
||||
suite.addTest(ProjectWithDepProj.suite());
|
||||
}
|
||||
|
||||
// #include <stdio.h>
|
||||
// #include <stdio.h>
|
||||
// void func1(void) {
|
||||
// int i = 0;
|
||||
// for (i=0; i<10;i++) {
|
||||
// printf("%i", i);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
//
|
||||
// int main(void) {
|
||||
|
@ -77,7 +78,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
}
|
||||
|
||||
// void func1(void);
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
//
|
||||
// int main(void) {
|
||||
|
@ -87,7 +88,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
IBinding b0 = getBindingFromASTName("func1;", 5);
|
||||
assertTrue(b0 instanceof IFunction);
|
||||
}
|
||||
|
||||
|
||||
// typedef struct {
|
||||
// int utm;
|
||||
// } usertype;
|
||||
|
@ -132,7 +133,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertInstance(type, IEnumeration.class);
|
||||
assertTrue(type instanceof IEnumeration);
|
||||
}
|
||||
|
||||
|
||||
// int globalVar;
|
||||
|
||||
// // don't include header
|
||||
|
@ -268,10 +269,10 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
e= (IEnumeration) b1;
|
||||
ei= e.getEnumerators();
|
||||
assertEquals(1, ei.length);
|
||||
}
|
||||
}
|
||||
|
||||
// // no header needed
|
||||
|
||||
|
||||
// typedef struct {
|
||||
// int member;
|
||||
// } t_struct;
|
||||
|
@ -289,7 +290,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(tdIndex instanceof IIndexBinding);
|
||||
assertTrue(tdAST instanceof ITypedef);
|
||||
assertTrue(tdIndex instanceof ITypedef);
|
||||
|
||||
|
||||
IType tAST= ((ITypedef) tdAST).getType();
|
||||
IType tIndex= ((ITypedef) tdIndex).getType();
|
||||
assertTrue(tAST instanceof ICompositeType);
|
||||
|
@ -304,7 +305,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(tdIndex instanceof IIndexBinding);
|
||||
assertTrue(tdAST instanceof ITypedef);
|
||||
assertTrue(tdIndex instanceof ITypedef);
|
||||
|
||||
|
||||
tAST= ((ITypedef) tdAST).getType();
|
||||
tIndex= ((ITypedef) tdIndex).getType();
|
||||
assertTrue(tAST instanceof ICompositeType);
|
||||
|
@ -319,7 +320,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(tdIndex instanceof IIndexBinding);
|
||||
assertTrue(tdAST instanceof ITypedef);
|
||||
assertTrue(tdIndex instanceof ITypedef);
|
||||
|
||||
|
||||
tAST= ((ITypedef) tdAST).getType();
|
||||
tIndex= ((ITypedef) tdIndex).getType();
|
||||
assertTrue(tAST instanceof IEnumeration);
|
||||
|
@ -327,13 +328,13 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(tAST.isSameType(tIndex));
|
||||
assertTrue(tIndex.isSameType(tAST));
|
||||
}
|
||||
|
||||
|
||||
// struct outer {
|
||||
// union {
|
||||
// int var1;
|
||||
// };
|
||||
// };
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// struct outer x;
|
||||
|
@ -354,7 +355,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
// int var1;
|
||||
// };
|
||||
// };
|
||||
|
||||
|
||||
// #include "header.h"
|
||||
// void test() {
|
||||
// union outer x;
|
||||
|
@ -369,14 +370,14 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(outer instanceof ICCompositeTypeScope);
|
||||
assertEquals("outer", outer.getScopeName().toString());
|
||||
}
|
||||
|
||||
|
||||
// int myFunc();
|
||||
|
||||
|
||||
// int myFunc(var)
|
||||
// int var;
|
||||
// {
|
||||
// return var;
|
||||
// }
|
||||
// int var;
|
||||
// {
|
||||
// return var;
|
||||
// }
|
||||
// int main(void) {
|
||||
// return myFunc(0);
|
||||
// }
|
||||
|
@ -390,7 +391,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
assertTrue(params[0].getType() instanceof IBasicType);
|
||||
assertEquals(IBasicType.Kind.eInt, ((IBasicType) params[0].getType()).getKind());
|
||||
}
|
||||
|
||||
|
||||
// typedef struct S S;
|
||||
// void setValue(S *pSelf, int value);
|
||||
|
||||
|
@ -404,7 +405,7 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
IBinding b = getBindingFromASTName("value =", 5);
|
||||
assertTrue(b instanceof IField);
|
||||
}
|
||||
|
||||
|
||||
// void f255(
|
||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||
|
@ -439,8 +440,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int,
|
||||
// int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int);
|
||||
|
||||
// void test() {
|
||||
|
||||
// void test() {
|
||||
// f255(
|
||||
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
|
@ -463,8 +464,8 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
public void testFunctionsWithManyParameters_Bug319186() throws Exception {
|
||||
getBindingFromASTName("f255", 0);
|
||||
getBindingFromASTName("f256", 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// struct B {
|
||||
// float f;
|
||||
// };
|
||||
|
@ -474,5 +475,17 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
|||
// };
|
||||
public void testDesignatedInitializer_Bug210019() throws Exception {
|
||||
IField f= getBindingFromASTName("f", 0);
|
||||
}
|
||||
}
|
||||
|
||||
// struct S {
|
||||
// int data;
|
||||
// };
|
||||
|
||||
// void test(void (*f)(void*)) {
|
||||
// struct S *i;
|
||||
// f(&i->data);
|
||||
// }
|
||||
public void testBug394151() throws Exception {
|
||||
IParameter f= getBindingFromASTName("f(", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2013 Symbian 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -1490,9 +1491,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
assertFalse(b0 instanceof IIndexBinding);
|
||||
ICPPConstructor b1 = getBindingFromASTName("B(int x)", 1, ICPPConstructor.class);
|
||||
assertFalse(b1 instanceof IIndexBinding);
|
||||
ICPPConstructor b2 = getBindingFromASTName("B(0)", 1, ICPPConstructor.class);
|
||||
assertFalse(b2 instanceof IIndexBinding);
|
||||
assertEquals(b1, b2);
|
||||
ICPPClassType b2 = getBindingFromASTName("B(0)", 1, ICPPClassType.class);
|
||||
ICPPMethod b3 = getBindingFromASTName("m(0)", 1, ICPPMethod.class);
|
||||
assertFalse(b3 instanceof IIndexBinding);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2012 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2013 Symbian 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
|
||||
|
@ -300,7 +300,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// X<A> xa= new X<A>();
|
||||
// }
|
||||
public void testUnindexedConstructorInstance() {
|
||||
IBinding b0= getBindingFromASTName("X<A>()", 4);
|
||||
IBinding b0= getBindingFromImplicitASTName("X<A>()", 4);
|
||||
assertInstance(b0, ICPPConstructor.class);
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
// assertEquals(3, _ctcs.length); // two implicit plus the constructor template
|
||||
|
||||
IBinding b2= getBindingFromASTName("D<int>(", 1);
|
||||
IBinding b3= getBindingFromASTName("D<int>(", 6);
|
||||
IBinding b3= getBindingFromImplicitASTName("D<int>(", 6);
|
||||
|
||||
assertInstance(b2, ICPPClassTemplate.class); // *D*<int>(5, 6)
|
||||
assertInstance(b2, ICPPClassType.class); // *D*<int>(5, 6)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 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
|
||||
|
@ -45,6 +45,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeOfDependentExpression;
|
||||
|
||||
/**
|
||||
* This is a utility class to help convert AST elements to Strings corresponding to
|
||||
|
@ -408,6 +409,8 @@ public class ASTTypeUtil {
|
|||
|
||||
IQualifierType qt= (IQualifierType) type;
|
||||
needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile(), false);
|
||||
} else if (type instanceof TypeOfDependentExpression) {
|
||||
result.append(((TypeOfDependentExpression) type).getSignature());
|
||||
} else if (type instanceof ISemanticProblem) {
|
||||
result.append('?');
|
||||
} else if (type != null) {
|
||||
|
@ -584,7 +587,7 @@ public class ASTTypeUtil {
|
|||
if (parenthesis == null) {
|
||||
parenthesis= new BitSet();
|
||||
}
|
||||
parenthesis.set(postfix.size()-1);
|
||||
parenthesis.set(postfix.size() - 1);
|
||||
}
|
||||
appendTypeString(tj, normalize, result);
|
||||
needParenthesis= false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -33,11 +34,11 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
|||
setName(name);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
protected void copyAbstractEnumerator(ASTEnumerator copy, CopyStyle style) {
|
||||
|
||||
protected <T extends ASTEnumerator> T copy(T copy, CopyStyle style) {
|
||||
copy.setName(name == null ? null : name.copy(style));
|
||||
copy.setValue(value == null ? null : value.copy(style));
|
||||
copy.setOffsetAndLength(this);
|
||||
return super.copy(copy, style);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,23 +126,26 @@ public abstract class ASTEnumerator extends ASTNode implements IASTEnumerator, I
|
|||
}
|
||||
|
||||
private void createEnumValues(IASTEnumerationSpecifier parent) {
|
||||
IValue previousExplicitValue = null;
|
||||
int delta = 0;
|
||||
IASTEnumerator[] etors= parent.getEnumerators();
|
||||
long cv= -1;
|
||||
boolean isknown= true;
|
||||
for (IASTEnumerator etor : etors) {
|
||||
cv++;
|
||||
IValue val;
|
||||
IASTExpression expr= etor.getValue();
|
||||
if (expr != null) {
|
||||
IValue val= Value.create(expr, Value.MAX_RECURSION_DEPTH);
|
||||
Long nv= val.numericalValue();
|
||||
isknown= false;
|
||||
if (nv != null) {
|
||||
isknown= true;
|
||||
cv= nv.longValue();
|
||||
val= Value.create(expr, Value.MAX_RECURSION_DEPTH);
|
||||
previousExplicitValue = val;
|
||||
delta = 1;
|
||||
} else {
|
||||
if (previousExplicitValue != null) {
|
||||
val = Value.incrementedValue(previousExplicitValue, delta);
|
||||
} else {
|
||||
val = Value.create(delta);
|
||||
}
|
||||
delta++;
|
||||
}
|
||||
if (etor instanceof ASTEnumerator) {
|
||||
((ASTEnumerator) etor).integralValue= isknown ? Value.create(cv) : Value.UNKNOWN;
|
||||
((ASTEnumerator) etor).integralValue= val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 Google, Inc and others.
|
||||
* Copyright (c) 2011, 2013 Google, Inc 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -129,7 +130,11 @@ public class SizeofCalculator {
|
|||
sizeof_long_long = getSize(sizeofMacros, "__SIZEOF_LONG_LONG__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_int128 = getSize(sizeofMacros, "__SIZEOF_INT128__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_short = getSize(sizeofMacros, "__SIZEOF_SHORT__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_bool = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$
|
||||
SizeAndAlignment size = getSize(sizeofMacros, "__SIZEOF_BOOL__", maxAlignment); //$NON-NLS-1$
|
||||
// __SIZEOF_BOOL__ is not defined by GCC but sizeof(bool) is needed for template resolution.
|
||||
if (size == null)
|
||||
size = SIZE_1;
|
||||
sizeof_bool = size;
|
||||
sizeof_wchar_t = getSize(sizeofMacros, "__SIZEOF_WCHAR_T__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_float = getSize(sizeofMacros, "__SIZEOF_FLOAT__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_complex_float = getSizeOfPair(sizeof_float);
|
||||
|
@ -152,7 +157,7 @@ public class SizeofCalculator {
|
|||
sizeof_long_long = null;
|
||||
sizeof_int128 = size_16;
|
||||
sizeof_short = null;
|
||||
sizeof_bool = null;
|
||||
sizeof_bool = SIZE_1;
|
||||
sizeof_wchar_t = null;
|
||||
sizeof_float = null;
|
||||
sizeof_complex_float = null;
|
||||
|
@ -178,7 +183,12 @@ public class SizeofCalculator {
|
|||
if (type instanceof IBasicType) {
|
||||
return sizeAndAlignment((IBasicType) type);
|
||||
}
|
||||
if (type instanceof IPointerType || type instanceof ICPPReferenceType) {
|
||||
// [expr.sizeof]/2: "When applied to a reference or a reference type, the
|
||||
// result is the size of the referenced type."
|
||||
if (type instanceof ICPPReferenceType) {
|
||||
return sizeAndAlignment(((ICPPReferenceType) type).getType());
|
||||
}
|
||||
if (type instanceof IPointerType) {
|
||||
if (type instanceof ICPPPointerToMemberType)
|
||||
return null;
|
||||
return sizeof_pointer;
|
||||
|
@ -310,14 +320,24 @@ public class SizeofCalculator {
|
|||
if (field.isStatic())
|
||||
continue;
|
||||
IType fieldType = field.getType();
|
||||
SizeAndAlignment info = sizeAndAlignment(fieldType);
|
||||
SizeAndAlignment info;
|
||||
// sizeof() on a reference type returns the size of the referenced type.
|
||||
// However, a reference field in a structure only occupies as much space
|
||||
// as a pointer.
|
||||
if (fieldType instanceof ICPPReferenceType) {
|
||||
info = sizeof_pointer;
|
||||
} else {
|
||||
info = sizeAndAlignment(fieldType);
|
||||
}
|
||||
if (info == null)
|
||||
return null;
|
||||
if (union) {
|
||||
if (size < info.size)
|
||||
size = info.size;
|
||||
} else {
|
||||
size += info.alignment - (size - 1) % info.alignment - 1 + info.size;
|
||||
if (size > 0)
|
||||
size += info.alignment - (size - 1) % info.alignment - 1;
|
||||
size += info.size;
|
||||
}
|
||||
if (maxAlignment < info.alignment)
|
||||
maxAlignment = info.alignment;
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
||||
|
@ -53,16 +54,20 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
|
@ -77,6 +82,7 @@ public class Value implements IValue {
|
|||
public static final int MAX_RECURSION_DEPTH = 25;
|
||||
public static final Value UNKNOWN= new Value("<unknown>".toCharArray(), null); //$NON-NLS-1$
|
||||
public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$
|
||||
private static final IType INT_TYPE= new CPPBasicType(ICPPBasicType.Kind.eInt, 0);
|
||||
|
||||
private static final Number VALUE_CANNOT_BE_DETERMINED = new Number() {
|
||||
@Override
|
||||
|
@ -271,6 +277,16 @@ public class Value implements IValue {
|
|||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public static IValue incrementedValue(IValue value, int increment) {
|
||||
Long val = value.numericalValue();
|
||||
if (val != null) {
|
||||
return create(val.longValue() + increment);
|
||||
}
|
||||
ICPPEvaluation arg1 = value.getEvaluation();
|
||||
EvalFixed arg2 = new EvalFixed(INT_TYPE, ValueCategory.PRVALUE, create(increment));
|
||||
return create(new EvalBinary(IASTBinaryExpression.op_plus, arg1, arg2));
|
||||
}
|
||||
|
||||
private static Number applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
|
||||
switch (operator) {
|
||||
case op_sizeof:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2007, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -191,7 +192,7 @@ public abstract class VariableReadWriteFlags {
|
|||
final IType type= functionNameExpression.getExpressionType();
|
||||
if (type instanceof IFunctionType) {
|
||||
return rwArgumentForFunctionCall((IFunctionType) type, i, indirection);
|
||||
} else {
|
||||
} else if (funcCall instanceof IASTImplicitNameOwner) {
|
||||
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) funcCall).getImplicitNames();
|
||||
if (implicitNames.length == 1) {
|
||||
IASTImplicitName name = implicitNames[0];
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -34,11 +34,6 @@ public class CASTEnumerator extends ASTEnumerator {
|
|||
|
||||
@Override
|
||||
public CASTEnumerator copy(CopyStyle style) {
|
||||
CASTEnumerator copy = new CASTEnumerator();
|
||||
copyAbstractEnumerator(copy, style);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(new CASTEnumerator(), style);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2011 Symbian Software Systems and others.
|
||||
* Copyright (c) 2008, 2013 Symbian 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* Andrew Ferguson (Symbian) - Initial Implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* IBM Corporation
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -68,12 +69,18 @@ public class CPPASTAmbiguousTemplateArgument extends ASTAmbiguousNode implements
|
|||
name.setBinding(null);
|
||||
namedTypeSpec.setName(name);
|
||||
}
|
||||
} else if (node instanceof IASTIdExpression) {
|
||||
IASTIdExpression id= (IASTIdExpression) node;
|
||||
final IASTName name = id.getName();
|
||||
name.setBinding(null);
|
||||
id.setName(name);
|
||||
}
|
||||
} else {
|
||||
// Unwrap variadic pack expansion if necessary.
|
||||
if (node instanceof ICPPASTPackExpansionExpression)
|
||||
node= ((ICPPASTPackExpansionExpression) node).getPattern();
|
||||
|
||||
if (node instanceof IASTIdExpression) {
|
||||
IASTIdExpression id= (IASTIdExpression) node;
|
||||
final IASTName name = id.getName();
|
||||
name.setBinding(null);
|
||||
id.setName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -124,7 +124,7 @@ public class CPPASTBinaryTypeIdExpression extends ASTNode implements ICPPASTExpr
|
|||
fEvaluation= EvalFixed.INCOMPLETE;
|
||||
} else {
|
||||
IType t1= CPPVisitor.createType(fOperand1);
|
||||
IType t2= CPPVisitor.createType(fOperand1);
|
||||
IType t2= CPPVisitor.createType(fOperand2);
|
||||
if (t1 == null || t2 == null) {
|
||||
fEvaluation= EvalFixed.INCOMPLETE;
|
||||
} else {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* John Camelon (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -35,11 +35,6 @@ public class CPPASTEnumerator extends ASTEnumerator {
|
|||
|
||||
@Override
|
||||
public CPPASTEnumerator copy(CopyStyle style) {
|
||||
CPPASTEnumerator copy = new CPPASTEnumerator();
|
||||
copyAbstractEnumerator(copy, style);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
return copy(new CPPASTEnumerator(), style);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2013 Wind River Systems, Inc. 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:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Natan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
@ -74,7 +76,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
|
|||
} else {
|
||||
type= new CPPParameterPackType(type);
|
||||
}
|
||||
fEvaluation= new EvalFixed(type, PRVALUE, Value.UNKNOWN);
|
||||
fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
|
||||
}
|
||||
return fEvaluation;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -47,8 +48,10 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
|||
public IType getBaseClassType() {
|
||||
if (baseClass == null) {
|
||||
IBinding b = base.getName().resolveBinding();
|
||||
if (b instanceof IProblemBinding || ! (b instanceof IType)) {
|
||||
if (b instanceof IProblemBinding) {
|
||||
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID());
|
||||
} else if (!(b instanceof IType)) {
|
||||
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ISemanticProblem.BINDING_NO_CLASS);
|
||||
} else {
|
||||
baseClass= (IType) b;
|
||||
IType check= getNestedType(baseClass, TDEF);
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CPPClosureType extends PlatformObject implements ICPPClassType, ICP
|
|||
// Function call operator
|
||||
final IType returnType= getReturnType();
|
||||
final IType[] parameterTypes= getParameterTypes();
|
||||
ft= new CPPFunctionType(returnType, parameterTypes, isMutable(), false, false);
|
||||
ft= new CPPFunctionType(returnType, parameterTypes, !isMutable(), false, false);
|
||||
|
||||
ICPPParameter[] params = new ICPPParameter[parameterTypes.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2012, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -84,8 +85,16 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
IASTNode point);
|
||||
|
||||
/**
|
||||
* Determines size of the template parameter pack.
|
||||
* Searches the evaluation for a usage of a template parameter which is a parameter pack,
|
||||
* and returns the number of arguments bound to that parameter pack in the given
|
||||
* template parameter map.
|
||||
*
|
||||
* Can also return one of the special values CPPTemplates.PACK_SIZE_DEFER,
|
||||
* CPPTemplates.PACK_SIZE_FAIL, and CPPTemplates.PACK_SIZE_NOT_FOUND. See their
|
||||
* declarations for their meanings.
|
||||
*
|
||||
* See also CPPTemplates.determinePackSize().
|
||||
*
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
int determinePackSize(ICPPTemplateParameterMap tpMap);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc and others.
|
||||
* Copyright (c) 2012, 2013 Google, Inc 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
|
||||
|
@ -11,207 +11,18 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||
|
||||
private static class SignatureBuilder implements ITypeMarshalBuffer {
|
||||
private static final byte NULL_TYPE= 0;
|
||||
private static final byte UNSTORABLE_TYPE= (byte) -1;
|
||||
|
||||
private final StringBuilder fBuffer;
|
||||
|
||||
/**
|
||||
* Constructor for input buffer.
|
||||
*/
|
||||
public SignatureBuilder() {
|
||||
fBuffer= new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fBuffer.toString();
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
return CharArrayUtils.extractChars(fBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalBinding(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ISerializableType) {
|
||||
((ISerializableType) binding).marshal(this);
|
||||
} else if (binding == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
appendSeparator();
|
||||
if (binding instanceof ICPPBinding) {
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
|
||||
fBuffer.append(param.isParameterPack() ? '*' : '#');
|
||||
fBuffer.append(param.getParameterID());
|
||||
} else {
|
||||
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
|
||||
}
|
||||
} else {
|
||||
fBuffer.append(binding.getNameCharArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalType(IType type) throws CoreException {
|
||||
if (type instanceof ISerializableType) {
|
||||
((ISerializableType) type).marshal(this);
|
||||
} else if (type == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else if (type instanceof IBinding) {
|
||||
marshalBinding((IBinding) type);
|
||||
} else {
|
||||
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||
putByte(UNSTORABLE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
|
||||
if (eval == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
eval.marshal(this, includeValues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalValue(IValue value) throws CoreException {
|
||||
if (value instanceof Value) {
|
||||
((Value) value).marshall(this);
|
||||
} else {
|
||||
putByte(NULL_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
|
||||
if (arg.isNonTypeValue()) {
|
||||
putByte(VALUE);
|
||||
arg.getNonTypeEvaluation().marshal(this, true);
|
||||
} else {
|
||||
marshalType(arg.getTypeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putByte(byte value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFixedInt(int value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInt(int value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLong(long value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putCharArray(char[] chars) {
|
||||
appendSeparator();
|
||||
for (char c : chars) {
|
||||
fBuffer.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendSeparator() {
|
||||
if (fBuffer.length() != 0)
|
||||
fBuffer.append(' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding unmarshalBinding() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType unmarshalType() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue unmarshalValue() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getByte() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoreException unmarshallingError() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedInt() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getCharArray() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
CPPEvaluation() {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -550,14 +550,6 @@ public class CPPSemantics {
|
|||
if (parent instanceof ICPPASTConstructorChainInitializer) {
|
||||
return true;
|
||||
}
|
||||
if (parent instanceof ICPPASTNamedTypeSpecifier) {
|
||||
parent= parent.getParent();
|
||||
if (parent instanceof IASTTypeId && parent.getParent() instanceof ICPPASTNewExpression) {
|
||||
IASTDeclarator dtor = ((IASTTypeId) parent).getAbstractDeclarator();
|
||||
if (dtor != null && dtor.getPointerOperators().length == 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3103,27 +3095,43 @@ public class CPPSemantics {
|
|||
return null;
|
||||
|
||||
IType type = ((ICPPVariable) binding).getType();
|
||||
try {
|
||||
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
|
||||
if (!(type instanceof ICPPClassType))
|
||||
return null;
|
||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
||||
return null;
|
||||
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
|
||||
if (!(type instanceof ICPPClassType))
|
||||
return null;
|
||||
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
|
||||
return null;
|
||||
|
||||
final ICPPClassType classType = (ICPPClassType) type;
|
||||
return findImplicitlyCalledConstructor((ICPPClassType) type, initializer, name);
|
||||
}
|
||||
|
||||
public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) {
|
||||
IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE);
|
||||
if (!(type instanceof IPointerType))
|
||||
return null;
|
||||
type = ((IPointerType) type).getType();
|
||||
if (type instanceof ICPPClassType) {
|
||||
return findImplicitlyCalledConstructor((ICPPClassType) type,
|
||||
expr.getInitializer(), expr.getTypeId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType type, IASTInitializer initializer,
|
||||
IASTNode typeId) {
|
||||
try {
|
||||
if (initializer instanceof IASTEqualsInitializer) {
|
||||
// Copy initialization.
|
||||
IASTEqualsInitializer eqInit= (IASTEqualsInitializer) initializer;
|
||||
ICPPASTInitializerClause initClause = (ICPPASTInitializerClause) eqInit.getInitializerClause();
|
||||
final ICPPEvaluation evaluation = initClause.getEvaluation();
|
||||
IType sourceType= evaluation.getTypeOrFunctionSet(name);
|
||||
ValueCategory isLValue= evaluation.getValueCategory(name);
|
||||
IType sourceType= evaluation.getTypeOrFunctionSet(typeId);
|
||||
ValueCategory isLValue= evaluation.getValueCategory(typeId);
|
||||
if (sourceType != null) {
|
||||
Cost c;
|
||||
if (calculateInheritanceDepth(sourceType, classType, name) >= 0) {
|
||||
c = Conversions.copyInitializationOfClass(isLValue, sourceType, classType, false, name);
|
||||
if (calculateInheritanceDepth(sourceType, type, typeId) >= 0) {
|
||||
c = Conversions.copyInitializationOfClass(isLValue, sourceType, type, false, typeId);
|
||||
} else {
|
||||
c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, name);
|
||||
c = Conversions.checkImplicitConversionSequence(type, sourceType, isLValue, UDCMode.ALLOWED, Context.ORDINARY, typeId);
|
||||
}
|
||||
if (c.converts()) {
|
||||
ICPPFunction f = c.getUserDefinedConversion();
|
||||
|
@ -3136,7 +3144,7 @@ public class CPPSemantics {
|
|||
// List initialization.
|
||||
ICPPEvaluation eval= ((ICPPASTInitializerList) initializer).getEvaluation();
|
||||
if (eval instanceof EvalInitList) {
|
||||
Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, name);
|
||||
Cost c= Conversions.listInitializationSequence((EvalInitList) eval, type, UDCMode.ALLOWED, true, typeId);
|
||||
if (c.converts()) {
|
||||
ICPPFunction f = c.getUserDefinedConversion();
|
||||
if (f instanceof ICPPConstructor)
|
||||
|
@ -3145,35 +3153,22 @@ public class CPPSemantics {
|
|||
}
|
||||
} else if (initializer instanceof ICPPASTConstructorInitializer) {
|
||||
// Direct initialization.
|
||||
return findImplicitlyCalledConstructor(classType,
|
||||
(ICPPASTConstructorInitializer) initializer, name);
|
||||
return findImplicitlyCalledConstructor(type,
|
||||
(ICPPASTConstructorInitializer) initializer, typeId);
|
||||
} else if (initializer == null) {
|
||||
// Default initialization.
|
||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name);
|
||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(type, typeId);
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
if (ctor.getRequiredArgumentCount() == 0)
|
||||
return ctor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ICPPConstructor findImplicitlyCalledConstructor(ICPPASTNewExpression expr) {
|
||||
IType type = getNestedType(expr.getExpressionType(), TDEF | REF | CVTYPE);
|
||||
if (!(type instanceof IPointerType))
|
||||
return null;
|
||||
type = ((IPointerType) type).getType();
|
||||
IASTInitializer initializer = expr.getInitializer();
|
||||
if (type instanceof ICPPClassType && initializer instanceof ICPPASTConstructorInitializer) {
|
||||
return findImplicitlyCalledConstructor((ICPPClassType) type,
|
||||
(ICPPASTConstructorInitializer) initializer, expr.getTypeId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ICPPConstructor findImplicitlyCalledConstructor(ICPPClassType classType,
|
||||
ICPPASTConstructorInitializer initializer, IASTNode typeId) {
|
||||
final IASTInitializerClause[] arguments = initializer.getArguments();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2013 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
|
||||
|
@ -81,6 +81,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
|
@ -161,9 +162,23 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMod
|
|||
* type instantiation.
|
||||
*/
|
||||
public class CPPTemplates {
|
||||
// The three constants below are used as special return values for the various overloads
|
||||
// of CPPTemplates.determinePackSize() and for ICPPEvaluation.determinePackSize(), which
|
||||
// search a type, template argument, or value for a usage of a template parameter pack
|
||||
// and return the number of arguments bound to that parameter pack in an
|
||||
// ICPPTemplateParameterMap.
|
||||
|
||||
// Used to indicate that the parameter pack is not bound to any arguments in the
|
||||
// template parameter map. Computation of the pack size needs to be deferred until
|
||||
// arguments for it become available.
|
||||
static final int PACK_SIZE_DEFER = -1;
|
||||
|
||||
// Used to indicate that two different packs with different sizes were found.
|
||||
static final int PACK_SIZE_FAIL = -2;
|
||||
|
||||
// Used to indicate that no template parameter packs were found.
|
||||
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
|
||||
|
||||
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
||||
|
||||
/**
|
||||
|
@ -1958,13 +1973,34 @@ public class CPPTemplates {
|
|||
return arg;
|
||||
}
|
||||
|
||||
private static ICPPFunctionType getFunctionTypeIgnoringParametersWithDefaults(ICPPFunction function) {
|
||||
ICPPParameter[] parameters = function.getParameters();
|
||||
IType[] parameterTypes = new IType[parameters.length];
|
||||
int i;
|
||||
for (i = 0; i < parameters.length; ++i) {
|
||||
ICPPParameter parameter = parameters[i];
|
||||
if (!parameter.hasDefaultValue()) {
|
||||
parameterTypes[i] = parameter.getType();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
ICPPFunctionType originalType = function.getType();
|
||||
if (i == parameters.length) // no parameters with default arguments
|
||||
return originalType;
|
||||
return new CPPFunctionType(originalType.getReturnType(), ArrayUtil.trim(parameterTypes),
|
||||
originalType.isConst(), originalType.isVolatile(), originalType.takesVarArgs());
|
||||
}
|
||||
|
||||
private static int compareSpecialization(ICPPFunctionTemplate f1, ICPPFunctionTemplate f2, TypeSelection mode, IASTNode point) throws DOMException {
|
||||
ICPPFunction transF1 = transferFunctionTemplate(f1, point);
|
||||
if (transF1 == null)
|
||||
return -1;
|
||||
|
||||
final ICPPFunctionType ft2 = f2.getType();
|
||||
final ICPPFunctionType transFt1 = transF1.getType();
|
||||
// Ignore parameters with default arguments in the transformed function template
|
||||
// as per [temp.func.order] p5.
|
||||
final ICPPFunctionType transFt1 = getFunctionTypeIgnoringParametersWithDefaults(transF1);
|
||||
IType[] pars;
|
||||
IType[] args;
|
||||
switch(mode) {
|
||||
|
@ -2118,8 +2154,6 @@ public class CPPTemplates {
|
|||
final ICPPTemplateParameter[] tpars2 = f2.getTemplateParameters();
|
||||
final ICPPTemplateArgument[] targs1 = f1.getTemplateArguments();
|
||||
final ICPPTemplateArgument[] targs2 = f2.getTemplateArguments();
|
||||
if (targs1.length != targs2.length)
|
||||
return false;
|
||||
|
||||
// Transfer arguments of specialization 1
|
||||
final int tpars1Len = tpars1.length;
|
||||
|
@ -2129,22 +2163,17 @@ public class CPPTemplates {
|
|||
final ICPPTemplateParameter param = tpars1[i];
|
||||
final ICPPTemplateArgument arg = uniqueArg(param);
|
||||
args[i]= arg;
|
||||
transferMap.put(param, arg);
|
||||
if (param.isParameterPack()) {
|
||||
transferMap.put(param, new ICPPTemplateArgument[] { arg });
|
||||
} else {
|
||||
transferMap.put(param, arg);
|
||||
}
|
||||
}
|
||||
final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point, false);
|
||||
|
||||
// Deduce arguments for specialization 2
|
||||
final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2);
|
||||
if (!TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point))
|
||||
return false;
|
||||
|
||||
// Compare
|
||||
for (int i = 0; i < targs2.length; i++) {
|
||||
ICPPTemplateArgument transferredArg2= instantiateArgument(targs2[i], deductionMap, -1, null, point);
|
||||
if (!transferredArg2.isSameValue(transferredArgs1[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return TemplateArgumentDeduction.fromTemplateArguments(tpars2, targs2, transferredArgs1, deductionMap, point);
|
||||
}
|
||||
|
||||
static boolean isValidType(IType t) {
|
||||
|
@ -2226,6 +2255,9 @@ public class CPPTemplates {
|
|||
pType= instantiateType(pType, map, -1, null, point);
|
||||
}
|
||||
|
||||
if (argType instanceof ICPPParameterPackType) {
|
||||
argType = ((ICPPParameterPackType) argType).getType();
|
||||
}
|
||||
if (argType instanceof ICPPUnknownType) {
|
||||
return new CPPTemplateNonTypeArgument(arg.getNonTypeValue(), pType);
|
||||
}
|
||||
|
|
|
@ -360,8 +360,13 @@ public class EvalID extends CPPEvaluation {
|
|||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
if (fNameOwner instanceof ICPPUnknownBinding) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize((ICPPUnknownBinding) fNameOwner, tpMap));
|
||||
}
|
||||
if (fTemplateArgs != null) {
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -11,6 +11,7 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -49,7 +50,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
|
@ -663,46 +663,7 @@ public class SemanticUtil {
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static boolean containsUniqueTypeForParameterPack(IType type) {
|
||||
if (type instanceof ICPPFunctionType) {
|
||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||
if (containsUniqueTypeForParameterPack(ft.getReturnType()))
|
||||
return true;
|
||||
|
||||
for (IType pt : ft.getParameterTypes()) {
|
||||
if (containsUniqueTypeForParameterPack(pt))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type instanceof ICPPPointerToMemberType) {
|
||||
if (containsUniqueTypeForParameterPack(((ICPPPointerToMemberType) type).getMemberOfClass()))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type instanceof IBinding) {
|
||||
IBinding owner = ((IBinding) type).getOwner();
|
||||
if (owner instanceof IType) {
|
||||
if (containsUniqueTypeForParameterPack((IType) owner))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateArgument[] args = ((ICPPTemplateInstance) type).getTemplateArguments();
|
||||
for (ICPPTemplateArgument arg : args) {
|
||||
if (containsUniqueTypeForParameterPack(arg.getTypeValue()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (type instanceof ITypeContainer) {
|
||||
final ITypeContainer tc = (ITypeContainer) type;
|
||||
final IType nestedType= tc.getType();
|
||||
return containsUniqueTypeForParameterPack(nestedType);
|
||||
}
|
||||
|
||||
public static boolean isUniqueTypeForParameterPack(IType type) {
|
||||
if (type instanceof UniqueType) {
|
||||
return ((UniqueType) type).isForParameterPack();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2013 Google, Inc 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:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
class SignatureBuilder implements ITypeMarshalBuffer {
|
||||
private static final byte NULL_TYPE= 0;
|
||||
private static final byte UNSTORABLE_TYPE= (byte) -1;
|
||||
|
||||
private final StringBuilder fBuffer;
|
||||
|
||||
/**
|
||||
* Constructor for input buffer.
|
||||
*/
|
||||
public SignatureBuilder() {
|
||||
fBuffer= new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return fBuffer.toString();
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
return CharArrayUtils.extractChars(fBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalBinding(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ISerializableType) {
|
||||
((ISerializableType) binding).marshal(this);
|
||||
} else if (binding == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
appendSeparator();
|
||||
if (binding instanceof ICPPBinding) {
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
|
||||
fBuffer.append(param.isParameterPack() ? '*' : '#');
|
||||
fBuffer.append(param.getParameterID());
|
||||
} else {
|
||||
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
|
||||
}
|
||||
} else {
|
||||
fBuffer.append(binding.getNameCharArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalType(IType type) throws CoreException {
|
||||
if (type instanceof ISerializableType) {
|
||||
((ISerializableType) type).marshal(this);
|
||||
} else if (type == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else if (type instanceof IBinding) {
|
||||
marshalBinding((IBinding) type);
|
||||
} else {
|
||||
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||
putByte(UNSTORABLE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
|
||||
if (eval == null) {
|
||||
putByte(NULL_TYPE);
|
||||
} else {
|
||||
eval.marshal(this, includeValues);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalValue(IValue value) throws CoreException {
|
||||
if (value instanceof Value) {
|
||||
((Value) value).marshall(this);
|
||||
} else {
|
||||
putByte(NULL_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
|
||||
if (arg.isNonTypeValue()) {
|
||||
putByte(VALUE);
|
||||
arg.getNonTypeEvaluation().marshal(this, true);
|
||||
} else {
|
||||
marshalType(arg.getTypeValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putByte(byte value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFixedInt(int value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInt(int value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putLong(long value) {
|
||||
appendSeparator();
|
||||
fBuffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putCharArray(char[] chars) {
|
||||
appendSeparator();
|
||||
for (char c : chars) {
|
||||
fBuffer.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendSeparator() {
|
||||
if (fBuffer.length() != 0)
|
||||
fBuffer.append(' ');
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding unmarshalBinding() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType unmarshalType() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IValue unmarshalValue() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getByte() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoreException unmarshallingError() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFixedInt() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getCharArray() throws CoreException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -36,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
|
@ -431,7 +431,7 @@ public class TemplateArgumentDeduction {
|
|||
deduct.incPackOffset();
|
||||
} else {
|
||||
if (j >= fnParCount)
|
||||
return result;
|
||||
return -1;
|
||||
|
||||
par= fnPars[j];
|
||||
if (par instanceof ICPPParameterPackType) {
|
||||
|
@ -606,15 +606,36 @@ public class TemplateArgumentDeduction {
|
|||
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
||||
IASTNode point) throws DOMException {
|
||||
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(pars, null, map, 0);
|
||||
final int len= a.length;
|
||||
if (p == null || p.length != len) {
|
||||
if (p == null) {
|
||||
return false;
|
||||
}
|
||||
for (int j= 0; j < len; j++) {
|
||||
if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
|
||||
return false;
|
||||
boolean containsPackExpansion= false;
|
||||
for (int j= 0; j < p.length; j++) {
|
||||
if (p[j].isPackExpansion()) {
|
||||
deduct = new TemplateArgumentDeduction(deduct, a.length - j);
|
||||
containsPackExpansion= true;
|
||||
if (j != p.length - 1) {
|
||||
return false; // A pack expansion must be the last argument to the specialization.
|
||||
}
|
||||
ICPPTemplateArgument pattern = p[j].getExpansionPattern();
|
||||
for (int i= j; i < a.length; i++) {
|
||||
if (!deduct.fromTemplateArgument(pattern, a[i], point)) {
|
||||
return false;
|
||||
}
|
||||
deduct.incPackOffset();
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
if (j >= a.length) {
|
||||
return false; // Not enough arguments.
|
||||
}
|
||||
if (!deduct.fromTemplateArgument(p[j], a[j], point)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!containsPackExpansion && p.length < a.length)
|
||||
return false; // Too many arguments.
|
||||
return verifyDeduction(pars, map, false, point);
|
||||
}
|
||||
|
||||
|
@ -636,16 +657,8 @@ public class TemplateArgumentDeduction {
|
|||
deducedArg= tpar.getDefaultValue();
|
||||
if (deducedArg != null) {
|
||||
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
|
||||
if (deducedArg != null) {
|
||||
if (deducedArg instanceof CPPTemplateTypeArgument) {
|
||||
CPPTemplateTypeArgument deducedTypeArg = (CPPTemplateTypeArgument) deducedArg;
|
||||
if (!(deducedTypeArg.getTypeValue() instanceof ISemanticProblem)) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
} else {
|
||||
// TODO: Check for problems in non-type or template template parameters?
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
if (CPPTemplates.isValidArgument(deducedArg)) {
|
||||
tpMap.put(tpar, deducedArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -957,7 +970,7 @@ public class TemplateArgumentDeduction {
|
|||
return false;
|
||||
return fDeducedArgs.putPackElement(parID, fPackOffset, arg, fPackSize);
|
||||
}
|
||||
if (SemanticUtil.containsUniqueTypeForParameterPack(arg.getTypeValue()))
|
||||
if (SemanticUtil.isUniqueTypeForParameterPack(arg.getTypeValue()))
|
||||
return false;
|
||||
fDeducedArgs.put(parID, arg);
|
||||
return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2012, 2013 Wind River Systems, Inc. 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
|
||||
|
@ -7,9 +7,11 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
|
@ -48,6 +50,17 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
|
|||
}
|
||||
}
|
||||
|
||||
public char[] getSignature() {
|
||||
SignatureBuilder buf = new SignatureBuilder();
|
||||
try {
|
||||
marshal(buf);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new char[] { '?' };
|
||||
}
|
||||
return buf.getSignature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
|
||||
|
|
|
@ -130,7 +130,7 @@ abstract class LocationCtx implements ILocationCtx {
|
|||
* Returns the sequence of file locations spanning the given range.
|
||||
* Assumes that the range starts within this context.
|
||||
*/
|
||||
public abstract boolean collectLocations(int sequenceNumber, int length, ArrayList<IASTNodeLocation> sofar);
|
||||
public abstract void collectLocations(int sequenceNumber, int length, ArrayList<IASTNodeLocation> sofar);
|
||||
|
||||
/**
|
||||
* Support for the dependency tree, add inclusion statements found in this context.
|
||||
|
|
|
@ -32,7 +32,7 @@ class LocationCtxContainer extends LocationCtx {
|
|||
private int fChildSequenceLength;
|
||||
|
||||
private ArrayList<LocationCtx> fChildren;
|
||||
private AbstractCharArray fSource;
|
||||
private final AbstractCharArray fSource;
|
||||
private int[] fLineOffsets;
|
||||
|
||||
public LocationCtxContainer(LocationCtxContainer parent, AbstractCharArray source,
|
||||
|
@ -138,47 +138,55 @@ class LocationCtxContainer extends LocationCtx {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean collectLocations(int sequenceNumber, final int length, ArrayList<IASTNodeLocation> locations) {
|
||||
public void collectLocations(int sequenceNumber, final int length, ArrayList<IASTNodeLocation> locations) {
|
||||
if (length < 1)
|
||||
return;
|
||||
|
||||
final int endSequenceNumber= sequenceNumber + length;
|
||||
if (fChildren != null) {
|
||||
int childIdx= Math.max(0, findChildIdxLessOrEqualThan(sequenceNumber, false));
|
||||
for (; childIdx < fChildren.size(); childIdx++) {
|
||||
final LocationCtx child= fChildren.get(childIdx);
|
||||
|
||||
// create the location between start and the child
|
||||
// Create the location between start and the child
|
||||
if (sequenceNumber < child.fSequenceNumber) {
|
||||
// compute offset backwards from the child's offset
|
||||
// Compute offset backwards from the child's offset in this location
|
||||
final int offset= child.fEndOffsetInParent - (child.fSequenceNumber - sequenceNumber);
|
||||
// it the child is not affected, we are done.
|
||||
|
||||
// Requested range ends before the child.
|
||||
if (endSequenceNumber <= child.fSequenceNumber) {
|
||||
addFileLocation(offset, endSequenceNumber - sequenceNumber, locations);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
if (offset < child.fOffsetInParent)
|
||||
|
||||
final int gapLen = child.fOffsetInParent - offset;
|
||||
if (gapLen > 0)
|
||||
addFileLocation(offset, child.fOffsetInParent - offset, locations);
|
||||
|
||||
sequenceNumber= child.fSequenceNumber;
|
||||
assert sequenceNumber < endSequenceNumber;
|
||||
}
|
||||
|
||||
// let the child create locations
|
||||
// Let the child create locations
|
||||
final int childEndSequenceNumber= child.fSequenceNumber + child.getSequenceLength();
|
||||
if (sequenceNumber < childEndSequenceNumber) {
|
||||
if (child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations)) {
|
||||
return true;
|
||||
}
|
||||
if (sequenceNumber < childEndSequenceNumber
|
||||
|| (sequenceNumber == childEndSequenceNumber && !locations.isEmpty())) {
|
||||
child.collectLocations(sequenceNumber, endSequenceNumber - sequenceNumber, locations);
|
||||
sequenceNumber= childEndSequenceNumber;
|
||||
if (sequenceNumber >= endSequenceNumber)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create the location after the last child.
|
||||
// Create the location after the last child.
|
||||
final int myEndNumber = fSequenceNumber + getSequenceLength();
|
||||
final int offset= fSource.getLength() - (myEndNumber - sequenceNumber);
|
||||
if (endSequenceNumber <= myEndNumber) {
|
||||
addFileLocation(offset, endSequenceNumber - sequenceNumber, locations);
|
||||
return true;
|
||||
} else {
|
||||
addFileLocation(offset, fSource.getLength() - offset, locations);
|
||||
}
|
||||
addFileLocation(offset, fSource.getLength() - offset, locations);
|
||||
return false;
|
||||
}
|
||||
|
||||
private ArrayList<IASTNodeLocation> addFileLocation(int offset, int length, ArrayList<IASTNodeLocation> sofar) {
|
||||
|
|
|
@ -25,7 +25,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
|
|||
private final LocationMap fLocationMap;
|
||||
private final int fLength;
|
||||
private final ImageLocationInfo[] fLocationInfos;
|
||||
private ASTMacroReferenceName fExpansionName;
|
||||
private final ASTMacroReferenceName fExpansionName;
|
||||
|
||||
public LocationCtxMacroExpansion(LocationMap map, LocationCtxContainer parent, int parentOffset, int parentEndOffset,
|
||||
int sequenceNumber, int length, ImageLocationInfo[] imageLocations, ASTMacroReferenceName expansionName) {
|
||||
|
@ -45,17 +45,15 @@ class LocationCtxMacroExpansion extends LocationCtx {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean collectLocations(int start, int length, ArrayList<IASTNodeLocation> locations) {
|
||||
public void collectLocations(int start, int length, ArrayList<IASTNodeLocation> locations) {
|
||||
final int offset= start - fSequenceNumber;
|
||||
assert offset >= 0 && length >= 0;
|
||||
|
||||
if (offset + length <= fLength) {
|
||||
locations.add(new ASTMacroExpansionLocation(this, offset, length));
|
||||
return true;
|
||||
} else {
|
||||
locations.add(new ASTMacroExpansionLocation(this, offset, fLength-offset));
|
||||
}
|
||||
|
||||
locations.add(new ASTMacroExpansionLocation(this, offset, fLength-offset));
|
||||
return false;
|
||||
}
|
||||
|
||||
public ASTMacroExpansion getExpansion() {
|
||||
|
|
|
@ -268,7 +268,7 @@
|
|||
<pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*):(\d*): (\*\*\* .*)" severity="Error"/>
|
||||
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: \*\*\* .*" severity="Error"/>
|
||||
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*: Target (.*) not remade because of errors." severity="Error"/>
|
||||
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*command not found.*" severity="Error"/>
|
||||
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*[Cc]ommand not found.*" severity="Error"/>
|
||||
<pattern description-expr="$1" eat-processed-line="true" file-expr="" line-expr="" regex="Error:\s*(.*)" severity="Error"/>
|
||||
<pattern description-expr="make: $3" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="(.*[Mm]akefile):(\d*): warning: (.*)" severity="Warning"/>
|
||||
<pattern description-expr="$0" eat-processed-line="true" file-expr="" line-expr="" regex=".*make.*\[.*\] Error [-]{0,1}\d*.*" severity="Warning"/>
|
||||
|
|
|
@ -20,7 +20,7 @@ import junit.framework.TestSuite;
|
|||
import org.eclipse.jface.text.IRegion;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2BaseTest;
|
||||
import org.eclipse.cdt.core.parser.tests.ast2.AST2TestBase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.eclipse.cdt.internal.ui.search.LinkedNamesFinder;
|
|||
/**
|
||||
* Tests for LinkedNamesFinder class.
|
||||
*/
|
||||
public class LinkedNamesFinderTest extends AST2BaseTest {
|
||||
public class LinkedNamesFinderTest extends AST2TestBase {
|
||||
private static class RegionComparator implements Comparator<IRegion> {
|
||||
@Override
|
||||
public int compare(IRegion r1, IRegion r2) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
* Copyright (c) 2000, 2013 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||
*******************************************************************************/
|
||||
|
@ -20,13 +20,12 @@ import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
|
|||
|
||||
/**
|
||||
* Semantic highlighting tests.
|
||||
*
|
||||
*
|
||||
* <p>Derived from JDT.<p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
||||
|
||||
private static final boolean PRINT_POSITIONS= false;
|
||||
|
||||
private static final Class<?> THIS= SemanticHighlightingTest.class;
|
||||
|
@ -101,7 +100,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
createPosition(108, 4, 26),
|
||||
createPosition(112, 4, 25),
|
||||
createPosition(117, 4, 32),
|
||||
};
|
||||
};
|
||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||
assertEqualPositions(expected, actual);
|
||||
}
|
||||
|
@ -121,10 +120,9 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
createPosition(108, 4, 26),
|
||||
createPosition(112, 4, 25),
|
||||
createPosition(117, 4, 32),
|
||||
createPosition(118, 23, 9),
|
||||
createPosition(122, 4, 15),
|
||||
createPosition(130, 13, 9),
|
||||
};
|
||||
};
|
||||
Position[] actual= getSemanticHighlightingPositions();
|
||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||
assertEqualPositions(expected, actual);
|
||||
|
@ -134,7 +132,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
setUpSemanticHighlighting(SemanticHighlightings.STATIC_METHOD_INVOCATION);
|
||||
Position[] expected= new Position[] {
|
||||
createPosition(122, 4, 15),
|
||||
};
|
||||
};
|
||||
Position[] actual= getSemanticHighlightingPositions();
|
||||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||
assertEqualPositions(expected, actual);
|
||||
|
@ -256,6 +254,7 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
createPosition(112, 4, 14),
|
||||
createPosition(117, 4, 14),
|
||||
createPosition(118, 4, 9),
|
||||
createPosition(118, 23, 9),
|
||||
createPosition(120, 4, 8),
|
||||
createPosition(129, 4, 8),
|
||||
createPosition(147, 42, 7),
|
||||
|
@ -297,7 +296,6 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
assertEqualPositions(expected, actual);
|
||||
}
|
||||
|
||||
|
||||
public void testGlobalVariableHighlighting() throws Exception {
|
||||
setUpSemanticHighlighting(SemanticHighlightings.GLOBAL_VARIABLE);
|
||||
Position[] actual= getSemanticHighlightingPositions();
|
||||
|
@ -421,5 +419,4 @@ public class SemanticHighlightingTest extends AbstractSemanticHighlightingTest {
|
|||
if (PRINT_POSITIONS) System.out.println(toString(actual));
|
||||
assertEqualPositions(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -629,9 +629,11 @@ LanguageSettingsProviderAssociationExtensionPoint=Language Settings Provider UI
|
|||
overrideAnnotation.label = C/C++ Override indicators
|
||||
|
||||
transfer.EditorAppearance.name = C/C++ Editor Appearance
|
||||
transfer.EditorAppearance.description = Preference related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...)
|
||||
transfer.EditorAppearance.description = Preferences related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...)
|
||||
transfer.EditorBehavior.name = C/C++ Editor Behavior
|
||||
transfer.EditorBehavior.description = Preference related to how the editor process the edited code (typing, save action, etc...)
|
||||
transfer.EditorBehavior.description = Preferences related to how the editor deals with the edited code (typing, save action, etc...)
|
||||
transfer.CodeStyle.name = C/C++ Code Style
|
||||
transfer.CodeStyle.description = C/C++ > Code Style preferences
|
||||
|
||||
# Refresh Exclusion Contributors
|
||||
RefreshExclusionContributor.name = Resources
|
||||
|
|
|
@ -4499,6 +4499,7 @@
|
|||
<extension
|
||||
point="org.eclipse.ui.preferenceTransfer">
|
||||
<transfer
|
||||
icon="icons/view16/c_pers.gif"
|
||||
id="org.eclipse.cdt.ui.transfer.editor.appearance"
|
||||
name="%transfer.EditorAppearance.name">
|
||||
<mapping scope="instance">
|
||||
|
@ -4557,6 +4558,7 @@
|
|||
</description>
|
||||
</transfer>
|
||||
<transfer
|
||||
icon="icons/view16/c_pers.gif"
|
||||
id="org.eclipse.cdt.ui.transfer.editor.behavior"
|
||||
name="%transfer.EditorBehavior.name">
|
||||
<mapping scope="instance">
|
||||
|
@ -4590,15 +4592,31 @@
|
|||
<key name="stickyOccurrences"/>
|
||||
<key name="markOverloadedOperatorsOccurrences"/>
|
||||
<key name="scalability." match="prefix"/>
|
||||
<key
|
||||
name="content_assist_proposals_timeout">
|
||||
</key>
|
||||
<key name="content_assist_proposals_timeout"/>
|
||||
</entry>
|
||||
</mapping>
|
||||
<description>
|
||||
%transfer.EditorBehavior.description
|
||||
</description>
|
||||
</transfer>
|
||||
<transfer
|
||||
icon="icons/view16/c_pers.gif"
|
||||
id="org.eclipse.cdt.ui.transfer.code_style"
|
||||
name="%transfer.CodeStyle.name">
|
||||
<mapping scope="instance">
|
||||
<entry node="org.eclipse.cdt.ui">
|
||||
<key name="codetemplates." match="prefix"/>
|
||||
<key name="nameStyle." match="prefix"/>
|
||||
<key name="formatter_profile"/>
|
||||
<key name="class_member_ascending_visibility_order"/>
|
||||
<key name="function_output_parameters_before_input"/>
|
||||
<key name="function_pass_output_parameters_by_pointer"/>
|
||||
</entry>
|
||||
</mapping>
|
||||
<description>
|
||||
%transfer.CodeStyle.description
|
||||
</description>
|
||||
</transfer>
|
||||
|
||||
</extension>
|
||||
<extension
|
||||
|
|
|
@ -207,7 +207,7 @@ public abstract class AbstractCModelOutlinePage extends Page
|
|||
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, isChecked());
|
||||
}
|
||||
|
||||
public boolean isIncludesGroupingEnabled () {
|
||||
public boolean isIncludesGroupingEnabled() {
|
||||
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ public abstract class AbstractCModelOutlinePage extends Page
|
|||
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, isChecked());
|
||||
}
|
||||
|
||||
public boolean isMacroGroupingEnabled () {
|
||||
public boolean isMacroGroupingEnabled() {
|
||||
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS);
|
||||
}
|
||||
}
|
||||
|
@ -374,8 +374,8 @@ public abstract class AbstractCModelOutlinePage extends Page
|
|||
} else if (fInput != null) {
|
||||
try {
|
||||
element= fInput.getElementAtOffset(offset);
|
||||
} catch (CModelException exc) {
|
||||
CUIPlugin.log(exc);
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
if (element != null) {
|
||||
|
@ -526,7 +526,7 @@ public abstract class AbstractCModelOutlinePage extends Page
|
|||
fTreeViewer.setInput(fInput);
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
|
||||
|
||||
IHandlerService handlerService= (IHandlerService)site.getService(IHandlerService.class);
|
||||
IHandlerService handlerService= (IHandlerService) site.getService(IHandlerService.class);
|
||||
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ public abstract class AbstractCModelOutlinePage extends Page
|
|||
public void setInput(ITranslationUnit unit) {
|
||||
fInput = unit;
|
||||
if (fTreeViewer != null) {
|
||||
fTreeViewer.setInput (fInput);
|
||||
fTreeViewer.setInput(fInput);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
|
|||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.util.NameComposer;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
|
@ -254,17 +253,6 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
categoryTree.postSetSelection(new StructuredSelection(element));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProjectSpecificOptions(IProject project) {
|
||||
if (super.hasProjectSpecificOptions(project))
|
||||
return true;
|
||||
|
||||
if (project != null) {
|
||||
return ProjectTemplateStore.hasProjectSpecificTempates(project);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
pixelConverter = new PixelConverter(parent);
|
||||
|
@ -416,11 +404,6 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
updateConfigurationBlock(categoryTree.getSelectedElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateSettings(Key changedKey, String oldValue, String newValue) {
|
||||
StatusInfo status = new StatusInfo();
|
||||
|
@ -648,7 +631,6 @@ public class NameStyleBlock extends OptionsConfigurationBlock {
|
|||
|
||||
private class NameStyleAdapter extends ViewerComparator
|
||||
implements ITreeListAdapter<Category>, IDialogFieldListener {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(TreeListDialogField<Category> field) {
|
||||
updateConfigurationBlock(field.getSelectedElements());
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
|||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
public class CUILabelProvider extends LabelProvider implements IColorProvider, IStyledLabelProvider {
|
||||
|
||||
protected CElementImageProvider fImageLabelProvider;
|
||||
protected StorageLabelProvider fStorageLabelProvider;
|
||||
|
||||
|
@ -136,9 +135,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
return image;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ILabelProvider#getImage
|
||||
*/
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
Image result= fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element));
|
||||
|
@ -159,10 +155,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
return text;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ILabelProvider#getText
|
||||
*/
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
String result= CElementLabels.getTextLabel(element, evaluateTextFlags(element));
|
||||
|
@ -186,10 +178,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
return string;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IBaseLabelProvider#dispose
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (fLabelDecorators != null) {
|
||||
|
@ -203,9 +191,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
fImageLabelProvider.dispose();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
if (fLabelDecorators != null) {
|
||||
|
@ -217,17 +202,11 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
super.addListener(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IBaseLabelProvider#isLabelProperty(Object, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IBaseLabelProvider#removeListener(ILabelProviderListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
if (fLabelDecorators != null) {
|
||||
|
@ -252,9 +231,6 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Color getForeground(Object element) {
|
||||
if (element instanceof ISourceReference) {
|
||||
|
@ -270,12 +246,8 @@ public class CUILabelProvider extends LabelProvider implements IColorProvider, I
|
|||
return fDefaultColor;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,9 +7,13 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.viewsupport;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceStatus;
|
||||
|
@ -41,7 +45,7 @@ import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
|||
/**
|
||||
* LabelDecorator that decorates an element's image with error and warning overlays that
|
||||
* represent the severity of markers attached to the element's underlying resource. To see
|
||||
* a problem decoration for a marker, the marker needs to be a subtype of <code>IMarker.PROBLEM</code>.
|
||||
* a problem decoration for a marker, the marker needs to be a subtype of {@code IMarker.PROBLEM}.
|
||||
* <p>
|
||||
* Note: Only images for elements in Java projects are currently updated on marker changes.
|
||||
* </p>
|
||||
|
@ -49,23 +53,20 @@ import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
|
|||
* @since 2.0
|
||||
*/
|
||||
public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator {
|
||||
|
||||
/**
|
||||
* This is a special <code>LabelProviderChangedEvent</code> carring additional
|
||||
* information whether the event orgins from a maker change.
|
||||
* This is a special {@code LabelProviderChangedEvent} carrying additional
|
||||
* information whether the event originates from a maker change.
|
||||
* <p>
|
||||
* <code>ProblemsLabelChangedEvent</code>s are only generated by <code>
|
||||
* ProblemsLabelDecorator</code>s.
|
||||
* </p>
|
||||
* {@code ProblemsLabelChangedEvent}s are only generated by {@code ProblemsLabelDecorator}s.
|
||||
*/
|
||||
public static class ProblemsLabelChangedEvent extends LabelProviderChangedEvent {
|
||||
|
||||
private boolean fMarkerChange;
|
||||
|
||||
/**
|
||||
* Note: This constructor is for internal use only. Clients should not call this constructor.
|
||||
*/
|
||||
public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource, boolean isMarkerChange) {
|
||||
public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource,
|
||||
boolean isMarkerChange) {
|
||||
super(source, changedResource);
|
||||
fMarkerChange= isMarkerChange;
|
||||
}
|
||||
|
@ -80,17 +81,45 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
public boolean isMarkerChange() {
|
||||
return fMarkerChange;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MarkersCacheKey {
|
||||
private IResource res;
|
||||
private int depth;
|
||||
|
||||
public MarkersCacheKey(IResource res, int depth) {
|
||||
this.res = res;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return res.hashCode() + 31 * depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
MarkersCacheKey other = (MarkersCacheKey) obj;
|
||||
return depth == other.depth && res.equals(other.res);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING;
|
||||
private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;
|
||||
private static final IMarker[] EMPTY_MARKER_ARRAY = {};
|
||||
|
||||
private ImageDescriptorRegistry fRegistry;
|
||||
private boolean fUseNewRegistry= false;
|
||||
private boolean fUseNewRegistry;
|
||||
private IProblemChangedListener fProblemChangedListener;
|
||||
|
||||
private ListenerList fListeners;
|
||||
private Map<MarkersCacheKey, IMarker[]> fMarkersCache = new HashMap<MarkersCacheKey, IMarker[]>();
|
||||
|
||||
/**
|
||||
* Creates a new <code>ProblemsLabelDecorator</code>.
|
||||
|
@ -119,7 +148,6 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
return fRegistry;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String decorateText(String text, Object element) {
|
||||
return text;
|
||||
|
@ -175,23 +203,29 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement) throws CoreException {
|
||||
private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement)
|
||||
throws CoreException {
|
||||
if (res == null || !res.isAccessible()) {
|
||||
return 0;
|
||||
}
|
||||
int info= 0;
|
||||
|
||||
IMarker[] markers= res.findMarkers(IMarker.PROBLEM, true, depth);
|
||||
if (markers != null) {
|
||||
for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
|
||||
IMarker curr= markers[i];
|
||||
if (sourceElement == null || isMarkerInRange(curr, sourceElement)) {
|
||||
int priority= curr.getAttribute(IMarker.SEVERITY, -1);
|
||||
if (priority == IMarker.SEVERITY_WARNING) {
|
||||
info= ERRORTICK_WARNING;
|
||||
} else if (priority == IMarker.SEVERITY_ERROR) {
|
||||
info= ERRORTICK_ERROR;
|
||||
}
|
||||
MarkersCacheKey cacheKey = new MarkersCacheKey(res, depth);
|
||||
IMarker[] markers = fMarkersCache .get(cacheKey);
|
||||
if (markers == null) {
|
||||
markers= res.findMarkers(IMarker.PROBLEM, true, depth);
|
||||
if (markers == null)
|
||||
markers = EMPTY_MARKER_ARRAY;
|
||||
fMarkersCache.put(cacheKey, markers);
|
||||
}
|
||||
for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
|
||||
IMarker curr= markers[i];
|
||||
if (sourceElement == null || isMarkerInRange(curr, sourceElement)) {
|
||||
int priority= curr.getAttribute(IMarker.SEVERITY, -1);
|
||||
if (priority == IMarker.SEVERITY_WARNING) {
|
||||
info= ERRORTICK_WARNING;
|
||||
} else if (priority == IMarker.SEVERITY_ERROR) {
|
||||
info= ERRORTICK_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +262,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException {
|
||||
ISourceRange range= sourceElement.getSourceRange();
|
||||
if (range != null) {
|
||||
if (offSet ==-1) {
|
||||
if (offSet == -1) {
|
||||
return (line >= range.getStartLine() && line <= range.getEndLine());
|
||||
}
|
||||
int rangeOffset= range.getStartPos();
|
||||
|
@ -282,6 +316,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
|
|||
}
|
||||
|
||||
protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
|
||||
fMarkersCache.clear();
|
||||
if (fListeners != null && !fListeners.isEmpty()) {
|
||||
LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
|
||||
Object[] listeners= fListeners.getListeners();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -29,7 +29,6 @@ public final class NewClassWizardMessages extends NLS {
|
|||
public static String NewClassCreationWizardPage_namespace_label;
|
||||
public static String NewClassCreationWizardPage_namespace_button;
|
||||
public static String NewClassCreationWizardPage_error_EnterNamespace;
|
||||
public static String NewClassCreationWizardPage_error_EnclosingNamespaceNotExists;
|
||||
public static String NewClassCreationWizardPage_error_NamespaceExistsDifferentCase;
|
||||
public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExists;
|
||||
public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||
# Copyright (c) 2004, 2013 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
|
||||
|
@ -34,11 +34,10 @@ NewClassCreationWizardPage_namespace_label=&Namespace:
|
|||
NewClassCreationWizardPage_namespace_button=Bro&wse...
|
||||
|
||||
NewClassCreationWizardPage_error_EnterNamespace=Namespace is empty.
|
||||
NewClassCreationWizardPage_error_EnclosingNamespaceNotExists=Enclosing namespace does not exist.
|
||||
NewClassCreationWizardPage_error_NamespaceExistsDifferentCase=Namespace with the same name exists in a different scope.
|
||||
NewClassCreationWizardPage_error_TypeMatchingNamespaceExists=Another type with the same name as specified namespace exists.
|
||||
NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase=Another type with the same name as specified namespace exists in a different scope.
|
||||
NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace does not exist. A new namespace will be created.
|
||||
NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace ''{0}'' does not exist. A new namespace will be created.
|
||||
NewClassCreationWizardPage_error_InvalidNamespace=Namespace is not valid. {0}.
|
||||
NewClassCreationWizardPage_warning_NamespaceDiscouraged=Namespace is discouraged. {0}.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2013 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
|
||||
|
@ -1591,17 +1591,8 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
ICProject project = getCurrentProject();
|
||||
|
||||
if (project != null) {
|
||||
/* search for parent name space first */
|
||||
int searchResult;
|
||||
if (typeName.isQualified()) {
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, ICPPNamespace.class);
|
||||
if (searchResult != NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
|
||||
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnclosingNamespaceNotExists);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
|
||||
switch(searchResult) {
|
||||
int searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
|
||||
switch (searchResult) {
|
||||
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
|
||||
status.setOK();
|
||||
return status;
|
||||
|
@ -1615,7 +1606,17 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase);
|
||||
return status;
|
||||
case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
|
||||
status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists);
|
||||
// Find the highest ancestor namespace that does not exist.
|
||||
IQualifiedTypeName ns = typeName;
|
||||
while (ns.isQualified()) {
|
||||
IQualifiedTypeName ns1 = ns.getEnclosingTypeName();
|
||||
if (NewClassWizardUtil.searchForCppType(ns1, project, ICPPNamespace.class) == NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
|
||||
break;
|
||||
}
|
||||
ns = ns1;
|
||||
}
|
||||
status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists,
|
||||
ns.getFullyQualifiedName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1638,7 +1639,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
StatusInfo status = new StatusInfo();
|
||||
|
||||
String className = getClassName();
|
||||
// must not be empty
|
||||
// Must not be empty.
|
||||
if (className == null || className.length() == 0) {
|
||||
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterClassName);
|
||||
return status;
|
||||
|
@ -1669,7 +1670,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
}
|
||||
}
|
||||
int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class);
|
||||
switch(searchResult) {
|
||||
switch (searchResult) {
|
||||
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
|
||||
status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExists);
|
||||
return status;
|
||||
|
@ -1729,7 +1730,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject());
|
||||
if (provider != null) {
|
||||
//TODO get the scanner info for the actual source folder
|
||||
// TODO Get the scanner info for the actual source folder.
|
||||
IScannerInfo info = provider.getScannerInformation(project.getProject());
|
||||
if (info != null) {
|
||||
String[] includePaths = info.getIncludePaths();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.utils.ui.controls;
|
||||
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
@ -22,34 +21,33 @@ import org.eclipse.swt.widgets.Layout;
|
|||
* @noextend This class is not intended to be subclassed by clients.
|
||||
*/
|
||||
public class TabFolderLayout extends Layout {
|
||||
|
||||
@Override
|
||||
protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
|
||||
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
|
||||
if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
|
||||
return new Point(wHint, hHint);
|
||||
|
||||
Control [] children = composite.getChildren ();
|
||||
|
||||
Control[] children = composite.getChildren();
|
||||
int count = children.length;
|
||||
int maxWidth = 0, maxHeight = 0;
|
||||
for (int i=0; i<count; i++) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
Control child = children [i];
|
||||
Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
|
||||
maxWidth = Math.max (maxWidth, pt.x);
|
||||
maxHeight = Math.max (maxHeight, pt.y);
|
||||
Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
|
||||
maxWidth = Math.max(maxWidth, pt.x);
|
||||
maxHeight = Math.max(maxHeight, pt.y);
|
||||
}
|
||||
|
||||
|
||||
if (wHint != SWT.DEFAULT)
|
||||
maxWidth= wHint;
|
||||
if (hHint != SWT.DEFAULT)
|
||||
maxHeight= hHint;
|
||||
|
||||
return new Point(maxWidth, maxHeight);
|
||||
|
||||
|
||||
return new Point(maxWidth, maxHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout (Composite composite, boolean flushCache) {
|
||||
protected void layout(Composite composite, boolean flushCache) {
|
||||
Rectangle rect= composite.getClientArea();
|
||||
|
||||
|
||||
Control[] children = composite.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
children[i].setBounds(rect);
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
import org.eclipse.debug.core.commands.IDebugCommandHandler;
|
||||
|
||||
/**
|
||||
* Command handler for the "Debug New Executable" command.
|
||||
*
|
||||
* @since 7.3
|
||||
*/
|
||||
public interface IDebugNewExecutableHandler extends IDebugCommandHandler {
|
||||
}
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/new_exec.gif
Executable file
BIN
debug/org.eclipse.cdt.debug.ui/icons/obj16/new_exec.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 949 B |
|
@ -242,3 +242,9 @@ OpenNewView.name = Open New View
|
|||
|
||||
# Disassembly Ruler Column extension point
|
||||
extPoint.disassemblyRulerColumn=Disassembly Ruler Column
|
||||
|
||||
# Debug New Executable Command
|
||||
DebugNewExecutable.name=Debug New Executable
|
||||
DebugNewExecutable.description=Debug a new executable
|
||||
DebugNewExecutable.label=Debug New Executable...
|
||||
DebugNewExecutable.tooltip=Debug a new executable
|
||||
|
|
|
@ -2012,7 +2012,12 @@
|
|||
id="org.eclipse.cdt.debug.ui.command.connect"
|
||||
name="%Connect.name">
|
||||
</command>
|
||||
|
||||
<command
|
||||
categoryId="org.eclipse.cdt.debug.ui.category.debugViewLayout"
|
||||
description="%DebugNewExecutable.description"
|
||||
id="org.eclipse.cdt.debug.ui.command.debugNewExecutable"
|
||||
name="%DebugNewExecutable.name">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.handlers">
|
||||
|
@ -2079,6 +2084,10 @@
|
|||
class="org.eclipse.cdt.debug.internal.ui.commands.ConnectCommandHandler"
|
||||
commandId="org.eclipse.cdt.debug.ui.command.connect">
|
||||
</handler>
|
||||
<handler
|
||||
class="org.eclipse.cdt.debug.internal.ui.commands.DebugNewExecutableHandler"
|
||||
commandId="org.eclipse.cdt.debug.ui.command.debugNewExecutable">
|
||||
</handler>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.expressions.definitions">
|
||||
|
@ -2520,6 +2529,28 @@
|
|||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
<!--
|
||||
<menuContribution
|
||||
locationURI="toolbar:org.eclipse.debug.ui.DebugView?before=stepGroup">
|
||||
<command
|
||||
commandId="org.eclipse.cdt.debug.ui.command.debugNewExecutable"
|
||||
icon="icons/obj16/new_exec.gif"
|
||||
label="%DebugNewExecutable.label"
|
||||
style="push"
|
||||
tooltip="%DebugNewExecutable.tooltip">
|
||||
</command>
|
||||
</menuContribution>
|
||||
-->
|
||||
<menuContribution
|
||||
locationURI="popup:org.eclipse.debug.ui.DebugView?before=emptyLaunchGroup">
|
||||
<command
|
||||
commandId="org.eclipse.cdt.debug.ui.command.debugNewExecutable"
|
||||
icon="icons/obj16/new_exec.gif"
|
||||
label="%DebugNewExecutable.label"
|
||||
style="push"
|
||||
tooltip="%DebugNewExecutable.tooltip">
|
||||
</command>
|
||||
</menuContribution>
|
||||
|
||||
<!-- Connect contributions to debug view menu, toolbar menu -->
|
||||
<menuContribution
|
||||
|
|
|
@ -89,10 +89,13 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
|
|||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.debug.ui.ISourcePresentation;
|
||||
import org.eclipse.debug.ui.IValueDetailListener;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
|
@ -105,7 +108,7 @@ import com.ibm.icu.text.MessageFormat;
|
|||
/**
|
||||
* @see IDebugModelPresentation
|
||||
*/
|
||||
public class CDebugModelPresentation extends LabelProvider implements IDebugModelPresentation {
|
||||
public class CDebugModelPresentation extends LabelProvider implements IDebugModelPresentation, IColorProvider {
|
||||
|
||||
public final static String DISPLAY_FULL_PATHS = "DISPLAY_FULL_PATHS"; //$NON-NLS-1$
|
||||
|
||||
|
@ -194,6 +197,14 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
}
|
||||
if ( file != null )
|
||||
return new FileEditorInput( file );
|
||||
// There is no file associated with this breakpoint. See if another editor is available from an adapter
|
||||
ISourcePresentation srcPres = (ISourcePresentation) Platform.getAdapterManager().getAdapter(b, ISourcePresentation.class);
|
||||
if ( srcPres != null ) {
|
||||
IEditorInput editor = srcPres.getEditorInput(b);
|
||||
if ( editor != null ) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( element instanceof FileStorage || element instanceof LocalFileStorage ) {
|
||||
return new ExternalEditorInput( ((IStorage) element).getFullPath() );
|
||||
|
@ -220,7 +231,20 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
if ( input != null ) {
|
||||
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
||||
IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() );
|
||||
id = (descriptor != null) ? descriptor.getId() : CUIPlugin.EDITOR_ID;
|
||||
id = CUIPlugin.EDITOR_ID;
|
||||
if ( descriptor != null ) {
|
||||
id = descriptor.getId();
|
||||
}
|
||||
else if ( element instanceof ICBreakpoint ) {
|
||||
// There is no associated editor ID for this breakpoint, see if an alternative can be supplied from an adapter.
|
||||
ISourcePresentation sourcePres = (ISourcePresentation) Platform.getAdapterManager().getAdapter(element, ISourcePresentation.class);
|
||||
if ( sourcePres != null ) {
|
||||
String lid = sourcePres.getEditorId(input, element);
|
||||
if ( lid != null ) {
|
||||
id = lid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
@ -797,4 +821,21 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return MessageFormat.format( string, (Object[]) args );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getForeground(Object element) {
|
||||
IColorProvider colorProv = (IColorProvider) Platform.getAdapterManager().getAdapter(element, IColorProvider.class);
|
||||
if ( colorProv != null ) {
|
||||
return colorProv.getForeground(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground(Object element) {
|
||||
IColorProvider colorProv = (IColorProvider) Platform.getAdapterManager().getAdapter(element, IColorProvider.class);
|
||||
if ( colorProv != null ) {
|
||||
return colorProv.getBackground(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.commands;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler;
|
||||
import org.eclipse.debug.ui.actions.DebugCommandHandler;
|
||||
|
||||
public class DebugNewExecutableHandler extends DebugCommandHandler {
|
||||
|
||||
@Override
|
||||
protected Class<?> getCommandType() {
|
||||
return IDebugNewExecutableHandler.class;
|
||||
}
|
||||
}
|
|
@ -124,6 +124,12 @@ public class ReverseToggleCommandHandler extends DebugCommandHandler implements
|
|||
return adapter;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.actions.DebugCommandHandler#postExecute(org.eclipse.debug.core.IRequest, java.lang.Object[])
|
||||
*
|
||||
* We keep this logic for users that may not do the refresh themselves.
|
||||
*/
|
||||
@Override
|
||||
protected void postExecute(IRequest request, Object[] targets) {
|
||||
super.postExecute(request, targets);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.WeakHashMap;
|
|||
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.IConnectHandler;
|
||||
import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler;
|
||||
import org.eclipse.cdt.debug.core.model.IResumeWithoutSignalHandler;
|
||||
import org.eclipse.cdt.debug.core.model.IReverseResumeHandler;
|
||||
import org.eclipse.cdt.debug.core.model.IReverseStepIntoHandler;
|
||||
|
@ -49,6 +50,7 @@ import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand;
|
|||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbConnectCommand;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbDebugNewExecutableCommand;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseStepIntoCommand;
|
||||
|
@ -114,6 +116,7 @@ public class GdbAdapterFactory
|
|||
final GdbResumeWithoutSignalCommand fResumeWithoutSignalCommand;
|
||||
final GdbRestartCommand fRestartCommand;
|
||||
final DsfTerminateCommand fTerminateCommand;
|
||||
final GdbDebugNewExecutableCommand fDebugNewExecutableCommand;
|
||||
final GdbConnectCommand fConnectCommand;
|
||||
final GdbDisconnectCommand fDisconnectCommand;
|
||||
final IDebugModelProvider fDebugModelProvider;
|
||||
|
@ -162,7 +165,8 @@ public class GdbAdapterFactory
|
|||
fResumeWithoutSignalCommand = new GdbResumeWithoutSignalCommand(session);
|
||||
fRestartCommand = new GdbRestartCommand(session, fLaunch);
|
||||
fTerminateCommand = new DsfTerminateCommand(session);
|
||||
fConnectCommand = new GdbConnectCommand(session);
|
||||
fDebugNewExecutableCommand = new GdbDebugNewExecutableCommand(session, fLaunch);
|
||||
fConnectCommand = new GdbConnectCommand(session, fLaunch);
|
||||
fDisconnectCommand = new GdbDisconnectCommand(session);
|
||||
fSuspendTrigger = new GdbSuspendTrigger(session, fLaunch);
|
||||
fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
|
||||
|
@ -189,6 +193,7 @@ public class GdbAdapterFactory
|
|||
session.registerModelAdapter(IRestartHandler.class, fRestartCommand);
|
||||
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
||||
session.registerModelAdapter(IConnectHandler.class, fConnectCommand);
|
||||
session.registerModelAdapter(IDebugNewExecutableHandler.class, fDebugNewExecutableCommand);
|
||||
session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand);
|
||||
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
|
||||
session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget);
|
||||
|
@ -249,6 +254,7 @@ public class GdbAdapterFactory
|
|||
session.unregisterModelAdapter(IRestartHandler.class);
|
||||
session.unregisterModelAdapter(ITerminateHandler.class);
|
||||
session.unregisterModelAdapter(IConnectHandler.class);
|
||||
session.unregisterModelAdapter(IDebugNewExecutableHandler.class);
|
||||
session.unregisterModelAdapter(IDisconnectHandler.class);
|
||||
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
|
||||
session.unregisterModelAdapter(IRefreshAllTarget.class);
|
||||
|
@ -279,6 +285,7 @@ public class GdbAdapterFactory
|
|||
fRestartCommand.dispose();
|
||||
fTerminateCommand.dispose();
|
||||
fConnectCommand.dispose();
|
||||
fDebugNewExecutableCommand.dispose();
|
||||
fDisconnectCommand.dispose();
|
||||
fSuspendTrigger.dispose();
|
||||
fReverseToggleTarget.dispose();
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.concurrent.CancellationException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.model.IConnectHandler;
|
||||
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
|
@ -35,9 +36,11 @@ import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
|||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.gdb.actions.IConnect;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.ProcessInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.ProcessPrompter.PrompterInfo;
|
||||
|
@ -68,7 +71,8 @@ import org.eclipse.swt.widgets.Shell;
|
|||
import org.eclipse.ui.progress.UIJob;
|
||||
|
||||
public class GdbConnectCommand extends AbstractDebugCommand implements IConnectHandler, IConnect {
|
||||
|
||||
|
||||
private final GdbLaunch fLaunch;
|
||||
private final DsfExecutor fExecutor;
|
||||
private final DsfServicesTracker fTracker;
|
||||
|
||||
|
@ -82,7 +86,8 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
// the binary location for a local attach session.
|
||||
private Map<String, String> fProcessNameToBinaryMap = new HashMap<String, String>();
|
||||
|
||||
public GdbConnectCommand(DsfSession session) {
|
||||
public GdbConnectCommand(DsfSession session, GdbLaunch launch) {
|
||||
fLaunch = launch;
|
||||
fExecutor = session.getExecutor();
|
||||
fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||
}
|
||||
|
@ -143,10 +148,12 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
IProcessExtendedInfo[] fProcessList = null;
|
||||
DataRequestMonitor<Object> fRequestMonitor;
|
||||
boolean fNewProcessSupported;
|
||||
boolean fRemote;
|
||||
|
||||
public PromptForPidJob(String name, boolean newProcessSupported, IProcessExtendedInfo[] procs, DataRequestMonitor<Object> rm) {
|
||||
public PromptForPidJob(String name, boolean newProcessSupported, boolean remote, IProcessExtendedInfo[] procs, DataRequestMonitor<Object> rm) {
|
||||
super(name);
|
||||
fNewProcessSupported = newProcessSupported;
|
||||
fRemote = remote;
|
||||
fProcessList = procs;
|
||||
fRequestMonitor = rm;
|
||||
}
|
||||
|
@ -158,11 +165,11 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
null);
|
||||
|
||||
try {
|
||||
PrompterInfo info = new PrompterInfo(fNewProcessSupported, fProcessList);
|
||||
PrompterInfo info = new PrompterInfo(fNewProcessSupported, fRemote, fProcessList);
|
||||
Object result = new ProcessPrompter().handleStatus(null, info);
|
||||
if (result == null) {
|
||||
fRequestMonitor.cancel();
|
||||
} else if (result instanceof IProcessExtendedInfo[] || result instanceof String) {
|
||||
} else if (result instanceof IProcessExtendedInfo[] || result instanceof NewExecutableInfo) {
|
||||
fRequestMonitor.setData(result);
|
||||
} else if (result instanceof Integer) {
|
||||
// This is the case where the user typed in a pid number directly
|
||||
|
@ -288,9 +295,11 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
public void run() {
|
||||
final IProcesses procService = fTracker.getService(IProcesses.class);
|
||||
ICommandControlService commandControl = fTracker.getService(ICommandControlService.class);
|
||||
IGDBBackend backend = fTracker.getService(IGDBBackend.class);
|
||||
|
||||
if (procService != null && commandControl != null) {
|
||||
if (procService != null && commandControl != null && backend != null) {
|
||||
final ICommandControlDMContext controlCtx = commandControl.getContext();
|
||||
final boolean remote = backend.getSessionType() == SessionType.REMOTE;
|
||||
|
||||
// First check if the "New..." button should be enabled.
|
||||
procService.isDebugNewProcessSupported(controlCtx, new DataRequestMonitor<Boolean>(fExecutor, rm) {
|
||||
|
@ -314,7 +323,8 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
// Prompt the user to choose one or more processes, or to start a new one
|
||||
new PromptForPidJob(
|
||||
LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$
|
||||
newProcessSupported,
|
||||
newProcessSupported,
|
||||
remote,
|
||||
procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]),
|
||||
new DataRequestMonitor<Object>(fExecutor, rm) {
|
||||
@Override
|
||||
|
@ -325,9 +335,9 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
@Override
|
||||
protected void handleSuccess() {
|
||||
Object data = getData();
|
||||
if (data instanceof String) {
|
||||
if (data instanceof NewExecutableInfo) {
|
||||
// User wants to start a new process
|
||||
startNewProcess(controlCtx, (String)data, rm);
|
||||
startNewProcess(controlCtx, (NewExecutableInfo)data, rm);
|
||||
} else if (data instanceof IProcessExtendedInfo[]) {
|
||||
attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm);
|
||||
} else {
|
||||
|
@ -412,11 +422,23 @@ public class GdbConnectCommand extends AbstractDebugCommand implements IConnectH
|
|||
});
|
||||
}
|
||||
|
||||
private void startNewProcess(ICommandControlDMContext controlDmc, String binaryPath, RequestMonitor rm) {
|
||||
private void startNewProcess(ICommandControlDMContext controlDmc, NewExecutableInfo info, RequestMonitor rm) {
|
||||
IGDBProcesses procService = fTracker.getService(IGDBProcesses.class);
|
||||
procService.debugNewProcess(
|
||||
controlDmc, binaryPath,
|
||||
new HashMap<String, Object>(), new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> attributes = fLaunch.getLaunchConfiguration().getAttributes();
|
||||
attributes.put(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, info.getTargetPath());
|
||||
attributes.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, info.getArguments());
|
||||
procService.debugNewProcess(
|
||||
controlDmc,
|
||||
info.getHostPath(),
|
||||
attributes,
|
||||
new DataRequestMonitor<IDMContext>(fExecutor, rm));
|
||||
}
|
||||
catch(CoreException e) {
|
||||
rm.setStatus(e.getStatus());
|
||||
rm.done();
|
||||
}
|
||||
}
|
||||
|
||||
private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) {
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IProcesses;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.NewExecutableDialog;
|
||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
||||
import org.eclipse.cdt.dsf.gdb.service.SessionType;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.IRequest;
|
||||
import org.eclipse.debug.core.commands.AbstractDebugCommand;
|
||||
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
|
||||
public class GdbDebugNewExecutableCommand extends AbstractDebugCommand implements IDebugNewExecutableHandler {
|
||||
|
||||
private class PromptJob extends UIJob {
|
||||
|
||||
private DataRequestMonitor<NewExecutableInfo> fRequestMonitor;
|
||||
private boolean fRemote = false;
|
||||
|
||||
private PromptJob( boolean remote, DataRequestMonitor<NewExecutableInfo> rm ) {
|
||||
super( Messages.GdbDebugNewExecutableCommand_New_Executable_Prompt_Job );
|
||||
fRemote = remote;
|
||||
fRequestMonitor = rm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatus runInUIThread( IProgressMonitor monitor ) {
|
||||
int flags = ( fRemote ) ? NewExecutableDialog.REMOTE : 0;
|
||||
NewExecutableDialog dialog = new NewExecutableDialog( GdbUIPlugin.getShell(), flags );
|
||||
final boolean canceled = dialog.open() == Window.CANCEL;
|
||||
final NewExecutableInfo info = dialog.getExecutableInfo();
|
||||
fExecutor.execute( new DsfRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if ( canceled )
|
||||
fRequestMonitor.cancel();
|
||||
else
|
||||
fRequestMonitor.setData( info );
|
||||
fRequestMonitor.done();
|
||||
}
|
||||
} );
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
private final GdbLaunch fLaunch;
|
||||
private final DsfExecutor fExecutor;
|
||||
private final DsfServicesTracker fTracker;
|
||||
|
||||
public GdbDebugNewExecutableCommand( DsfSession session, GdbLaunch launch ) {
|
||||
super();
|
||||
fLaunch = launch;
|
||||
fExecutor = session.getExecutor();
|
||||
fTracker = new DsfServicesTracker( GdbUIPlugin.getBundleContext(), session.getId() );
|
||||
}
|
||||
|
||||
public boolean canDebugNewExecutable() {
|
||||
|
||||
Query<Boolean> canDebugQuery = new Query<Boolean>() {
|
||||
@Override
|
||||
public void execute( DataRequestMonitor<Boolean> rm ) {
|
||||
IProcesses procService = fTracker.getService( IProcesses.class );
|
||||
ICommandControlService commandControl = fTracker.getService( ICommandControlService.class );
|
||||
|
||||
if ( procService == null || commandControl == null ) {
|
||||
rm.setData( false );
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
procService.isDebugNewProcessSupported( commandControl.getContext(), rm );
|
||||
}
|
||||
};
|
||||
try {
|
||||
fExecutor.execute( canDebugQuery );
|
||||
return canDebugQuery.get();
|
||||
}
|
||||
catch( InterruptedException e ) {
|
||||
}
|
||||
catch( ExecutionException e ) {
|
||||
}
|
||||
catch( RejectedExecutionException e ) {
|
||||
// Can be thrown if the session is shutdown
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void debugNewExecutable( final RequestMonitor rm ) {
|
||||
IGDBBackend backend = fTracker.getService( IGDBBackend.class );
|
||||
final IProcesses procService = fTracker.getService( IProcesses.class );
|
||||
final ICommandControlService commandControl = fTracker.getService( ICommandControlService.class );
|
||||
if ( backend == null || procService == null || commandControl == null ) {
|
||||
rm.setStatus( new Status( IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available" ) ); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
PromptJob job = new PromptJob(
|
||||
backend.getSessionType() == SessionType.REMOTE,
|
||||
new DataRequestMonitor<NewExecutableInfo>( fExecutor, rm ){
|
||||
|
||||
@Override
|
||||
protected void handleCancel() {
|
||||
rm.cancel();
|
||||
rm.done();
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
try {
|
||||
@SuppressWarnings( "unchecked" )
|
||||
Map<String, Object> attributes = getLaunchConfiguration().getAttributes();
|
||||
attributes.put( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, getData().getTargetPath() );
|
||||
attributes.put( ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, getData().getArguments() );
|
||||
procService.debugNewProcess(
|
||||
commandControl.getContext(),
|
||||
getData().getHostPath(),
|
||||
attributes,
|
||||
new ImmediateDataRequestMonitor<IDMContext>( rm ) );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
rm.setStatus( e.getStatus() );
|
||||
rm.done();
|
||||
}
|
||||
};
|
||||
} );
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute( Object[] targets, IProgressMonitor monitor, IRequest request ) throws CoreException {
|
||||
Query<Boolean> query = new Query<Boolean>() {
|
||||
|
||||
@Override
|
||||
protected void execute( DataRequestMonitor<Boolean> rm ) {
|
||||
debugNewExecutable( rm );
|
||||
}
|
||||
};
|
||||
try {
|
||||
fExecutor.execute( query );
|
||||
query.get();
|
||||
}
|
||||
catch( InterruptedException e ) {
|
||||
}
|
||||
catch( ExecutionException e ) {
|
||||
}
|
||||
catch( CancellationException e ) {
|
||||
// Nothing to do, just ignore the command since the user
|
||||
// cancelled it.
|
||||
}
|
||||
catch( RejectedExecutionException e ) {
|
||||
// Can be thrown if the session is shutdown
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isExecutable( Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request ) throws CoreException {
|
||||
return canDebugNewExecutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getTarget( Object element ) {
|
||||
if ( element instanceof GdbLaunch || element instanceof IDMVMContext )
|
||||
return element;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
fTracker.dispose();
|
||||
}
|
||||
|
||||
private ILaunchConfiguration getLaunchConfiguration() {
|
||||
return fLaunch.getLaunchConfiguration();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Ericsson and others.
|
||||
* Copyright (c) 2009, 2013 Ericsson 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ericsson - initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Listen for IReverseModeChangedDMEvent (Bug 399163)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import java.util.concurrent.RejectedExecutionException;
|
|||
import org.eclipse.cdt.debug.core.model.IReverseToggleHandler;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.Query;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
|
@ -24,15 +26,23 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
|||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IReverseRunControl;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IReverseRunControl.IReverseModeChangedDMEvent;
|
||||
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.IRequest;
|
||||
import org.eclipse.debug.core.commands.AbstractDebugCommand;
|
||||
import org.eclipse.debug.core.commands.IDebugCommandRequest;
|
||||
import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.commands.ICommandService;
|
||||
import org.eclipse.ui.progress.WorkbenchJob;
|
||||
import org.eclipse.ui.services.IEvaluationService;
|
||||
|
||||
/**
|
||||
* Command that toggles the Reverse Debugging feature
|
||||
|
@ -42,13 +52,33 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest;
|
|||
public class GdbReverseToggleCommand extends AbstractDebugCommand implements IReverseToggleHandler {
|
||||
private final DsfExecutor fExecutor;
|
||||
private final DsfServicesTracker fTracker;
|
||||
private final DsfSession fSession;
|
||||
|
||||
public GdbReverseToggleCommand(DsfSession session) {
|
||||
fExecutor = session.getExecutor();
|
||||
fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
|
||||
fSession = session;
|
||||
try {
|
||||
fExecutor.execute(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fSession.addServiceEventListener(GdbReverseToggleCommand.this, null);
|
||||
}
|
||||
});
|
||||
} catch(RejectedExecutionException e) {}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
try {
|
||||
fExecutor.execute(new DsfRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fSession.removeServiceEventListener(GdbReverseToggleCommand.this);
|
||||
}
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
// Session already gone.
|
||||
}
|
||||
fTracker.dispose();
|
||||
}
|
||||
|
||||
|
@ -195,4 +225,30 @@ public class GdbReverseToggleCommand extends AbstractDebugCommand implements IRe
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @noreference This method is not intended to be referenced by clients.
|
||||
*/
|
||||
@DsfServiceEventHandler
|
||||
public void eventDispatched(IReverseModeChangedDMEvent e) {
|
||||
new WorkbenchJob("") { //$NON-NLS-1$
|
||||
@Override
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
// Request re-evaluation of property "org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled" to update
|
||||
// visibility of reverse stepping commands.
|
||||
IEvaluationService exprService = (IEvaluationService) PlatformUI.getWorkbench().getService(IEvaluationService.class);
|
||||
if (exprService != null) {
|
||||
exprService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled"); //$NON-NLS-1$
|
||||
}
|
||||
// Refresh reverse toggle commands with the new state of reverse enabled.
|
||||
// This is in order to keep multiple toggle actions in UI in sync.
|
||||
ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
|
||||
if (commandService != null) {
|
||||
commandService.refreshElements("org.eclipse.cdt.debug.ui.command.reverseToggle", null); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}.schedule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ericsson - initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Instruction-level step-return does not make sense (bug 399123)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
|
||||
|
||||
|
@ -26,7 +27,6 @@ public class GdbUncallCommand extends GdbAbstractReverseStepCommand implements I
|
|||
|
||||
@Override
|
||||
protected final StepType getStepType() {
|
||||
boolean instructionSteppingEnabled = getSteppingMode() != null && getSteppingMode().isInstructionSteppingEnabled();
|
||||
return instructionSteppingEnabled ? StepType.INSTRUCTION_STEP_RETURN : StepType.STEP_RETURN;
|
||||
return StepType.STEP_RETURN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.commands;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Arguments;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary_file_does_not_exist;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary_must_be_specified;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary_on_host;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary_on_target;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Browse;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Debug_New_Executable;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Host_binary_must_be_specified;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Invalid_binary;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Invalid_host_binary;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_New_Executable_Prompt_Job;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Select_Binary;
|
||||
|
||||
public static String GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages( Messages.class.getName(), Messages.class );
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2012 Mentor Graphics 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:
|
||||
# Mentor Graphics - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
GdbDebugNewExecutableCommand_Arguments=Arguments:
|
||||
GdbDebugNewExecutableCommand_Binary=Binary:
|
||||
GdbDebugNewExecutableCommand_Binary_file_does_not_exist=Binary file does not exist
|
||||
GdbDebugNewExecutableCommand_Binary_must_be_specified=Binary must be specified
|
||||
GdbDebugNewExecutableCommand_Binary_on_host=Binary on host:
|
||||
GdbDebugNewExecutableCommand_Binary_on_target=Binary on target:
|
||||
GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified=Binary on target must be specified
|
||||
GdbDebugNewExecutableCommand_Browse=Browse...
|
||||
GdbDebugNewExecutableCommand_Debug_New_Executable=Debug New Executable
|
||||
GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist=Host binary file does not exist
|
||||
GdbDebugNewExecutableCommand_Host_binary_must_be_specified=Host binary must be specified
|
||||
GdbDebugNewExecutableCommand_Invalid_binary=Invalid binary
|
||||
GdbDebugNewExecutableCommand_Invalid_host_binary=Invalid host binary
|
||||
GdbDebugNewExecutableCommand_New_Executable_Prompt_Job=New Executable Prompt Job
|
||||
GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target=Select binaries on the host and the target and specify the arguments
|
||||
GdbDebugNewExecutableCommand_Select_Binary=Select Binary
|
||||
GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments=Select a binary and specify the arguments
|
|
@ -0,0 +1,169 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Mentor Graphics 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:
|
||||
* Mentor Graphics - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.commands.Messages;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
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.Control;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class NewExecutableDialog extends TitleAreaDialog {
|
||||
|
||||
public static final int REMOTE = 0x1;
|
||||
|
||||
private int fFlags = 0;
|
||||
private NewExecutableInfo fInfo = null;
|
||||
|
||||
private Text fHostBinaryText;
|
||||
private Text fTargetBinaryText;
|
||||
private Text fArgumentsText;
|
||||
|
||||
public NewExecutableDialog( Shell parentShell, int flags ) {
|
||||
super( parentShell );
|
||||
setShellStyle( getShellStyle() | SWT.RESIZE );
|
||||
fFlags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents( Composite parent ) {
|
||||
Control control = super.createContents( parent );
|
||||
validate();
|
||||
return control;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea( Composite parent ) {
|
||||
boolean remote = (fFlags & REMOTE) > 0;
|
||||
|
||||
getShell().setText( Messages.GdbDebugNewExecutableCommand_Debug_New_Executable );
|
||||
setTitle( Messages.GdbDebugNewExecutableCommand_Select_Binary );
|
||||
String message = ( remote ) ?
|
||||
Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target :
|
||||
Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments;
|
||||
setMessage( message );
|
||||
|
||||
Composite control = (Composite)super.createDialogArea( parent );
|
||||
Composite comp = new Composite( control, SWT.NONE );
|
||||
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true );
|
||||
GridLayout layout = new GridLayout( 3, false );
|
||||
comp.setLayout( layout );
|
||||
comp.setLayoutData( gd );
|
||||
|
||||
new Label( comp, SWT.None ).setText( remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host : Messages.GdbDebugNewExecutableCommand_Binary );
|
||||
fHostBinaryText = new Text( comp, SWT.BORDER );
|
||||
fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
|
||||
fHostBinaryText.addModifyListener( new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText( ModifyEvent e ) {
|
||||
validate();
|
||||
}
|
||||
} );
|
||||
Button browseButton = new Button( comp, SWT.PUSH );
|
||||
browseButton.setText( Messages.GdbDebugNewExecutableCommand_Browse );
|
||||
browseButton.setFont( JFaceResources.getDialogFont() );
|
||||
setButtonLayoutData( browseButton );
|
||||
browseButton.addSelectionListener( new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent e ) {
|
||||
FileDialog dialog = new FileDialog( getShell() );
|
||||
dialog.setFileName( fHostBinaryText.getText() );
|
||||
String result = dialog.open();
|
||||
if ( result != null ) {
|
||||
fHostBinaryText.setText( result );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
if ( remote ) {
|
||||
new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Binary_on_target );
|
||||
fTargetBinaryText = new Text( comp, SWT.BORDER );
|
||||
fTargetBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) );
|
||||
fTargetBinaryText.addModifyListener( new ModifyListener() {
|
||||
|
||||
@Override
|
||||
public void modifyText( ModifyEvent e ) {
|
||||
validate();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Arguments );
|
||||
fArgumentsText = new Text( comp, SWT.BORDER );
|
||||
fArgumentsText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) );
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
String targetPath = ( fTargetBinaryText != null ) ? fTargetBinaryText.getText().trim() : null;
|
||||
String args = fArgumentsText.getText().trim();
|
||||
fInfo = new NewExecutableInfo( fHostBinaryText.getText().trim(), targetPath, args );
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
public NewExecutableInfo getExecutableInfo() {
|
||||
return fInfo;
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
boolean remote = (fFlags & REMOTE) > 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String hostBinary = fHostBinaryText.getText().trim();
|
||||
if ( hostBinary.isEmpty() ) {
|
||||
sb.append( ( remote ) ?
|
||||
Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified :
|
||||
Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified );
|
||||
}
|
||||
else {
|
||||
File file = new File( hostBinary );
|
||||
if ( !file.exists() ) {
|
||||
sb.append( ( remote ) ?
|
||||
Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist :
|
||||
Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist );
|
||||
}
|
||||
else if ( file.isDirectory() ) {
|
||||
sb.append( ( remote ) ?
|
||||
Messages.GdbDebugNewExecutableCommand_Invalid_host_binary :
|
||||
Messages.GdbDebugNewExecutableCommand_Invalid_binary );
|
||||
}
|
||||
}
|
||||
if ( fTargetBinaryText != null ) {
|
||||
if ( fTargetBinaryText.getText().trim().length() == 0 ) {
|
||||
if ( sb.length() != 0 ) {
|
||||
sb.append( "\n " ); //$NON-NLS-1$
|
||||
}
|
||||
sb.append( Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified );
|
||||
}
|
||||
}
|
||||
setErrorMessage( ( sb.length() != 0 ) ? sb.toString() : null );
|
||||
getButton( IDialogConstants.OK_ID ).setEnabled( getErrorMessage() == null );
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue