diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java index a495b3139dc..621fac82895 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java @@ -34,7 +34,6 @@ import org.eclipse.cdt.core.search.SearchEngine; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.internal.core.browser.cache.TypeCacheManager; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer; import org.eclipse.cdt.internal.core.search.PathCollector; import org.eclipse.cdt.internal.core.search.PatternSearchJob; @@ -60,7 +59,6 @@ import org.eclipse.core.runtime.Platform; */ public class DependencyTests extends TestCase implements IIndexChangeListener { IFile file; - IFileDocument fileDoc; IProject testProject; NullProgressMonitor monitor; IndexManager indexManager; @@ -735,7 +733,6 @@ import org.eclipse.core.runtime.Platform; CTestPlugin.getDefault().getFileInPlugin(new Path(resourceLocation))), false, monitor); } - fileDoc = new IFileDocument(file); waitForIndex(10); // only wait 20 seconds max. return file; } diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java index d9e63926c52..b900dedc339 100644 --- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java +++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/SourceIndexerTests.java @@ -32,8 +32,6 @@ import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IQueryResult; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; -import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer; import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants; import org.eclipse.cdt.internal.core.search.indexing.IndexManager; @@ -51,7 +49,6 @@ import org.eclipse.core.runtime.Path; */ public class SourceIndexerTests extends TestCase implements IIndexChangeListener { IFile file; - IFileDocument fileDoc; IProject testProject; NullProgressMonitor monitor; IndexManager indexManager; @@ -186,7 +183,6 @@ public class SourceIndexerTests extends TestCase implements IIndexChangeListener CTestPlugin.getDefault().getFileInPlugin(new Path(resourceLocation))), false, monitor); } - fileDoc = new IFileDocument(file); waitForIndex(20); // only wait 20 seconds max. return file; } diff --git a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java index 0d78403cf45..96ebdf31cdb 100644 --- a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java +++ b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/DependencyQueryJob.java @@ -1,6 +1,14 @@ -/* - * Created on Jul 23, 2003 - */ +/******************************************************************************* + * Copyright (c) 2003, 2005 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + package org.eclipse.cdt.internal.core.sourcedependency; import java.io.IOException; @@ -8,16 +16,12 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.index.IIndexStorage; import org.eclipse.cdt.core.search.SearchEngine; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.impl.BlocksIndexInput; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.impl.IncludeEntry; import org.eclipse.cdt.internal.core.index.impl.IndexInput; import org.eclipse.cdt.internal.core.index.impl.IndexedFile; -import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer; import org.eclipse.cdt.internal.core.search.IndexSelector; import org.eclipse.cdt.internal.core.search.indexing.IndexManager; @@ -114,11 +118,6 @@ public class DependencyQueryJob implements IIndexJob { if (progressMonitor != null && progressMonitor.isCanceled()) throw new OperationCanceledException(); - -// IIndex inMemIndex = indexManager.peekAtIndex(new Path(((Index)index).toString.substring("Index for ".length()).replace('\\','/'))); -// if (inMemIndex != index) { -// System.out.println("SANITY CHECK: search job using obsolete index: ["+index+ "] instead of: ["+inMemIndex+"]"); -// } if (index == null) return COMPLETE; @@ -157,14 +156,7 @@ public class DependencyQueryJob implements IIndexJob { } finally { input.close(); } - // - //String[] tempFiles = this.indexManager.getFileDependencies(project,file); -// if (tempFiles != null){ -// System.out.println("DQJOB File Deps : " + tempFiles.length); -// for (int i=0; iIDocument represent a data source, e.g. a File (FileDocument), - * an IFile (IFileDocument), - * or other kinds of data sources (URL, ...). An IIndexer indexes anIDocument. - */ - -public interface IDocument { - /** - * Returns the content of the document, in a byte array. - */ - byte[] getByteContent() throws IOException; - /** - * Returns the content of the document, in a char array. - */ - char[] getCharContent() throws IOException; - /** - * Returns the encoding for this document - */ - String getEncoding(); - /** - * returns the name of the document (e.g. its path for a File, or its relative path - * in the workbench for an IFile). - */ - String getName(); - /** - * Returns the content of the document, as a String. - */ - public String getStringContent() throws IOException; - /** - * Returns the type of the document. - */ - String getType(); -} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java index 7f0d72d23eb..396d81291b5 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IEntryResult.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -9,10 +9,19 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; - +/** + * IEntryResult is the interface used to represent individual index + * entries for the purpose of client queries. + */ public interface IEntryResult { - public int[] getIndexFlags(); + /** + * Returns the unique file numbers of files that have a + * reference to this entry. + */ public int[] getFileReferences(); + /** + * Returns the encoded word of this entry + */ public char[] getWord(); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java index 583c32cd1b8..3d418481419 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -23,9 +23,9 @@ import org.eclipse.core.runtime.IPath; public interface IIndex { /** - * Adds the given document to the index. + * Adds the given file to the index. */ - void add(IDocument document, IIndexer indexer) throws IOException; + void add(IFile file, IIndexer indexer) throws IOException; /** * Empties the index. */ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexer.java index 2c7f2c6e8fe..c77a4cee1bd 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -19,13 +19,13 @@ import org.eclipse.core.resources.IFile; */ public interface IIndexer { /** - * Indexes the given document, adding the document name and the word references + * Indexes the given file, adding the file name and the word references * to this document to the given IIndex.The caller should use * shouldIndex() first to determine whether this indexer handles * the given type of file, and only call this method if so. */ - void index(IDocument document, IIndexerOutput output) throws java.io.IOException; + void index(IFile document, IIndexerOutput output) throws java.io.IOException; /** * Returns whether the IIndexer can index the given IFile or not. diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java index 0157dc05f60..253ea5af626 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/IIndexerOutput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -18,14 +18,13 @@ import org.eclipse.cdt.internal.core.index.impl.IndexedFile; */ public interface IIndexerOutput { - public void addDocument(IDocument document); - public void addRef(char[] word, int indexFlags); - public void addRef(String word, int indexFlags); + public void addRef(int indexedFileNumber, char[] word); + public void addRef(int indexedFileNumber, String word); + public IndexedFile getIndexedFile(String path); - public IndexedFile addSecondaryIndexedFile(IDocument document); - public IndexedFile addSecondaryExternalIndexedFile(String path); + public IndexedFile addIndexedFile(String path); //For Dep Tree - public void addIncludeRef(char[] word); - public void addIncludeRef(String word); - public void addRelatives(String inclusion, String parent); + public void addIncludeRef(int indexedFileNumber, char[] word); + public void addIncludeRef(int indexedFileNumber, String word); + public void addRelatives(int indexedFileNumber, String inclusion, String parent); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsAddCompilationUnitToIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsAddCompilationUnitToIndex.java index 36aba18e7bc..36ab494a083 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsAddCompilationUnitToIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsAddCompilationUnitToIndex.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.index.ctagsindexer; import java.io.IOException; import org.eclipse.cdt.internal.core.index.IIndex; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; @@ -28,7 +27,7 @@ public class CTagsAddCompilationUnitToIndex extends CTagsAddFileToIndex { } protected boolean indexDocument(IIndex index) throws IOException { if (!initializeContents()) return false; - index.add(new IFileDocument(resource, this.contents), new CTagsIndexerRunner(resource, indexer)); + index.add(resource, new CTagsIndexerRunner(resource, indexer)); return true; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsConsoleParser.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsConsoleParser.java index 6d2f94869c9..9595188cae4 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsConsoleParser.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsConsoleParser.java @@ -114,13 +114,13 @@ public class CTagsConsoleParser implements IConsoleParser { } if (entryType != null) - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry(fullName,entryType,type), getIndexFlag()); + indexer.getOutput().addRef(getFileNumber(),IndexEncoderUtil.encodeEntry(fullName,entryType,type)); } /** * @return */ - private int getIndexFlag() { + private int getFileNumber() { int fileNum = 0; IndexedFile mainIndexFile = indexer.getOutput().getIndexedFile( indexer.getResourceFile().getFullPath().toString()); diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java index d7e6bec1a94..d1c2aed9ae5 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsFileReader.java @@ -17,12 +17,10 @@ import java.io.IOException; import java.util.List; import org.eclipse.cdt.core.search.ICSearchConstants; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndexer; import org.eclipse.cdt.internal.core.index.IIndexerOutput; import org.eclipse.cdt.internal.core.index.domsourceindexer.IndexEncoderUtil; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.impl.IndexedFile; import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants; import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants; @@ -67,7 +65,7 @@ public class CTagsFileReader { currentFileName = fileName; currentFile = (IFile) project.findMember(fileName); indexer = new MiniIndexer(currentFile); - index.add(new IFileDocument(currentFile),indexer); + index.add(currentFile,indexer); } //encode new tag in current file @@ -129,14 +127,14 @@ public class CTagsFileReader { } if (entryType != null) - output.addRef(IndexEncoderUtil.encodeEntry(fullName,entryType,type), fileNum); + output.addRef(fileNum, IndexEncoderUtil.encodeEntry(fullName,entryType,type)); } /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.index.IIndexer#index(org.eclipse.cdt.internal.core.index.IDocument, org.eclipse.cdt.internal.core.index.IIndexerOutput) */ - public void index(IDocument document, IIndexerOutput output) throws IOException { + public void index(IFile file, IIndexerOutput output) throws IOException { this.output = output; - this.output.addDocument(document); + IndexedFile indFile =output.addIndexedFile(file.getFullPath().toString()); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java index c3f8d2f427a..1e00563f517 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexAll.java @@ -16,18 +16,12 @@ import java.io.IOException; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.internal.core.index.IIndex; -import org.eclipse.cdt.internal.core.index.IQueryResult; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; -import org.eclipse.cdt.internal.core.search.SimpleLookupTable; import org.eclipse.cdt.internal.core.search.indexing.IndexManager; import org.eclipse.cdt.internal.core.search.indexing.ReadWriteMonitor; import org.eclipse.cdt.internal.core.search.processing.JobManager; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceProxy; -import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; @@ -70,46 +64,6 @@ class CTagsIndexAll extends CTagsIndexRequest { monitor.enterRead(); // ask permission to read saveIfNecessary(index, monitor); - IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$ - int max = results == null ? 0 : results.length; - final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11); - final String OK = "OK"; //$NON-NLS-1$ - final String DELETED = "DELETED"; //$NON-NLS-1$ - for (int i = 0; i < max; i++) - indexedFileNames.put(results[i].getPath(), DELETED); - - project.accept( new IResourceProxyVisitor() { - - public boolean visit(IResourceProxy proxy) throws CoreException { - switch(proxy.getType()){ - case IResource.FILE: - IResource resource=proxy.requestResource(); - indexedFileNames.put(resource.getFullPath().toString(), resource); - return false; - } - return true; - }},IResource.NONE); - - - /*Object[] names = indexedFileNames.keyTable; - Object[] values = indexedFileNames.valueTable; - boolean shouldSave = false; - for (int i = 0, length = names.length; i < length; i++) { - String name = (String) names[i]; - if (name != null) { - if (this.isCancelled) return false; - - Object value = values[i]; - if (value != OK) { - shouldSave = true; - if (value == DELETED) - indexer.remove(name, this.indexPath); - else - indexer.addSource((IFile) value, this.indexPath); - } - } - }*/ - //Timing support long startTime=0, cTagsEndTime=0, endTime=0; @@ -142,13 +96,6 @@ class CTagsIndexAll extends CTagsIndexRequest { } } - } catch (CoreException e) { - if (IndexManager.VERBOSE) { - JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ - e.printStackTrace(); - } - indexer.removeIndex(this.indexPath); - return false; } catch (IOException e) { if (IndexManager.VERBOSE) { JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java index 677591bee9d..9348e184864 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexer.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.index.ICDTIndexer; import org.eclipse.cdt.core.index.IIndexStorage; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndexerOutput; import org.eclipse.cdt.internal.core.index.sourceindexer.CIndexStorage; @@ -148,7 +147,7 @@ public class CTagsIndexer extends AbstractCExtension implements ICDTIndexer { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.index.IIndexer#index(org.eclipse.cdt.internal.core.index.IDocument, org.eclipse.cdt.internal.core.index.IIndexerOutput) */ - public void index(IDocument document, IIndexerOutput output) + public void index(IFile document, IIndexerOutput output) throws IOException { // TODO Auto-generated method stub diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexerRunner.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexerRunner.java index 2f0f97dcca9..44ef980a94b 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexerRunner.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexerRunner.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; -import org.eclipse.cdt.internal.core.index.IDocument; +import org.eclipse.cdt.internal.core.index.impl.IndexedFile; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; @@ -50,8 +50,8 @@ public class CTagsIndexerRunner extends AbstractIndexer { /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#indexFile(org.eclipse.cdt.internal.core.index.IDocument) */ - protected void indexFile(IDocument document) throws IOException { - output.addDocument(document); + protected void indexFile(IFile file) throws IOException { + IndexedFile indFile =output.addIndexedFile(file.getFullPath().toString()); String[] args = {"ctags", //$NON-NLS-1$ "--excmd=number", //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java index da755c63f96..001aa017727 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java @@ -145,7 +145,7 @@ public class CGenerateIndexVisitor extends CASTVisitor { * @param indexFlag * @throws DOMException */ - private void processNameBinding(IASTName name, IBinding binding, int indexFlag) throws DOMException { + private void processNameBinding(IASTName name, IBinding binding, int fileNumber) throws DOMException { // determine type EntryType entryType = null; if (binding instanceof ICompositeType) { @@ -180,18 +180,16 @@ public class CGenerateIndexVisitor extends CASTVisitor { if (entryType != null) { if (name.isDeclaration()) { - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry( + indexer.getOutput().addRef(fileNumber,IndexEncoderUtil.encodeEntry( getFullyQualifiedName(name), entryType, - ICSearchConstants.DECLARATIONS), - indexFlag); + ICSearchConstants.DECLARATIONS)); } else if (name.isReference()) { - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry( + indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry( getFullyQualifiedName(name), entryType, - ICSearchConstants.REFERENCES), - indexFlag); + ICSearchConstants.REFERENCES)); } } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java index 60dfb40239a..40ecf139ce1 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java @@ -164,7 +164,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor { * @param limitTo * @throws DOMException */ - private void processNameBinding(IASTName name, IBinding binding, int indexFlag, LimitTo limitTo) throws DOMException { + private void processNameBinding(IASTName name, IBinding binding, int fileNumber, LimitTo limitTo) throws DOMException { // determine LimitTo if (limitTo == null) { if (name.isDeclaration()) { @@ -222,18 +222,17 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor { ICPPDelegate[] delegates = ((ICPPUsingDeclaration)binding).getDelegates(); for (int i = 0; i < delegates.length; i++) { IBinding orig = delegates[i].getBinding(); - processNameBinding(name, orig, indexFlag, ICSearchConstants.REFERENCES); // reference to the original binding - processNameBinding(name, delegates[i], indexFlag, ICSearchConstants.DECLARATIONS); // declaration of the new name + processNameBinding(name, orig, fileNumber, ICSearchConstants.REFERENCES); // reference to the original binding + processNameBinding(name, delegates[i], fileNumber, ICSearchConstants.DECLARATIONS); // declaration of the new name } return; } if (entryType != null && limitTo != null) { - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry( + indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry( getFullyQualifiedName(binding), entryType, - limitTo), - indexFlag); + limitTo)); } // add base classes and friends @@ -247,11 +246,10 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor { for (int i = 0; i < baseClauses.length; ++i) { if (!(baseClauses[i] instanceof CPPBaseProblem)) { ICompositeType baseClass = (ICompositeType) ((ICPPBase)baseClauses[i]).getBaseClass(); - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry( + indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry( getFullyQualifiedName(baseClass), IIndexEncodingConstants.DERIVED, - ICSearchConstants.DECLARATIONS), - indexFlag); + ICSearchConstants.DECLARATIONS)); } } //Get friends @@ -259,11 +257,10 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor { for (int i = 0; i < friendClauses.length; ++i) { IBinding friendClause = friendClauses[i]; if (friendClause instanceof ICompositeType) { - indexer.getOutput().addRef(IndexEncoderUtil.encodeEntry( + indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry( getFullyQualifiedName(friendClause), IIndexEncodingConstants.FRIEND, - ICSearchConstants.DECLARATIONS), - indexFlag); + ICSearchConstants.DECLARATIONS)); } } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddCompilationUnitToIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddCompilationUnitToIndex.java index f8fb70aaca0..b34d50af28d 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddCompilationUnitToIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMAddCompilationUnitToIndex.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.index.domsourceindexer; import java.io.IOException; import org.eclipse.cdt.internal.core.index.IIndex; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.sourceindexer.AddCompilationUnitToIndex; import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer; import org.eclipse.core.resources.IFile; @@ -31,7 +30,7 @@ public class DOMAddCompilationUnitToIndex extends AddCompilationUnitToIndex { */ protected boolean indexDocument(IIndex index) throws IOException { if (!initializeContents()) return false; - index.add(new IFileDocument(resource, contents), new DOMSourceIndexerRunner(resource, indexer)); + index.add(resource, new DOMSourceIndexerRunner(resource, indexer)); return true; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java index 32180ca3d91..bf6f96f123a 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java @@ -1,5 +1,5 @@ /*********************************************************************** - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2005 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 @@ -30,7 +30,7 @@ import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.parser.ParseError; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.search.ICSearchConstants; -import org.eclipse.cdt.internal.core.index.IDocument; +import org.eclipse.cdt.internal.core.index.impl.IndexedFile; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer; import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants; @@ -65,9 +65,10 @@ public class DOMSourceIndexerRunner extends AbstractIndexer { } - protected void indexFile(IDocument document) throws IOException { + protected void indexFile(IFile file) throws IOException { // Add the name of the file to the index - output.addDocument(document); + IndexedFile indFile =output.addIndexedFile(file.getFullPath().toString()); + int problems = indexer.indexProblemsEnabled(resourceFile.getProject()); setProblemMarkersEnabled(problems); requestRemoveMarkers(resourceFile, null); @@ -165,13 +166,12 @@ public class DOMSourceIndexerRunner extends AbstractIndexer { // } // } // } - int indexFlag = getOutput().getIndexedFile( + int fileNumber = getOutput().getIndexedFile( getResourceFile().getFullPath().toString()).getFileNumber(); - getOutput().addRef(IndexEncoderUtil.encodeEntry( + getOutput().addRef(fileNumber,IndexEncoderUtil.encodeEntry( new char[][] {include.toCharArray()}, IIndexEncodingConstants.INCLUDE, - ICSearchConstants.REFERENCES), - indexFlag); + ICSearchConstants.REFERENCES)); /* See if this file has been encountered before */ indexer.haveEncounteredHeader(resourceProject.getFullPath(),new Path(include)); @@ -184,12 +184,11 @@ public class DOMSourceIndexerRunner extends AbstractIndexer { private void processMacroDefinitions(IASTPreprocessorMacroDefinition[] macroDefinitions) { for (int i = 0; i < macroDefinitions.length; i++) { IASTName macro = macroDefinitions[i].getName(); - int indexFlag = IndexEncoderUtil.calculateIndexFlags(this, macro); - getOutput().addRef(IndexEncoderUtil.encodeEntry( + int fileNumber = IndexEncoderUtil.calculateIndexFlags(this, macro); + getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry( new char[][] {macro.toCharArray()}, IIndexEncodingConstants.MACRO, - ICSearchConstants.DECLARATIONS), - indexFlag); + ICSearchConstants.DECLARATIONS)); } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java index 97aae24f068..b781f10aef9 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java @@ -1,5 +1,5 @@ /*********************************************************************** - * Copyright (c) 2004 IBM Corporation and others. + * Copyright (c) 2005 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 @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.search.ICSearchConstants; import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo; -import org.eclipse.cdt.internal.core.index.impl.IFileDocument; import org.eclipse.cdt.internal.core.index.impl.IndexedFile; import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer; import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants; @@ -111,12 +110,12 @@ public class IndexEncoderUtil { else { //Need to add file to index if (tempFile != null){ - indFile = indexer.getOutput().addSecondaryIndexedFile(new IFileDocument(tempFile)); + indFile = indexer.getOutput().addIndexedFile(tempFile.getFullPath().toString()); if (indFile != null) fileNum = indFile.getFileNumber(); } else { - indFile = indexer.getOutput().addSecondaryExternalIndexedFile(fileName); + indFile = indexer.getOutput().addIndexedFile(fileName); if (indFile != null) fileNum = indFile.getFileNumber(); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java index 6cdfc110b63..09c89d7adcd 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/BlocksIndexInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -17,10 +17,10 @@ import java.util.ArrayList; import org.eclipse.cdt.internal.core.CharOperation; import org.eclipse.cdt.internal.core.Util; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IQueryResult; import org.eclipse.cdt.internal.core.util.LRUCache; +import org.eclipse.jface.text.IDocument; /** * This input is used for reading indexes saved using a BlocksIndexOutput. @@ -122,13 +122,12 @@ public class BlocksIndexInput extends IndexInput { /** * @see IndexInput#getIndexedFile(IDocument) */ - public IndexedFile getIndexedFile(IDocument document) throws java.io.IOException { + public IndexedFile getIndexedFile(String fullPath) throws java.io.IOException { setFirstFile(); - String name= document.getName(); while (hasMoreFiles()) { IndexedFile file= getCurrentFile(); String path= file.getPath(); - if (path.equals(name)) + if (path.equals(fullPath)) return file; moveToNextFile(); } @@ -245,7 +244,7 @@ public class BlocksIndexInput extends IndexInput { case -1 : WordEntry entry = getEntry(pattern); if (entry == null) return null; - return new IEntryResult[]{ new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags()) }; + return new IEntryResult[]{ new EntryResult(entry.getWord(), entry.getRefs()) }; case 0 : blockNums = summary.getAllBlockNums(); break; @@ -267,7 +266,7 @@ public class BlocksIndexInput extends IndexInput { if (count == entries.length){ System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count); } - entries[count++] = new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags()); + entries[count++] = new EntryResult(entry.getWord(), entry.getRefs()); found = true; } else { if (found) break; @@ -297,7 +296,7 @@ public class BlocksIndexInput extends IndexInput { if (count == entries.length){ System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count); } - entries[count++] = new EntryResult(entry.getWord(), entry.getRefs(), entry.getRefsIndexFlags()); + entries[count++] = new EntryResult(entry.getWord(), entry.getRefs()); found = true; } else { if (found) break; diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java index 15ceaf4a55e..236dd90fd0f 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/EntryResult.java @@ -17,12 +17,10 @@ import org.eclipse.cdt.internal.core.index.IEntryResult; public class EntryResult implements IEntryResult { private char[] word; private int[] fileRefs; - private int[] indexFlags; -public EntryResult(char[] word, int[] refs, int[] indexFlags) { +public EntryResult(char[] word, int[] refs) { this.word = word; this.fileRefs = refs; - this.indexFlags = indexFlags; } public boolean equals(Object anObject){ @@ -39,13 +37,6 @@ public boolean equals(Object anObject){ for (int i = 0; i < length; i++){ if (refs[i] != otherRefs[i]) return false; } - - int[] indexRefs, indexOtherRefs; - if ((length = (indexRefs = this.indexFlags).length) != (indexOtherRefs = anEntryResult.indexFlags).length) return false; - for (int i = 0; i < length; i++){ - if (indexRefs[i] != indexOtherRefs[i]) return false; - } - return true; } return false; @@ -74,8 +65,5 @@ public String toString(){ return buffer.toString(); } -public int[] getIndexFlags() { - return indexFlags; -} } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java index 820c65e0c69..5663fdfa3f6 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/GammaCompressedIndexBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -144,7 +144,7 @@ public class GammaCompressedIndexBlock extends IndexBlock { int ref= prevRef + readCodeStream.readGamma(); if (ref < prevRef) throw new InternalError(); - entry.addRef(ref,0); + entry.addRef(ref); prevRef= ref; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IFileDocument.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IFileDocument.java deleted file mode 100644 index 9ac1afee68f..00000000000 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IFileDocument.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.index.impl; - -import java.io.IOException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.cdt.internal.core.CharOperation; - - -/** - * An IFileDocument represents an IFile. - */ - -public class IFileDocument extends PropertyDocument { - protected IFile file; - - // cached contents if needed - only one of them is used at a time - protected char[] charContents; - protected byte[] byteContents; - /** - * IFileDocument constructor comment. - */ - public IFileDocument(IFile file) { - this(file, (char[])null); - } - /** - * IFileDocument constructor comment. - */ - public IFileDocument(IFile file, byte[] byteContents) { - this.file= file; - this.byteContents= byteContents; - } - /** - * IFileDocument constructor comment. - */ - public IFileDocument(IFile file, char[] charContents) { - this.file= file; - this.charContents= charContents; - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getByteContent() - */ - public byte[] getByteContent() throws IOException { - if (byteContents != null) return byteContents; - IPath location = file.getLocation(); - if (location == null) return new byte[0]; - return byteContents = org.eclipse.cdt.internal.core.Util.getFileByteContent(location.toFile()); - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getCharContent() - */ - public char[] getCharContent() throws IOException { - if (charContents != null) return charContents; - IPath location = file.getLocation(); - if (location == null) return CharOperation.NO_CHAR; - return charContents = org.eclipse.cdt.internal.core.Util.getFileCharContent( - location.toFile(), - getEncoding()); - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getEncoding() - */ - public String getEncoding() { - //TODO: Indexer - get encoding - return null; - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getName() - */ - public String getName() { - return file.getFullPath().toString(); - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getStringContent() - */ - public String getStringContent() throws java.io.IOException { - return new String(getCharContent()); - } - /** - * @see org.eclipse.jdt.internal.core.index.IDocument#getType() - */ - public String getType() { - String extension= file.getFileExtension(); - if (extension == null) - return ""; //$NON-NLS-1$ - return extension; - } -} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java index ca81de5a211..75d2af87a3b 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/InMemoryIndex.java @@ -13,7 +13,7 @@ package org.eclipse.cdt.internal.core.index.impl; import java.io.File; import java.io.IOException; -import org.eclipse.cdt.internal.core.index.IDocument; +import org.eclipse.cdt.internal.core.index.IIndex; /** * This index stores the document names in an ObjectVector, and the words in @@ -49,15 +49,8 @@ public class InMemoryIndex { includes= new IncludeEntryHashedArray(501); init(); } - - public IndexedFile addDocument(IDocument document) { - IndexedFile indexedFile= this.files.add(document); - this.footprint += indexedFile.footprint() + 4; - this.sortedFiles = null; - return indexedFile; - } - public IndexedFile addExternalFilePath(String path){ + public IndexedFile addFile(String path){ IndexedFile indexedFile = this.files.add(path); this.footprint += indexedFile.footprint() + 4; this.sortedFiles = null; @@ -104,12 +97,12 @@ public class InMemoryIndex { /** * Adds the references of the word to the index (reference = number of the file the word belongs to). */ - protected void addRef(char[] word, int[] references, int[] indexFlags) { + protected void addRef(char[] word, int[] references) { int size= references.length; int i= 0; while (i < size) { if (references[i] != 0) - addRef(word, references[i], indexFlags[i]); + addRef(word, references[i]); i++; } } @@ -118,31 +111,29 @@ public class InMemoryIndex { * If the word does not exist, it adds it in the index. * @param indexFlags */ - protected void addRef(char[] word, int fileNum, int indexFlags) { + protected void addRef(char[] word, int fileNum) { WordEntry entry= this.words.get(word); if (entry == null) { entry= new WordEntry(word); - //entry.addRef(fileNum, indexFlags); - entry.addRef(indexFlags, indexFlags); + entry.addRef(fileNum); this.words.add(entry); this.sortedWordEntries= null; this.footprint += entry.footprint(); } else { - //this.footprint += entry.addRef(fileNum, indexFlags); - this.footprint += entry.addRef(indexFlags, indexFlags); + this.footprint += entry.addRef(fileNum); } } - public void addRef(IndexedFile indexedFile, char[] word, int indexFlags) { - addRef(word, indexedFile.getFileNumber(), indexFlags); + public void addRef(IndexedFile indexedFile, char[] word) { + addRef(word, indexedFile.getFileNumber()); } - public void addRef(IndexedFile indexedFile, String word, int indexFlags) { - addRef(word.toCharArray(), indexedFile.getFileNumber(), indexFlags); + public void addRef(IndexedFile indexedFile, String word) { + addRef(word.toCharArray(), indexedFile.getFileNumber()); } - public void addRelatives(IndexedFile indexedFile, String inclusion, String parent) { - addRelatives(indexedFile.getFileNumber(),inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null); + public void addRelatives(int fileNumber, String inclusion, String parent) { + addRelatives(fileNumber,inclusion.toCharArray(),(parent != null ) ? parent.toCharArray() : null); } protected void addRelatives(int fileNumber, char[] inclusion, char[] parent) { diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java index e2f369a25f4..9cfd5c9caaa 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Index.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -20,7 +20,6 @@ import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.ICDTIndexer; import org.eclipse.cdt.core.index.IIndexDelta; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IIndex; import org.eclipse.cdt.internal.core.index.IIndexer; @@ -90,16 +89,16 @@ public class Index implements IIndex { * If the document already exists in the index, it overrides the previous one. The changes will be * taken into account after a merge. */ - public void add(IDocument document, IIndexer indexer) throws IOException { + public void add(IFile file, IIndexer indexer) throws IOException { if (timeToMerge()) { merge(); } - IndexedFile indexedFile= addsIndex.getIndexedFile(document.getName()); + IndexedFile indexedFile= addsIndex.getIndexedFile(file.getFullPath().toString()); if (indexedFile != null /*&& removedInAdds.get(document.getName()) == null*/ ) remove(indexedFile, MergeFactory.ADDS_INDEX); IndexerOutput output= new IndexerOutput(addsIndex); - indexer.index(document, output); + indexer.index(file, output); state= CAN_MERGE; } /** @@ -360,9 +359,8 @@ public class Index implements IIndex { int fileNum=0; List tempFileReturn = new ArrayList(); try { - IDocument temp = new IFileDocument(file); input.open(); - IndexedFile inFile = input.getIndexedFile(temp); + IndexedFile inFile = input.getIndexedFile(file.getFullPath().toString()); fileNum =inFile.getFileNumber(); IncludeEntry[] tempEntries = input.queryIncludeEntries(fileNum); diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java index 61e368c58a1..9c4e3407ee7 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.index.impl; import java.io.IOException; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IQueryResult; @@ -79,11 +78,11 @@ public abstract class IndexInput { */ public abstract IndexedFile getIndexedFile(int fileNum) throws IOException; /** - * Returns the indexedFile corresponding to the given document in the index the input + * Returns the indexedFile corresponding to the given file path in the index the input * reads in (e.g. the indexedFile with the same path in this index), or null if such * indexedFile does not exist. */ - public abstract IndexedFile getIndexedFile(IDocument document) throws IOException; + public abstract IndexedFile getIndexedFile(String fullpath) throws IOException; /** * Returns the number of files in the index. */ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFile.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFile.java index 8f0e1b2a100..8243d8163ee 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFile.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFile.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.index.impl; import org.eclipse.cdt.internal.core.index.IQueryResult; -import org.eclipse.cdt.internal.core.index.IDocument; /** * An indexedFile associates a number to a document path, and document properties. @@ -28,12 +27,7 @@ public class IndexedFile implements IQueryResult { this.fileNumber= fileNum; this.path= path; } - public IndexedFile(IDocument document, int fileNum) { - if (fileNum < 1) - throw new IllegalArgumentException(); - this.path= document.getName(); - this.fileNumber= fileNum; - } + /** * Returns the size of the indexedFile. */ diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java index 024cc42da0c..ff8da7094d5 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexedFileHashedArray.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.core.index.impl; import java.util.ArrayList; -import org.eclipse.cdt.internal.core.index.IDocument; - public final class IndexedFileHashedArray { private IndexedFile elements[]; @@ -31,10 +29,6 @@ public IndexedFileHashedArray(int size) { this.replacedElements = null; } -public IndexedFile add(IDocument document) { - return add(new IndexedFile(document, ++lastId)); -} - public IndexedFile add(String path){ return add(new IndexedFile(path, ++lastId)); } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java index d50be9d3802..dc00f462def 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/IndexerOutput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -10,20 +10,15 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.index.impl; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IIndexerOutput; /** - * An indexerOutput is used by an indexer to add documents and word references to - * an inMemoryIndex. It keeps track of the document being indexed and add the - * word references to this document (so you do not need to precise the document - * each time you add a word). + * An indexerOutput is used by an indexer to add files and word references to + * an inMemoryIndex. */ public class IndexerOutput implements IIndexerOutput { protected InMemoryIndex index; - protected IndexedFile indexedFile; - protected IDocument document; /** * IndexerOutput constructor comment. */ @@ -31,47 +26,37 @@ public class IndexerOutput implements IIndexerOutput { this.index= index; } /** - * Adds the given document to the inMemoryIndex. + * Adds a reference to the given word to the inMemoryIndex. */ - public void addDocument(IDocument document) { - if (indexedFile == null) { - indexedFile= index.addDocument(document); - } else { + public void addRef(int indexedFileNumber, char[] word) { + if (indexedFileNumber == 0) { throw new IllegalStateException(); } + index.addRef(word, indexedFileNumber); } /** * Adds a reference to the given word to the inMemoryIndex. */ - public void addRef(char[] word, int indexFlags) { - if (indexedFile == null) { - throw new IllegalStateException(); - } - index.addRef(indexedFile, word, indexFlags); - } - /** - * Adds a reference to the given word to the inMemoryIndex. - */ - public void addRef(String word, int indexFlags) { - addRef(word.toCharArray(), indexFlags); + public void addRef(int indexedFileNumber, String word) { + addRef(indexedFileNumber, word.toCharArray()); } - public void addRelatives(String inclusion, String parent) { - if (indexedFile == null) { - throw new IllegalStateException(); - } - index.addRelatives(indexedFile, inclusion, parent); - } - - public void addIncludeRef(char[] word) { - if (indexedFile == null) { + public void addRelatives(int indexedFileNumber, String inclusion, String parent) { + if (indexedFileNumber == 0) { throw new IllegalStateException(); } - index.addIncludeRef(indexedFile, word); + index.addRelatives(indexedFileNumber, inclusion, parent); } - public void addIncludeRef(String word) { - addIncludeRef(word.toCharArray()); + public void addIncludeRef(int indexedFileNumber, char[] word) { + if (indexedFileNumber == 0) { + throw new IllegalStateException(); + } + index.addIncludeRef(word, indexedFileNumber); + } + + public void addIncludeRef(int indexedFileNumber, String word) { + addIncludeRef(indexedFileNumber, word.toCharArray()); } public IndexedFile getIndexedFile(String path) { @@ -79,21 +64,11 @@ public class IndexerOutput implements IIndexerOutput { } /** - * Adds a file to the InMemoryIndex but does not supplant the current - * file being indexed. This method is to be used if the current file being indexed - * needs to make reference to a file that has not been added to the index as of yet. + * Adds the file path to the index, creating a new file entry + * for it */ - public IndexedFile addSecondaryIndexedFile(IDocument document) { - return index.addDocument(document); - } - - /** - * Adds a file to the InMemoryIndex but does not supplant the current - * file being indexed. This method is to be used if the current file being indexed - * needs to make reference to an external file that has not been added to the index as of yet. - */ - public IndexedFile addSecondaryExternalIndexedFile(String path) { - return index.addExternalFilePath(path); + public IndexedFile addIndexedFile(String path) { + return index.addFile(path); } } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java index 8f182db6ac8..d4454731dd1 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/MergeFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -213,7 +213,7 @@ public class MergeFactory { word2.catRefs(word2); word1.mapRefs(mappingOld); word2.mapRefs(mappingAdds); - word1.addRefs(word2.getRefs(),word2.getRefsIndexFlags()); + word1.addRefs(word2.getRefs()); mergeOutput.addWord(word1); addsInput.moveToNextWordEntry(); oldInput.moveToNextWordEntry(); diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/PropertyDocument.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/PropertyDocument.java deleted file mode 100644 index c959426ad72..00000000000 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/PropertyDocument.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.index.impl; - -import java.util.Enumeration; -import java.util.Hashtable; - -import org.eclipse.cdt.internal.core.index.IDocument; - -/** - * The properties of a document are stored into a hashtable. - * @see IDocument - */ - -public abstract class PropertyDocument implements IDocument { - protected Hashtable properties; - public PropertyDocument() { - properties= new Hashtable(5); - } - /** - * @see IDocument#getProperty - */ - public String getProperty(String property) { - return (String) properties.get(property); - } - /** - * @see IDocument#getPropertyNames - */ - - public Enumeration getPropertyNames() { - return properties.keys(); - } - /** - * @see IDocument#setProperty - */ - - public void setProperty(String property, String value) { - properties.put(property, value); - } -} diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java index 1129839ea45..636a5e35c3c 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/SimpleIndexInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.index.impl; import java.io.IOException; import java.util.ArrayList; -import org.eclipse.cdt.internal.core.index.IDocument; import org.eclipse.cdt.internal.core.index.IEntryResult; import org.eclipse.cdt.internal.core.index.IQueryResult; +import org.eclipse.jface.text.IDocument; /** * A simpleIndexInput is an input on an in memory Index. @@ -63,11 +63,10 @@ public class SimpleIndexInput extends IndexInput { /** * @see IndexInput#getIndexedFile(IDocument) */ - public IndexedFile getIndexedFile(IDocument document) throws IOException { - String name= document.getName(); + public IndexedFile getIndexedFile(String fullPath) throws IOException { for (int i= index.getNumFiles(); i >= 1; i--) { IndexedFile file= getIndexedFile(i); - if (name.equals(file.getPath())) + if (fullPath.equals(file.getPath())) return file; } return null; diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java index 76cfb43cf40..6abcd24cc7b 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/Util.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -91,14 +91,7 @@ public class Util { quickSort(list, left, original_right); } } - private static void quickSort(int[] list, int left, int right, int[] dependentList) { - - //If we are sorting 2 arrays, make sure that they are the same length - if (dependentList != null){ - if (list.length != dependentList.length) - return; - } - + private static void quickSort(int[] list, int left, int right) { int original_left= left; int original_right= right; int mid= list[(left + right) / 2]; @@ -113,22 +106,15 @@ public class Util { int tmp= list[left]; list[left]= list[right]; list[right]= tmp; - - if (dependentList != null){ - int depTmp = dependentList[left]; - dependentList[left]=dependentList[right]; - dependentList[right]=depTmp; - } - left++; right--; } } while (left <= right); if (original_left < right) { - quickSort(list, original_left, right, dependentList); + quickSort(list, original_left, right); } if (left < original_right) { - quickSort(list, left, original_right, dependentList); + quickSort(list, left, original_right); } } private static void quickSort(String[] list, int left, int right) { @@ -317,11 +303,7 @@ public class Util { } public static void sort(int[] list) { if (list.length > 1) - quickSort(list, 0, list.length - 1, null); - } - public static void sort(int[] list, int[] dependentList) { - if (list.length > 1) - quickSort(list, 0, list.length - 1, dependentList); + quickSort(list, 0, list.length - 1); } public static void sort(String[] list) { if (list.length > 1) diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java index dfd0e293a56..68626a319bd 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. + * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ public class WordEntry { protected char[] fWord; protected int fNumRefs; protected int[] fRefs; - protected int[] fRefsIndexFlags; + public WordEntry() { this(CharOperation.NO_CHAR); @@ -26,41 +26,31 @@ public class WordEntry { fWord= word; fNumRefs= 0; fRefs= new int[1]; - fRefsIndexFlags = new int[1]; - } + } /** * Adds a reference and records the change in footprint. */ - public int addRef(int fileNum, int indexFlags) { + public int addRef(int fileNum) { if (fNumRefs > 0 && fRefs[fNumRefs - 1] == fileNum) { return 0; } if (fNumRefs < fRefs.length) { int tempNumRefs = fNumRefs; fRefs[fNumRefs++]= fileNum; - //Add index flags - fRefsIndexFlags[tempNumRefs]=indexFlags; return 0; } - - // For rt.jar, 73265 word entries are created. 51997 have 1 ref, then 9438, 3738, 1980, 1214, 779, 547, 429, 371 etc. + int newSize= fNumRefs < 4 ? 4 : fNumRefs * 2; // so will start @ 1, grow to 4, 8, 16, 32, 64 etc. System.arraycopy(fRefs, 0, fRefs= new int[newSize], 0, fNumRefs); - // Resize the index flags array at this time as well - System.arraycopy(fRefsIndexFlags,0,fRefsIndexFlags=new int[newSize],0,fNumRefs); - - int tempNumRefs=fNumRefs; + fRefs[fNumRefs++]= fileNum; - fRefsIndexFlags[tempNumRefs]=indexFlags; - return (newSize - fNumRefs + 1) * 4; } /** * Adds a set of references and records the change in footprint. */ - public void addRefs(int[] refs, int[] indexRefs) { + public void addRefs(int[] refs) { int[] newRefs= new int[fNumRefs + refs.length]; - int[] newIndexRefs = new int[fNumRefs + indexRefs.length]; int pos1= 0; int pos2= 0; int posNew= 0; @@ -72,29 +62,22 @@ public class WordEntry { while (pos1 < fNumRefs || pos2 < refs.length) { if (pos1 >= fNumRefs) { r2= refs[pos2]; - i2= indexRefs[pos2]; compare= -1; } else if (pos2 >= refs.length) { compare= 1; r1= fRefs[pos1]; - i1= fRefsIndexFlags[pos1]; } else { r1= fRefs[pos1]; r2= refs[pos2]; - - i1=fRefsIndexFlags[pos1]; - i2=indexRefs[pos2]; compare= r2 - r1; } if (compare > 0) { newRefs[posNew]= r1; - newIndexRefs[posNew]=i1; posNew++; pos1++; } else { if (r2 != 0) { newRefs[posNew]= r2; - newIndexRefs[posNew]=i2; posNew++; } pos2++; @@ -102,15 +85,14 @@ public class WordEntry { } fRefs= newRefs; fNumRefs= posNew; - fRefsIndexFlags=newIndexRefs; } /** * Returns the size of the wordEntry */ public int footprint() { //Size of Object + (number of fields * size of Fields) + (Size of ArrayObject + (Number of chars * sizeof Chars)) + - //(Size of ArrayObject + (Number of refs * sizeof int)) + (Size of ArrayObject + (Number of indexRefs * sizeof int)) - return 8 + (4 * 4) + (8 + fWord.length * 2) + (8 + fRefs.length * 4) + (8 + fRefsIndexFlags.length * 4); + //(Size of ArrayObject + (Number of refs * sizeof int)) + return 8 + (4 * 4) + (8 + fWord.length * 2) + (8 + fRefs.length * 4); } /** * Returns the number of references, e.g. the number of files this word appears in. @@ -125,13 +107,6 @@ public class WordEntry { if (i < fNumRefs) return fRefs[i]; throw new IndexOutOfBoundsException(); } - /** - * returns the index bit field in the i position - */ - public int getIndexFlag(int i) { - if (i < fNumRefs) return fRefsIndexFlags[i]; - throw new IndexOutOfBoundsException(); - } /** * Returns the references of the wordEntry (the number of the files it appears in). */ @@ -140,14 +115,6 @@ public class WordEntry { System.arraycopy(fRefs, 0, result, 0, fNumRefs); return result; } - /** - * Returns the wordEntry's references index flags - */ - public int[] getRefsIndexFlags() { - int[] result= new int[fNumRefs]; - System.arraycopy(fRefsIndexFlags, 0, result, 0, fNumRefs); - return result; - } /** * returns the word of the wordEntry. */ @@ -163,31 +130,22 @@ public class WordEntry { */ public void mapRefs(int[] mappings) { int position= 0; - int position2= 0; - + for (int i= 0; i < fNumRefs; i++) { //Take care that the reference is actually within the bounds of the mapping int map= -1; - int map2= -1; - + if(fRefs[i] >= 0 && fRefs[i] < mappings.length) map= mappings[fRefs[i]]; if (map != -1 && map != 0) fRefs[position++]= map; - - if (fRefsIndexFlags[i] >= 0 && fRefsIndexFlags[i] < mappings.length) - map2 = mappings[fRefsIndexFlags[i]]; - if (map2 != -1 && map2 != 0) - fRefsIndexFlags[position2++] = map2; - } fNumRefs= position; //to be changed! System.arraycopy(fRefs, 0, (fRefs= new int[fNumRefs]), 0, fNumRefs); - System.arraycopy(fRefsIndexFlags, 0, (fRefsIndexFlags = new int[fNumRefs]),0,fNumRefs); - Util.sort(fRefs, fRefsIndexFlags); + Util.sort(fRefs); } /** * Clears the wordEntry. @@ -195,7 +153,6 @@ public class WordEntry { public void reset(char[] word) { for (int i= fNumRefs; i-- > 0;) { fRefs[i]= 0; - fRefsIndexFlags[i]=0; } fNumRefs= 0; fWord= word; @@ -208,12 +165,9 @@ public class WordEntry { */ public void catRefs(WordEntry word) { int[] wordFileRefs = word.fRefs; - int[] wordIndexFlags=word.fRefsIndexFlags; ObjectSet set = new ObjectSet(4); for (int i=0; i