# NetBeans IDE HG Patch # This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /work/src/netbeans-jm # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: maven.indexer/manifest.mf --- maven.indexer/manifest.mf +++ maven.indexer/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/indexer/Bundle.properties AutoUpdate-Show-In-Client: false -OpenIDE-Module-Specification-Version: 2.36 +OpenIDE-Module-Specification-Version: 2.37 OpenIDE-Module: org.netbeans.modules.maven.indexer/2 Index: maven.indexer/nbproject/project.properties --- maven.indexer/nbproject/project.properties +++ maven.indexer/nbproject/project.properties @@ -40,7 +40,7 @@ test.config.stableBTD.includes=**/*Test.class is.autoload=true -javac.source=1.6 +javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial release.external/indexer-core-5.1.1-patched.jar=modules/ext/maven/indexer-core-5.1.1-patched.jar release.external/indexer-artifact-5.1.1.jar=modules/ext/maven/indexer-artifact-5.1.1.jar Index: maven.indexer/nbproject/project.xml --- maven.indexer/nbproject/project.xml +++ maven.indexer/nbproject/project.xml @@ -186,6 +186,7 @@ org.apache.lucene.util.cache org.netbeans.modules.maven.indexer.api org.netbeans.modules.maven.indexer.api.ui + org.netbeans.modules.maven.indexer.spi org.netbeans.modules.maven.indexer.spi.ui org.netbeans.modules.maven.indexer.spi.impl Index: maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java @@ -119,8 +119,8 @@ import org.netbeans.modules.maven.indexer.spi.ContextLoadedQuery; import org.netbeans.modules.maven.indexer.spi.DependencyInfoQueries; import org.netbeans.modules.maven.indexer.spi.GenericFindQuery; -import org.netbeans.modules.maven.indexer.spi.Redo; -import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation; +import org.netbeans.modules.maven.indexer.spi.impl.Redo; +import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation; import org.netbeans.modules.maven.indexer.spi.impl.IndexingNotificationProvider; import org.openide.modules.Places; import org.openide.util.BaseUtilities; Index: maven.indexer/src/org/netbeans/modules/maven/indexer/OnStop.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/OnStop.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/OnStop.java @@ -44,7 +44,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation; +import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation; import org.openide.util.Lookup; @org.openide.modules.OnStop Index: maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryIndexer.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryIndexer.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryIndexer.java @@ -44,7 +44,7 @@ import java.util.Collection; import org.apache.maven.artifact.Artifact; import org.netbeans.api.annotations.common.NonNull; -import org.netbeans.modules.maven.indexer.spi.RepositoryIndexerImplementation; +import org.netbeans.modules.maven.indexer.spi.impl.RepositoryIndexerImplementation; import org.openide.util.Lookup; /** Index: maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryQueries.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryQueries.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryQueries.java @@ -42,6 +42,7 @@ package org.netbeans.modules.maven.indexer.api; +import org.netbeans.modules.maven.indexer.spi.impl.Redo; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -71,23 +72,76 @@ /** * query result set + * @param * @since 2.9 */ public final static class Result { - private final List skipped = new ArrayList(); - private List results = new ArrayList(); - private final Redo redoAction; - int totalResults = 0; - int returnedResults = 0; + private final QueryResultImplementation impl; /** - * used internally by the repository indexing/searching engine(s) + * Creates a Result instance. + * @param impl */ - Result(Redo redo) { - redoAction = redo; + public Result(QueryResultImplementation impl) { + this.impl = impl; } /** + * Returns true is one or more indexes were skipped, e.g. because the indexing was taking place. + * @return + */ + public synchronized boolean isPartial() { + return impl.isPartial(); + } + + /** + * Waits for currently unaccessible indexes to finish, not to be called in AWT thread. + */ + public void waitForSkipped() { + assert !ProjectIDEServices.isEventDispatchThread(); + impl.waitForSkipped(); + } + + /** + * Returns a list of results + * @return + */ + public synchronized List getResults() { + return impl.getResults(); + } + + /** + * Total number of hits + * @return + * @since 2.20 + */ + public int getTotalResultCount() { + return impl.getTotalResultCount(); + } + + /** + * in some cases not entirely accurate number of processed and returned hits, typically should be less or equals to totalResultCount + * @return + * @since 2.20 + */ + public int getReturnedResultCount() { + return impl.getReturnedResultCount(); + } + + ResultInternal getImpl() { + return (ResultInternal) impl; + } + } + + private final static class ResultInternal implements QueryResultImplementation { + private final List skipped = new ArrayList(); + private List results = new ArrayList(); + private Runnable redoAction; + + int totalResults = 0; + int returnedResults = 0; + + /** * returns true is one or more indexes were skipped, eg because the indexing was taking place. * @return */ @@ -106,8 +160,9 @@ * waits for currently unaccessible indexes to finish, not to be called in AWT thread. */ public void waitForSkipped() { - assert !ProjectIDEServices.isEventDispatchThread(); - redoAction.run(this); + if(redoAction != null) { + redoAction.run(); + } synchronized (this) { skipped.clear(); } @@ -161,82 +216,87 @@ returnedResults = returnedResults + moreReturnedResults; } - - + void setRedoAction(Runnable redoAction) { + this.redoAction = redoAction; } + } - static { new AccessorImpl(); } - - static class AccessorImpl extends NexusRepositoryIndexerImpl.Accessor { @Override public void addSkipped(Result result, Collection infos) { - result.addSkipped(infos); + result.getImpl().addSkipped(infos); } @Override public List getSkipped(Result result) { - return result.getSkipped(); + return result.getImpl().getSkipped(); } @Override public void addSkipped(Result result, RepositoryInfo info) { - result.addSkipped(info); + result.getImpl().addSkipped(info); } @Override public Result createStringResult(Redo redo) { - return new Result(redo); + return createResult(redo); } + protected static Result createResult(final Redo redo) { + ResultInternal resultInternal = new ResultInternal<>(); + final Result result = new Result<>(resultInternal); + resultInternal.setRedoAction(() -> { redo.run(result); }); + return result; + } + @Override public Result createVersionResult(Redo redo) { - return new Result(redo); + return createResult(redo); } @Override public void setStringResults(Result result, Collection newResults) { - result.setResults(newResults); + result.getImpl().setResults(newResults); } @Override public void setVersionResults(Result result, Collection newResults) { - result.setResults(newResults); + result.getImpl().setResults(newResults); } @Override public Result createGroupResult(Redo redo) { - return new Result(redo); + return createResult(redo); } @Override public void setGroupResults(Result result, Collection newResults) { - result.setResults(newResults); + result.getImpl().setResults(newResults); } @Override public Result createClassResult(Redo redo) { - return new Result(redo); + return createResult(redo); } @Override public void setClassResults(Result result, Collection newResults) { - result.setResults(newResults); + result.getImpl().setResults(newResults); } @Override public void addTotalResults(Result result, int moreResults) { - result.addTotalResultCount(moreResults); + result.getImpl().addTotalResultCount(moreResults); } @Override public void addReturnedResults(Result result, int moreResults) { - result.addReturnedResultCount(moreResults); + result.getImpl().addReturnedResultCount(moreResults); } } Index: maven.indexer/src/org/netbeans/modules/maven/indexer/spi/QueryResultImplementation.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/spi/QueryResultImplementation.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/spi/QueryResultImplementation.java @@ -0,0 +1,85 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2016 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2016 Sun Microsystems, Inc. + */ +package org.netbeans.modules.maven.indexer.spi; + +import java.util.List; +import org.netbeans.modules.maven.indexer.api.RepositoryQueries; + +/** + * Implement to provide a maven index query result. + * + * @author Tomas Stupka + * @param + * @since 2.37 + * @see org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result + */ +public interface QueryResultImplementation { + /** + * Returns true is one or more indexes were skipped, e.g. because the indexing was taking place. + * @return + */ + public boolean isPartial(); + + /** + * Waits for currently unaccessible indexes to finish, not to be called in AWT thread. + */ + public void waitForSkipped(); + + /** + * Returns the results. + * @return + */ + public List getResults(); + + /** + * Total number of hits. + * @return + */ + public int getTotalResultCount(); + + /** + * In some cases not entirely accurate number of processed and returned hits, + * typically should be less or equal to {@link #getReturnedResultCount()} + * @return + */ + public int getReturnedResultCount(); +} Index: maven.indexer/src/org/netbeans/modules/maven/indexer/spi/Redo.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/spi/Redo.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/spi/Redo.java @@ -1,53 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2012 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2012 Sun Microsystems, Inc. - */ -package org.netbeans.modules.maven.indexer.spi; - -import org.netbeans.modules.maven.indexer.api.RepositoryQueries; - -/** - * used internally by the repository indexing/searching engine(s) - * @author mkleint - */ -public interface Redo { - void run(RepositoryQueries.Result result); -} - Index: maven.indexer/src/org/netbeans/modules/maven/indexer/spi/RepositoryIndexerImplementation.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/spi/RepositoryIndexerImplementation.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/spi/RepositoryIndexerImplementation.java @@ -1,67 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright 2010 Oracle and/or its affiliates. All rights reserved. - * - * Oracle and Java are registered trademarks of Oracle and/or its affiliates. - * Other names may be trademarks of their respective owners. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common - * Development and Distribution License("CDDL") (collectively, the - * "License"). You may not use this file except in compliance with the - * License. You can obtain a copy of the License at - * http://www.netbeans.org/cddl-gplv2.html - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the - * specific language governing permissions and limitations under the - * License. When distributing the software, include this License Header - * Notice in each file and include the License file at - * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the GPL Version 2 section of the License file that - * accompanied this code. If applicable, add the following below the - * License Header, with the fields enclosed by brackets [] replaced by - * your own identifying information: - * "Portions Copyrighted [year] [name of copyright owner]" - * - * If you wish your version of this file to be governed by only the CDDL - * or only the GPL Version 2, indicate your decision by adding - * "[Contributor] elects to include this software in this distribution - * under the [CDDL or GPL Version 2] license." If you do not indicate a - * single choice of license, a recipient has the option to distribute - * your version of this file under either the CDDL, the GPL Version 2 or - * to extend the choice of license to its licensees as provided above. - * However, if you add GPL Version 2 code and therefore, elected the GPL - * Version 2 license, then the option applies only if the new code is - * made subject to such option by the copyright holder. - * - * Contributor(s): - * - * Portions Copyrighted 2008 Sun Microsystems, Inc. - */ -package org.netbeans.modules.maven.indexer.spi; - -import java.util.Collection; -import org.apache.maven.artifact.Artifact; -import org.netbeans.modules.maven.indexer.api.RepositoryInfo; - -/** - * Implementation of repository indexer (repository manager). Apart from basic - * indexing features also serves as provider of various index queries. - * There is one implementation based on apache indexer - * - * @author Milos Kleint - */ -public interface RepositoryIndexerImplementation { - - /** - * Index local repository or retrieve remote prepopulated index for local use. - * @param repo - */ - void indexRepo(RepositoryInfo repo); - - void updateIndexWithArtifacts(RepositoryInfo repo, Collection artifacts); - - void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact); - -} Index: maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/Redo.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/Redo.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/Redo.java @@ -0,0 +1,53 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.modules.maven.indexer.spi.impl; + +import org.netbeans.modules.maven.indexer.api.RepositoryQueries; + +/** + * used internally by the repository indexing/searching engine(s) + * @author mkleint + */ +public interface Redo { + void run(RepositoryQueries.Result result); +} + Index: maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/RepositoryIndexerImplementation.java --- maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/RepositoryIndexerImplementation.java +++ maven.indexer/src/org/netbeans/modules/maven/indexer/spi/impl/RepositoryIndexerImplementation.java @@ -0,0 +1,67 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2010 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ +package org.netbeans.modules.maven.indexer.spi.impl; + +import java.util.Collection; +import org.apache.maven.artifact.Artifact; +import org.netbeans.modules.maven.indexer.api.RepositoryInfo; + +/** + * Implementation of repository indexer (repository manager). Apart from basic + * indexing features also serves as provider of various index queries. + * There is one implementation based on apache indexer + * + * @author Milos Kleint + */ +public interface RepositoryIndexerImplementation { + + /** + * Index local repository or retrieve remote prepopulated index for local use. + * @param repo + */ + void indexRepo(RepositoryInfo repo); + + void updateIndexWithArtifacts(RepositoryInfo repo, Collection artifacts); + + void deleteArtifactFromIndex(RepositoryInfo repo, Artifact artifact); + +} Index: maven/test/unit/src/org/netbeans/modules/maven/classpath/ClassPathProviderImplTest.java --- maven/test/unit/src/org/netbeans/modules/maven/classpath/ClassPathProviderImplTest.java +++ maven/test/unit/src/org/netbeans/modules/maven/classpath/ClassPathProviderImplTest.java @@ -64,7 +64,7 @@ import org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result; import org.netbeans.modules.maven.indexer.api.RepositoryUtil; import org.netbeans.modules.maven.indexer.spi.ChecksumQueries; -import org.netbeans.modules.maven.indexer.spi.Redo; +import org.netbeans.modules.maven.indexer.spi.impl.Redo; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.filesystems.test.TestFileUtils;