Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 97172 Details for
Bug 227822
[select] ClassCastException thrown if unable to resolve core Java types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug227822_002.txt (text/plain), 9.90 KB, created by
David Audel
on 2008-04-23 04:29:27 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2008-04-23 04:29:27 EDT
Size:
9.90 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java,v >retrieving revision 1.24 >diff -u -r1.24 SelectionOnQualifiedTypeReference.java >--- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java 10 May 2006 18:03:41 -0000 1.24 >+++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java 23 Apr 2008 08:28:46 -0000 >@@ -25,7 +25,9 @@ > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; > import org.eclipse.jdt.internal.compiler.lookup.Binding; >+import org.eclipse.jdt.internal.compiler.lookup.PackageBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.Scope; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > >@@ -42,11 +44,18 @@ > // it can be a package, type or member type > Binding binding = scope.getTypeOrPackage(tokens); > if (!binding.isValidBinding()) { >- // tolerate some error cases >- if (binding.problemId() == ProblemReasons.NotVisible){ >- throw new SelectionNodeFound(binding); >- } >- scope.problemReporter().invalidType(this, (TypeBinding) binding); >+ // tolerate some error cases >+ if (binding.problemId() == ProblemReasons.NotVisible){ >+ throw new SelectionNodeFound(binding); >+ } >+ >+ if (binding instanceof TypeBinding) { >+ scope.problemReporter().invalidType(this, (TypeBinding) binding); >+ } else if (binding instanceof PackageBinding) { >+ ProblemReferenceBinding problemBinding = new ProblemReferenceBinding(((PackageBinding)binding).compoundName, null, binding.problemId()); >+ scope.problemReporter().invalidType(this, problemBinding); >+ } >+ > throw new SelectionNodeFound(); > } > >Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java,v >retrieving revision 1.24 >diff -u -r1.24 SelectionOnSingleTypeReference.java >--- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java 10 May 2006 18:03:41 -0000 1.24 >+++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java 23 Apr 2008 08:28:46 -0000 >@@ -24,7 +24,9 @@ > import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; > import org.eclipse.jdt.internal.compiler.lookup.Binding; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >+import org.eclipse.jdt.internal.compiler.lookup.PackageBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.Scope; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >@@ -40,7 +42,12 @@ > // it can be a package, type or member type > Binding binding = scope.getTypeOrPackage(new char[][] {token}); > if (!binding.isValidBinding()) { >- scope.problemReporter().invalidType(this, (TypeBinding) binding); >+ if (binding instanceof TypeBinding) { >+ scope.problemReporter().invalidType(this, (TypeBinding) binding); >+ } else if (binding instanceof PackageBinding) { >+ ProblemReferenceBinding problemBinding = new ProblemReferenceBinding(((PackageBinding)binding).compoundName, null, binding.problemId()); >+ scope.problemReporter().invalidType(this, problemBinding); >+ } > throw new SelectionNodeFound(); > } > throw new SelectionNodeFound(binding); >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java,v >retrieving revision 1.72 >diff -u -r1.72 AllJavaModelTests.java >--- src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java 20 Jun 2006 11:33:01 -0000 1.72 >+++ src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java 23 Apr 2008 08:28:48 -0000 >@@ -86,6 +86,7 @@ > > // Support for "open on" feature tests > ResolveTests.class, >+ ResolveTests2.class, > ResolveTests_1_5.class, > SelectionJavadocModelTests.class, > >Index: src/org/eclipse/jdt/core/tests/model/ResolveTests2.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/model/ResolveTests2.java >diff -N src/org/eclipse/jdt/core/tests/model/ResolveTests2.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/model/ResolveTests2.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,195 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.model; >+ >+import org.eclipse.jdt.core.*; >+ >+import junit.framework.*; >+ >+public class ResolveTests2 extends ModifyingResourceTests { >+ >+static { >+// TESTS_NAMES = new String[] { "testSecondaryTypes" }; >+} >+public static Test suite() { >+ return buildModelTestSuite(ResolveTests2.class); >+} >+ >+public ResolveTests2(String name) { >+ super(name); >+} >+public void setUpSuite() throws Exception { >+ super.setUpSuite(); >+ >+ setUpJavaProject("Resolve"); >+} >+public void tearDownSuite() throws Exception { >+ deleteProject("Resolve"); >+ >+ super.tearDownSuite(); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 >+public void testBug227822a() throws Exception { >+ try { >+ // create P1 >+ this.createJavaProject( >+ "P1", >+ new String[]{"src"}, >+ new String[]{}, >+ "bin"); >+ >+ this.createFolder("/P1/src/a"); >+ this.createFile( >+ "/P1/src/a/Test.java", >+ "package a;\n"+ >+ "public class Test {\n" + >+ " java.lang.Object var;\n"+ >+ "}"); >+ >+ waitUntilIndexesReady(); >+ >+ // do code select >+ ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); >+ >+ String str = cu.getSource(); >+ >+ String selection = "java.lang.Object"; >+ int start = str.lastIndexOf(selection); >+ int length = selection.length(); >+ IJavaElement[] elements = cu.codeSelect(start, length); >+ >+ assertElementsEqual( >+ "Unexpected elements", >+ "", >+ elements >+ ); >+ } finally { >+ this.deleteProject("P1"); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 >+public void testBug227822b() throws Exception { >+ try { >+ // create P1 >+ this.createJavaProject( >+ "P1", >+ new String[]{"src"}, >+ new String[]{}, >+ "bin"); >+ >+ this.createFolder("/P1/src/a"); >+ this.createFile( >+ "/P1/src/a/Test.java", >+ "package a;\n"+ >+ "public class Test {\n" + >+ " javaz.lang.Objectz var;\n"+ >+ "}"); >+ >+ waitUntilIndexesReady(); >+ >+ // do code select >+ ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); >+ >+ String str = cu.getSource(); >+ >+ String selection = "javaz.lang.Objectz"; >+ int start = str.lastIndexOf(selection); >+ int length = selection.length(); >+ IJavaElement[] elements = cu.codeSelect(start, length); >+ >+ assertElementsEqual( >+ "Unexpected elements", >+ "", >+ elements >+ ); >+ } finally { >+ this.deleteProject("P1"); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 >+public void testBug227822c() throws Exception { >+ try { >+ // create P1 >+ this.createJavaProject( >+ "P1", >+ new String[]{"src"}, >+ new String[]{}, >+ "bin"); >+ >+ this.createFolder("/P1/src/a"); >+ this.createFile( >+ "/P1/src/a/Test.java", >+ "package a;\n"+ >+ "public class Test {\n" + >+ " java var;\n"+ >+ "}"); >+ >+ waitUntilIndexesReady(); >+ >+ // do code select >+ ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); >+ >+ String str = cu.getSource(); >+ >+ String selection = "java"; >+ int start = str.lastIndexOf(selection); >+ int length = selection.length(); >+ IJavaElement[] elements = cu.codeSelect(start, length); >+ >+ assertElementsEqual( >+ "Unexpected elements", >+ "", >+ elements >+ ); >+ } finally { >+ this.deleteProject("P1"); >+ } >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=227822 >+public void testBug227822d() throws Exception { >+ try { >+ // create P1 >+ this.createJavaProject( >+ "P1", >+ new String[]{"src"}, >+ new String[]{}, >+ "bin"); >+ >+ this.createFolder("/P1/src/a"); >+ this.createFile( >+ "/P1/src/a/Test.java", >+ "package a;\n"+ >+ "public class Test {\n" + >+ " javaz var;\n"+ >+ "}"); >+ >+ waitUntilIndexesReady(); >+ >+ // do code select >+ ICompilationUnit cu= getCompilationUnit("P1", "src", "a", "Test.java"); >+ >+ String str = cu.getSource(); >+ >+ String selection = "javaz"; >+ int start = str.lastIndexOf(selection); >+ int length = selection.length(); >+ IJavaElement[] elements = cu.codeSelect(start, length); >+ >+ assertElementsEqual( >+ "Unexpected elements", >+ "", >+ elements >+ ); >+ } finally { >+ this.deleteProject("P1"); >+ } >+} >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 227822
:
96645
|
96646
| 97172