### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/core/search/SearchDocument.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchDocument.java,v retrieving revision 1.14 diff -u -r1.14 SearchDocument.java --- search/org/eclipse/jdt/core/search/SearchDocument.java 27 Jun 2008 16:04:08 -0000 1.14 +++ search/org/eclipse/jdt/core/search/SearchDocument.java 17 Sep 2008 17:08:46 -0000 @@ -10,7 +10,8 @@ *******************************************************************************/ package org.eclipse.jdt.core.search; -import org.eclipse.jdt.internal.core.search.indexing.InternalSearchDocument; +import org.eclipse.jdt.internal.compiler.SourceElementParser; +import org.eclipse.jdt.internal.core.index.Index; /** * A search document encapsulates a content to be either indexed or searched in. @@ -21,7 +22,10 @@ * * @since 3.0 */ -public abstract class SearchDocument extends InternalSearchDocument { +public abstract class SearchDocument { + private Index index; + private String containerRelativePath; + private SourceElementParser parser; private String documentPath; private SearchParticipant participant; @@ -47,7 +51,8 @@ * @param key the key of the index entry */ public void addIndexEntry(char[] category, char[] key) { - super.addIndexEntry(category, key); + if (this.index != null) + this.index.addIndexEntry(category, key, getContainerRelativePath()); } /** @@ -88,6 +93,12 @@ */ public abstract char[] getCharContents(); + private String getContainerRelativePath() { + if (this.containerRelativePath == null) + this.containerRelativePath = this.index.containerRelativePath(getPath()); + return this.containerRelativePath; + } + /** * Returns the encoding for this document. *

@@ -100,6 +111,14 @@ public abstract String getEncoding(); /** + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + */ + public SourceElementParser getParser() { + return this.parser; + } + + /** * Returns the participant that created this document. * * @return the participant that created this document @@ -125,6 +144,23 @@ * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}. */ public void removeAllIndexEntries() { - super.removeAllIndexEntries(); + if (this.index != null) + this.index.remove(getContainerRelativePath()); + } + + /** + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + */ + public void setIndex(Index indexToSet) { + this.index = indexToSet; + } + + /** + * @nooverride This method is not intended to be re-implemented or extended by clients. + * @noreference This method is not intended to be referenced by clients. + */ + public void setParser(SourceElementParser sourceElementParser) { + this.parser = sourceElementParser; } } Index: search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java,v retrieving revision 1.44 diff -u -r1.44 SourceIndexer.java --- search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java 27 Jun 2008 16:03:49 -0000 1.44 +++ search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java 17 Sep 2008 17:08:46 -0000 @@ -44,7 +44,7 @@ // Create a new Parser SourceIndexerRequestor requestor = new SourceIndexerRequestor(this); String documentPath = this.document.getPath(); - SourceElementParser parser = ((InternalSearchDocument) this.document).parser; + SourceElementParser parser = this.document.getParser(); if (parser == null) { IPath path = new Path(documentPath); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); Index: search/org/eclipse/jdt/internal/core/search/indexing/InternalSearchDocument.java =================================================================== RCS file: search/org/eclipse/jdt/internal/core/search/indexing/InternalSearchDocument.java diff -N search/org/eclipse/jdt/internal/core/search/indexing/InternalSearchDocument.java --- search/org/eclipse/jdt/internal/core/search/indexing/InternalSearchDocument.java 27 Jun 2008 16:03:49 -0000 1.12 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.indexing; - -import org.eclipse.jdt.internal.compiler.SourceElementParser; -import org.eclipse.jdt.internal.core.index.Index; - -/** - * Internal search document implementation - */ -public class InternalSearchDocument { - Index index; - private String containerRelativePath; - SourceElementParser parser; - /* - * Hidden by API SearchDocument subclass - */ - public void addIndexEntry(char[] category, char[] key) { - if (this.index != null) - this.index.addIndexEntry(category, key, getContainerRelativePath()); - } - private String getContainerRelativePath() { - if (this.containerRelativePath == null) - this.containerRelativePath = this.index.containerRelativePath(getPath()); - return this.containerRelativePath; - } - /* - * Hidden by API SearchDocument subclass - */ - public void removeAllIndexEntries() { - if (this.index != null) - this.index.remove(getContainerRelativePath()); - } - /* - * Hidden by API SearchDocument subclass - */ - public String getPath() { - return null; // implemented by subclass - } -} Index: search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java,v retrieving revision 1.160 diff -u -r1.160 IndexManager.java --- search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 8 Sep 2008 14:33:20 -0000 1.160 +++ search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java 17 Sep 2008 17:08:46 -0000 @@ -98,7 +98,7 @@ if (JavaCore.getPlugin() == null) return; SearchParticipant participant = SearchEngine.getDefaultSearchParticipant(); SearchDocument document = participant.getDocument(resource.getFullPath().toString()); - ((InternalSearchDocument) document).parser = parser; + document.setParser(parser); IPath indexLocation = computeIndexLocation(containerPath); scheduleDocumentIndexing(document, containerPath, indexLocation, participant); } @@ -355,10 +355,10 @@ } public void indexDocument(SearchDocument searchDocument, SearchParticipant searchParticipant, Index index, IPath indexLocation) { try { - ((InternalSearchDocument) searchDocument).index = index; + searchDocument.setIndex(index); searchParticipant.indexDocument(searchDocument, indexLocation); } finally { - ((InternalSearchDocument) searchDocument).index = null; + searchDocument.setIndex(null); } } /**