### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v
retrieving revision 1.86
diff -u -r1.86 JavaSearchBugsTests.java
--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 3 Oct 2006 11:31:47 -0000 1.86
+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Oct 2006 16:25:15 -0000
@@ -11,6 +11,7 @@
package org.eclipse.jdt.core.tests.model;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import junit.framework.Test;
@@ -82,6 +83,36 @@
}
}
+class TypeNameMatchCollector extends TypeNameMatchRequestor {
+ private int index = -1;
+ public String[] results = new String[10];
+ public void acceptTypeNameMatch(TypeNameMatch match) {
+ int length = results.length;
+ if (++index > length) {
+ System.arraycopy(results, 0, results = new String[length+10], 0, length);
+ }
+ try {
+ IType type = match.getType();
+ if (type != null) {
+ results[index] = type.toString();
+ }
+ }
+ catch (JavaModelException jme) {
+ assertTrue("We should not have any JavaModel exception! Message:"+jme.getMessage(), false);
+ }
+ }
+ public String toString() {
+ String[] strings = new String[index+1];
+ System.arraycopy(results, 0, strings, 0, index+1);
+ Arrays.sort(strings);
+ StringBuffer buffer = new StringBuffer();
+ for (int i=0; i<=index; i++) {
+ if (i>0) buffer.append('\n');
+ buffer.append(strings[i]);
+ }
+ return buffer.toString();
+ }
+}
IJavaSearchScope getJavaSearchScopeBugs() {
return SearchEngine.createJavaSearchScope(new IJavaProject[] {getJavaProject("JavaSearchBugs")});
}
@@ -6879,7 +6910,7 @@
"public class Y {}\n"
);
IJavaSearchScope scope = getJavaSearchScopeBugs();
- TestTypeNameMatchRequestor requestor1 = new TestTypeNameMatchRequestor();
+ TypeNameMatchCollector requestor1 = new TypeNameMatchCollector();
new SearchEngine(this.workingCopies).searchAllTypeNames(
"b148380".toCharArray(),
SearchPattern.R_EXACT_MATCH,
@@ -6890,15 +6921,13 @@
requestor1,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null);
- assertSearchResults(
- "interface I [in [Working copy] I.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
+ String expected = "class Sub [in [Working copy] Sub.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
"class X [in [Working copy] X.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
- "class Sub [in [Working copy] Sub.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
- "class Y [in [Working copy] Y.java [in b148380 [in src [in JavaSearchBugs]]]]",
- requestor1);
- /* DISABLED as results order is not the same on different VM...
- * Expected same result with the wc owner
- TestTypeNameMatchRequestor requestor2 = new TestTypeNameMatchRequestor();
+ "class Y [in [Working copy] Y.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
+ "interface I [in [Working copy] I.java [in b148380 [in src [in JavaSearchBugs]]]]";
+ assertSearchResults(expected, requestor1);
+ // Expected same result with the wc owner
+ TypeNameMatchCollector requestor2 = new TypeNameMatchCollector();
new SearchEngine(this.wcOwner).searchAllTypeNames(
"b148380".toCharArray(),
SearchPattern.R_EXACT_MATCH,
@@ -6909,16 +6938,11 @@
requestor2,
IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
null);
- assertSearchResults("class Sub [in [Working copy] Sub.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
- "class Y [in [Working copy] Y.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
- "interface I [in [Working copy] I.java [in b148380 [in src [in JavaSearchBugs]]]]\n" +
- "class X [in [Working copy] X.java [in b148380 [in src [in JavaSearchBugs]]]]",
- requestor2);
- */
+ assertSearchResults(expected, requestor2);
}
public void testBug148380_SearchAllTypes_cu() throws CoreException, JavaModelException {
IJavaSearchScope scope = getJavaSearchScopeBugs();
- TestTypeNameMatchRequestor requestor = new TestTypeNameMatchRequestor();
+ TypeNameMatchCollector requestor = new TypeNameMatchCollector();
new SearchEngine().searchAllTypeNames(
null,
SearchPattern.R_EXACT_MATCH,
@@ -6936,7 +6960,7 @@
}
public void testBug148380_SearchAllTypes_cu_wksp() throws CoreException, JavaModelException {
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
- TestTypeNameMatchRequestor requestor = new TestTypeNameMatchRequestor();
+ TypeNameMatchCollector requestor = new TypeNameMatchCollector();
new SearchEngine().searchAllTypeNames(
null,
SearchPattern.R_EXACT_MATCH,
@@ -7083,26 +7107,4 @@
);
}
-/**
- * Bug 156491: [1.5][search] interfaces and annotations could be found with only one requets of searchAllTypeName
- * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=156491"
- */
-class TestTypeNameMatchRequestor extends TypeNameMatchRequestor {
- public StringBuffer results = new StringBuffer();
- public void acceptTypeNameMatch(TypeNameMatch match) {
- if (results.length() > 0) results.append('\n');
- try {
- IType type = match.resolvedType();
- if (type != null) {
- results.append(type.toString());
- }
- }
- catch (JavaModelException jme) {
- assertTrue("We should not have no JavaModel exception! Message:"+jme.getMessage(), false);
- }
- }
- public String toString() {
- return this.results.toString();
- }
-}
}
\ No newline at end of file
#P org.eclipse.jdt.core
Index: search/org/eclipse/jdt/internal/core/search/WorkingCopiesTypeNameMatch.java
===================================================================
RCS file: search/org/eclipse/jdt/internal/core/search/WorkingCopiesTypeNameMatch.java
diff -N search/org/eclipse/jdt/internal/core/search/WorkingCopiesTypeNameMatch.java
--- search/org/eclipse/jdt/internal/core/search/WorkingCopiesTypeNameMatch.java 3 Oct 2006 11:32:05 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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.internal.core.search;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.search.TypeNameMatch;
-
-/**
- * Specific match collected while searching for all type names
- * when type belongs to a working copy.
- *
- * @since 3.3
- */
-public class WorkingCopiesTypeNameMatch extends TypeNameMatch {
- private ICompilationUnit[] workingCopies;
-
-public WorkingCopiesTypeNameMatch(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, String path, ICompilationUnit[] workingCopies) {
- super(modifiers, packageName, typeName, enclosingTypeNames, path);
- this.workingCopies = workingCopies;
-}
-
-/* (non-Javadoc)
- * @see org.eclipse.jdt.core.search.TypeNameMatch#getWorkingCopies()
- */
-protected ICompilationUnit[] getWorkingCopies() {
- return this.workingCopies;
-}
-}
Index: search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java,v
retrieving revision 1.39
diff -u -r1.39 BasicSearchEngine.java
--- search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 3 Oct 2006 11:32:05 -0000 1.39
+++ search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 6 Oct 2006 16:25:27 -0000
@@ -326,7 +326,7 @@
* Returns the list of working copies used by this search engine.
* Returns null if none.
*/
- public ICompilationUnit[] getWorkingCopies() {
+ private ICompilationUnit[] getWorkingCopies() {
ICompilationUnit[] copies;
if (this.workingCopies != null) {
if (this.workingCopyOwner == null) {
@@ -779,7 +779,7 @@
// add type names from working copies
if (copies != null) {
for (int i = 0; i < copiesLength; i++) {
- ICompilationUnit workingCopy = copies[i];
+ final ICompilationUnit workingCopy = copies[i];
if (!scope.encloses(workingCopy)) continue;
final String path = workingCopy.getPath().toString();
if (workingCopy.isConsistent()) {
@@ -808,7 +808,11 @@
kind = TypeDeclaration.INTERFACE_DECL;
}
if (match(typeSuffix, packageName, typeName, typeMatchRule, kind, packageDeclaration, simpleName)) {
- nameRequestor.acceptType(type.getFlags(), packageDeclaration, simpleName, enclosingTypeNames, path, null);
+ if (nameRequestor instanceof TypeNameMatchRequestorWrapper) {
+ ((TypeNameMatchRequestorWrapper)nameRequestor).requestor.acceptTypeNameMatch(new TypeNameMatch(type));
+ } else {
+ nameRequestor.acceptType(type.getFlags(), packageDeclaration, simpleName, enclosingTypeNames, path, null);
+ }
}
}
} else {
@@ -824,7 +828,12 @@
}
public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope compilationUnitScope) {
if (match(typeSuffix, packageName, typeName, typeMatchRule, TypeDeclaration.kind(typeDeclaration.modifiers), packageDeclaration, typeDeclaration.name)) {
- nameRequestor.acceptType(typeDeclaration.modifiers, packageDeclaration, typeDeclaration.name, CharOperation.NO_CHAR_CHAR, path, null);
+ if (nameRequestor instanceof TypeNameMatchRequestorWrapper) {
+ IType type = workingCopy.getType(new String(typeName));
+ ((TypeNameMatchRequestorWrapper)nameRequestor).requestor.acceptTypeNameMatch(new TypeNameMatch(type, typeDeclaration.modifiers));
+ } else {
+ nameRequestor.acceptType(typeDeclaration.modifiers, packageDeclaration, typeDeclaration.name, CharOperation.NO_CHAR_CHAR, path, null);
+ }
}
return true;
}
@@ -842,7 +851,15 @@
}
}
// report
- nameRequestor.acceptType(memberTypeDeclaration.modifiers, packageDeclaration, memberTypeDeclaration.name, enclosingTypeNames, path, null);
+ if (nameRequestor instanceof TypeNameMatchRequestorWrapper) {
+ IType type = workingCopy.getType(new String(enclosingTypeNames[0]));
+ for (int j=1, l=enclosingTypeNames.length; j
- * User can get type from this match using {@link #resolvedType()} method. - *
* This class is not intended to be instantiated or subclassed by clients. *
+ * * @see TypeNameMatchRequestor * * @since 3.3 */ public class TypeNameMatch { -//private IType type; -private int modifiers; -private char[] packageName; -private char[] simpleTypeName; -private char[][] enclosingTypeNames; -private String path; -//private boolean initialized; +private IType type; + +private int modifiers = -1; // store modifiers to avoid java model population /** * Creates a new type name match. */ -public TypeNameMatch(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, String path) { - this.modifiers = modifiers; - this.packageName = packageName; - this.simpleTypeName = typeName; - this.enclosingTypeNames = enclosingTypeNames; - this.path = path; +public TypeNameMatch(IType type) { + this.type = type; } -/** - * Returns the enclosing type names (if any) of the type. - * - * @return the enclosing type names (if any) of the type - */ -public final char[][] getEnclosingTypeNames() { - return enclosingTypeNames; +public TypeNameMatch(IType type, int modifiers) { + this(type); + this.modifiers = modifiers; } /** - * Fully qualified name of type (e.g. package name + '.' enclosing type names + '.' simple name) + * Returns the java model type corresponding to fully qualified type name (based + * on package, enclosing types and simple name). * - * @return Fully qualified type name of the type + * @return the java model type + * @throws JavaModelException + * happens when type stored information are not valid */ -public final char[] getFullyQualifiedName() { - return CharOperation.concat(this.packageName, getTypeContainerName(), '.'); +public IType getType() throws JavaModelException { + return this.type; } -/** - * Returns the modifiers of the type. +/* + * (non-Javadoc) * - * @return the type modifiers + * @see java.lang.Object#toString() */ -public final int getModifiers() { - return modifiers; +public String toString() { + return this.type.toString(); } -/* - * Specific package fragment root while resolving type - */ -protected IPackageFragmentRoot getPackageFragmentRoot() { - return null; +public IPackageFragmentRoot getPackageFragmentRoot() { + return (IPackageFragmentRoot) this.type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); } /** - * Returns the package name of the type. + * Fully qualified name of type (e.g. package name + '.' enclosing type names + + * '.' simple name) * - * @return the package name + * @return Fully qualified type name of the type */ -public final char[] getPackageName() { - return packageName; +public String getFullyQualifiedName() { + return this.type.getFullyQualifiedName('.'); } /** - * Returns the full path of the resource. - * This path may include the jar file path following by '|' separator - * if the type is a binary included in a jar. + * Fully qualified name of type (e.g. package name + '.' enclosing type names + + * '.' simple name) * - * @return the full path of the resource + * @return Fully qualified type name of the type */ -public final String getPath() { - return path; +public String getTypeQualifiedName() { + return this.type.getTypeQualifiedName('.'); } -/* - * Project used to resolve type +/** + * Returns the modifiers of the type. + * + * @return the type modifiers */ -protected IProject getProject() { - return ResourcesPlugin.getWorkspace().getRoot().getProject(new Path(this.path).segment(0)); +public int getModifiers() { + return this.modifiers; } /** - * Returns the name of the type. + * Returns the package name of the type. * - * @return the type name + * @return the package name */ -public final char[] getSimpleTypeName() { - return simpleTypeName; +public String getPackageName() { + return this.type.getPackageFragment().getElementName(); } /** - * Returns the java model type corresponding to fully qualified type name - * (based on package, enclosing types and simple name). + * Returns the name of the type. * - * @return the java model type - * @throws JavaModelException happens when type stored information are not valid + * @return the type name */ -public IType resolvedType() throws JavaModelException { - IJavaProject javaProject = JavaCore.create(getProject()); - if (javaProject == null) return null; // cannot initialize without a project - return javaProject.findType(new String(packageName), new String(getTypeContainerName()), getPackageFragmentRoot(), getWorkingCopies(), null); +public String getSimpleTypeName() { + return this.type.getElementName(); } /** @@ -152,21 +127,12 @@ * * @return Name of the type container */ -public final char[] getTypeContainerName() { - return this.enclosingTypeNames == null ? this.simpleTypeName : CharOperation.concatWith(this.enclosingTypeNames, this.simpleTypeName, '.'); -} - -/* - * Working copies to look in while resolving type - */ -protected ICompilationUnit[] getWorkingCopies() { - return null; -} - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -public String toString() { - return new String(getFullyQualifiedName()); +public String getTypeContainerName() { + IType outerType = this.type.getDeclaringType(); + if (outerType != null) { + return outerType.getFullyQualifiedName('.'); + } else { + return this.type.getPackageFragment().getElementName(); + } } } Index: search/org/eclipse/jdt/core/search/SearchEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java,v retrieving revision 1.132 diff -u -r1.132 SearchEngine.java --- search/org/eclipse/jdt/core/search/SearchEngine.java 3 Oct 2006 11:32:36 -0000 1.132 +++ search/org/eclipse/jdt/core/search/SearchEngine.java 6 Oct 2006 16:25:27 -0000 @@ -765,7 +765,7 @@ int waitingPolicy, IProgressMonitor progressMonitor) throws JavaModelException { - TypeNameMatchRequestorWrapper requestorWrapper = new TypeNameMatchRequestorWrapper(nameMatchRequestor, scope, this.basicEngine.getWorkingCopies()); + TypeNameMatchRequestorWrapper requestorWrapper = new TypeNameMatchRequestorWrapper(nameMatchRequestor, scope); this.basicEngine.searchAllTypeNames(packageName, packageMatchRule, typeName, typeMatchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor); } Index: model/org/eclipse/jdt/internal/core/JavaProject.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v retrieving revision 1.373 diff -u -r1.373 JavaProject.java --- model/org/eclipse/jdt/internal/core/JavaProject.java 3 Oct 2006 11:32:05 -0000 1.373 +++ model/org/eclipse/jdt/internal/core/JavaProject.java 6 Oct 2006 16:25:25 -0000 @@ -1218,15 +1218,14 @@ /* * Internal findType with instanciated name lookup */ - IType findType(String packageName, String typeQualifiedName, IPackageFragmentRoot root, NameLookup lookup, boolean considerSecondaryTypes, IProgressMonitor progressMonitor) throws JavaModelException { + IType findType(String packageName, String typeQualifiedName, NameLookup lookup, boolean considerSecondaryTypes, IProgressMonitor progressMonitor) throws JavaModelException { NameLookup.Answer answer = lookup.findType( typeQualifiedName, packageName, - root, false, NameLookup.ACCEPT_ALL, - considerSecondaryTypes, // wait for indexes (in case we need to consider secondary types) - true, + considerSecondaryTypes, + true, // wait for indexes (in case we need to consider secondary types) false/*don't check restrictions*/, progressMonitor); return answer == null ? null : answer.type; @@ -1239,9 +1238,8 @@ return findType( packageName, typeQualifiedName, - null, - lookup, // do not consider secondary types - false, + lookup, + false, // do not consider secondary types null); } @@ -1253,23 +1251,8 @@ return findType( packageName, typeQualifiedName, - null, - lookup, // consider secondary types - true, - progressMonitor); - } - - /** - * @see IJavaProject#findType(String, String, IPackageFragmentRoot, ICompilationUnit[], IProgressMonitor) - */ - public IType findType(String packageName, String typeQualifiedName, IPackageFragmentRoot root, ICompilationUnit[] workingCopies, IProgressMonitor progressMonitor) throws JavaModelException { - NameLookup lookup = newNameLookup(workingCopies); - return findType( - packageName, - typeQualifiedName, - root, - lookup, // consider secondary types - true, + lookup, + true, // consider secondary types progressMonitor); } Index: model/org/eclipse/jdt/internal/core/NameLookup.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java,v retrieving revision 1.111 diff -u -r1.111 NameLookup.java --- model/org/eclipse/jdt/internal/core/NameLookup.java 3 Oct 2006 11:32:05 -0000 1.111 +++ model/org/eclipse/jdt/internal/core/NameLookup.java 6 Oct 2006 16:25:26 -0000 @@ -571,7 +571,6 @@ public Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions) { return findType(typeName, packageName, - null, partialMatch, acceptFlags, true/* consider secondary types */, @@ -586,11 +585,10 @@ public Answer findType( String typeName, String packageName, - IPackageFragmentRoot root, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, - boolean waitForIndexes, + boolean waitForIndexes, boolean checkRestrictions, IProgressMonitor monitor) { if (packageName == null || packageName.length() == 0) { @@ -612,10 +610,6 @@ IJavaProject javaProject = null; Answer suggestedAnswer = null; for (int i= 0; i < length; i++) { - if (root != null && !packages[i].getParent().equals(root)) { - // filter package which are not in same root - continue; - } type = findType(typeName, packages[i], partialMatch, acceptFlags); if (type != null) { AccessRestriction accessRestriction = null; @@ -770,7 +764,7 @@ packageName= name.substring(0, index); className= name.substring(index + 1); } - return findType(className, packageName, null, partialMatch, acceptFlags, considerSecondaryTypes, waitForIndexes, checkRestrictions, monitor); + return findType(className, packageName, partialMatch, acceptFlags, considerSecondaryTypes, waitForIndexes, checkRestrictions, monitor); } private IType getMemberType(IType type, String name, int dot) { Index: model/org/eclipse/jdt/core/IJavaProject.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java,v retrieving revision 1.88 diff -u -r1.88 IJavaProject.java --- model/org/eclipse/jdt/core/IJavaProject.java 3 Oct 2006 11:32:05 -0000 1.88 +++ model/org/eclipse/jdt/core/IJavaProject.java 6 Oct 2006 16:25:20 -0000 @@ -344,34 +344,6 @@ * @since 3.2 */ IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner, IProgressMonitor progressMonitor) throws JavaModelException; - /** - * Returns the first type found following this project's classpath - * with the given package name and type qualified name - * ornull
if none is found.
- * The package name is a dot-separated name.
- * The type qualified name is also a dot-separated name. For example,
- * a class B defined as a member type of a class A should have the
- * type qualified name "A.B".
- * The returned type may be a part of one of the given compilation units.
- * If a package fragment root is specified, then the returned type, if any,
- * will belong to a package fragment which parent is the given package fragment root.
- *
- * @param packageName the given package name
- * @param typeQualifiedName the given type qualified name
- * @param root Package fragment root which must include the search type.
- * May be null
.
- * @param units Compilation units returned may be a part of.
- * May be null
.
- * @param progressMonitor the progress monitor to report progress to,
- * or null
if no progress monitor is provided
- * @exception JavaModelException if this project does not exist or if an
- * exception occurs while accessing its corresponding resource
- * @return the first type found following this project's classpath
- * with the given fully qualified name or null
if none is found
- * @see IType#getFullyQualifiedName(char)
- * @since 3.3
- */
- IType findType(String packageName, String typeQualifiedName, IPackageFragmentRoot root, ICompilationUnit[] units, IProgressMonitor progressMonitor) throws JavaModelException;
/**
* Returns all of the existing package fragment roots that exist
Index: model/org/eclipse/jdt/core/JavaCore.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v
retrieving revision 1.553
diff -u -r1.553 JavaCore.java
--- model/org/eclipse/jdt/core/JavaCore.java 3 Oct 2006 15:18:46 -0000 1.553
+++ model/org/eclipse/jdt/core/JavaCore.java 6 Oct 2006 16:25:23 -0000
@@ -1322,31 +1322,6 @@
return JavaModelManager.create(file, null/*unknown java project*/);
}
/**
- * Returns the Java element corresponding to the given file, its project being the given
- * project.
- * Returns null
if unable to associate the given file
- * with a Java element.
- *
- * The file must be one of:
ICompilationUnit
.class
file - the element returned is the corresponding IClassFile
.jar
file - the element returned is the corresponding IPackageFragmentRoot
- * Creating a Java element has the side effect of creating and opening all of the
- * element's parents if they are not yet open.
- *
- * @param file the given file
- * @return the Java element corresponding to the given file, or
- * null
if unable to associate the given file
- * with a Java element
- * @since 3.3
- */
- public static IJavaElement create(IFile file, IJavaProject project) {
- return JavaModelManager.create(file, project);
- }
- /**
* Returns the package fragment or package fragment root corresponding to the given folder, or
* null
if unable to associate the given folder with a Java element.
*
@@ -1408,6 +1383,34 @@
return JavaModelManager.create(resource, null/*unknown java project*/);
}
/**
+ * Returns the Java element corresponding to the given file, its project being the given
+ * project. Returns null
if unable to associate the given resource
+ * with a Java element.
+ *
+ * The resource must be one of:
IJavaProject
ICompilationUnit
.class
file - the element returned is the corresponding IClassFile
.jar
file - the element returned is the corresponding IPackageFragmentRoot
IPackageFragmentRoot
+ * or IPackageFragment
IJavaModel
+ * Creating a Java element has the side effect of creating and opening all of the
+ * element's parents if they are not yet open.
+ *
+ * @param resource the given resource
+ * @return the Java element corresponding to the given file, or
+ * null
if unable to associate the given file
+ * with a Java element
+ * @since 3.3
+ */
+ public static IJavaElement create(IResource resource, IJavaProject project) {
+ return JavaModelManager.create(resource, project);
+ }
+ /**
* Returns the Java model.
*
* @param root the given root
Index: buildnotes_jdt-core.html
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v
retrieving revision 1.5442
diff -u -r1.5442 buildnotes_jdt-core.html
--- buildnotes_jdt-core.html 5 Oct 2006 19:15:43 -0000 1.5442
+++ buildnotes_jdt-core.html 6 Oct 2006 16:25:20 -0000
@@ -52,6 +52,19 @@
TypeNameMatch
has been changed to improve memory consumption performance.
+It now creates IType handle while accepting the type information from indexes and stores their modifiers
+to avoid java element opening while getting this piece of information.+IType findType(String packageName, + String typeQualifiedName, + IPackageFragmentRoot root, + ICompilationUnit[] units, + IProgressMonitor progressMonitor) throws JavaModelException; ++
searchAllTypeNames
available methods...
IJavaProject
API method to let clients finding types in a project with additional working copies
-and in a specific package fragment root:
--/** - * Returns the first type found following this project's classpath - * with the given package name and type qualified name - * or-null
if none is found. - * The package name is a dot-separated name. - * The type qualified name is also a dot-separated name. For example, - * a class B defined as a member type of a class A should have the - * type qualified name "A.B". - * The returned type may be a part of one of the given compilation units. - * If a package fragment root is specified, then the returned type, if any, - * will belong to a package fragment which parent is the given package fragment root. - * - * @param packageName the given package name - * @param typeQualifiedName the given type qualified name - * @param root Package fragment root which must include the search type. - * May benull
. - * @param units Compilation units returned may be a part of. - * May benull
. - * @param progressMonitor the progress monitor to report progress to, - * ornull
if no progress monitor is provided - * @exception JavaModelException if this project does not exist or if an - * exception occurs while accessing its corresponding resource - * @return the first type found following this project's classpath - * with the given fully qualified name ornull
if none is found - * @see IType#getFullyQualifiedName(char) - * @since 3.3 - */ -IType findType(String packageName, - String typeQualifiedName, - IPackageFragmentRoot root, - ICompilationUnit[] units, - IProgressMonitor progressMonitor) throws JavaModelException; -
JavaCore
API method to create a java element from an IFile
using a specific project: