diff --git a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java b/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
--- a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
+++ b/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
@@ -4254,7 +4254,7 @@
} // End of TestIndexFactoryImpl class
- private static final class TestIndexImpl implements DocumentIndex {
+ private static final class TestIndexImpl implements DocumentIndex.DocumentIndexWithStatus {
public TestIndexImpl(DocumentIndex original) {
this.original = original;
@@ -4265,6 +4265,11 @@
return Status.VALID;
}
+ @Override
+ public boolean isValid() throws IOException {
+ return true;
+ }
+
// --------------------------------------------------------------------
// IndexImpl implementation
// --------------------------------------------------------------------
diff --git a/java.source/nbproject/project.properties b/java.source/nbproject/project.properties
--- a/java.source/nbproject/project.properties
+++ b/java.source/nbproject/project.properties
@@ -46,7 +46,7 @@
javadoc.title=Java Source
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
-spec.version.base=0.79.1
+spec.version.base=0.80.1
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/javac-api-nb-7.0-b07.jar
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
${o.n.core.dir}/lib/boot.jar:\
diff --git a/java.source/nbproject/project.xml b/java.source/nbproject/project.xml
--- a/java.source/nbproject/project.xml
+++ b/java.source/nbproject/project.xml
@@ -257,8 +257,7 @@
- 2
- 2.2.1
+ 1.5.1
diff --git a/java.source/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java b/java.source/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java
--- a/java.source/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java
+++ b/java.source/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java
@@ -127,7 +127,12 @@
return IndexManager.readAccess(new IndexManager.Action() {
@Override
public Boolean run() throws IOException, InterruptedException {
- return index.getStatus(false) == Index.Status.EMPTY;
+ if (index instanceof Index.IndexWithStatus) {
+ //Fast path
+ return ((Index.IndexWithStatus)index).getStatus(false) == Index.Status.EMPTY;
+ } else {
+ return !index.exists();
+ }
}
}).booleanValue();
} catch (InterruptedException ie) {
@@ -142,7 +147,11 @@
@Override
public boolean isValid() {
try {
- return index.getStatus(true) != Index.Status.INVALID;
+ if (index instanceof Index.IndexWithStatus) {
+ return ((Index.IndexWithStatus)index).getStatus(true) != Index.Status.INVALID;
+ } else {
+ return index.isValid(true);
+ }
} catch (IOException ex) {
return false;
}
diff --git a/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java b/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
--- a/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
+++ b/java.source/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
@@ -2186,7 +2186,7 @@
}
- private static class TestIndex implements Index {
+ private static class TestIndex implements Index.IndexWithStatus {
//Activate the TestIndex.await after scan is done
//during the scan the prebuildArgs may call the index
//and cause deadlock
@@ -2200,7 +2200,17 @@
public Status getStatus(boolean tryOpen) throws IOException {
return Status.VALID;
}
-
+
+ @Override
+ public boolean exists() {
+ return true;
+ }
+
+ @Override
+ public boolean isValid(boolean tryOpen) throws IOException {
+ return true;
+ }
+
@Override
public void query(
Collection super T> result,
diff --git a/java.sourceui/nbproject/project.properties b/java.sourceui/nbproject/project.properties
--- a/java.sourceui/nbproject/project.properties
+++ b/java.sourceui/nbproject/project.properties
@@ -2,4 +2,4 @@
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.6
javadoc.arch=${basedir}/arch.xml
-spec.version.base=1.22.1
+spec.version.base=1.23.1
diff --git a/java.sourceui/nbproject/project.xml b/java.sourceui/nbproject/project.xml
--- a/java.sourceui/nbproject/project.xml
+++ b/java.sourceui/nbproject/project.xml
@@ -124,8 +124,7 @@
- 2
- 2.2.1
+ 1.5.1
diff --git a/parsing.api/nbproject/project.properties b/parsing.api/nbproject/project.properties
--- a/parsing.api/nbproject/project.properties
+++ b/parsing.api/nbproject/project.properties
@@ -2,4 +2,4 @@
javac.source=1.6
javadoc.apichanges=${basedir}/apichanges.xml
javadoc.arch=${basedir}/arch.xml
-spec.version.base=1.42.1
+spec.version.base=1.43.1
diff --git a/parsing.api/nbproject/project.xml b/parsing.api/nbproject/project.xml
--- a/parsing.api/nbproject/project.xml
+++ b/parsing.api/nbproject/project.xml
@@ -109,8 +109,7 @@
- 2
- 2.2.1
+ 1.5.1
diff --git a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupport.java b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupport.java
--- a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupport.java
+++ b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupport.java
@@ -47,6 +47,7 @@
import org.netbeans.modules.parsing.impl.indexing.FileObjectIndexable;
import org.netbeans.modules.parsing.impl.indexing.IndexFactoryImpl;
import org.netbeans.modules.parsing.impl.indexing.SPIAccessor;
+import org.netbeans.modules.parsing.lucene.support.DocumentIndex;
import org.netbeans.modules.parsing.lucene.support.Index;
import org.netbeans.modules.parsing.spi.indexing.Context;
import org.netbeans.modules.parsing.spi.indexing.Indexable;
@@ -107,7 +108,11 @@
*/
public boolean isValid() {
try {
- return spiIndex.getStatus() != Index.Status.INVALID;
+ if (spiIndex instanceof DocumentIndex.DocumentIndexWithStatus) {
+ return ((DocumentIndex.DocumentIndexWithStatus)spiIndex).getStatus() != Index.Status.INVALID;
+ } else {
+ return spiIndex.isValid();
+ }
} catch (IOException e) {
return false;
}
diff --git a/parsing.lucene/manifest.mf b/parsing.lucene/manifest.mf
--- a/parsing.lucene/manifest.mf
+++ b/parsing.lucene/manifest.mf
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: false
-OpenIDE-Module: org.netbeans.modules.parsing.lucene/2
+OpenIDE-Module: org.netbeans.modules.parsing.lucene
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/parsing/lucene/Bundle.properties
-OpenIDE-Module-Specification-Version: 2.2.1
+OpenIDE-Module-Specification-Version: 1.5.1
diff --git a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/DocumentIndexImpl.java b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/DocumentIndexImpl.java
--- a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/DocumentIndexImpl.java
+++ b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/DocumentIndexImpl.java
@@ -67,7 +67,7 @@
*
* @author Tomas Zezula
*/
-public final class DocumentIndexImpl implements DocumentIndex {
+public final class DocumentIndexImpl implements DocumentIndex.DocumentIndexWithStatus {
private final Index luceneIndex;
private static final Convertor ADD_CONVERTOR = new AddConvertor();
@@ -148,9 +148,22 @@
*/
@Override
public Index.Status getStatus() throws IOException {
- return luceneIndex.getStatus(true);
+ if (luceneIndex instanceof Index.IndexWithStatus) {
+ return ((Index.IndexWithStatus)luceneIndex).getStatus(true);
+ } else if (luceneIndex.isValid(true)) {
+ return Index.Status.VALID;
+ } else if (!luceneIndex.exists()) {
+ return Index.Status.EMPTY;
+ } else {
+ return Index.Status.INVALID;
+ }
}
-
+
+ @Override
+ public boolean isValid() throws IOException {
+ return luceneIndex.isValid(true);
+ }
+
@Override
public void close() throws IOException {
luceneIndex.close();
diff --git a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/LuceneIndex.java b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/LuceneIndex.java
--- a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/LuceneIndex.java
+++ b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/LuceneIndex.java
@@ -100,7 +100,7 @@
* @author Tomas Zezula
*/
//@NotTreadSafe
-public class LuceneIndex implements Index {
+public class LuceneIndex implements Index.IndexWithStatus {
private static final String PROP_INDEX_POLICY = "java.index.useMemCache"; //NOI18N
private static final String PROP_CACHE_SIZE = "java.index.size"; //NOI18N
@@ -375,6 +375,16 @@
}
@Override
+ public boolean exists() {
+ return this.dirCache.exists();
+ }
+
+ @Override
+ public boolean isValid(boolean tryOpen) throws IOException {
+ return dirCache.getStatus(tryOpen) == Index.Status.VALID;
+ }
+
+ @Override
public void clear () throws IOException {
try {
IndexManager.writeAccess(new IndexManager.Action() {
diff --git a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/DocumentIndex.java b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/DocumentIndex.java
--- a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/DocumentIndex.java
+++ b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/DocumentIndex.java
@@ -54,7 +54,19 @@
* @author Tomas Zezula
*/
public interface DocumentIndex {
-
+
+ public static interface DocumentIndexWithStatus extends DocumentIndex {
+ /**
+ * Checks the validity of the index, see {@link Index#isValid(boolean)} for details
+ * Checks the validity of the index, see {@link Index#getStatus(boolean)} for details
+ * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
+ * when the index does not exist or {@link Status#VALID} if the index is valid
+ * @throws IOException in case of IO error
+ * @since 1.5
+ */
+ public Index.Status getStatus() throws IOException;
+ }
+
/**
* Adds a document into the index.
* The document may not be added persistently until {@link DocumentIndex#store(boolean)} is called
@@ -69,13 +81,11 @@
void removeDocument (@NonNull String primaryKey);
/**
- * Checks the validity of the index, see {@link Index#getStatus(boolean)} for details
- * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
- * when the index does not exist or {@link Status#VALID} if the index is valid
+ * Checks the validity of the index, see {@link Index#isValid(boolean)} for details
+ * @return true if index exists and is not broken
* @throws IOException in case of IO error
- * @since 2.1
*/
- public Index.Status getStatus() throws IOException;
+ public boolean isValid() throws IOException;
/**
* Closes the index.
diff --git a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Index.java b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Index.java
--- a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Index.java
+++ b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/Index.java
@@ -65,7 +65,7 @@
/**
* Index status returned by {@link Index#getStatus(boolean)} method
- * @since 2.1
+ * @since 1.5
*/
enum Status {
/**
@@ -81,24 +81,39 @@
*/
VALID;
}
-
+
+ public static interface IndexWithStatus extends Index {
+ /**
+ * Checks the validity of the index. The index is invalid when it's broken.
+ * @param tryOpen when true the {@link Index} does exact but more expensive check.
+ * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
+ * when the index does not exist or {@link Status#VALID} if the index is valid
+ * @throws IOException in case of IO problem
+ * @since 1.5
+ */
+ Status getStatus (boolean tryOpen) throws IOException;
+ }
+
/**
* An exception thrown by {@link Index} when operation is called on
* a closed index.
*/
public static final class IndexClosedException extends IOException {
}
-
+
+ /**
+ * Check if the index already exists
+ * @return true if the index already exists on disk.
+ */
+ boolean exists ();
/**
* Checks the validity of the index. The index is invalid when it's broken.
* @param tryOpen when true the {@link Index} does exact but more expensive check.
- * @return {@link Status#INVALID} when the index is broken, {@link Status#EMPTY}
- * when the index does not exist or {@link Status#VALID} if the index is valid
+ * @return true when {@link Index} is not broken
* @throws IOException in case of IO problem
- * @since 2.1
*/
- Status getStatus (boolean tryOpen) throws IOException;
+ boolean isValid (boolean tryOpen) throws IOException;
/**
* Queries the {@link Index} by given queries.