mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 517954 - ClassCastException in CVisitor.findBindingsForContentAssist()
Change-Id: I0780b422ee727def577f78ed600f66a3ef4728d0
This commit is contained in:
parent
68a609fe44
commit
c24e5d17b3
4 changed files with 24 additions and 2 deletions
|
@ -1529,7 +1529,15 @@ public class CVisitor extends ASTQueries {
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
|
|
||||||
if (prop == IASTFieldReference.FIELD_NAME) {
|
if (prop == IASTFieldReference.FIELD_NAME) {
|
||||||
result = (IBinding[]) findBinding((IASTFieldReference) name.getParent(), isPrefix);
|
Object res = findBinding((IASTFieldReference) name.getParent(), isPrefix);
|
||||||
|
if (isPrefix) {
|
||||||
|
result = (IBinding[]) res;
|
||||||
|
} else {
|
||||||
|
IBinding binding = (IBinding) res;
|
||||||
|
if (binding != null) {
|
||||||
|
result = new IBinding[] { binding };
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (prop == ICASTFieldDesignator.FIELD_NAME) {
|
} else if (prop == ICASTFieldDesignator.FIELD_NAME) {
|
||||||
result = findBindingForContentAssist((ICASTFieldDesignator) name.getParent(), isPrefix);
|
result = findBindingForContentAssist((ICASTFieldDesignator) name.getParent(), isPrefix);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal;
|
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
|
import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistMessages;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ParameterGuessingProposal;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ParameterGuessingProposal;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
|
import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
|
||||||
|
@ -155,6 +156,9 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
(Object[]) processor.computeContextInformation(sourceViewer, offset);
|
(Object[]) processor.computeContextInformation(sourceViewer, offset);
|
||||||
long endTime= System.currentTimeMillis();
|
long endTime= System.currentTimeMillis();
|
||||||
assertTrue(results != null);
|
assertTrue(results != null);
|
||||||
|
// Make sure no exception was thrown during content assist invocation.
|
||||||
|
assertTrue(processor.getErrorMessage() == null ||
|
||||||
|
processor.getErrorMessage().equals(ContentAssistMessages.ContentAssistProcessor_no_completions));
|
||||||
|
|
||||||
if (filterResults) {
|
if (filterResults) {
|
||||||
if (isTemplate) {
|
if (isTemplate) {
|
||||||
|
|
|
@ -976,4 +976,14 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
|
||||||
final String[] expected= {"_f204758(_e204758)"};
|
final String[] expected= {"_f204758(_e204758)"};
|
||||||
assertCompletionResults(expected);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int main(void) {
|
||||||
|
// struct {
|
||||||
|
// void (*bar)(p1, p2, p3...);
|
||||||
|
// } foo;
|
||||||
|
// foo.bar(/*cursor*/
|
||||||
|
public void testClassCastException_Bug517954() throws Exception {
|
||||||
|
// Just check that no exception is thrown while invoking completion.
|
||||||
|
assertContentAssistResults(fCursorOffset, new String[]{}, DEFAULT_FLAGS | ALLOW_EXTRA_RESULTS, CompareType.ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
/**
|
/**
|
||||||
* Helper class to get NLSed messages.
|
* Helper class to get NLSed messages.
|
||||||
*/
|
*/
|
||||||
final class ContentAssistMessages extends NLS {
|
public final class ContentAssistMessages extends NLS {
|
||||||
|
|
||||||
private static final String BUNDLE_NAME= ContentAssistMessages.class.getName();
|
private static final String BUNDLE_NAME= ContentAssistMessages.class.getName();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue