mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
ee18e8567c
39 changed files with 2808 additions and 2644 deletions
|
@ -596,7 +596,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
// with UTF-8 encoding since GNU compilers can handle only UTF-8 characters.
|
// with UTF-8 encoding since GNU compilers can handle only UTF-8 characters.
|
||||||
// Include paths with locale characters will be handled properly regardless
|
// Include paths with locale characters will be handled properly regardless
|
||||||
// of the language as long as the encoding is set to UTF-8.
|
// of the language as long as the encoding is set to UTF-8.
|
||||||
// Default language is set for parser because it relies on English messages
|
// English language is set for parser because it relies on English messages
|
||||||
// in the output of the 'gcc -v' command.
|
// in the output of the 'gcc -v' command.
|
||||||
|
|
||||||
List<String> envp = new ArrayList<String>(Arrays.asList(BuildRunnerHelper.getEnvp(currentCfgDescription)));
|
List<String> envp = new ArrayList<String>(Arrays.asList(BuildRunnerHelper.getEnvp(currentCfgDescription)));
|
||||||
|
@ -606,7 +606,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
envp.add(ENV_LANGUAGE + "=C"); // override for GNU gettext //$NON-NLS-1$
|
envp.add(ENV_LANGUAGE + "=en"); // override for GNU gettext //$NON-NLS-1$
|
||||||
envp.add(ENV_LC_ALL + "=C.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$
|
envp.add(ENV_LC_ALL + "=C.UTF-8"); // for other parts of the system libraries //$NON-NLS-1$
|
||||||
|
|
||||||
return envp.toArray(new String[envp.size()]);
|
return envp.toArray(new String[envp.size()]);
|
||||||
|
|
|
@ -1206,7 +1206,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if output of '-n'/'--just-print' or '-w'/'--print-directory' options of make can be recognized.
|
* Checks if output of -w or --print-directory options of make can be recognized.
|
||||||
*
|
*
|
||||||
* @throws Exception...
|
* @throws Exception...
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Mike Kucera (IBM)
|
* Mike Kucera (IBM)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -366,19 +367,20 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public int size() { return nameList.size(); }
|
public int size() { return nameList.size(); }
|
||||||
|
|
||||||
public void dump() {
|
public void dump() {
|
||||||
for (int i=0; i<size(); i++) {
|
for (int i= 0; i < size(); i++) {
|
||||||
IASTName name= getName(i);
|
IASTName name= getName(i);
|
||||||
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
|
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
|
||||||
System.out.println(i+": #"+name.getRawSignature()+"# "+parent);
|
System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
|
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < collector.size(); i++)
|
for (int i = 0; i < collector.size(); i++) {
|
||||||
if (collector.getName(i).resolveBinding() == binding)
|
if (collector.getName(i).resolveBinding() == binding)
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
assertEquals(num, count);
|
assertEquals(num, count);
|
||||||
}
|
}
|
||||||
|
@ -490,11 +492,11 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
|
||||||
assertNotNull("Expected object of "+clazz.getName()+" but got a null value", o);
|
assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
|
||||||
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
|
||||||
for (Class c : cs) {
|
for (Class c : cs) {
|
||||||
assertNotNull("Expected object of "+c.getName()+" but got a null value", o);
|
assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
|
||||||
assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
|
assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
|
||||||
}
|
}
|
||||||
return clazz.cast(o);
|
return clazz.cast(o);
|
||||||
}
|
}
|
||||||
|
@ -521,9 +523,9 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
return tu;
|
return tu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProblemBinding assertProblem(String section, int len) {
|
public IProblemBinding assertProblem(String section, int len) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len= section.length()+len;
|
len= section.length() + len;
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
|
||||||
binding instanceof IProblemBinding);
|
binding instanceof IProblemBinding);
|
||||||
|
@ -532,11 +534,11 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len= section.length()+len;
|
len= section.length() + len;
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
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) {
|
if (binding == null) {
|
||||||
fail("Null binding resolved for name: " + section.substring(0, len));
|
fail("Null binding resolved for name: " + section.substring(0, len));
|
||||||
|
@ -548,7 +550,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
IASTName name= findName(section, len);
|
IASTName name= findName(section, len);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
String selection = section.substring(0, len);
|
String selection = section.substring(0, len);
|
||||||
fail("Found unexpected \""+selection+"\": " + name.resolveBinding());
|
fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +561,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("did not find \"" + selection + "\"", name);
|
||||||
|
|
||||||
assertInstance(name, IASTImplicitName.class);
|
assertInstance(name, IASTImplicitName.class);
|
||||||
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
|
||||||
|
@ -587,7 +589,7 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
public void assertNoImplicitName(String section, int len) {
|
public void assertNoImplicitName(String section, int len) {
|
||||||
IASTName name = findImplicitName(section, len);
|
IASTName name = findImplicitName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNull("found name \""+selection+"\"", name);
|
assertNull("found name \"" + selection + "\"", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
public IASTImplicitName[] getImplicitNames(String section, int len) {
|
||||||
|
@ -627,6 +629,23 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
return selector.findImplicitName(offset, len);
|
return selector.findImplicitName(offset, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends IASTNode> T assertNode(String context, String nodeText, Class<T> type, Class... cs) {
|
||||||
|
if (context == null) {
|
||||||
|
context = contents;
|
||||||
|
}
|
||||||
|
int offset = contents.indexOf(context);
|
||||||
|
assertTrue("Context \"" + context + "\" not found", offset >= 0);
|
||||||
|
int nodeOffset = context.indexOf(nodeText);
|
||||||
|
assertTrue("Node \"" + nodeText + "\" not found", nodeOffset >= 0);
|
||||||
|
IASTNodeSelector selector = tu.getNodeSelector(null);
|
||||||
|
IASTNode node = selector.findNode(offset + nodeOffset, nodeText.length());
|
||||||
|
return assertType(node, type, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends IASTNode> T assertNode(String nodeText, Class<T> type, Class... cs) {
|
||||||
|
return assertNode(contents, nodeText, type, cs);
|
||||||
|
}
|
||||||
|
|
||||||
private String renderProblemID(int i) {
|
private String renderProblemID(int i) {
|
||||||
try {
|
try {
|
||||||
for (Field field : IProblemBinding.class.getDeclaredFields()) {
|
for (Field field : IProblemBinding.class.getDeclaredFields()) {
|
||||||
|
@ -647,29 +666,53 @@ public class AST2BaseTest extends BaseTestCase {
|
||||||
|
|
||||||
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
len+= section.length();
|
len += section.length();
|
||||||
IBinding binding= binding(section, len);
|
IBinding binding= binding(section, len);
|
||||||
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
assertTrue("ProblemBinding for name: " + section.substring(0, len),
|
||||||
!(binding instanceof IProblemBinding));
|
!(binding instanceof IProblemBinding));
|
||||||
assertInstance(binding, type);
|
return assertType(binding, type, cs);
|
||||||
for (Class c : cs) {
|
|
||||||
assertInstance(binding, c);
|
|
||||||
}
|
|
||||||
return type.cast(binding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends IBinding> T assertNonProblem(String section, Class<T> type, Class... cs) {
|
||||||
|
return assertNonProblem(section, section.length(), type, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends IBinding> T assertNonProblem(String context, String name, Class<T> type, Class... cs) {
|
||||||
|
IBinding binding= binding(context, name);
|
||||||
|
assertTrue("ProblemBinding for name: " + name, !(binding instanceof IProblemBinding));
|
||||||
|
return assertType(binding, type, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, U extends T> U assertType(T obj, Class<U> type, Class... cs) {
|
||||||
|
assertInstance(obj, type);
|
||||||
|
for (Class c : cs) {
|
||||||
|
assertInstance(obj, c);
|
||||||
|
}
|
||||||
|
return type.cast(obj);
|
||||||
|
}
|
||||||
|
|
||||||
private IBinding binding(String section, int len) {
|
private IBinding binding(String section, int len) {
|
||||||
IASTName name = findName(section, len);
|
IASTName name = findName(section, len);
|
||||||
final String selection = section.substring(0, len);
|
final String selection = section.substring(0, len);
|
||||||
assertNotNull("did not find \""+selection+"\"", name);
|
assertNotNull("Did not find \"" + selection + "\"", name);
|
||||||
assertEquals(selection, name.getRawSignature());
|
assertEquals(selection, name.getRawSignature());
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
assertNotNull("No binding for "+name.getRawSignature(), binding);
|
assertNotNull("No binding for " + name.getRawSignature(), binding);
|
||||||
|
|
||||||
return name.resolveBinding();
|
return name.resolveBinding();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private IBinding binding(String context, String name) {
|
||||||
|
IASTName astName = findName(context, name);
|
||||||
|
assertEquals(name, astName.getRawSignature());
|
||||||
|
|
||||||
|
IBinding binding = astName.resolveBinding();
|
||||||
|
assertNotNull("No binding for " + astName.getRawSignature(), binding);
|
||||||
|
|
||||||
|
return astName.resolveBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang) throws Exception {
|
final protected IASTTranslationUnit parseAndCheckBindings(String code, ParserLanguage lang) throws Exception {
|
||||||
return parseAndCheckBindings(code, lang, false);
|
return parseAndCheckBindings(code, lang, false);
|
||||||
|
|
|
@ -4705,6 +4705,33 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame(i, col.getName(7).resolveBinding());
|
assertSame(i, col.getName(7).resolveBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename T>
|
||||||
|
// class basic_string {
|
||||||
|
// basic_string& operator+=(const T* s);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// basic_string<T> operator+(const T* cs, const basic_string<T>& s);
|
||||||
|
//
|
||||||
|
// template<typename T>
|
||||||
|
// basic_string<T> operator+(const basic_string<T>& s, const T* cs);
|
||||||
|
//
|
||||||
|
// typedef basic_string<char> string;
|
||||||
|
//
|
||||||
|
// void test(const string& s) {
|
||||||
|
// auto s1 = "" + s + "";
|
||||||
|
// auto s2 = s1 += "";
|
||||||
|
// }
|
||||||
|
public void testTypedefPreservation_380498() throws Exception {
|
||||||
|
BindingAssertionHelper ba= getAssertionHelper();
|
||||||
|
ICPPVariable s1 = ba.assertNonProblem("s1", ICPPVariable.class);
|
||||||
|
assertTrue(s1.getType() instanceof ITypedef);
|
||||||
|
assertEquals("string", ((ITypedef) s1.getType()).getName());
|
||||||
|
ICPPVariable s2 = ba.assertNonProblem("s2", ICPPVariable.class);
|
||||||
|
assertTrue(s2.getType() instanceof ITypedef);
|
||||||
|
assertEquals("string", ((ITypedef) s2.getType()).getName());
|
||||||
|
}
|
||||||
|
|
||||||
// int f() {
|
// int f() {
|
||||||
// return 5;
|
// return 5;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -127,7 +128,6 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
* Testcases on the AST.
|
* Testcases on the AST.
|
||||||
*/
|
*/
|
||||||
public class AST2Tests extends AST2BaseTest {
|
public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
private static final int NUM_TESTS = 3;
|
private static final int NUM_TESTS = 3;
|
||||||
|
|
||||||
public static TestSuite suite() {
|
public static TestSuite suite() {
|
||||||
|
@ -1625,10 +1625,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
|
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
|
||||||
IASTDeclaration[] declarations = tu.getDeclarations();
|
IASTDeclaration[] declarations = tu.getDeclarations();
|
||||||
IType plainInt = ((IVariable)((IASTSimpleDeclaration)declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType signedInt = ((IVariable)((IASTSimpleDeclaration)declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType unsignedInt = ((IVariable)((IASTSimpleDeclaration)declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType unsignedInt = ((IVariable)((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
IType noSpec = ((IVariable)((IASTSimpleDeclaration)declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
|
IType noSpec = ((IVariable)((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
|
||||||
assertTrue(plainInt.isSameType(signedInt));
|
assertTrue(plainInt.isSameType(signedInt));
|
||||||
assertFalse(plainInt.isSameType(unsignedInt));
|
assertFalse(plainInt.isSameType(unsignedInt));
|
||||||
assertFalse(signedInt.isSameType(unsignedInt));
|
assertFalse(signedInt.isSameType(unsignedInt));
|
||||||
|
@ -2055,7 +2055,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getName();
|
.getName();
|
||||||
final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
|
final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
|
||||||
.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
|
.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
|
||||||
final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer)dtor.getInitializer()).getInitializerClause();
|
final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor.getInitializer()).getInitializerClause();
|
||||||
IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
|
IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
|
||||||
.getDesignators()[0]).getName();
|
.getDesignators()[0]).getName();
|
||||||
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
|
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
|
||||||
|
@ -2229,18 +2229,12 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
.getDeclarations()[0];
|
IFunction f = (IFunction) def1.getDeclarator().getName().resolveBinding();
|
||||||
IFunction f = (IFunction) def1.getDeclarator().getName()
|
IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
.resolveBinding();
|
IFunction f2 = (IFunction) def2.getDeclarator().getName().resolveBinding();
|
||||||
IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu.getDeclarations()[2];
|
||||||
.getDeclarations()[1];
|
IFunction f3 = (IFunction) def3.getDeclarator().getName().resolveBinding();
|
||||||
IFunction f2 = (IFunction) def2.getDeclarator().getName()
|
|
||||||
.resolveBinding();
|
|
||||||
IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu
|
|
||||||
.getDeclarations()[2];
|
|
||||||
IFunction f3 = (IFunction) def3.getDeclarator().getName()
|
|
||||||
.resolveBinding();
|
|
||||||
|
|
||||||
IFunctionType ft = f.getType();
|
IFunctionType ft = f.getType();
|
||||||
IFunctionType ft2 = f2.getType();
|
IFunctionType ft2 = f2.getType();
|
||||||
|
@ -2251,17 +2245,15 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
|
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
|
||||||
assertTrue(ft3.getReturnType() instanceof IPointerType);
|
assertTrue(ft3.getReturnType() instanceof IPointerType);
|
||||||
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
|
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
|
||||||
assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType())
|
assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType()).getReturnType()
|
||||||
.getType()).getReturnType() instanceof IBasicType);
|
instanceof IBasicType);
|
||||||
|
|
||||||
// test tu.getDeclarationsInAST(IBinding)
|
// test tu.getDeclarationsInAST(IBinding)
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName()
|
IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName().resolveBinding());
|
||||||
.resolveBinding());
|
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], def1.getDeclarator().getName());
|
assertEquals(decls[0], def1.getDeclarator().getName());
|
||||||
|
|
||||||
decls = tu.getDeclarationsInAST(def2.getDeclarator().getName()
|
decls = tu.getDeclarationsInAST(def2.getDeclarator().getName().resolveBinding());
|
||||||
.resolveBinding());
|
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], def2.getDeclarator().getName());
|
assertEquals(decls[0], def2.getDeclarator().getName());
|
||||||
|
|
||||||
|
@ -2276,8 +2268,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// any parameter to type function returning T is adjusted to be pointer to
|
// any parameter to type function returning T is adjusted to be pointer to
|
||||||
// function returning T
|
// function returning T
|
||||||
public void testParmToFunction() throws Exception {
|
public void testParmToFunction() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(
|
IASTTranslationUnit tu = parse("int f(int g(void)) { return g();}", ParserLanguage.C);
|
||||||
"int f(int g(void)) { return g();}", ParserLanguage.C); //$NON-NLS-1$
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
|
@ -2300,7 +2291,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
||||||
IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator())
|
IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator())
|
||||||
.getParameters()[0].getDeclarator().getName();
|
.getParameters()[0].getDeclarator().getName();
|
||||||
IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
|
IASTName name_g_call =
|
||||||
|
((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
|
||||||
.getBody()).getStatements()[0]).getReturnValue())
|
.getBody()).getStatements()[0]).getReturnValue())
|
||||||
.getFunctionNameExpression()).getName();
|
.getFunctionNameExpression()).getName();
|
||||||
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
|
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
|
||||||
|
@ -2312,15 +2304,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArrayPointerFunction() throws Exception {
|
public void testArrayPointerFunction() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(
|
IASTTranslationUnit tu = parse("int (*v[])(int *x, int *y);", ParserLanguage.C);
|
||||||
"int (*v[])(int *x, int *y);", ParserLanguage.C); //$NON-NLS-1$
|
|
||||||
|
|
||||||
assertTrue(tu.isFrozen());
|
assertTrue(tu.isFrozen());
|
||||||
for (int i = 0; i < NUM_TESTS; i++) {
|
for (int i = 0; i < NUM_TESTS; i++) {
|
||||||
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl
|
IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName()
|
.getNestedDeclarator().getName().resolveBinding();
|
||||||
.resolveBinding();
|
|
||||||
|
|
||||||
IType vt_1 = v.getType();
|
IType vt_1 = v.getType();
|
||||||
assertTrue(vt_1 instanceof IArrayType);
|
assertTrue(vt_1 instanceof IArrayType);
|
||||||
|
@ -2348,8 +2338,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName()
|
.getDeclarators()[0]).getNestedDeclarator().getName()
|
||||||
.resolveBinding());
|
.resolveBinding());
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl
|
assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
|
||||||
.getDeclarators()[0]).getNestedDeclarator().getName());
|
.getNestedDeclarator().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -2396,8 +2386,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], name_DWORD);
|
assertEquals(decls[0], name_DWORD);
|
||||||
|
|
||||||
decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2
|
decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2.getDeclSpecifier())
|
||||||
.getDeclSpecifier()).getName().resolveBinding());
|
.getName().resolveBinding());
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], name_DWORD);
|
assertEquals(decls[0], name_DWORD);
|
||||||
|
|
||||||
|
@ -3226,10 +3216,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
|
||||||
IASTDeclaration[] decls = tu.getDeclarations();
|
IASTDeclaration[] decls = tu.getDeclarations();
|
||||||
|
|
||||||
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
|
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
|
||||||
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
|
assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
|
||||||
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int foo();
|
// int foo();
|
||||||
|
@ -3246,7 +3236,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IVariable zoot = (IVariable) col.getName(4).resolveBinding();
|
IVariable zoot = (IVariable) col.getName(4).resolveBinding();
|
||||||
IType t = zoot.getType();
|
IType t = zoot.getType();
|
||||||
assertTrue(t instanceof IBasicType);
|
assertTrue(t instanceof IBasicType);
|
||||||
assertEquals(((IBasicType)t).getType(), IBasicType.t_int);
|
assertEquals(((IBasicType) t).getType(), IBasicType.t_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug95866() throws Exception {
|
public void testBug95866() throws Exception {
|
||||||
|
@ -3392,7 +3382,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void test1043290() throws Exception {
|
public void test1043290() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
|
||||||
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||||
IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements();
|
IASTStatement [] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
|
||||||
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
|
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
|
||||||
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
|
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
|
||||||
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
|
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
|
||||||
|
@ -3765,8 +3755,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals("method", methodc.getName());
|
assertEquals("method", methodc.getName());
|
||||||
assertInstance(methodb, ICPPMethod.class);
|
assertInstance(methodb, ICPPMethod.class);
|
||||||
assertInstance(methodc, ICPPMethod.class);
|
assertInstance(methodc, ICPPMethod.class);
|
||||||
assertEquals("A", ((ICPPMethod)methodb).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodb).getClassOwner().getName());
|
||||||
assertEquals("A", ((ICPPMethod)methodc).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodc).getClassOwner().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -3817,8 +3807,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals("method", methodAA.getName());
|
assertEquals("method", methodAA.getName());
|
||||||
assertInstance(methodA, ICPPMethod.class);
|
assertInstance(methodA, ICPPMethod.class);
|
||||||
assertInstance(methodAA, ICPPMethod.class);
|
assertInstance(methodAA, ICPPMethod.class);
|
||||||
assertEquals("A", ((ICPPMethod)methodA).getClassOwner().getName());
|
assertEquals("A", ((ICPPMethod) methodA).getClassOwner().getName());
|
||||||
assertEquals("AA", ((ICPPMethod)methodAA).getClassOwner().getName());
|
assertEquals("AA", ((ICPPMethod) methodAA).getClassOwner().getName());
|
||||||
|
|
||||||
tu = validateCopy(tu);
|
tu = validateCopy(tu);
|
||||||
}
|
}
|
||||||
|
@ -4217,7 +4207,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept(col);
|
tu.accept(col);
|
||||||
for (Object o : col.nameList) {
|
for (Object o : col.nameList) {
|
||||||
IASTName n = (IASTName)o;
|
IASTName n = (IASTName) o;
|
||||||
if (n.isReference() && "f1".equals(n.toString()))
|
if (n.isReference() && "f1".equals(n.toString()))
|
||||||
assertTrue(n.resolveBinding() instanceof IProblemBinding);
|
assertTrue(n.resolveBinding() instanceof IProblemBinding);
|
||||||
else
|
else
|
||||||
|
@ -4773,20 +4763,20 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
{
|
{
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true);
|
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
|
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
|
||||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
|
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
|
||||||
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
|
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
|
||||||
IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
|
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
|
||||||
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
||||||
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
||||||
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
|
IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
|
||||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
|
IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
|
||||||
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
|
IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
|
||||||
IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
|
IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
|
||||||
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
|
||||||
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
|
||||||
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
|
||||||
|
@ -4982,7 +4972,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// VOID func(VOID) {
|
// VOID func(VOID) {
|
||||||
// }
|
// }
|
||||||
public void testTypedefVoid_Bug221567() throws Exception {
|
public void testTypedefVoid_Bug221567() throws Exception {
|
||||||
final boolean[] isCpps= {false, true};
|
final boolean[] isCpps= { false, true };
|
||||||
String code= getAboveComment();
|
String code= getAboveComment();
|
||||||
for (boolean isCpp : isCpps) {
|
for (boolean isCpp : isCpps) {
|
||||||
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
|
||||||
|
@ -4998,13 +4988,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IType pt = pts[0];
|
IType pt = pts[0];
|
||||||
assertInstance(rt, ITypedef.class);
|
assertInstance(rt, ITypedef.class);
|
||||||
assertInstance(pt, ITypedef.class);
|
assertInstance(pt, ITypedef.class);
|
||||||
rt= ((ITypedef)rt).getType();
|
rt= ((ITypedef) rt).getType();
|
||||||
pt= ((ITypedef)pt).getType();
|
pt= ((ITypedef) pt).getType();
|
||||||
|
|
||||||
assertTrue(rt instanceof IBasicType);
|
assertTrue(rt instanceof IBasicType);
|
||||||
assertEquals(IBasicType.t_void, ((IBasicType)rt).getType());
|
assertEquals(IBasicType.t_void, ((IBasicType) rt).getType());
|
||||||
assertTrue(pt instanceof IBasicType);
|
assertTrue(pt instanceof IBasicType);
|
||||||
assertEquals(IBasicType.t_void, ((IBasicType)pt).getType());
|
assertEquals(IBasicType.t_void, ((IBasicType) pt).getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6092,6 +6082,29 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typedef long unsigned int size_t;
|
||||||
|
//
|
||||||
|
// size_t a = 0;
|
||||||
|
// size_t x = a + 5;
|
||||||
|
// size_t y = 2 + a;
|
||||||
|
// size_t y = a * 2;
|
||||||
|
public void testTypeOfExpressionWithTypedef_380498() throws Exception {
|
||||||
|
final boolean[] isCpps= { false, true };
|
||||||
|
String code= getAboveComment();
|
||||||
|
for (boolean isCpp : isCpps) {
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
|
||||||
|
IASTExpression exp = ba.assertNode("a + 5", IASTExpression.class);
|
||||||
|
assertTrue(exp.getExpressionType() instanceof ITypedef);
|
||||||
|
assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
|
||||||
|
exp = ba.assertNode("2 + a", IASTExpression.class);
|
||||||
|
assertTrue(exp.getExpressionType() instanceof ITypedef);
|
||||||
|
assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
|
||||||
|
exp = ba.assertNode("a * 2", IASTExpression.class);
|
||||||
|
assertTrue(exp.getExpressionType() instanceof ITypedef);
|
||||||
|
assertEquals("size_t", ((ITypedef) exp.getExpressionType()).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// typedef int TInt;
|
// typedef int TInt;
|
||||||
// int a= TInt; //ref
|
// int a= TInt; //ref
|
||||||
public void testTypeAsExpressionIsProblem_261175() throws Exception {
|
public void testTypeAsExpressionIsProblem_261175() throws Exception {
|
||||||
|
@ -6317,8 +6330,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
|
||||||
IASTInitializer init = ((IASTSimpleDeclaration)declarations[index]).getDeclarators()[0].getInitializer();
|
IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
|
||||||
return (IBasicType)((IASTExpression)((IASTEqualsInitializer)init).getInitializerClause()).getExpressionType();
|
return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void test() {
|
// void test() {
|
||||||
|
@ -6862,10 +6875,10 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
//
|
//
|
||||||
public void testBug273797() throws Exception {
|
public void testBug273797() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
||||||
IASTName n = ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0].getName();
|
IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0].getName();
|
||||||
IVariable v = (IVariable) n.resolveBinding();
|
IVariable v = (IVariable) n.resolveBinding();
|
||||||
|
|
||||||
ICArrayType t = (ICArrayType)v.getType();
|
ICArrayType t = (ICArrayType) v.getType();
|
||||||
assertFalse(t.isConst());
|
assertFalse(t.isConst());
|
||||||
assertFalse(t.isRestrict());
|
assertFalse(t.isRestrict());
|
||||||
assertFalse(t.isVolatile());
|
assertFalse(t.isVolatile());
|
||||||
|
@ -6884,9 +6897,9 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testBug278797() throws Exception {
|
public void testBug278797() throws Exception {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
|
||||||
IASTFunctionDefinition func = (IASTFunctionDefinition)tu.getDeclarations()[1];
|
IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1];
|
||||||
IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement)func.getBody()).getStatements()[0]);
|
IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]);
|
||||||
IType t = ((IASTCastExpression)stmt.getExpression()).getOperand().getExpressionType();
|
IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType();
|
||||||
assertNotNull(t);
|
assertNotNull(t);
|
||||||
assertTrue(t instanceof IEnumeration);
|
assertTrue(t instanceof IEnumeration);
|
||||||
}
|
}
|
||||||
|
@ -6902,34 +6915,34 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
//int a[2][3] = {{1,2,3},{4,5,6}};
|
//int a[2][3] = {{1,2,3},{4,5,6}};
|
||||||
{
|
{
|
||||||
IASTDeclaration d = tu.getDeclarations()[0];
|
IASTDeclaration d = tu.getDeclarations()[0];
|
||||||
IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
|
IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
|
||||||
IType t = ((IVariable)b).getType();
|
IType t = ((IVariable) b).getType();
|
||||||
assertTrue(t instanceof IArrayType);
|
assertTrue(t instanceof IArrayType);
|
||||||
IArrayType at1 = (IArrayType)t;
|
IArrayType at1 = (IArrayType) t;
|
||||||
IASTExpression size1 = at1.getArraySizeExpression();
|
IASTExpression size1 = at1.getArraySizeExpression();
|
||||||
assertTrue(at1.getType() instanceof IArrayType);
|
assertTrue(at1.getType() instanceof IArrayType);
|
||||||
IArrayType at2 = (IArrayType) at1.getType();
|
IArrayType at2 = (IArrayType) at1.getType();
|
||||||
IASTExpression size2 = at2.getArraySizeExpression();
|
IASTExpression size2 = at2.getArraySizeExpression();
|
||||||
assertTrue(size1 instanceof IASTLiteralExpression);
|
assertTrue(size1 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size1).getValue()[0], '2');
|
assertEquals(((IASTLiteralExpression) size1).getValue()[0], '2');
|
||||||
assertTrue(size2 instanceof IASTLiteralExpression);
|
assertTrue(size2 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size2).getValue()[0], '3');
|
assertEquals(((IASTLiteralExpression) size2).getValue()[0], '3');
|
||||||
}
|
}
|
||||||
//int b[3][2] = {{1,2},{3,4},{5,6}};
|
//int b[3][2] = {{1,2},{3,4},{5,6}};
|
||||||
{
|
{
|
||||||
IASTDeclaration d = tu.getDeclarations()[1];
|
IASTDeclaration d = tu.getDeclarations()[1];
|
||||||
IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
|
IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
|
||||||
IType t = ((IVariable)b).getType();
|
IType t = ((IVariable) b).getType();
|
||||||
assertTrue(t instanceof IArrayType);
|
assertTrue(t instanceof IArrayType);
|
||||||
IArrayType at1 = (IArrayType)t;
|
IArrayType at1 = (IArrayType) t;
|
||||||
IASTExpression size1 = at1.getArraySizeExpression();
|
IASTExpression size1 = at1.getArraySizeExpression();
|
||||||
assertTrue(at1.getType() instanceof IArrayType);
|
assertTrue(at1.getType() instanceof IArrayType);
|
||||||
IArrayType at2 = (IArrayType) at1.getType();
|
IArrayType at2 = (IArrayType) at1.getType();
|
||||||
IASTExpression size2 = at2.getArraySizeExpression();
|
IASTExpression size2 = at2.getArraySizeExpression();
|
||||||
assertTrue(size1 instanceof IASTLiteralExpression);
|
assertTrue(size1 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size1).getValue()[0], '3');
|
assertEquals(((IASTLiteralExpression) size1).getValue()[0], '3');
|
||||||
assertTrue(size2 instanceof IASTLiteralExpression);
|
assertTrue(size2 instanceof IASTLiteralExpression);
|
||||||
assertEquals(((IASTLiteralExpression)size2).getValue()[0], '2');
|
assertEquals(((IASTLiteralExpression) size2).getValue()[0], '2');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6962,7 +6975,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void testBug295851() throws Exception {
|
public void testBug295851() throws Exception {
|
||||||
for (ParserLanguage lang : ParserLanguage.values()) {
|
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||||
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
|
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
|
||||||
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclSpecifier();
|
IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclSpecifier();
|
||||||
IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
|
IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
|
||||||
IValue value = enumeratorBinding.getValue();
|
IValue value = enumeratorBinding.getValue();
|
||||||
assertEquals(2, value.numericalValue().longValue());
|
assertEquals(2, value.numericalValue().longValue());
|
||||||
|
@ -6984,20 +6997,20 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
// }
|
// }
|
||||||
public void testBindingsOnFields() throws Exception {
|
public void testBindingsOnFields() throws Exception {
|
||||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false);
|
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false);
|
||||||
IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[2]).getBody();
|
IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody();
|
||||||
|
|
||||||
// Get the IFields bindings from the type used in the declaration of structure
|
// Get the IFields bindings from the type used in the declaration of structure
|
||||||
IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement)bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
|
IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
|
||||||
ICompositeType t = (ICompositeType)((IVariable)n.resolveBinding()).getType();
|
ICompositeType t = (ICompositeType)((IVariable) n.resolveBinding()).getType();
|
||||||
IField[] fields = t.getFields();
|
IField[] fields = t.getFields();
|
||||||
assertTrue(fields.length == 2);
|
assertTrue(fields.length == 2);
|
||||||
|
|
||||||
// Get the IField for the first assignment
|
// Get the IField for the first assignment
|
||||||
IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[1]).getExpression()).getOperand1();
|
IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1();
|
||||||
IBinding field1 = ref1.getFieldName().resolveBinding();
|
IBinding field1 = ref1.getFieldName().resolveBinding();
|
||||||
|
|
||||||
// Get the IField for the second assignment
|
// Get the IField for the second assignment
|
||||||
IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[2]).getExpression()).getOperand1();
|
IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1();
|
||||||
IBinding field2 = ref2.getFieldName().resolveBinding();
|
IBinding field2 = ref2.getFieldName().resolveBinding();
|
||||||
|
|
||||||
// Compare the IField from the type and the assignments
|
// Compare the IField from the type and the assignments
|
||||||
|
@ -7045,7 +7058,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
|
IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
|
||||||
IType t = owner.getExpressionType();
|
IType t = owner.getExpressionType();
|
||||||
assertTrue(t instanceof ICompositeType);
|
assertTrue(t instanceof ICompositeType);
|
||||||
assertEquals("s",((ICompositeType)t).getName());
|
assertEquals("s", ((ICompositeType) t).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7347,7 +7360,6 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void a() {
|
// void a() {
|
||||||
// typedef float size_t;
|
// typedef float size_t;
|
||||||
// sizeof(10); // wrong - getExpressionType returns float
|
// sizeof(10); // wrong - getExpressionType returns float
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.settings.model.extension;
|
package org.eclipse.cdt.core.settings.model.extension;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
|
||||||
public abstract class CLanguageData extends CDataObject {
|
public abstract class CLanguageData extends CDataObject {
|
||||||
protected CLanguageData() {
|
|
||||||
|
|
||||||
|
protected CLanguageData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// public abstract CDataObject[] getChildrenOfKind(int kind);
|
// public abstract CDataObject[] getChildrenOfKind(int kind);
|
||||||
|
@ -52,7 +52,7 @@ public abstract class CLanguageData extends CDataObject {
|
||||||
|
|
||||||
public abstract void setSourceExtensions(String exts[]);
|
public abstract void setSourceExtensions(String exts[]);
|
||||||
|
|
||||||
public boolean containsDiscoveredScannerInfo(){
|
public boolean containsDiscoveredScannerInfo() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
* James Blackburn (Broadcom Corp.)
|
* James Blackburn (Broadcom Corp.)
|
||||||
* Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
|
* Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
package org.eclipse.cdt.internal.core.settings.model;
|
||||||
|
|
||||||
|
@ -62,21 +62,21 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
private boolean fNeedsPersistance;
|
private boolean fNeedsPersistance;
|
||||||
private boolean fIsCfgModified;
|
private boolean fIsCfgModified;
|
||||||
|
|
||||||
CfgIdPair(CfgIdPair base){
|
CfgIdPair(CfgIdPair base) {
|
||||||
fId = base.fId;
|
fId = base.fId;
|
||||||
fPersistanceName = base.fPersistanceName;
|
fPersistanceName = base.fPersistanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
CfgIdPair(QualifiedName persistanceName){
|
CfgIdPair(QualifiedName persistanceName) {
|
||||||
fPersistanceName = persistanceName;
|
fPersistanceName = persistanceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId(){
|
public String getId() {
|
||||||
if(fId == null){
|
if (fId == null) {
|
||||||
fId = load();
|
fId = load();
|
||||||
if(fId == null){
|
if (fId == null) {
|
||||||
fId = getFirstCfgId();
|
fId = getFirstCfgId();
|
||||||
if(fId != null){
|
if (fId != null) {
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICConfigurationDescription getConfiguration() {
|
public ICConfigurationDescription getConfiguration() {
|
||||||
if(fCfg == null){
|
if (fCfg == null) {
|
||||||
String id = getId();
|
String id = getId();
|
||||||
if(id != null){
|
if (id != null) {
|
||||||
fCfg = getConfigurationById(id);
|
fCfg = getConfigurationById(id);
|
||||||
if(fCfg == null){
|
if (fCfg == null) {
|
||||||
fId = getFirstCfgId();
|
fId = getFirstCfgId();
|
||||||
if(fId != null){
|
if (fId != null) {
|
||||||
fCfg = getConfigurationById(fId);
|
fCfg = getConfigurationById(fId);
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return fCfg;
|
return fCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfiguration(ICConfigurationDescription cfg){
|
public void setConfiguration(ICConfigurationDescription cfg) {
|
||||||
if(cfg.getProjectDescription() != CProjectDescription.this)
|
if (cfg.getProjectDescription() != CProjectDescription.this)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
if(cfg.getId().equals(getId()))
|
if (cfg.getId().equals(getId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fCfg = cfg;
|
fCfg = cfg;
|
||||||
|
@ -114,11 +114,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
fNeedsPersistance = true;
|
fNeedsPersistance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configurationRemoved(ICConfigurationDescription cfg){
|
public void configurationRemoved(ICConfigurationDescription cfg) {
|
||||||
if(cfg.getProjectDescription() != CProjectDescription.this)
|
if (cfg.getProjectDescription() != CProjectDescription.this)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
if(!cfg.getId().equals(getId()))
|
if (!cfg.getId().equals(getId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fIsCfgModified = true;
|
fIsCfgModified = true;
|
||||||
|
@ -126,7 +126,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
getConfiguration();
|
getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String load(){
|
private String load() {
|
||||||
try {
|
try {
|
||||||
return getProject().getPersistentProperty(fPersistanceName);
|
return getProject().getPersistentProperty(fPersistanceName);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -135,8 +135,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean store(String oldId, boolean force){
|
private boolean store(String oldId, boolean force) {
|
||||||
if(force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)){
|
if (force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)) {
|
||||||
try {
|
try {
|
||||||
getProject().setPersistentProperty(fPersistanceName, fId);
|
getProject().setPersistentProperty(fPersistanceName, fId);
|
||||||
fIsCfgModified = false;
|
fIsCfgModified = false;
|
||||||
|
@ -162,7 +162,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
fIsCreating = isCreating;
|
fIsCreating = isCreating;
|
||||||
ICStorageElement el = null;
|
ICStorageElement el = null;
|
||||||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
if(loading){
|
if (loading) {
|
||||||
Map<String, ICStorageElement> cfgStorMap = mngr.createCfgStorages(this);
|
Map<String, ICStorageElement> cfgStorMap = mngr.createCfgStorages(this);
|
||||||
|
|
||||||
for (ICStorageElement sel : cfgStorMap.values()) {
|
for (ICStorageElement sel : cfgStorMap.values()) {
|
||||||
|
@ -174,22 +174,22 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrefs = new CProjectDescriptionPreferences(el,
|
fPrefs = new CProjectDescriptionPreferences(el,
|
||||||
(CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false),
|
(CProjectDescriptionPreferences) mngr.getProjectDescriptionWorkspacePreferences(false),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
fPropertiesMap = new HashMap<QualifiedName, Object>();
|
fPropertiesMap = new HashMap<QualifiedName, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProject(IProject project){
|
public void updateProject(IProject project) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadDatas(){
|
public void loadDatas() {
|
||||||
if(!fIsReadOnly || !fIsLoading)
|
if (!fIsReadOnly || !fIsLoading)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
|
||||||
try {
|
try {
|
||||||
cache.loadData();
|
cache.loadData();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -203,15 +203,15 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
// fIsLoading = false;
|
// fIsLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applyDatas(SettingsContext context){
|
public boolean applyDatas(SettingsContext context) {
|
||||||
if(!fIsReadOnly || !fIsApplying)
|
if (!fIsReadOnly || !fIsApplying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
|
||||||
try {
|
try {
|
||||||
if(cache.applyData(context))
|
if (cache.applyData(context))
|
||||||
modified = true;
|
modified = true;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -233,7 +233,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
* setModified (false)
|
* setModified (false)
|
||||||
* set the ICSettingsStorage to readonly
|
* set the ICSettingsStorage to readonly
|
||||||
*/
|
*/
|
||||||
public void doneApplying(){
|
public void doneApplying() {
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
fIsApplying = false;
|
fIsApplying = false;
|
||||||
|
|
||||||
|
@ -246,31 +246,31 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
setModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doneLoading(){
|
public void doneLoading() {
|
||||||
doneInitializing();
|
doneInitializing();
|
||||||
fIsLoading = false;
|
fIsLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoading(boolean loading){
|
public void setLoading(boolean loading) {
|
||||||
fIsLoading = loading;
|
fIsLoading = loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doneInitializing(){
|
private void doneInitializing() {
|
||||||
for (ICConfigurationDescription cfg : fCfgMap.values()) {
|
for (ICConfigurationDescription cfg : fCfgMap.values()) {
|
||||||
// FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please!
|
// FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please!
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)cfg;
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) cfg;
|
||||||
cache.doneInitialization();
|
cache.doneInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
fPrefs.setReadOnly(true);
|
fPrefs.setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoading(){
|
public boolean isLoading() {
|
||||||
return fIsLoading;
|
return fIsLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApplying(){
|
public boolean isApplying() {
|
||||||
return fIsApplying;
|
return fIsApplying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,30 +296,30 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
|
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
|
||||||
|
|
||||||
for(Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
try {
|
try {
|
||||||
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
|
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo) iter.next();
|
||||||
if(fIsReadOnly){
|
if (fIsReadOnly) {
|
||||||
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
||||||
CConfigurationDescriptionCache baseCache = null;
|
CConfigurationDescriptionCache baseCache = null;
|
||||||
if(baseData instanceof CConfigurationDescriptionCache){
|
if (baseData instanceof CConfigurationDescriptionCache) {
|
||||||
baseCache = (CConfigurationDescriptionCache)baseData;
|
baseCache = (CConfigurationDescriptionCache) baseData;
|
||||||
baseData = baseCache.getConfigurationData();
|
baseData = baseCache.getConfigurationData();
|
||||||
}
|
}
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription)cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription) cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
|
||||||
configurationCreated(cache);
|
configurationCreated(cache);
|
||||||
} else {
|
} else {
|
||||||
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
CConfigurationData baseData = cfgDes.getConfigurationData(false);
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
}
|
}
|
||||||
} catch (CoreException e){
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>)base.fPropertiesMap.clone();
|
HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>) base.fPropertiesMap.clone();
|
||||||
fPropertiesMap = cloneMap;
|
fPropertiesMap = cloneMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,14 +328,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
* This occurs during the SetCProjectDescription Operation
|
* This occurs during the SetCProjectDescription Operation
|
||||||
*/
|
*/
|
||||||
void switchToCachedConfigurationDescriptions() throws CoreException {
|
void switchToCachedConfigurationDescriptions() throws CoreException {
|
||||||
|
|
||||||
for (Map.Entry<String, ICConfigurationDescription> e : fCfgMap.entrySet()) {
|
for (Map.Entry<String, ICConfigurationDescription> e : fCfgMap.entrySet()) {
|
||||||
if (e.getValue() instanceof CConfigurationDescription) {
|
if (e.getValue() instanceof CConfigurationDescription) {
|
||||||
CConfigurationDescription cfgDes = (CConfigurationDescription)e.getValue();
|
CConfigurationDescription cfgDes = (CConfigurationDescription) e.getValue();
|
||||||
CConfigurationData baseData = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false);
|
CConfigurationData baseData = ((IInternalCCfgInfo) cfgDes).getConfigurationData(false);
|
||||||
CConfigurationDescriptionCache baseCache = null;
|
CConfigurationDescriptionCache baseCache = null;
|
||||||
if(baseData instanceof CConfigurationDescriptionCache){
|
if (baseData instanceof CConfigurationDescriptionCache) {
|
||||||
baseCache = (CConfigurationDescriptionCache)baseData;
|
baseCache = (CConfigurationDescriptionCache) baseData;
|
||||||
baseData = baseCache.getConfigurationData();
|
baseData = baseCache.getConfigurationData();
|
||||||
}
|
}
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache,
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache,
|
||||||
|
@ -345,14 +344,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void configurationCreated(ICConfigurationDescription des){
|
void configurationCreated(ICConfigurationDescription des) {
|
||||||
fCfgMap.put(des.getId(), des);
|
fCfgMap.put(des.getId(), des);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription createConfiguration(String id, String name,
|
public ICConfigurationDescription createConfiguration(String id, String name,
|
||||||
ICConfigurationDescription base) throws CoreException{
|
ICConfigurationDescription base) throws CoreException{
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -364,8 +363,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return fActiveCfgInfo.getConfiguration();
|
return fActiveCfgInfo.getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFirstCfgId(){
|
private String getFirstCfgId() {
|
||||||
if(!fCfgMap.isEmpty()){
|
if (!fCfgMap.isEmpty()) {
|
||||||
return fCfgMap.keySet().iterator().next();
|
return fCfgMap.keySet().iterator().next();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -378,9 +377,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription getConfigurationByName(String name) {
|
public ICConfigurationDescription getConfigurationByName(String name) {
|
||||||
for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
|
||||||
ICConfigurationDescription cfg = iter.next();
|
ICConfigurationDescription cfg = iter.next();
|
||||||
if(name.equals(cfg.getName()))
|
if (name.equals(cfg.getName()))
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -393,18 +392,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConfiguration(String name) throws WriteAccessException {
|
public void removeConfiguration(String name) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
|
|
||||||
CConfigurationDescription cfgDes = (CConfigurationDescription)getConfigurationByName(name);
|
CConfigurationDescription cfgDes = (CConfigurationDescription) getConfigurationByName(name);
|
||||||
if(cfgDes != null){
|
if (cfgDes != null) {
|
||||||
cfgDes.removeConfiguration();
|
cfgDes.removeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void configurationRemoved(CConfigurationDescription des){
|
void configurationRemoved(CConfigurationDescription des) {
|
||||||
fCfgMap.remove(des.getId());
|
fCfgMap.remove(des.getId());
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
|
|
||||||
|
@ -414,25 +412,24 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
((CConfigurationDescription)cfg).removeConfiguration();
|
((CConfigurationDescription) cfg).removeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setActiveConfiguration(
|
public void setActiveConfiguration(
|
||||||
ICConfigurationDescription cfg) throws WriteAccessException {
|
ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
if(cfg == null)
|
if (cfg == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
fActiveCfgInfo.setConfiguration(cfg);
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fSettingCfgInfo.setConfiguration(cfg);
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -492,10 +489,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateChild(CDataProxy child, boolean write) {
|
public void updateChild(CDataProxy child, boolean write) {
|
||||||
if(write){
|
if (write) {
|
||||||
try {
|
try {
|
||||||
String oldId = child.getId();
|
String oldId = child.getId();
|
||||||
CConfigurationDescription cfgDes = ((CConfigurationDescription)child);
|
CConfigurationDescription cfgDes = ((CConfigurationDescription) child);
|
||||||
cfgDes.doWritable();
|
cfgDes.doWritable();
|
||||||
updateMap(cfgDes, oldId);
|
updateMap(cfgDes, oldId);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -504,8 +501,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMap(CConfigurationDescription des, String oldId){
|
void updateMap(CConfigurationDescription des, String oldId) {
|
||||||
if(!oldId.equals(des.getId())){
|
if (!oldId.equals(des.getId())) {
|
||||||
fCfgMap.remove(oldId);
|
fCfgMap.remove(oldId);
|
||||||
fCfgMap.put(des.getId(), des);
|
fCfgMap.put(des.getId(), des);
|
||||||
}
|
}
|
||||||
|
@ -515,26 +512,26 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if (fRootStorageElement == null)
|
if (fRootStorageElement == null)
|
||||||
throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$
|
throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$
|
||||||
|
|
||||||
// if(fRootStorageElement == null){
|
// if (fRootStorageElement == null) {
|
||||||
// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
|
// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
|
||||||
// }
|
// }
|
||||||
return fRootStorageElement;
|
return fRootStorageElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICStorageElement doGetCachedRootStorageElement(){
|
// ICStorageElement doGetCachedRootStorageElement() {
|
||||||
// return fRootStorageElement;
|
// return fRootStorageElement;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ICSettingsStorage getStorageBase() throws CoreException{
|
ICSettingsStorage getStorageBase() throws CoreException{
|
||||||
if(fStorage == null)
|
if (fStorage == null)
|
||||||
// fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement());
|
// fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement());
|
||||||
throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
|
throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
|
||||||
return fStorage;
|
return fStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
|
public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -542,7 +539,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
|
public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
|
CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
|
||||||
configurationCreated(cfg);
|
configurationCreated(cfg);
|
||||||
|
@ -550,47 +547,48 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsDescriptionPersistence() {
|
boolean needsDescriptionPersistence() {
|
||||||
if(fIsModified)
|
if (fIsModified)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fPrefs.isModified())
|
if (fPrefs.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(fStorage.isModified())
|
if (fStorage.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(ICConfigurationDescription cfgDes : fCfgMap.values())
|
for (ICConfigurationDescription cfgDes : fCfgMap.values()) {
|
||||||
if(cfgDes.isModified())
|
if (cfgDes.isModified())
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isModified() {
|
public boolean isModified() {
|
||||||
if(needsDescriptionPersistence())
|
if (needsDescriptionPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(needsActiveCfgPersistence())
|
if (needsActiveCfgPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(needsSettingCfgPersistence())
|
if (needsSettingCfgPersistence())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setModified(boolean modified){
|
private void setModified(boolean modified) {
|
||||||
fIsModified = modified;
|
fIsModified = modified;
|
||||||
|
|
||||||
if(!modified){
|
if (!modified) {
|
||||||
fActiveCfgInfo.fIsCfgModified = false;
|
fActiveCfgInfo.fIsCfgModified = false;
|
||||||
|
|
||||||
fSettingCfgInfo.fIsCfgModified = false;
|
fSettingCfgInfo.fIsCfgModified = false;
|
||||||
|
|
||||||
fPrefs.setModified(false);
|
fPrefs.setModified(false);
|
||||||
|
|
||||||
//no need to do that for config cache since they always maintain the "isModified == false"
|
// no need to do that for config cache since they always maintain the "isModified == false"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,8 +612,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICConfigurationDescription getDefaultSettingConfiguration(){
|
public ICConfigurationDescription getDefaultSettingConfiguration() {
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
return getActiveConfiguration();
|
return getActiveConfiguration();
|
||||||
|
|
||||||
return fSettingCfgInfo.getConfiguration();
|
return fSettingCfgInfo.getConfiguration();
|
||||||
|
@ -623,14 +621,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
if(cfg == null)
|
if (cfg == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
fSettingCfgInfo.setConfiguration(cfg);
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
|
|
||||||
if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fActiveCfgInfo.setConfiguration(cfg);
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,10 +639,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSessionProperty(QualifiedName name, Object value) {
|
public void setSessionProperty(QualifiedName name, Object value) {
|
||||||
if(value != null)
|
if (value != null) {
|
||||||
fPropertiesMap.put(name, value);
|
fPropertiesMap.put(name, value);
|
||||||
else
|
} else {
|
||||||
fPropertiesMap.remove(name);
|
fPropertiesMap.remove(name);
|
||||||
|
}
|
||||||
|
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
}
|
}
|
||||||
|
@ -654,41 +653,41 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
getStorageBase().removeStorage(id);
|
getStorageBase().removeStorage(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchToCachedAppliedData(CProjectDescription appliedCache){
|
void switchToCachedAppliedData(CProjectDescription appliedCache) {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ICConfigurationDescription[] cfgs = appliedCache.getConfigurations();
|
ICConfigurationDescription[] cfgs = appliedCache.getConfigurations();
|
||||||
for(int i = 0; i < cfgs.length; i++){
|
for (int i = 0; i < cfgs.length; i++) {
|
||||||
CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)cfgs[i];
|
CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache) cfgs[i];
|
||||||
CConfigurationDescription des = (CConfigurationDescription)getChildSettingById(cfgCache.getId());
|
CConfigurationDescription des = (CConfigurationDescription) getChildSettingById(cfgCache.getId());
|
||||||
if(des != null){
|
if (des != null) {
|
||||||
des.setData(cfgCache);
|
des.setData(cfgCache);
|
||||||
// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false);
|
// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false);
|
||||||
// rcDes = des.getResourceDescription(new Path("dd"), false);
|
// rcDes = des.getResourceDescription(new Path("dd"), false);
|
||||||
// ICBuildSetting bs = des.getBuildSetting();
|
// ICBuildSetting bs = des.getBuildSetting();
|
||||||
// ICLanguageSetting lss[] = ((ICFolderDescription)rcDes).getLanguageSettings();
|
// ICLanguageSetting lss[] = ((ICFolderDescription) rcDes).getLanguageSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPersistActiveCfg(String oldId, boolean force){
|
boolean checkPersistActiveCfg(String oldId, boolean force) {
|
||||||
return fActiveCfgInfo.store(oldId, force);
|
return fActiveCfgInfo.store(oldId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkPersistSettingCfg(String oldId, boolean force){
|
boolean checkPersistSettingCfg(String oldId, boolean force) {
|
||||||
return fSettingCfgInfo.store(oldId, force);
|
return fSettingCfgInfo.store(oldId, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsActiveCfgPersistence(){
|
boolean needsActiveCfgPersistence() {
|
||||||
return fActiveCfgInfo.fIsCfgModified;
|
return fActiveCfgInfo.fIsCfgModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needsSettingCfgPersistence(){
|
boolean needsSettingCfgPersistence() {
|
||||||
return fSettingCfgInfo.fIsCfgModified;
|
return fSettingCfgInfo.fIsCfgModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
CProjectDescriptionPreferences getPreferences(){
|
CProjectDescriptionPreferences getPreferences() {
|
||||||
return fPrefs;
|
return fPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,10 +718,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCdtProjectCreated() {
|
public void setCdtProjectCreated() {
|
||||||
if(!fIsCreating)
|
if (!fIsCreating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
fIsCreating = false;
|
fIsCreating = false;
|
||||||
|
@ -730,11 +729,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public void touch() throws WriteAccessException {
|
public void touch() throws WriteAccessException {
|
||||||
if(fIsReadOnly)
|
if (fIsReadOnly)
|
||||||
throw ExceptionFactory.createIsReadOnlyException();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
|
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ 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.SemanticUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a utility class to help convert AST elements to Strings corresponding to the
|
* This is a utility class to help convert AST elements to Strings corresponding to
|
||||||
* AST element's type.
|
* the AST element's type.
|
||||||
*
|
*
|
||||||
* @noextend This class is not intended to be subclassed by clients.
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
@ -58,9 +58,9 @@ public class ASTTypeUtil {
|
||||||
private static final int DEAULT_ITYPE_SIZE = 2;
|
private static final int DEAULT_ITYPE_SIZE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation for the parameters of the given function type. The
|
* Returns a string representation for the parameters of the given function type.
|
||||||
* representation contains the comma-separated list of the normalized parameter type
|
* The representation contains the comma-separated list of the normalized parameter
|
||||||
* representations wrapped in parentheses.
|
* type representations wrapped in parentheses.
|
||||||
*/
|
*/
|
||||||
public static String getParameterTypeString(IFunctionType type) {
|
public static String getParameterTypeString(IFunctionType type) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
@ -493,7 +493,7 @@ public class ASTTypeUtil {
|
||||||
} else {
|
} else {
|
||||||
if (type instanceof ICPPReferenceType) {
|
if (type instanceof ICPPReferenceType) {
|
||||||
// reference types ignore cv-qualifiers
|
// reference types ignore cv-qualifiers
|
||||||
cvq=null;
|
cvq= null;
|
||||||
// lvalue references win over rvalue references
|
// lvalue references win over rvalue references
|
||||||
if (ref == null || ref.isRValueReference()) {
|
if (ref == null || ref.isRValueReference()) {
|
||||||
// delay reference to see if there are more
|
// delay reference to see if there are more
|
||||||
|
@ -599,23 +599,24 @@ public class ASTTypeUtil {
|
||||||
*
|
*
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
public static String getType(IASTDeclarator decltor) {
|
public static String getType(IASTDeclarator declarator) {
|
||||||
// get the most nested declarator
|
// get the most nested declarator
|
||||||
while (decltor.getNestedDeclarator() != null)
|
while (declarator.getNestedDeclarator() != null) {
|
||||||
decltor = decltor.getNestedDeclarator();
|
declarator = declarator.getNestedDeclarator();
|
||||||
|
}
|
||||||
|
|
||||||
IBinding binding = decltor.getName().resolveBinding();
|
IBinding binding = declarator.getName().resolveBinding();
|
||||||
IType type = null;
|
IType type = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (binding instanceof IEnumerator) {
|
if (binding instanceof IEnumerator) {
|
||||||
type = ((IEnumerator)binding).getType();
|
type = ((IEnumerator) binding).getType();
|
||||||
} else if (binding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
type = ((IFunction)binding).getType();
|
type = ((IFunction) binding).getType();
|
||||||
} else if (binding instanceof ITypedef) {
|
} else if (binding instanceof ITypedef) {
|
||||||
type = ((ITypedef)binding).getType();
|
type = ((ITypedef) binding).getType();
|
||||||
} else if (binding instanceof IVariable) {
|
} else if (binding instanceof IVariable) {
|
||||||
type = ((IVariable)binding).getType();
|
type = ((IVariable) binding).getType();
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return EMPTY_STRING;
|
return EMPTY_STRING;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface IASTNodeSelector {
|
public interface IASTNodeSelector {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name for the exact given range, or <code>null</code> if there is no such node.
|
* Returns the name for the exact given range, or <code>null</code> if there is no such node.
|
||||||
* Will not return an implicit name.
|
* Will not return an implicit name.
|
||||||
|
|
|
@ -21,15 +21,15 @@ public interface IASTTypeId extends IASTNode {
|
||||||
public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
public static final IASTTypeId[] EMPTY_TYPEID_ARRAY = new IASTTypeId[0];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>DECL_SPECIFIER</code> represents the relationship between an <code>IASTTypeId</code> and
|
* <code>DECL_SPECIFIER</code> represents the relationship between an <code>IASTTypeId</code>
|
||||||
* it's nested <code>IASTDeclSpecifier</code>.
|
* and it's nested <code>IASTDeclSpecifier</code>.
|
||||||
*/
|
*/
|
||||||
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty(
|
public static final ASTNodeProperty DECL_SPECIFIER = new ASTNodeProperty(
|
||||||
"IASTTypeId.DECL_SPECIFIER - IASTDeclSpecifier for IASTTypeId"); //$NON-NLS-1$
|
"IASTTypeId.DECL_SPECIFIER - IASTDeclSpecifier for IASTTypeId"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>ABSTRACT_DECLARATOR</code> represents the relationship between an <code>IASTTypeId</code> and
|
* <code>ABSTRACT_DECLARATOR</code> represents the relationship between an <code>IASTTypeId</code>
|
||||||
* it's nested <code>IASTDeclarator</code>.
|
* and it's nested <code>IASTDeclarator</code>.
|
||||||
*/
|
*/
|
||||||
public static final ASTNodeProperty ABSTRACT_DECLARATOR = new ASTNodeProperty(
|
public static final ASTNodeProperty ABSTRACT_DECLARATOR = new ASTNodeProperty(
|
||||||
"IASTTypeId.ABSTRACT_DECLARATOR - IASTDeclarator for IASTTypeId"); //$NON-NLS-1$
|
"IASTTypeId.ABSTRACT_DECLARATOR - IASTDeclarator for IASTTypeId"); //$NON-NLS-1$
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -22,5 +22,4 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IProblemType extends IType, ISemanticProblem {
|
public interface IProblemType extends IType, ISemanticProblem {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface IType extends Cloneable {
|
public interface IType extends Cloneable {
|
||||||
public static final IType[] EMPTY_TYPE_ARRAY = new IType[0];
|
public static final IType[] EMPTY_TYPE_ARRAY = {};
|
||||||
public static final ASTTypeMatcher TYPE_MATCHER = new ASTTypeMatcher();
|
public static final ASTTypeMatcher TYPE_MATCHER = new ASTTypeMatcher();
|
||||||
|
|
||||||
public Object clone();
|
public Object clone();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ITypedef extends IBinding, IType {
|
public interface ITypedef extends IBinding, IType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type that this thing is a typedef of
|
* Returns the type that this thing is a typedef of
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICPPPointerToMemberType extends IPointerType {
|
public interface ICPPPointerToMemberType extends IPointerType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class to whose members this points to.
|
* Returns the class to whose members this points to.
|
||||||
* @return Either ICPPClassType or ICPPTeplateTypeParameter.
|
* @return Either ICPPClassType or ICPPTeplateTypeParameter.
|
||||||
*/
|
*/
|
||||||
public IType getMemberOfClass();
|
public IType getMemberOfClass();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser;
|
package org.eclipse.cdt.internal.core.dom.parser;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public abstract class ArithmeticConversion {
|
||||||
|
|
||||||
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
||||||
if (op1 instanceof IBasicType) {
|
if (op1 instanceof IBasicType) {
|
||||||
final Kind kind = ((IBasicType)op1).getKind();
|
final Kind kind = ((IBasicType) op1).getKind();
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case eUnspecified:
|
case eUnspecified:
|
||||||
case eVoid:
|
case eVoid:
|
||||||
|
@ -190,7 +190,8 @@ public abstract class ArithmeticConversion {
|
||||||
return signedType;
|
return signedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return createBasicType(signedType.getKind(), changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
|
return createBasicType(signedType.getKind(),
|
||||||
|
changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBasicType promote(IType type, Domain domain) {
|
private IBasicType promote(IType type, Domain domain) {
|
||||||
|
@ -331,21 +332,21 @@ public abstract class ArithmeticConversion {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (basicTarget.isShort()) {
|
if (basicTarget.isShort()) {
|
||||||
return n < (Short.MAX_VALUE + 1L)*2;
|
return n < (Short.MAX_VALUE + 1L) * 2;
|
||||||
}
|
}
|
||||||
// Can't represent long longs with java longs.
|
// Can't represent long longs with java longs.
|
||||||
if (basicTarget.isLong() || basicTarget.isLongLong()) {
|
if (basicTarget.isLong() || basicTarget.isLongLong()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return n < (Integer.MAX_VALUE + 1L)*2;
|
return n < (Integer.MAX_VALUE + 1L) * 2;
|
||||||
|
|
||||||
case eFloat:
|
case eFloat:
|
||||||
float f= n;
|
float f= n;
|
||||||
return (long)f == n;
|
return (long) f == n;
|
||||||
|
|
||||||
case eDouble:
|
case eDouble:
|
||||||
double d= n;
|
double d= n;
|
||||||
return (long)d == n;
|
return (long) d == n;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.restoreTypedefs;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
@ -54,11 +57,7 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
copy.op = op;
|
copy.op = op;
|
||||||
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
||||||
copy.setOperand2(operand2 == null ? null : operand2.copy(style));
|
copy.setOperand2(operand2 == null ? null : operand2.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,9 +117,9 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
|
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
switch (action.visit(this)) {
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
|
|
||||||
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
|
||||||
N stack= new N(bexpr);
|
N stack= new N(bexpr);
|
||||||
while(stack != null) {
|
while (stack != null) {
|
||||||
IASTBinaryExpression expr= stack.fExpression;
|
IASTBinaryExpression expr= stack.fExpression;
|
||||||
if (stack.fState == 0) {
|
if (stack.fState == 0) {
|
||||||
if (action.shouldVisitExpressions) {
|
if (action.shouldVisitExpressions) {
|
||||||
|
@ -211,11 +210,13 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
@Override
|
@Override
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
final int op = getOperator();
|
final int op = getOperator();
|
||||||
final IType t1= CVisitor.unwrapTypedefs(getOperand1().getExpressionType());
|
IType originalType1 = getOperand1().getExpressionType();
|
||||||
final IType t2= CVisitor.unwrapTypedefs(getOperand2().getExpressionType());
|
IType originalType2 = getOperand2().getExpressionType();
|
||||||
IType type= CArithmeticConversion.convertCOperandTypes(op, t1, t2);
|
final IType type1= CVisitor.unwrapTypedefs(originalType1);
|
||||||
|
final IType type2= CVisitor.unwrapTypedefs(originalType2);
|
||||||
|
IType type= CArithmeticConversion.convertCOperandTypes(op, type1, type2);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
return type;
|
return restoreTypedefs(type, originalType1, originalType2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -230,25 +231,25 @@ public class CASTBinaryExpression extends ASTNode
|
||||||
return new CBasicType(Kind.eInt, 0, this);
|
return new CBasicType(Kind.eInt, 0, this);
|
||||||
|
|
||||||
case IASTBinaryExpression.op_plus:
|
case IASTBinaryExpression.op_plus:
|
||||||
if (t1 instanceof IArrayType) {
|
if (type1 instanceof IArrayType) {
|
||||||
return arrayTypeToPointerType((ICArrayType) t1);
|
return arrayTypeToPointerType((ICArrayType) type1);
|
||||||
} else if (t2 instanceof IPointerType) {
|
} else if (type2 instanceof IPointerType) {
|
||||||
return t2;
|
return restoreTypedefs(type2, originalType2);
|
||||||
} else if (t2 instanceof IArrayType) {
|
} else if (type2 instanceof IArrayType) {
|
||||||
return arrayTypeToPointerType((ICArrayType) t2);
|
return arrayTypeToPointerType((ICArrayType) type2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IASTBinaryExpression.op_minus:
|
case IASTBinaryExpression.op_minus:
|
||||||
if (t2 instanceof IPointerType || t2 instanceof IArrayType) {
|
if (type2 instanceof IPointerType || type2 instanceof IArrayType) {
|
||||||
if (t1 instanceof IPointerType || t1 instanceof IArrayType) {
|
if (type1 instanceof IPointerType || type1 instanceof IArrayType) {
|
||||||
return CVisitor.getPtrDiffType(this);
|
return CVisitor.getPtrDiffType(this);
|
||||||
}
|
}
|
||||||
return t1;
|
return restoreTypedefs(type1, originalType1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return t1;
|
return restoreTypedefs(type1, originalType1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IType arrayTypeToPointerType(ICArrayType type) {
|
private IType arrayTypeToPointerType(ICArrayType type) {
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.restoreTypedefs;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -30,7 +33,6 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
private int operator;
|
private int operator;
|
||||||
private IASTExpression operand;
|
private IASTExpression operand;
|
||||||
|
|
||||||
|
|
||||||
public CASTUnaryExpression() {
|
public CASTUnaryExpression() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,13 +48,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CASTUnaryExpression copy(CopyStyle style) {
|
public CASTUnaryExpression copy(CopyStyle style) {
|
||||||
CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null
|
CASTUnaryExpression copy =
|
||||||
: operand.copy(style));
|
new CASTUnaryExpression(operator, operand == null ? null : operand.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,22 +80,22 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept( ASTVisitor action ){
|
public boolean accept(ASTVisitor action) {
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.visit( this ) ){
|
switch (action.visit(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( operand != null ) if( !operand.accept( action ) ) return false;
|
if (operand != null && !operand.accept(action)) return false;
|
||||||
|
|
||||||
if( action.shouldVisitExpressions ){
|
if (action.shouldVisitExpressions) {
|
||||||
switch( action.leave( this ) ){
|
switch (action.leave(this)) {
|
||||||
case ASTVisitor.PROCESS_ABORT : return false;
|
case ASTVisitor.PROCESS_ABORT: return false;
|
||||||
case ASTVisitor.PROCESS_SKIP : return true;
|
case ASTVisitor.PROCESS_SKIP: return true;
|
||||||
default : break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -105,10 +103,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(IASTNode child, IASTNode other) {
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
if( child == operand )
|
if (child == operand) {
|
||||||
{
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
other.setPropertyInParent( child.getPropertyInParent() );
|
other.setParent(child.getParent());
|
||||||
other.setParent( child.getParent() );
|
|
||||||
operand = (IASTExpression) other;
|
operand = (IASTExpression) other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,24 +118,24 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
|
||||||
}
|
}
|
||||||
final IType exprType = getOperand().getExpressionType();
|
final IType exprType = getOperand().getExpressionType();
|
||||||
IType type = CVisitor.unwrapTypedefs(exprType);
|
IType type = CVisitor.unwrapTypedefs(exprType);
|
||||||
switch(op) {
|
switch (op) {
|
||||||
case op_star:
|
case op_star:
|
||||||
if (type instanceof IPointerType || type instanceof IArrayType) {
|
if (type instanceof IPointerType || type instanceof IArrayType) {
|
||||||
return ((ITypeContainer) type).getType();
|
return ((ITypeContainer) type).getType();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case op_amper:
|
case op_amper:
|
||||||
return new CPointerType(type, 0);
|
return new CPointerType(exprType, 0);
|
||||||
case op_minus:
|
case op_minus:
|
||||||
case op_plus:
|
case op_plus:
|
||||||
case op_tilde:
|
case op_tilde:
|
||||||
IType t= CArithmeticConversion.promoteCType(type);
|
IType t= CArithmeticConversion.promoteCType(type);
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
return t;
|
return restoreTypedefs(t, exprType);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return exprType; // return the original
|
return exprType; // Return the original.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,12 +9,17 @@
|
||||||
* John Camelon (IBM) - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
* Mike Kucera (IBM)
|
* Mike Kucera (IBM)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.restoreTypedefs;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
|
@ -37,14 +42,13 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
|
|
||||||
public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpression, IASTAmbiguityParent {
|
public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpression, IASTAmbiguityParent {
|
||||||
private int op;
|
private int op;
|
||||||
private IASTExpression operand1;
|
private IASTExpression operand1;
|
||||||
private IASTInitializerClause operand2;
|
private IASTInitializerClause operand2;
|
||||||
private IType type;
|
private IType type;
|
||||||
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
|
private ICPPFunction overload= UNINITIALIZED_FUNCTION;
|
||||||
private IASTImplicitName[] implicitNames = null;
|
private IASTImplicitName[] implicitNames;
|
||||||
|
|
||||||
public CPPASTBinaryExpression() {
|
public CPPASTBinaryExpression() {
|
||||||
}
|
}
|
||||||
|
@ -66,11 +70,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
copy.op = op;
|
copy.op = op;
|
||||||
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
|
||||||
copy.setInitOperand2(operand2 == null ? null : operand2.copy(style));
|
copy.setInitOperand2(operand2 == null ? null : operand2.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -314,21 +314,26 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
}
|
}
|
||||||
|
|
||||||
private IType createExpressionType() {
|
private IType createExpressionType() {
|
||||||
|
IType originalType1 = operand1.getExpressionType();
|
||||||
|
IType originalType2 = operand2 instanceof IASTExpression ?
|
||||||
|
((IASTExpression) operand2).getExpressionType() : null;
|
||||||
|
|
||||||
// Check for overloaded operator.
|
// Check for overloaded operator.
|
||||||
ICPPFunction o= getOverload();
|
ICPPFunction o= getOverload();
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
return typeFromFunctionCall(o);
|
IType type = typeFromFunctionCall(o);
|
||||||
|
return restoreTypedefs(type, originalType1, originalType2);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int op = getOperator();
|
final int op = getOperator();
|
||||||
IType type1 = prvalueType(operand1.getExpressionType());
|
IType type1 = prvalueType(originalType1);
|
||||||
if (type1 instanceof ISemanticProblem) {
|
if (type1 instanceof ISemanticProblem) {
|
||||||
return type1;
|
return type1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IType type2 = null;
|
IType type2 = null;
|
||||||
if (operand2 instanceof IASTExpression) {
|
if (originalType2 != null) {
|
||||||
type2= prvalueType(((IASTExpression) operand2).getExpressionType());
|
type2= prvalueType(originalType2);
|
||||||
if (type2 instanceof ISemanticProblem) {
|
if (type2 instanceof ISemanticProblem) {
|
||||||
return type2;
|
return type2;
|
||||||
}
|
}
|
||||||
|
@ -336,7 +341,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
|
|
||||||
IType type= CPPArithmeticConversion.convertCppOperandTypes(op, type1, type2);
|
IType type= CPPArithmeticConversion.convertCppOperandTypes(op, type1, type2);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
return type;
|
return restoreTypedefs(type, originalType1, originalType2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -352,10 +357,10 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
|
|
||||||
case IASTBinaryExpression.op_plus:
|
case IASTBinaryExpression.op_plus:
|
||||||
if (type1 instanceof IPointerType) {
|
if (type1 instanceof IPointerType) {
|
||||||
return type1;
|
return restoreTypedefs(type1, originalType1);
|
||||||
}
|
}
|
||||||
if (type2 instanceof IPointerType) {
|
if (type2 instanceof IPointerType) {
|
||||||
return type2;
|
return restoreTypedefs(type2, originalType2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -364,7 +369,7 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
if (type2 instanceof IPointerType) {
|
if (type2 instanceof IPointerType) {
|
||||||
return CPPVisitor.getPointerDiffType(this);
|
return CPPVisitor.getPointerDiffType(this);
|
||||||
}
|
}
|
||||||
return type1;
|
return restoreTypedefs(type1, originalType1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -381,6 +386,6 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr
|
||||||
}
|
}
|
||||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||||
}
|
}
|
||||||
return type1;
|
return restoreTypedefs(type1, originalType1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,8 @@ public class CPPASTTypeId extends ASTNode implements ICPPASTTypeId {
|
||||||
CPPASTTypeId copy = new CPPASTTypeId();
|
CPPASTTypeId copy = new CPPASTTypeId();
|
||||||
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
copy.setDeclSpecifier(declSpec == null ? null : declSpec.copy(style));
|
||||||
copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy(style));
|
copy.setAbstractDeclarator(absDecl == null ? null : absDecl.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
|
||||||
copy.isPackExpansion = isPackExpansion;
|
copy.isPackExpansion = isPackExpansion;
|
||||||
if (style == CopyStyle.withLocations) {
|
return copy(copy, style);
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -72,13 +72,9 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CPPASTUnaryExpression copy(CopyStyle style) {
|
public CPPASTUnaryExpression copy(CopyStyle style) {
|
||||||
CPPASTUnaryExpression copy = new CPPASTUnaryExpression(op, operand == null ? null
|
CPPASTUnaryExpression copy =
|
||||||
: operand.copy(style));
|
new CPPASTUnaryExpression(op, operand == null ? null : operand.copy(style));
|
||||||
copy.setOffsetAndLength(this);
|
return copy(copy, style);
|
||||||
if (style == CopyStyle.withLocations) {
|
|
||||||
copy.setCopyLocation(this);
|
|
||||||
}
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion;
|
import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion;
|
||||||
|
|
||||||
public class CPPArithmeticConversion extends ArithmeticConversion {
|
public class CPPArithmeticConversion extends ArithmeticConversion {
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Devin Steffler (IBM) - Initial API and implementation
|
* Devin Steffler (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
* An example is the GCC built-in typedef: typedef char * __builtin_va_list;
|
* An example is the GCC built-in typedef: typedef char * __builtin_va_list;
|
||||||
*/
|
*/
|
||||||
public class CPPImplicitTypedef extends CPPTypedef {
|
public class CPPImplicitTypedef extends CPPTypedef {
|
||||||
private IType type=null;
|
private IType type;
|
||||||
private char[] name=null;
|
private char[] name;
|
||||||
private IScope scope=null;
|
private IScope scope;
|
||||||
|
|
||||||
public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
|
public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
|
||||||
super(null);
|
super(null);
|
||||||
|
@ -135,5 +135,4 @@ public class CPPImplicitTypedef extends CPPTypedef {
|
||||||
public boolean isGloballyQualified() {
|
public boolean isGloballyQualified() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,20 +38,20 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binding for a c++ function parameter
|
* Binding for a c++ function parameter.
|
||||||
*/
|
*/
|
||||||
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding {
|
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding {
|
||||||
|
|
||||||
public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter {
|
public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter {
|
||||||
public CPPParameterProblem(IASTNode node, int id, char[] arg) {
|
public CPPParameterProblem(IASTNode node, int id, char[] arg) {
|
||||||
super(node, id, arg);
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IType fType = null;
|
private IType fType;
|
||||||
private IASTName[] fDeclarations = null;
|
private IASTName[] fDeclarations;
|
||||||
private int fPosition;
|
private int fPosition;
|
||||||
|
|
||||||
|
|
||||||
public CPPParameter(IASTName name, int pos) {
|
public CPPParameter(IASTName name, int pos) {
|
||||||
this.fDeclarations = new IASTName[] { name };
|
this.fDeclarations = new IASTName[] { name };
|
||||||
fPosition= pos;
|
fPosition= pos;
|
||||||
|
@ -67,17 +67,11 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return getType() instanceof ICPPParameterPackType;
|
return getType() instanceof ICPPParameterPackType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return fDeclarations;
|
return fDeclarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -121,17 +115,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return new String(getNameCharArray());
|
return new String(getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
IASTName name = getPrimaryDeclaration();
|
IASTName name = getPrimaryDeclaration();
|
||||||
|
@ -140,26 +129,17 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return CharArrayUtils.EMPTY;
|
return CharArrayUtils.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
|
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
|
||||||
*/
|
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
if (fDeclarations != null)
|
if (fDeclarations != null)
|
||||||
return fDeclarations[0];
|
return fDeclarations[0];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (fType == null && fDeclarations != null) {
|
if (fType == null && fDeclarations != null) {
|
||||||
|
@ -175,75 +155,48 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
return fType;
|
return fType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return new String[] { getName() };
|
return new String[] { getName() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return new char[][] { getNameCharArray() };
|
return new char[][] { getNameCharArray() };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGloballyQualified() {
|
public boolean isGloballyQualified() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
addDeclaration(node);
|
addDeclaration(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
//7.1.1-5 extern can not be used in the declaration of a parameter
|
// 7.1.1-5 extern can not be used in the declaration of a parameter
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
//7.1.1-8 mutable can only apply to class members
|
// 7.1.1-8 mutable can only apply to class members
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
private IType type;
|
private IType type;
|
||||||
|
|
||||||
public CPPTypedef(IASTName name) {
|
public CPPTypedef(IASTName name) {
|
||||||
// bug 223020 even though qualified names are not legal, we need to deal with them.
|
// Bug 223020 even though qualified names are not legal, we need to deal with them.
|
||||||
if (name != null && name.getParent() instanceof ICPPASTQualifiedName) {
|
if (name != null && name.getParent() instanceof ICPPASTQualifiedName) {
|
||||||
name= (IASTName) name.getParent();
|
name= (IASTName) name.getParent();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
if (o instanceof ITypedef) {
|
if (o instanceof ITypedef) {
|
||||||
IType t = getType();
|
IType t = getType();
|
||||||
if (t != null)
|
if (t != null)
|
||||||
return t.isSameType(((ITypedef)o).getType());
|
return t.isSameType(((ITypedef) o).getType());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
try {
|
try {
|
||||||
t = (IType) super.clone();
|
t = (IType) super.clone();
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
// Not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
@Override
|
@Override
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
IScope scope = getScope();
|
IScope scope = getScope();
|
||||||
while(scope != null) {
|
while (scope != null) {
|
||||||
if (scope instanceof ICPPBlockScope)
|
if (scope instanceof ICPPBlockScope)
|
||||||
return false;
|
return false;
|
||||||
scope = scope.getParent();
|
scope = scope.getParent();
|
||||||
|
|
|
@ -1762,10 +1762,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
* Creates the type for a parameter declaration.
|
* Creates the type for a parameter declaration.
|
||||||
*/
|
*/
|
||||||
public static IType createType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
|
public static IType createType(final ICPPASTParameterDeclaration pdecl, boolean forFuncType) {
|
||||||
IType pt;
|
|
||||||
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
|
IASTDeclSpecifier pDeclSpec = pdecl.getDeclSpecifier();
|
||||||
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
|
ICPPASTDeclarator pDtor = pdecl.getDeclarator();
|
||||||
pt = createType(pDeclSpec);
|
IType pt = createType(pDeclSpec);
|
||||||
if (pDtor != null) {
|
if (pDtor != null) {
|
||||||
pt = createType(pt, pDtor);
|
pt = createType(pt, pDtor);
|
||||||
}
|
}
|
||||||
|
@ -2017,7 +2016,8 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return createAutoType(autoInitClause, declSpec, declarator);
|
return createAutoType(autoInitClause, declSpec, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec,
|
||||||
|
IASTDeclarator declarator) {
|
||||||
// C++0x: 7.1.6.4
|
// C++0x: 7.1.6.4
|
||||||
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
|
||||||
// Detected a self referring auto type, e.g.: auto x = x;
|
// Detected a self referring auto type, e.g.: auto x = x;
|
||||||
|
@ -2064,6 +2064,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
return new ProblemType(ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE);
|
||||||
}
|
}
|
||||||
type = argument.getTypeValue();
|
type = argument.getTypeValue();
|
||||||
|
IType t = SemanticUtil.substituteTypedef(type, initType);
|
||||||
|
if (t != null)
|
||||||
|
type = t;
|
||||||
if (initClause instanceof ICPPASTInitializerList) {
|
if (initClause instanceof ICPPASTInitializerList) {
|
||||||
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
type = (IType) CPPTemplates.instantiate(initializer_list_template,
|
||||||
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) });
|
new ICPPTemplateArgument[] { new CPPTemplateArgument(type) });
|
||||||
|
|
|
@ -16,7 +16,16 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.COND_TDEF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.addQualifiers;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.calculateInheritanceDepth;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getCVQualifier;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.isVoidType;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@ -179,7 +188,7 @@ public class Conversions {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// — otherwise, the program is ill-formed.
|
// � otherwise, the program is ill-formed.
|
||||||
return Cost.NO_CONVERSION;
|
return Cost.NO_CONVERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,18 +1156,18 @@ public class Conversions {
|
||||||
* 4.1, 4.2, 4.3
|
* 4.1, 4.2, 4.3
|
||||||
*/
|
*/
|
||||||
public static IType lvalue_to_rvalue(IType type) {
|
public static IType lvalue_to_rvalue(IType type) {
|
||||||
type= SemanticUtil.getNestedType(type, TDEF | REF);
|
IType t= SemanticUtil.getNestedType(type, TDEF | REF);
|
||||||
if (type instanceof IArrayType) {
|
if (t instanceof IArrayType) {
|
||||||
return new CPPPointerType(((IArrayType) type).getType());
|
return new CPPPointerType(((IArrayType) t).getType());
|
||||||
}
|
}
|
||||||
if (type instanceof IFunctionType) {
|
if (t instanceof IFunctionType) {
|
||||||
return new CPPPointerType(type);
|
return new CPPPointerType(t);
|
||||||
}
|
}
|
||||||
IType uqType= SemanticUtil.getNestedType(type, TDEF | REF | ALLCVQ);
|
IType uqType= SemanticUtil.getNestedType(t, TDEF | REF | ALLCVQ);
|
||||||
if (uqType instanceof ICPPClassType) {
|
if (uqType instanceof ICPPClassType) {
|
||||||
return type;
|
return SemanticUtil.getNestedType(type, COND_TDEF | REF);
|
||||||
}
|
}
|
||||||
return uqType;
|
return SemanticUtil.getNestedType(t, COND_TDEF | REF | ALLCVQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.COND_TDEF;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
@ -26,22 +28,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods for computing the type of an expression
|
* Methods for computing the type of an expression.
|
||||||
*/
|
*/
|
||||||
public class ExpressionTypes {
|
public class ExpressionTypes {
|
||||||
|
|
||||||
public static IType glvalueType(IType type) {
|
public static IType glvalueType(IType type) {
|
||||||
// Reference types are removed.
|
// Reference types are removed.
|
||||||
return SemanticUtil.getNestedType(type, TDEF | REF);
|
return SemanticUtil.getNestedType(type, COND_TDEF | REF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType prvalueType(IType type) {
|
public static IType prvalueType(IType type) {
|
||||||
return Conversions.lvalue_to_rvalue(type);
|
return Conversions.lvalue_to_rvalue(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
|
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
|
||||||
final ICPPFunctionType ft = function.getType();
|
final ICPPFunctionType ft = function.getType();
|
||||||
return valueCategoryFromReturnType(ft.getReturnType());
|
return valueCategoryFromReturnType(ft.getReturnType());
|
||||||
|
@ -67,46 +67,46 @@ public class ExpressionTypes {
|
||||||
return typeFromReturnType(ft.getReturnType());
|
return typeFromReturnType(ft.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType typeFromReturnType(IType r) {
|
public static IType typeFromReturnType(IType type) {
|
||||||
r= SemanticUtil.getNestedType(r, TDEF);
|
IType t= SemanticUtil.getNestedType(type, TDEF);
|
||||||
if (r instanceof ICPPReferenceType) {
|
if (t instanceof ICPPReferenceType) {
|
||||||
return glvalueType(r);
|
return glvalueType(type);
|
||||||
}
|
}
|
||||||
return prvalueType(r);
|
return prvalueType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType typeOrFunctionSet(IASTExpression e) {
|
public static IType typeOrFunctionSet(IASTExpression exp) {
|
||||||
FunctionSetType fs= getFunctionSetType(e);
|
FunctionSetType fs= getFunctionSetType(exp);
|
||||||
if (fs != null) {
|
if (fs != null) {
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
return e.getExpressionType();
|
return exp.getExpressionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValueCategory valueCat(IASTExpression e) {
|
public static ValueCategory valueCat(IASTExpression exp) {
|
||||||
FunctionSetType fs= getFunctionSetType(e);
|
FunctionSetType fs= getFunctionSetType(exp);
|
||||||
if (fs != null)
|
if (fs != null)
|
||||||
return fs.getValueCategory();
|
return fs.getValueCategory();
|
||||||
return e.getValueCategory();
|
return exp.getValueCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FunctionSetType getFunctionSetType(IASTExpression e) {
|
private static FunctionSetType getFunctionSetType(IASTExpression exp) {
|
||||||
boolean addressOf= false;
|
boolean addressOf= false;
|
||||||
while (e instanceof IASTUnaryExpression) {
|
while (exp instanceof IASTUnaryExpression) {
|
||||||
final IASTUnaryExpression unary = (IASTUnaryExpression) e;
|
final IASTUnaryExpression unary = (IASTUnaryExpression) exp;
|
||||||
final int op= unary.getOperator();
|
final int op= unary.getOperator();
|
||||||
if (op == IASTUnaryExpression.op_bracketedPrimary) {
|
if (op == IASTUnaryExpression.op_bracketedPrimary) {
|
||||||
e= unary.getOperand();
|
exp= unary.getOperand();
|
||||||
} else if (!addressOf && op == IASTUnaryExpression.op_amper) {
|
} else if (!addressOf && op == IASTUnaryExpression.op_amper) {
|
||||||
addressOf= true;
|
addressOf= true;
|
||||||
e= unary.getOperand();
|
exp= unary.getOperand();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e instanceof IASTIdExpression) {
|
if (exp instanceof IASTIdExpression) {
|
||||||
IASTIdExpression idexpr= (IASTIdExpression) e;
|
IASTIdExpression idexpr= (IASTIdExpression) exp;
|
||||||
final IASTName name = idexpr.getName();
|
final IASTName name = idexpr.getName();
|
||||||
IBinding b= name.resolvePreBinding();
|
IBinding b= name.resolvePreBinding();
|
||||||
if (b instanceof CPPFunctionSet) {
|
if (b instanceof CPPFunctionSet) {
|
||||||
|
@ -115,4 +115,23 @@ public class ExpressionTypes {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IType restoreTypedefs(IType type, IType originalType) {
|
||||||
|
IType t = SemanticUtil.substituteTypedef(type, originalType);
|
||||||
|
if (t != null)
|
||||||
|
return t;
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IType restoreTypedefs(IType type, IType originalType1, IType originalType2) {
|
||||||
|
IType t = SemanticUtil.substituteTypedef(type, originalType1);
|
||||||
|
if (t != null)
|
||||||
|
return t;
|
||||||
|
if (originalType2 != null) {
|
||||||
|
t = SemanticUtil.substituteTypedef(type, originalType2);
|
||||||
|
if (t != null)
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.*;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.CONST;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.CONST_RESTRICT;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.CONST_VOLATILE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.CONST_VOLATILE_RESTRICT;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.NONE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.RESTRICT;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.VOLATILE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.VOLATILE_RESTRICT;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -60,20 +67,23 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Collection of static methods operating on C++ bindings.
|
||||||
*/
|
*/
|
||||||
public class SemanticUtil {
|
public class SemanticUtil {
|
||||||
private static final char[] OPERATOR_CHARS = Keywords.OPERATOR.toCharArray();
|
private static final char[] OPERATOR_CHARS = Keywords.OPERATOR.toCharArray();
|
||||||
// Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
// Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
||||||
private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length);
|
private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length);
|
||||||
|
|
||||||
public static final int TDEF = 0x01;
|
// Resolve typedefs.
|
||||||
public static final int REF = 0x02;
|
public static final int TDEF = 0x01;
|
||||||
public static final int CVTYPE = 0x04;
|
// Resolve typedefs, but only if necessary for a nested type transformation.
|
||||||
public static final int ALLCVQ= 0x08;
|
public static final int COND_TDEF = 0x02;
|
||||||
public static final int PTR= 0x10;
|
public static final int REF = 0x04;
|
||||||
public static final int MPTR= 0x20;
|
public static final int CVTYPE = 0x08;
|
||||||
public static final int ARRAY= 0x40;
|
public static final int ALLCVQ = 0x10;
|
||||||
|
public static final int PTR = 0x20;
|
||||||
|
public static final int MPTR = 0x40;
|
||||||
|
public static final int ARRAY = 0x80;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
|
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
|
||||||
|
@ -221,14 +231,25 @@ public class SemanticUtil {
|
||||||
*/
|
*/
|
||||||
public static IType getNestedType(IType type, int options) {
|
public static IType getNestedType(IType type, int options) {
|
||||||
final boolean tdef= (options & TDEF) != 0;
|
final boolean tdef= (options & TDEF) != 0;
|
||||||
|
final boolean cond_tdef= (options & COND_TDEF) != 0;
|
||||||
final boolean ptr= (options & PTR) != 0;
|
final boolean ptr= (options & PTR) != 0;
|
||||||
final boolean mptr= (options & MPTR) != 0;
|
final boolean mptr= (options & MPTR) != 0;
|
||||||
final boolean allcvq= (options & ALLCVQ) != 0;
|
final boolean allcvq= (options & ALLCVQ) != 0;
|
||||||
final boolean cvtype = (options & CVTYPE) != 0;
|
final boolean cvtype = (options & CVTYPE) != 0;
|
||||||
|
|
||||||
|
IType beforeTypedefs = null;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
IType t= null;
|
IType t= null;
|
||||||
if (type instanceof IPointerType) {
|
if (type instanceof ITypedef) {
|
||||||
|
if (tdef || cond_tdef) {
|
||||||
|
if (beforeTypedefs == null && cond_tdef) {
|
||||||
|
beforeTypedefs = type;
|
||||||
|
}
|
||||||
|
t= ((ITypedef) type).getType();
|
||||||
|
}
|
||||||
|
} else if (type instanceof IPointerType) {
|
||||||
|
beforeTypedefs = null;
|
||||||
final boolean isMbrPtr = type instanceof ICPPPointerToMemberType;
|
final boolean isMbrPtr = type instanceof ICPPPointerToMemberType;
|
||||||
if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) {
|
if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) {
|
||||||
t= ((IPointerType) type).getType();
|
t= ((IPointerType) type).getType();
|
||||||
|
@ -244,20 +265,20 @@ public class SemanticUtil {
|
||||||
}
|
}
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
} else if (tdef && type instanceof ITypedef) {
|
|
||||||
t= ((ITypedef) type).getType();
|
|
||||||
} else if (type instanceof IQualifierType) {
|
} else if (type instanceof IQualifierType) {
|
||||||
|
beforeTypedefs = null;
|
||||||
final IQualifierType qt = (IQualifierType) type;
|
final IQualifierType qt = (IQualifierType) type;
|
||||||
final IType qttgt = qt.getType();
|
final IType qttgt = qt.getType();
|
||||||
if (allcvq || cvtype) {
|
if (allcvq || cvtype) {
|
||||||
t= qttgt;
|
t= qttgt;
|
||||||
} else if (tdef) {
|
} else if (tdef || cond_tdef) {
|
||||||
t= getNestedType(qttgt, options);
|
t= getNestedType(qttgt, options);
|
||||||
if (t == qttgt)
|
if (t == qttgt)
|
||||||
return qt;
|
return qt;
|
||||||
return addQualifiers(t, qt.isConst(), qt.isVolatile(), false);
|
return addQualifiers(t, qt.isConst(), qt.isVolatile(), false);
|
||||||
}
|
}
|
||||||
} else if (type instanceof IArrayType) {
|
} else if (type instanceof IArrayType) {
|
||||||
|
beforeTypedefs = null;
|
||||||
final IArrayType atype= (IArrayType) type;
|
final IArrayType atype= (IArrayType) type;
|
||||||
if ((options & ARRAY) != 0) {
|
if ((options & ARRAY) != 0) {
|
||||||
t= atype.getType();
|
t= atype.getType();
|
||||||
|
@ -269,11 +290,12 @@ public class SemanticUtil {
|
||||||
return replaceNestedType((ITypeContainer) atype, newNested);
|
return replaceNestedType((ITypeContainer) atype, newNested);
|
||||||
}
|
}
|
||||||
} else if (type instanceof ICPPReferenceType) {
|
} else if (type instanceof ICPPReferenceType) {
|
||||||
|
beforeTypedefs = null;
|
||||||
final ICPPReferenceType rt = (ICPPReferenceType) type;
|
final ICPPReferenceType rt = (ICPPReferenceType) type;
|
||||||
if ((options & REF) != 0) {
|
if ((options & REF) != 0) {
|
||||||
t= rt.getType();
|
t= rt.getType();
|
||||||
} else if (tdef) {
|
} else if (tdef) {
|
||||||
// a typedef within the reference type can influence whether the reference is lvalue or rvalue
|
// A typedef within the reference type can influence whether the reference is lvalue or rvalue
|
||||||
IType nested= rt.getType();
|
IType nested= rt.getType();
|
||||||
IType newNested = getNestedType(nested, TDEF);
|
IType newNested = getNestedType(nested, TDEF);
|
||||||
if (nested == newNested)
|
if (nested == newNested)
|
||||||
|
@ -282,8 +304,12 @@ public class SemanticUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pack expansion types are dependent types, there is no need to descend into those.
|
// Pack expansion types are dependent types, there is no need to descend into those.
|
||||||
if (t == null)
|
if (t == null) {
|
||||||
|
if (beforeTypedefs != null) {
|
||||||
|
return beforeTypedefs;
|
||||||
|
}
|
||||||
return type;
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
type= t;
|
type= t;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +380,7 @@ public class SemanticUtil {
|
||||||
if (newNestedType == null)
|
if (newNestedType == null)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
// bug 249085 make sure not to add unnecessary qualifications
|
// Bug 249085 make sure not to add unnecessary qualifications
|
||||||
if (type instanceof IQualifierType) {
|
if (type instanceof IQualifierType) {
|
||||||
IQualifierType qt= (IQualifierType) type;
|
IQualifierType qt= (IQualifierType) type;
|
||||||
return addQualifiers(newNestedType, qt.isConst(), qt.isVolatile(), false);
|
return addQualifiers(newNestedType, qt.isConst(), qt.isVolatile(), false);
|
||||||
|
@ -365,6 +391,40 @@ public class SemanticUtil {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the given type or its nested type with a typedef if that type is the same as
|
||||||
|
* the type the typedef resolves to.
|
||||||
|
*
|
||||||
|
* @param type the type subject to substitution
|
||||||
|
* @param typedefType the type possibly containing the typedef as its nested type.
|
||||||
|
* @return the given type with the nested type replaced by the typedef, or {@code null} if
|
||||||
|
* the typedefType doesn't contain a typedef or the nested type doesn't match the typedef.
|
||||||
|
*/
|
||||||
|
public static IType substituteTypedef(IType type, IType typedefType) {
|
||||||
|
typedefType = getNestedType(typedefType, REF | ALLCVQ | PTR | ARRAY);
|
||||||
|
if (!(typedefType instanceof ITypedef))
|
||||||
|
return null;
|
||||||
|
IType nestedType = getNestedType(type, REF | ALLCVQ | PTR | ARRAY);
|
||||||
|
if (!nestedType.isSameType(((ITypedef) typedefType).getType()))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IType result = null;
|
||||||
|
ITypeContainer containerType = null;
|
||||||
|
for (IType t = type; ; t = containerType.getType()) {
|
||||||
|
IType newType = t == nestedType ? typedefType : (IType) t.clone();
|
||||||
|
if (result == null)
|
||||||
|
result = newType;
|
||||||
|
if (containerType != null) {
|
||||||
|
containerType.setType(newType);
|
||||||
|
}
|
||||||
|
if (t == nestedType)
|
||||||
|
return result;
|
||||||
|
if (!(t instanceof ITypeContainer))
|
||||||
|
return null;
|
||||||
|
containerType = (ITypeContainer) t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static IType mapToAST(IType type, IASTNode node) {
|
public static IType mapToAST(IType type, IASTNode node) {
|
||||||
if (type instanceof IFunctionType) {
|
if (type instanceof IFunctionType) {
|
||||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class CWDLocator extends AbstractErrorParser {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// This is emitted by GNU make using options -n, --just-print or -w, --print-directory.
|
// This is emitted by GNU make using options -w or --print-directory.
|
||||||
new ErrorPattern("make: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
|
new ErrorPattern("make: Entering directory `(.*)'", 0, 0) { //$NON-NLS-1$
|
||||||
@Override
|
@Override
|
||||||
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
protected boolean recordError(Matcher matcher, ErrorParserManager eoParser) {
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
@ -100,7 +100,7 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
|
||||||
@Override
|
@Override
|
||||||
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
|
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
|
||||||
throws CoreException, OperationCanceledException {
|
throws CoreException, OperationCanceledException {
|
||||||
SubMonitor sm = SubMonitor.convert(pm, 9);
|
SubMonitor sm = SubMonitor.convert(pm, 10);
|
||||||
|
|
||||||
RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
|
RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
|
||||||
if (status.hasError()) {
|
if (status.hasError()) {
|
||||||
|
@ -128,11 +128,6 @@ public class ExtractLocalVariableRefactoring extends CRefactoring {
|
||||||
if (isProgressMonitorCanceled(sm, initStatus))
|
if (isProgressMonitorCanceled(sm, initStatus))
|
||||||
return initStatus;
|
return initStatus;
|
||||||
|
|
||||||
sm.worked(1);
|
|
||||||
|
|
||||||
container.getNames(); //XXX Is this needed?
|
|
||||||
sm.worked(1);
|
|
||||||
|
|
||||||
info.addNamesToUsedNames(findAllDeclaredNames());
|
info.addNamesToUsedNames(findAllDeclaredNames());
|
||||||
sm.worked(1);
|
sm.worked(1);
|
||||||
|
|
||||||
|
|
|
@ -110,4 +110,4 @@ OccurrencesFinder_label_singular=''{0}'' - 1 occurrence in ''{1}''
|
||||||
# The first argument will be replaced by the element name, the second by the count and the last by the file name
|
# The first argument will be replaced by the element name, the second by the count and the last by the file name
|
||||||
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
|
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
|
||||||
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
|
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
|
||||||
OccurrencesFinder_occurrence_write_description=Write Occurrence of ''{0}''
|
OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}''
|
|
@ -10,7 +10,6 @@
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import org.eclipse.jface.text.DefaultInformationControl;
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
|
@ -32,12 +31,10 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for providing hover information for C
|
* Abstract class for providing hover information for C elements.
|
||||||
* elements.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
|
public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension,
|
||||||
|
ITextHoverExtension2, IInformationProviderExtension2 {
|
||||||
private IEditorPart fEditor;
|
private IEditorPart fEditor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -102,7 +99,7 @@ public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITe
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator()
|
* @see ITextHoverExtension2#getInformationPresenterControlCreator()
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Ericsson - Fix improper hover order (Bug 294812)
|
* Ericsson - Fix improper hover order (Bug 294812)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -39,10 +38,8 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
* hovers being placed before less specific ones.
|
* hovers being placed before less specific ones.
|
||||||
*/
|
*/
|
||||||
public class BestMatchHover extends AbstractCEditorTextHover {
|
public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that hover ordering is very important to be preserved by this
|
* Note that hover ordering is very important to be preserved by this class (bug 294812).
|
||||||
* class. (Bug 294812)
|
|
||||||
*/
|
*/
|
||||||
private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
|
private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
|
||||||
private List<ITextHover> fInstantiatedTextHovers;
|
private List<ITextHover> fInstantiatedTextHovers;
|
||||||
|
@ -63,16 +60,16 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
private void installTextHovers() {
|
private void installTextHovers() {
|
||||||
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
|
||||||
|
|
||||||
// initialize lists - indicates that the initialization happened
|
// Initialize lists - indicates that the initialization happened
|
||||||
fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
|
fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
|
||||||
fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
|
fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
|
||||||
|
|
||||||
// populate list
|
// Populate list
|
||||||
for (int i= 0; i < hoverDescs.length; i++) {
|
for (int i= 0; i < hoverDescs.length; i++) {
|
||||||
// ensure that we don't add ourselves to the list
|
// Ensure that we don't add ourselves to the list
|
||||||
if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
|
if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
|
||||||
fTextHoverSpecifications.add(hoverDescs[i]);
|
fTextHoverSpecifications.add(hoverDescs[i]);
|
||||||
// add place-holder for hover instance
|
// Add place-holder for hover instance
|
||||||
fInstantiatedTextHovers.add(null);
|
fInstantiatedTextHovers.add(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +87,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
ICEditorTextHover hover= spec.createTextHover();
|
ICEditorTextHover hover= spec.createTextHover();
|
||||||
if (hover != null) {
|
if (hover != null) {
|
||||||
hover.setEditor(getEditor());
|
hover.setEditor(getEditor());
|
||||||
// remember instance and mark as created
|
// Remember instance and mark as created
|
||||||
fInstantiatedTextHovers.set(i, hover);
|
fInstantiatedTextHovers.set(i, hover);
|
||||||
fTextHoverSpecifications.set(i, null);
|
fTextHoverSpecifications.set(i, null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -109,7 +106,6 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
|
||||||
checkTextHovers();
|
checkTextHovers();
|
||||||
fBestHover= null;
|
fBestHover= null;
|
||||||
|
|
||||||
|
@ -130,12 +126,11 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
|
||||||
checkTextHovers();
|
checkTextHovers();
|
||||||
fBestHover= null;
|
fBestHover= null;
|
||||||
|
|
||||||
|
@ -164,7 +159,7 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
|
* @see ITextHoverExtension#getHoverControlCreator()
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,16 +171,15 @@ public class BestMatchHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
|
* @see IInformationProviderExtension2#getInformationPresenterControlCreator()
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
// this is wrong, but left here for backwards compatibility
|
// This is wrong, but left here for backwards compatibility
|
||||||
if (fBestHover instanceof IInformationProviderExtension2)
|
if (fBestHover instanceof IInformationProviderExtension2)
|
||||||
return ((IInformationProviderExtension2)fBestHover).getInformationPresenterControlCreator();
|
return ((IInformationProviderExtension2) fBestHover).getInformationPresenterControlCreator();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.text.IRegion;
|
import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.ITextViewer;
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
@ -22,8 +21,8 @@ import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||||
import org.eclipse.cdt.ui.IRequiredInclude;
|
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
|
||||||
|
import org.eclipse.cdt.ui.IRequiredInclude;
|
||||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||||
import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
|
import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
|
||||||
|
|
||||||
|
@ -34,14 +33,11 @@ import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
|
||||||
|
|
||||||
public class CDocHover extends AbstractCEditorTextHover {
|
public class CDocHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for DefaultCEditorTextHover
|
|
||||||
*/
|
|
||||||
public CDocHover() {
|
public CDocHover() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see ITextHover#getHoverInfo(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer viewer, IRegion region) {
|
public String getHoverInfo(ITextViewer viewer, IRegion region) {
|
||||||
|
@ -61,7 +57,6 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
// call the Help to get info
|
// call the Help to get info
|
||||||
|
|
||||||
ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
|
ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
ITranslationUnit unit = getTranslationUnit();
|
ITranslationUnit unit = getTranslationUnit();
|
||||||
|
@ -81,7 +76,6 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
public IRegion getHoverRegion() {
|
public IRegion getHoverRegion() {
|
||||||
return hoverRegion;
|
return hoverRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
|
||||||
|
@ -93,7 +87,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
|
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype);
|
||||||
buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
|
buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
|
||||||
}
|
}
|
||||||
if(fs.getDescription() != null) {
|
if (fs.getDescription() != null) {
|
||||||
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
|
buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description);
|
||||||
//Don't convert this description since it could already be formatted
|
//Don't convert this description since it could already be formatted
|
||||||
buffer.append(fs.getDescription());
|
buffer.append(fs.getDescription());
|
||||||
|
@ -117,7 +111,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
HTMLPrinter.addPageEpilog(buffer);
|
HTMLPrinter.addPageEpilog(buffer);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch (Exception e) {
|
||||||
/* Ignore */
|
/* Ignore */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +119,7 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
|
* @see ITextHover#getHoverRegion(ITextViewer, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
|
||||||
|
@ -134,12 +128,12 @@ public class CDocHover extends AbstractCEditorTextHover {
|
||||||
if (selectedRange.x >= 0 &&
|
if (selectedRange.x >= 0 &&
|
||||||
selectedRange.y > 0 &&
|
selectedRange.y > 0 &&
|
||||||
offset >= selectedRange.x &&
|
offset >= selectedRange.x &&
|
||||||
offset <= selectedRange.x + selectedRange.y)
|
offset <= selectedRange.x + selectedRange.y) {
|
||||||
return new Region( selectedRange.x, selectedRange.y );
|
return new Region(selectedRange.x, selectedRange.y);
|
||||||
|
}
|
||||||
|
|
||||||
return CWordFinder.findWord(viewer.getDocument(), offset);
|
return CWordFinder.findWord(viewer.getDocument(), offset);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
import org.eclipse.jface.text.IInformationControlCreator;
|
import org.eclipse.jface.text.IInformationControlCreator;
|
||||||
|
@ -26,7 +25,6 @@ import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
* CEditorTexHoverProxy
|
* CEditorTexHoverProxy
|
||||||
*/
|
*/
|
||||||
public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
private CEditorTextHoverDescriptor fHoverDescriptor;
|
private CEditorTextHoverDescriptor fHoverDescriptor;
|
||||||
private ICEditorTextHover fHover;
|
private ICEditorTextHover fHover;
|
||||||
|
|
||||||
|
@ -132,5 +130,4 @@ public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.ui.part.IWorkbenchPartOrientation;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
|
Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
|
||||||
|
@ -33,7 +32,7 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
|
* @see AbstractCEditorTextHover#getHoverInfo2(ITextViewer, IRegion)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
|
||||||
|
@ -55,7 +54,7 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getInformationPresenterControlCreator()
|
* @see AbstractCEditorTextHover#getInformationPresenterControlCreator()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
|
@ -70,5 +69,4 @@ public class CMacroExpansionHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2011 QNX Software Systems and others.
|
* Copyright (c) 2002, 2012 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.text.c.hover;
|
package org.eclipse.cdt.internal.ui.text.c.hover;
|
||||||
|
|
||||||
|
@ -47,12 +48,20 @@ import org.eclipse.ui.part.IWorkbenchPartOrientation;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.IPositionConverter;
|
import org.eclipse.cdt.core.IPositionConverter;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
|
import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
@ -62,9 +71,14 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
|
@ -77,12 +91,14 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.ParserFactory;
|
import org.eclipse.cdt.core.parser.ParserFactory;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.text.ICPartitions;
|
import org.eclipse.cdt.ui.text.ICPartitions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
|
||||||
import org.eclipse.cdt.internal.corext.util.Strings;
|
import org.eclipse.cdt.internal.corext.util.Strings;
|
||||||
|
|
||||||
|
@ -95,15 +111,16 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||||
* A text hover presenting the source of the element under the cursor.
|
* A text hover presenting the source of the element under the cursor.
|
||||||
*/
|
*/
|
||||||
public class CSourceHover extends AbstractCEditorTextHover {
|
public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
protected static class SingletonRule implements ISchedulingRule {
|
protected static class SingletonRule implements ISchedulingRule {
|
||||||
public static final ISchedulingRule INSTANCE = new SingletonRule();
|
public static final ISchedulingRule INSTANCE = new SingletonRule();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(ISchedulingRule rule) {
|
public boolean contains(ISchedulingRule rule) {
|
||||||
return rule == this;
|
return rule == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConflicting(ISchedulingRule rule) {
|
public boolean isConflicting(ISchedulingRule rule) {
|
||||||
return rule == this;
|
return rule == this;
|
||||||
|
@ -114,69 +131,100 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* Computes the source location for a given identifier.
|
* Computes the source location for a given identifier.
|
||||||
*/
|
*/
|
||||||
protected static class ComputeSourceRunnable implements ASTRunnable {
|
protected static class ComputeSourceRunnable implements ASTRunnable {
|
||||||
|
|
||||||
private final ITranslationUnit fTU;
|
private final ITranslationUnit fTU;
|
||||||
private final IRegion fTextRegion;
|
private final IRegion fTextRegion;
|
||||||
|
private final String fSelection;
|
||||||
private final IProgressMonitor fMonitor;
|
private final IProgressMonitor fMonitor;
|
||||||
private String fSource;
|
private String fSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tUnit
|
* @param tUnit the translation unit
|
||||||
* @param textRegion
|
* @param textRegion the selected region
|
||||||
|
* @param selection the text of the selected region without
|
||||||
*/
|
*/
|
||||||
public ComputeSourceRunnable(ITranslationUnit tUnit, IRegion textRegion) {
|
public ComputeSourceRunnable(ITranslationUnit tUnit, IRegion textRegion, String selection) {
|
||||||
fTU= tUnit;
|
fTU= tUnit;
|
||||||
fTextRegion= textRegion;
|
fTextRegion= textRegion;
|
||||||
|
fSelection = selection;
|
||||||
fMonitor= new NullProgressMonitor();
|
fMonitor= new NullProgressMonitor();
|
||||||
fSource= null;
|
fSource= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
|
* @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(IASTTranslationUnit)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
try {
|
try {
|
||||||
IASTName name= ast.getNodeSelector(null).findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
|
IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||||
if (name != null) {
|
if (fSelection.equals(Keywords.AUTO)) {
|
||||||
IBinding binding= name.resolveBinding();
|
IASTNode node = nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
|
||||||
if (binding != null) {
|
if (node instanceof ICPPASTDeclSpecifier) {
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) node;
|
||||||
// Check for implicit names first, could be an implicit constructor call
|
IASTNode parent = declSpec.getParent();
|
||||||
if(name.getParent() instanceof IASTImplicitNameOwner) {
|
IASTDeclarator[] declarators = IASTDeclarator.EMPTY_DECLARATOR_ARRAY;
|
||||||
IASTImplicitNameOwner iastImplicitNameOwner = (IASTImplicitNameOwner) name.getParent();
|
if (parent instanceof IASTSimpleDeclaration) {
|
||||||
IASTName [] implicitNames = iastImplicitNameOwner.getImplicitNames();
|
declarators = ((IASTSimpleDeclaration) parent).getDeclarators();
|
||||||
if(implicitNames.length == 1) {
|
} else if (parent instanceof IASTParameterDeclaration) {
|
||||||
IBinding implicitNameBinding = implicitNames[0].resolveBinding();
|
declarators = new IASTDeclarator[] { ((IASTParameterDeclaration) parent).getDeclarator() };
|
||||||
if(implicitNameBinding instanceof ICPPConstructor) {
|
} else if (parent instanceof ICPPASTTypeId) {
|
||||||
binding = implicitNameBinding;
|
declarators = new IASTDeclarator[] { ((ICPPASTTypeId) parent).getAbstractDeclarator() };
|
||||||
|
}
|
||||||
|
IType type = null;
|
||||||
|
for (IASTDeclarator declarator : declarators) {
|
||||||
|
IType t = CPPVisitor.createType(declarator);
|
||||||
|
if (type == null) {
|
||||||
|
type = t;
|
||||||
|
} else if (!type.isSameType(t)) {
|
||||||
|
// Type varies between declarators - don't display anything.
|
||||||
|
type = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type != null && !(type instanceof IProblemType))
|
||||||
|
fSource = ASTTypeUtil.getType(type, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IASTName name= nodeSelector.findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
|
||||||
|
if (name != null) {
|
||||||
|
IBinding binding= name.resolveBinding();
|
||||||
|
if (binding != null) {
|
||||||
|
// Check for implicit names first, could be an implicit constructor call.
|
||||||
|
if (name.getParent() instanceof IASTImplicitNameOwner) {
|
||||||
|
IASTImplicitNameOwner implicitNameOwner = (IASTImplicitNameOwner) name.getParent();
|
||||||
|
IASTName[] implicitNames = implicitNameOwner.getImplicitNames();
|
||||||
|
if (implicitNames.length == 1) {
|
||||||
|
IBinding implicitNameBinding = implicitNames[0].resolveBinding();
|
||||||
|
if (implicitNameBinding instanceof ICPPConstructor) {
|
||||||
|
binding = implicitNameBinding;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
// report problem as source comment
|
// Report problem as source comment.
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
IProblemBinding problem= (IProblemBinding) binding;
|
IProblemBinding problem= (IProblemBinding) binding;
|
||||||
fSource= "/* Indexer Problem!\n" + //$NON-NLS-1$
|
fSource= "/* Problem:\n" + //$NON-NLS-1$
|
||||||
" * " + problem.getMessage() + //$NON-NLS-1$
|
" * " + problem.getMessage() + //$NON-NLS-1$
|
||||||
"\n */"; //$NON-NLS-1$
|
"\n */"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
} else if (binding instanceof IMacroBinding) {
|
||||||
|
fSource= computeSourceForMacro(ast, name, binding);
|
||||||
|
} else {
|
||||||
|
fSource= computeSourceForBinding(ast, binding);
|
||||||
}
|
}
|
||||||
} else if (binding instanceof IMacroBinding) {
|
|
||||||
fSource= computeSourceForMacro(ast, name, binding);
|
|
||||||
} else {
|
|
||||||
fSource= computeSourceForBinding(ast, binding);
|
|
||||||
}
|
|
||||||
if (fSource != null) {
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException exc) {
|
if (fSource != null) {
|
||||||
return exc.getStatus();
|
return Status.OK_STATUS;
|
||||||
} catch (DOMException exc) {
|
}
|
||||||
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", exc); //$NON-NLS-1$
|
} catch (CoreException e) {
|
||||||
|
return e.getStatus();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
|
@ -219,8 +267,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException, DOMException {
|
private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException, DOMException {
|
||||||
IName[] names = findDefsOrDecls(ast, binding);
|
IName[] names = findDefsOrDecls(ast, binding);
|
||||||
|
|
||||||
// in case the binding is a non-explicit specialization we need
|
// In case the binding is a non-explicit specialization we need
|
||||||
// to consider the original binding (bug 281396)
|
// to consider the original binding (bug 281396).
|
||||||
while (names.length == 0 && binding instanceof ICPPSpecialization) {
|
while (names.length == 0 && binding instanceof ICPPSpecialization) {
|
||||||
IBinding specializedBinding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
IBinding specializedBinding = ((ICPPSpecialization) binding).getSpecializedBinding();
|
||||||
if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
|
if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
|
||||||
|
@ -270,29 +318,29 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
IPath location= Path.fromOSString(fileName);
|
IPath location= Path.fromOSString(fileName);
|
||||||
LocationKind locationKind= LocationKind.LOCATION;
|
LocationKind locationKind= LocationKind.LOCATION;
|
||||||
if (name instanceof IASTName && !name.isReference()) {
|
if (name instanceof IASTName && !name.isReference()) {
|
||||||
IASTName astName= (IASTName)name;
|
IASTName astName= (IASTName) name;
|
||||||
if (astName.getTranslationUnit().getFilePath().equals(fileName)) {
|
if (astName.getTranslationUnit().getFilePath().equals(fileName)) {
|
||||||
int hoverOffset = fTextRegion.getOffset();
|
int hoverOffset = fTextRegion.getOffset();
|
||||||
if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() ||
|
if (hoverOffset <= nodeOffset && nodeOffset < hoverOffset + fTextRegion.getLength() ||
|
||||||
hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
|
hoverOffset >= nodeOffset && hoverOffset < nodeOffset + nodeLength) {
|
||||||
// bug 359352 - don't show source if its the same we are hovering on
|
// Bug 359352 - don't show source if its the same we are hovering on.
|
||||||
return null;
|
return computeHoverForDeclaration(astName);
|
||||||
}
|
}
|
||||||
if (fTU.getResource() != null) {
|
if (fTU.getResource() != null) {
|
||||||
// reuse editor buffer for names local to the translation unit
|
// Reuse editor buffer for names local to the translation unit
|
||||||
location= fTU.getResource().getFullPath();
|
location= fTU.getResource().getFullPath();
|
||||||
locationKind= LocationKind.IFILE;
|
locationKind= LocationKind.IFILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try to resolve path to a resource for proper encoding (bug 221029)
|
// Try to resolve path to a resource for proper encoding (bug 221029)
|
||||||
IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
|
IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
location= file.getFullPath();
|
location= file.getFullPath();
|
||||||
locationKind= LocationKind.IFILE;
|
locationKind= LocationKind.IFILE;
|
||||||
if (name instanceof IIndexName) {
|
if (name instanceof IIndexName) {
|
||||||
// need to adjust index offsets to current offsets
|
// Need to adjust index offsets to current offsets
|
||||||
// in case file has been modified since last index time
|
// in case file has been modified since last index time.
|
||||||
IIndexName indexName= (IIndexName) name;
|
IIndexName indexName= (IIndexName) name;
|
||||||
long timestamp= indexName.getFile().getTimestamp();
|
long timestamp= indexName.getFile().getTimestamp();
|
||||||
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
|
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
|
||||||
|
@ -331,7 +379,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// expand source range to include preceding comment, if any
|
// Expand source range to include preceding comment, if any
|
||||||
boolean isKnR= isKnRSource(name);
|
boolean isKnR= isKnRSource(name);
|
||||||
sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
|
sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
|
||||||
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
|
if (sourceStart == CHeuristicScanner.NOT_FOUND) {
|
||||||
|
@ -342,15 +390,46 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
|
String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
|
||||||
return source;
|
return source;
|
||||||
|
|
||||||
} catch (BadLocationException exc) {
|
} catch (BadLocationException e) {
|
||||||
// ignore - should not happen anyway
|
// Ignore - should not happen anyway
|
||||||
if (DEBUG) exc.printStackTrace();
|
if (DEBUG) e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
|
mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the hover containing the deduced type for a declaration based on {@code auto}
|
||||||
|
* keyword.
|
||||||
|
*
|
||||||
|
* @param name the name of the declarator
|
||||||
|
* @return the hover text, if the declaration is based on {@code auto} keyword,
|
||||||
|
* otherwise {@code null}.
|
||||||
|
*/
|
||||||
|
private String computeHoverForDeclaration(IASTName name) {
|
||||||
|
ICPPASTDeclarator declarator =
|
||||||
|
CPPVisitor.findAncestorWithType(name, ICPPASTDeclarator.class);
|
||||||
|
if (declarator == null)
|
||||||
|
return null;
|
||||||
|
IASTDeclaration declaration =
|
||||||
|
CPPVisitor.findAncestorWithType(declarator, IASTDeclaration.class);
|
||||||
|
IASTDeclSpecifier declSpec = null;
|
||||||
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
|
declSpec = ((IASTSimpleDeclaration) declaration).getDeclSpecifier();
|
||||||
|
} else if (declaration instanceof IASTParameterDeclaration) {
|
||||||
|
declSpec = ((IASTParameterDeclaration) declaration).getDeclSpecifier();
|
||||||
|
}
|
||||||
|
if (!(declSpec instanceof ICPPASTSimpleDeclSpecifier) ||
|
||||||
|
((ICPPASTSimpleDeclSpecifier) declSpec).getType() != IASTSimpleDeclSpecifier.t_auto) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
IType type = CPPVisitor.createType(declarator);
|
||||||
|
if (type instanceof IProblemType)
|
||||||
|
return null;
|
||||||
|
return ASTTypeUtil.getType(type, false) + " " + name.getRawSignature(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if the name is part of a KnR function definition.
|
* Determine if the name is part of a KnR function definition.
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -455,7 +534,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
|
if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
|
||||||
int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
|
int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
|
||||||
int lineOffset= doc.getLineOffset(nextNonWSLine);
|
int lineOffset= doc.getLineOffset(nextNonWSLine);
|
||||||
if (doc.get(lineOffset, nextNonWS - lineOffset).trim().length() == 0) {
|
if (doc.get(lineOffset, nextNonWS - lineOffset).trim().isEmpty()) {
|
||||||
sourceStart= doc.getLineOffset(nextNonWSLine);
|
sourceStart= doc.getLineOffset(nextNonWSLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,7 +546,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
|
private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
|
||||||
int sourceEnd= start;
|
int sourceEnd= start;
|
||||||
CHeuristicScanner scanner= new CHeuristicScanner(doc);
|
CHeuristicScanner scanner= new CHeuristicScanner(doc);
|
||||||
// expand forward to the end of the definition/declaration
|
// Expand forward to the end of the definition/declaration
|
||||||
boolean searchBrace= false;
|
boolean searchBrace= false;
|
||||||
boolean searchSemi= false;
|
boolean searchSemi= false;
|
||||||
boolean searchComma= false;
|
boolean searchComma= false;
|
||||||
|
@ -498,7 +577,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
sourceEnd= doc.getLength();
|
sourceEnd= doc.getLength();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// expand region to include whole line
|
// Expand region to include whole line
|
||||||
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
||||||
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
||||||
} else if (searchSemi) {
|
} else if (searchSemi) {
|
||||||
|
@ -506,7 +585,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (semi != CHeuristicScanner.NOT_FOUND) {
|
if (semi != CHeuristicScanner.NOT_FOUND) {
|
||||||
sourceEnd= semi+1;
|
sourceEnd= semi+1;
|
||||||
}
|
}
|
||||||
// expand region to include whole line
|
// Expand region to include whole line
|
||||||
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
|
||||||
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
|
||||||
} else if (searchComma) {
|
} else if (searchComma) {
|
||||||
|
@ -552,8 +631,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* @return an array of definitions, never <code>null</code>
|
* @return an array of definitions, never <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IName[] findDefinitions(IASTTranslationUnit ast,
|
private IName[] findDefinitions(IASTTranslationUnit ast, IBinding binding) throws CoreException {
|
||||||
IBinding binding) throws CoreException {
|
|
||||||
IName[] declNames= ast.getDefinitionsInAST(binding);
|
IName[] declNames= ast.getDefinitionsInAST(binding);
|
||||||
if (declNames.length == 0 && ast.getIndex() != null) {
|
if (declNames.length == 0 && ast.getIndex() != null) {
|
||||||
// search definitions in index
|
// search definitions in index
|
||||||
|
@ -570,8 +648,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
* @return an array of declarations, never <code>null</code>
|
* @return an array of declarations, never <code>null</code>
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IName[] findDeclarations(IASTTranslationUnit ast,
|
private IName[] findDeclarations(IASTTranslationUnit ast, IBinding binding) throws CoreException {
|
||||||
IBinding binding) throws CoreException {
|
|
||||||
IName[] declNames= ast.getDeclarationsInAST(binding);
|
IName[] declNames= ast.getDeclarationsInAST(binding);
|
||||||
if (declNames.length == 0 && ast.getIndex() != null) {
|
if (declNames.length == 0 && ast.getIndex() != null) {
|
||||||
// search declarations in index
|
// search declarations in index
|
||||||
|
@ -586,7 +663,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
public String getSource() {
|
public String getSource() {
|
||||||
return fSource;
|
return fSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -605,12 +681,12 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
if (editor != null) {
|
if (editor != null) {
|
||||||
IEditorInput input= editor.getEditorInput();
|
IEditorInput input= editor.getEditorInput();
|
||||||
IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
|
IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
|
||||||
IWorkingCopy copy = manager.getWorkingCopy(input);
|
IWorkingCopy workingCopy = manager.getWorkingCopy(input);
|
||||||
try {
|
try {
|
||||||
if (copy == null || !copy.isConsistent()) {
|
if (workingCopy == null || !workingCopy.isConsistent()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (CModelException exc) {
|
} catch (CModelException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,22 +694,21 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
try {
|
try {
|
||||||
expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
|
expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
|
||||||
expression = expression.trim();
|
expression = expression.trim();
|
||||||
if (expression.length() == 0)
|
if (expression.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//Before trying a search lets make sure that the user is not hovering over a keyword
|
// Before trying a search lets make sure that the user is not hovering
|
||||||
if (selectionIsKeyword(expression))
|
// over a keyword other than 'auto'.
|
||||||
|
if (selectionIsKeyword(expression) && !expression.equals(Keywords.AUTO))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String source= null;
|
// Try with the indexer.
|
||||||
|
String source= searchInIndex(workingCopy, hoverRegion, expression);
|
||||||
|
|
||||||
// Try with the indexer
|
if (source == null || source.trim().isEmpty())
|
||||||
source= searchInIndex(copy, hoverRegion);
|
|
||||||
|
|
||||||
if (source == null || source.trim().length() == 0)
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// we are actually interested in the comments, too.
|
// We are actually interested in the comments, too.
|
||||||
// source= removeLeadingComments(source);
|
// source= removeLeadingComments(source);
|
||||||
|
|
||||||
String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
@ -645,7 +720,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
|
|
||||||
source = Strings.concatenate(sourceLines, delim);
|
source = Strings.concatenate(sourceLines, delim);
|
||||||
return source;
|
return source;
|
||||||
|
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,7 +754,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
final int startLine= doc.getLineOfOffset(partitionOffset);
|
final int startLine= doc.getLineOfOffset(partitionOffset);
|
||||||
final int lineOffset= doc.getLineOffset(startLine);
|
final int lineOffset= doc.getLineOffset(startLine);
|
||||||
if (partitionOffset == lineOffset ||
|
if (partitionOffset == lineOffset ||
|
||||||
doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
|
doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
|
||||||
return lineOffset;
|
return lineOffset;
|
||||||
}
|
}
|
||||||
return commentOffset;
|
return commentOffset;
|
||||||
|
@ -690,13 +764,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
final int startLine= doc.getLineOfOffset(partitionOffset);
|
final int startLine= doc.getLineOfOffset(partitionOffset);
|
||||||
final int lineOffset= doc.getLineOffset(startLine);
|
final int lineOffset= doc.getLineOffset(startLine);
|
||||||
if (partitionOffset == lineOffset ||
|
if (partitionOffset == lineOffset ||
|
||||||
doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
|
doc.get(lineOffset, partitionOffset - lineOffset).trim().isEmpty()) {
|
||||||
commentOffset= lineOffset;
|
commentOffset= lineOffset;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return commentOffset;
|
return commentOffset;
|
||||||
} else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
|
} else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
|
||||||
if (doc.get(partition.getOffset(), partition.getLength()).trim().length() == 0) {
|
if (doc.get(partition.getOffset(), partition.getLength()).trim().isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (commentOffset >= 0) {
|
if (commentOffset >= 0) {
|
||||||
|
@ -713,7 +787,6 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip the leading comment from the given source string.
|
* Strip the leading comment from the given source string.
|
||||||
*
|
*
|
||||||
|
@ -732,13 +805,13 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
}
|
}
|
||||||
i= reader.getOffset();
|
i= reader.getOffset();
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
i= 0;
|
i= 0;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException e) {
|
||||||
CUIPlugin.log(ex);
|
CUIPlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,13 +820,14 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
return source.substring(i);
|
return source.substring(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String searchInIndex(final ITranslationUnit tUnit, IRegion textRegion) {
|
protected String searchInIndex(final ITranslationUnit tUnit, IRegion textRegion, String selection) {
|
||||||
final ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion);
|
final ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion, selection);
|
||||||
Job job= new Job(CHoverMessages.CSourceHover_jobTitle) {
|
Job job= new Job(CHoverMessages.CSourceHover_jobTitle) {
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
|
return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY,
|
||||||
|
monitor, computer);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
CUIPlugin.log(t);
|
CUIPlugin.log(t);
|
||||||
}
|
}
|
||||||
|
@ -769,16 +843,15 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
job.schedule();
|
job.schedule();
|
||||||
try {
|
try {
|
||||||
job.join();
|
job.join();
|
||||||
} catch (InterruptedException exc) {
|
} catch (InterruptedException e) {
|
||||||
job.cancel();
|
job.cancel();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return computer.getSource();
|
return computer.getSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether the given name is a known keyword.
|
* Checks whether the given name is a known keyword.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return <code>true</code> if the name is a known keyword or <code>false</code> if the
|
* @return <code>true</code> if the name is a known keyword or <code>false</code> if the
|
||||||
|
@ -802,7 +875,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
|
||||||
int orientation= SWT.NONE;
|
int orientation= SWT.NONE;
|
||||||
if (editor instanceof IWorkbenchPartOrientation)
|
if (editor instanceof IWorkbenchPartOrientation)
|
||||||
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
|
||||||
return new SourceViewerInformationControl(parent, false, orientation, getTooltipAffordanceString());
|
return new SourceViewerInformationControl(parent, false, orientation,
|
||||||
|
getTooltipAffordanceString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue