Skip to content

Commit

Permalink
Move java specific logic into the new java package.
Browse files Browse the repository at this point in the history
This keeps the main `qsync` package more language agnostic, and keeps language support better encapulated.

PiperOrigin-RevId: 588763291
  • Loading branch information
Googler authored and copybara-github committed Dec 7, 2023
1 parent e399f82 commit f28592b
Show file tree
Hide file tree
Showing 26 changed files with 87 additions and 76 deletions.
4 changes: 2 additions & 2 deletions base/src/com/google/idea/blaze/base/qsync/ProjectLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
import com.google.idea.blaze.qsync.BlazeProject;
import com.google.idea.blaze.qsync.BlazeProjectSnapshotBuilder;
import com.google.idea.blaze.qsync.BlazeProjectSnapshotBuilder.ProjectProtoTransform;
import com.google.idea.blaze.qsync.PackageStatementParser;
import com.google.idea.blaze.qsync.ParallelPackageReader;
import com.google.idea.blaze.qsync.ProjectRefresher;
import com.google.idea.blaze.qsync.VcsStateDiffer;
import com.google.idea.blaze.qsync.java.PackageStatementParser;
import com.google.idea.blaze.qsync.java.ParallelPackageReader;
import com.google.idea.blaze.qsync.project.ProjectDefinition;
import com.google.idea.blaze.qsync.project.ProjectPath;
import com.intellij.openapi.project.Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
import com.google.idea.blaze.common.Label;
import com.google.idea.blaze.common.PrintOutput;
import com.google.idea.blaze.exception.BuildException;
import com.google.idea.blaze.qsync.GeneratedSourceProjectUpdater;
import com.google.idea.blaze.qsync.GeneratedSourceProjectUpdater.GeneratedSourceJar;
import com.google.idea.blaze.qsync.SrcJarProjectUpdater;
import com.google.idea.blaze.qsync.TestSourceGlobMatcher;
import com.google.idea.blaze.qsync.cc.CcDependenciesInfo;
import com.google.idea.blaze.qsync.java.GeneratedSourceProjectUpdater;
import com.google.idea.blaze.qsync.java.GeneratedSourceProjectUpdater.GeneratedSourceJar;
import com.google.idea.blaze.qsync.java.JavaArtifactInfo;
import com.google.idea.blaze.qsync.java.JavaTargetInfo.JavaArtifacts;
import com.google.idea.blaze.qsync.java.JavaTargetInfo.JavaTargetArtifacts;
import com.google.idea.blaze.qsync.java.SrcJarProjectUpdater;
import com.google.idea.blaze.qsync.project.BuildGraphData;
import com.google.idea.blaze.qsync.project.ProjectDefinition;
import com.google.idea.blaze.qsync.project.ProjectPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.google.auto.value.AutoValue;
import com.google.idea.blaze.base.qsync.cache.FileCache.OutputArtifactDestinationAndLayout;
import com.google.idea.blaze.qsync.PackageStatementParser;
import com.google.idea.blaze.qsync.java.PackageStatementParser;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
Expand Down
6 changes: 3 additions & 3 deletions querysync/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ test_suite(
name = "querysync_tests",
tests = [
"//querysync/javatests/com/google/idea/blaze/qsync:AffectedPackagesTest",
"//querysync/javatests/com/google/idea/blaze/qsync:GeneratedSourceProjectUpdaterTest",
"//querysync/javatests/com/google/idea/blaze/qsync:GraphToProjectConverterTest",
"//querysync/javatests/com/google/idea/blaze/qsync:PackageStatementParserTest",
"//querysync/javatests/com/google/idea/blaze/qsync:PartialProjectRefreshTest",
"//querysync/javatests/com/google/idea/blaze/qsync:ProjectRefresherTest",
"//querysync/javatests/com/google/idea/blaze/qsync:QuerySyncTestUtilsTest",
"//querysync/javatests/com/google/idea/blaze/qsync:SrcJarProjectUpdaterTest",
"//querysync/javatests/com/google/idea/blaze/qsync:TestSourceGlobMatcherTest",
"//querysync/javatests/com/google/idea/blaze/qsync/cc:CcWorkspaceBuilderTest",
"//querysync/javatests/com/google/idea/blaze/qsync/java:GeneratedSourceProjectUpdaterTest",
"//querysync/javatests/com/google/idea/blaze/qsync/java:PackageStatementParserTest",
"//querysync/javatests/com/google/idea/blaze/qsync/java:SrcJarProjectUpdaterTest",
"//querysync/javatests/com/google/idea/blaze/qsync/project:BuildGraphTest",
"//querysync/javatests/com/google/idea/blaze/qsync/project:ProjectDefinitionTest",
"//querysync/javatests/com/google/idea/blaze/qsync/project:SnapshotSerializationTest",
Expand Down
1 change: 1 addition & 0 deletions querysync/java/com/google/idea/blaze/qsync/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ java_library(
"//querysync:__subpackages__",
],
deps = [
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:language_class_java_proto",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.idea.blaze.common.Context;
import com.google.idea.blaze.exception.BuildException;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.java.WorkspaceResolvingPackageReader;
import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot;
import com.google.idea.blaze.qsync.project.BuildGraphData;
import com.google.idea.blaze.qsync.project.PostQuerySyncData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.google.idea.blaze.common.PrintOutput;
import com.google.idea.blaze.common.RuleKinds;
import com.google.idea.blaze.exception.BuildException;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.project.BlazeProjectDataStorage;
import com.google.idea.blaze.qsync.project.BuildGraphData;
import com.google.idea.blaze.qsync.project.LanguageClassProto.LanguageClass;
Expand Down
2 changes: 2 additions & 0 deletions querysync/java/com/google/idea/blaze/qsync/java/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ java_library(
srcs = glob(["*.java"]),
deps = [
":java_target_info_java_proto",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//shared",
"//third_party/auto_value",
"@com_google_guava_guava//jar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.idea.blaze.qsync.SrcJarInnerPathFinder.AllowPackagePrefixes.ALLOW_NON_EMPTY_PACKAGE_PREFIXES;
import static com.google.idea.blaze.qsync.java.SrcJarInnerPathFinder.AllowPackagePrefixes.ALLOW_NON_EMPTY_PACKAGE_PREFIXES;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import com.google.idea.blaze.qsync.SrcJarInnerPathFinder.JarPath;
import com.google.idea.blaze.qsync.java.SrcJarInnerPathFinder.JarPath;
import com.google.idea.blaze.qsync.project.ProjectPath;
import com.google.idea.blaze.qsync.project.ProjectProto;
import com.google.idea.blaze.qsync.project.ProjectProto.Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import java.io.IOException;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.idea.blaze.qsync.SrcJarInnerPathFinder.AllowPackagePrefixes.EMPTY_PACKAGE_PREFIXES_ONLY;
import static com.google.idea.blaze.qsync.java.SrcJarInnerPathFinder.AllowPackagePrefixes.EMPTY_PACKAGE_PREFIXES_ONLY;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.common.collect.ImmutableList.toImmutableList;

Expand Down
2 changes: 2 additions & 0 deletions querysync/java/com/google/idea/blaze/qsync/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ java_binary(
deps = [
":cli_context",
"//querysync/java/com/google/idea/blaze/qsync",
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//shared",
"@com_google_guava_guava//jar",
Expand Down Expand Up @@ -43,6 +44,7 @@ java_binary(
visibility = ["//querysync:__pkg__"],
deps = [
"//querysync/java/com/google/idea/blaze/qsync",
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"@com_google_guava_guava//jar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.idea.blaze.qsync.SrcJarProjectUpdater;
import com.google.idea.blaze.qsync.java.SrcJarProjectUpdater;
import com.google.idea.blaze.qsync.project.ProjectPath;
import com.google.idea.blaze.qsync.project.ProjectPath.Root;
import com.google.idea.blaze.qsync.project.ProjectProto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import com.google.idea.blaze.exception.BuildException;
import com.google.idea.blaze.qsync.BlazeQueryParser;
import com.google.idea.blaze.qsync.GraphToProjectConverter;
import com.google.idea.blaze.qsync.PackageReader;
import com.google.idea.blaze.qsync.PackageStatementParser;
import com.google.idea.blaze.qsync.ParallelPackageReader;
import com.google.idea.blaze.qsync.WorkspaceResolvingPackageReader;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.java.PackageStatementParser;
import com.google.idea.blaze.qsync.java.ParallelPackageReader;
import com.google.idea.blaze.qsync.java.WorkspaceResolvingPackageReader;
import com.google.idea.blaze.qsync.project.BuildGraphData;
import com.google.idea.blaze.qsync.project.PostQuerySyncData;
import com.google.idea.blaze.qsync.project.SnapshotDeserializer;
Expand Down
47 changes: 1 addition & 46 deletions querysync/javatests/com/google/idea/blaze/qsync/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
],
deps = [
"//querysync/java/com/google/idea/blaze/qsync",
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//querysync/java/com/google/idea/blaze/qsync/query",
Expand Down Expand Up @@ -106,40 +107,6 @@ java_test(
],
)

java_test(
name = "GeneratedSourceProjectUpdaterTest",
size = "small",
srcs = ["GeneratedSourceProjectUpdaterTest.java"],
deps = [
":TestUtils",
"//querysync/java/com/google/idea/blaze/qsync",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata:project_protos",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)

java_test(
name = "SrcJarProjectUpdaterTest",
size = "small",
srcs = ["SrcJarProjectUpdaterTest.java"],
deps = [
":TestUtils",
"//querysync/java/com/google/idea/blaze/qsync",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata:project_protos",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)

java_test(
name = "TestSourceGlobMatcherTest",
size = "small",
Expand All @@ -151,15 +118,3 @@ java_test(
"@truth//jar",
],
)

java_test(
name = "PackageStatementParserTest",
size = "small",
srcs = ["PackageStatementParserTest.java"],
deps = [
"//querysync/java/com/google/idea/blaze/qsync",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.auto.value.AutoValue;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.project.ProjectDefinition;
import com.google.idea.blaze.qsync.project.QuerySyncLanguage;
import java.nio.file.Path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.idea.blaze.common.Context;
import com.google.idea.blaze.common.vcs.VcsState;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.query.QuerySummary;
import com.google.idea.blaze.qsync.testdata.TestData;
import java.io.IOException;
Expand Down Expand Up @@ -78,12 +79,12 @@ public static VcsStateDiffer noFilesChangedDiffer() {
}

@AutoValue
abstract static class PathPackage {
public abstract static class PathPackage {
abstract Path path();

abstract String pkg();

static PathPackage of(String path, String pkg) {
public static PathPackage of(String path, String pkg) {
return new AutoValue_QuerySyncTestUtils_PathPackage(Path.of(path), pkg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.idea.blaze.common.Context;
import com.google.idea.blaze.exception.BuildException;
import com.google.idea.blaze.qsync.java.PackageReader;
import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot;
import com.google.idea.blaze.qsync.project.BuildGraphData;
import com.google.idea.blaze.qsync.project.PostQuerySyncData;
Expand Down
45 changes: 45 additions & 0 deletions querysync/javatests/com/google/idea/blaze/qsync/java/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
java_test(
name = "GeneratedSourceProjectUpdaterTest",
size = "small",
srcs = ["GeneratedSourceProjectUpdaterTest.java"],
deps = [
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//querysync/javatests/com/google/idea/blaze/qsync:TestUtils",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata:project_protos",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)

java_test(
name = "SrcJarProjectUpdaterTest",
size = "small",
srcs = ["SrcJarProjectUpdaterTest.java"],
deps = [
"//querysync/java/com/google/idea/blaze/qsync/java",
"//querysync/java/com/google/idea/blaze/qsync/project",
"//querysync/java/com/google/idea/blaze/qsync/project:project_java_proto",
"//querysync/javatests/com/google/idea/blaze/qsync:TestUtils",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata",
"//querysync/javatests/com/google/idea/blaze/qsync/testdata:project_protos",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)

java_test(
name = "PackageStatementParserTest",
size = "small",
srcs = ["PackageStatementParserTest.java"],
deps = [
"//querysync/java/com/google/idea/blaze/qsync/java",
"@com_google_guava_guava//jar",
"@junit//jar",
"@truth//jar",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.idea.blaze.qsync.QuerySyncTestUtils.createSrcJar;

import com.google.common.collect.ImmutableSet;
import com.google.idea.blaze.qsync.GeneratedSourceProjectUpdater.GeneratedSourceJar;
import com.google.idea.blaze.qsync.QuerySyncTestUtils.PathPackage;
import com.google.idea.blaze.qsync.java.GeneratedSourceProjectUpdater.GeneratedSourceJar;
import com.google.idea.blaze.qsync.project.ProjectPath;
import com.google.idea.blaze.qsync.project.ProjectPath.Resolver;
import com.google.idea.blaze.qsync.project.ProjectProto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.common.truth.Truth.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.qsync;
package com.google.idea.blaze.qsync.java;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
Expand Down

0 comments on commit f28592b

Please sign in to comment.