View | Details | Raw Unified | Return to bug 247688
Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/SearchDocument.java (-4 / +40 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.search;
11
package org.eclipse.jdt.core.search;
12
12
13
import org.eclipse.jdt.internal.core.search.indexing.InternalSearchDocument;
13
import org.eclipse.jdt.internal.compiler.SourceElementParser;
14
import org.eclipse.jdt.internal.core.index.Index;
14
15
15
/**
16
/**
16
 * A search document encapsulates a content to be either indexed or searched in.
17
 * A search document encapsulates a content to be either indexed or searched in.
Lines 21-27 Link Here
21
 *
22
 *
22
 * @since 3.0
23
 * @since 3.0
23
 */
24
 */
24
public abstract class SearchDocument extends InternalSearchDocument {
25
public abstract class SearchDocument {
26
	private Index index;
27
	private String containerRelativePath;
28
	private SourceElementParser parser;
25
	private String documentPath;
29
	private String documentPath;
26
	private SearchParticipant participant;
30
	private SearchParticipant participant;
27
31
Lines 47-53 Link Here
47
	 * @param key the key of the index entry
51
	 * @param key the key of the index entry
48
	 */
52
	 */
49
	public void addIndexEntry(char[] category, char[] key) {
53
	public void addIndexEntry(char[] category, char[] key) {
50
		super.addIndexEntry(category, key);
54
		if (this.index != null)
55
			this.index.addIndexEntry(category, key, getContainerRelativePath());
51
	}
56
	}
52
57
53
	/**
58
	/**
Lines 88-93 Link Here
88
	 */
93
	 */
89
	public abstract char[] getCharContents();
94
	public abstract char[] getCharContents();
90
95
96
	private String getContainerRelativePath() {
97
		if (this.containerRelativePath == null)
98
			this.containerRelativePath = this.index.containerRelativePath(getPath());
99
		return this.containerRelativePath;
100
	}
101
91
	/**
102
	/**
92
	 * Returns the encoding for this document.
103
	 * Returns the encoding for this document.
93
	 * <p>
104
	 * <p>
Lines 100-105 Link Here
100
	public abstract String getEncoding();
111
	public abstract String getEncoding();
101
112
102
	/**
113
	/**
114
	 * @nooverride This method is not intended to be re-implemented or extended by clients.
115
	 * @noreference This method is not intended to be referenced by clients.
116
	 */
117
	public SourceElementParser getParser() {
118
		return this.parser;
119
	}
120
	
121
	/**
103
	 * Returns the participant that created this document.
122
	 * Returns the participant that created this document.
104
	 *
123
	 *
105
	 * @return the participant that created this document
124
	 * @return the participant that created this document
Lines 125-130 Link Here
125
	 * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
144
	 * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
126
	 */
145
	 */
127
	public void removeAllIndexEntries() {
146
	public void removeAllIndexEntries() {
128
		super.removeAllIndexEntries();
147
		if (this.index != null)
148
			this.index.remove(getContainerRelativePath());
149
	}
150
	
151
	/**
152
	 * @nooverride This method is not intended to be re-implemented or extended by clients.
153
	 * @noreference This method is not intended to be referenced by clients.
154
	 */
155
	public void setIndex(Index indexToSet) {
156
		this.index = indexToSet;
157
	}
158
	
159
	/**
160
	 * @nooverride This method is not intended to be re-implemented or extended by clients.
161
	 * @noreference This method is not intended to be referenced by clients.
162
	 */
163
	public void setParser(SourceElementParser sourceElementParser) {
164
		this.parser = sourceElementParser;
129
	}
165
	}
130
}
166
}
(-)search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java (-1 / +1 lines)
Lines 44-50 Link Here
44
		// Create a new Parser
44
		// Create a new Parser
45
		SourceIndexerRequestor requestor = new SourceIndexerRequestor(this);
45
		SourceIndexerRequestor requestor = new SourceIndexerRequestor(this);
46
		String documentPath = this.document.getPath();
46
		String documentPath = this.document.getPath();
47
		SourceElementParser parser = ((InternalSearchDocument) this.document).parser;
47
		SourceElementParser parser = this.document.getParser();
48
		if (parser == null) {
48
		if (parser == null) {
49
			IPath path = new Path(documentPath);
49
			IPath path = new Path(documentPath);
50
			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
50
			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
(-)search/org/eclipse/jdt/internal/core/search/indexing/InternalSearchDocument.java (-48 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core.search.indexing;
12
13
import org.eclipse.jdt.internal.compiler.SourceElementParser;
14
import org.eclipse.jdt.internal.core.index.Index;
15
16
/**
17
 * Internal search document implementation
18
 */
19
public class InternalSearchDocument {
20
	Index index;
21
	private String containerRelativePath;
22
	SourceElementParser parser;
23
	/*
24
	 * Hidden by API SearchDocument subclass
25
	 */
26
	public void addIndexEntry(char[] category, char[] key) {
27
		if (this.index != null)
28
			this.index.addIndexEntry(category, key, getContainerRelativePath());
29
	}
30
	private String getContainerRelativePath() {
31
		if (this.containerRelativePath == null)
32
			this.containerRelativePath = this.index.containerRelativePath(getPath());
33
		return this.containerRelativePath;
34
	}
35
	/*
36
	 * Hidden by API SearchDocument subclass
37
	 */
38
	public void removeAllIndexEntries() {
39
		if (this.index != null)
40
			this.index.remove(getContainerRelativePath());
41
	}
42
	/*
43
	 * Hidden by API SearchDocument subclass
44
	 */
45
	public String getPath() {
46
		return null; // implemented by subclass
47
	}
48
}
(-)search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java (-3 / +3 lines)
Lines 98-104 Link Here
98
	if (JavaCore.getPlugin() == null) return;
98
	if (JavaCore.getPlugin() == null) return;
99
	SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
99
	SearchParticipant participant = SearchEngine.getDefaultSearchParticipant();
100
	SearchDocument document = participant.getDocument(resource.getFullPath().toString());
100
	SearchDocument document = participant.getDocument(resource.getFullPath().toString());
101
	((InternalSearchDocument) document).parser = parser;
101
	document.setParser(parser);
102
	IPath indexLocation = computeIndexLocation(containerPath);
102
	IPath indexLocation = computeIndexLocation(containerPath);
103
	scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
103
	scheduleDocumentIndexing(document, containerPath, indexLocation, participant);
104
}
104
}
Lines 355-364 Link Here
355
}
355
}
356
public void indexDocument(SearchDocument searchDocument, SearchParticipant searchParticipant, Index index, IPath indexLocation) {
356
public void indexDocument(SearchDocument searchDocument, SearchParticipant searchParticipant, Index index, IPath indexLocation) {
357
	try {
357
	try {
358
		((InternalSearchDocument) searchDocument).index = index;
358
		searchDocument.setIndex(index);
359
		searchParticipant.indexDocument(searchDocument, indexLocation);
359
		searchParticipant.indexDocument(searchDocument, indexLocation);
360
	} finally {
360
	} finally {
361
		((InternalSearchDocument) searchDocument).index = null;
361
		searchDocument.setIndex(null);
362
	}
362
	}
363
}
363
}
364
/**
364
/**

Return to bug 247688