Skip to content

Commit

Permalink
Introduce compat class for VcsRepositoryCreator
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 341840316
  • Loading branch information
alice-ks authored and copybara-github committed Nov 11, 2020
1 parent 8eb3a55 commit 076c207
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 0 deletions.
1 change: 1 addition & 0 deletions sdkcompat/v193/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ java_library(
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
"com/google/idea/sdkcompat/cpp/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.vcs;

import com.intellij.dvcs.repo.Repository;
import com.intellij.dvcs.repo.VcsRepositoryCreator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import javax.annotation.Nullable;

/**
* Compatibility adapter for {@link VcsRepositoryCreator}. Changed to an interface in 2020.2.
* #api201
*/
public abstract class VcsRepositoryCreatorAdapter extends VcsRepositoryCreator {
private final Project myProject;

public VcsRepositoryCreatorAdapter(Project myProject) {
this.myProject = myProject;
}

@Nullable
public abstract Repository createRepository(
Project project, VirtualFile root, Disposable parentDisposable);

@Nullable
@Override
// #api201: Project parameter added in 2020.2
public Repository createRepositoryIfValid(VirtualFile root, Disposable parentDisposable) {
return createRepository(myProject, root, parentDisposable);
}
}
1 change: 1 addition & 0 deletions sdkcompat/v201/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ java_library(
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
"com/google/idea/sdkcompat/cpp/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.vcs;

import com.intellij.dvcs.repo.Repository;
import com.intellij.dvcs.repo.VcsRepositoryCreator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import javax.annotation.Nullable;

/**
* Compatibility adapter for {@link VcsRepositoryCreator}. Changed to an interface in 2020.2.
* #api201
*/
public abstract class VcsRepositoryCreatorAdapter extends VcsRepositoryCreator {
private final Project myProject;

public VcsRepositoryCreatorAdapter(Project myProject) {
this.myProject = myProject;
}

@Nullable
public abstract Repository createRepository(
Project project, VirtualFile root, Disposable parentDisposable);

@Nullable
@Override
// #api201: Project parameter added in 2020.2
public Repository createRepositoryIfValid(VirtualFile root, Disposable parentDisposable) {
return createRepository(myProject, root, parentDisposable);
}
}
1 change: 1 addition & 0 deletions sdkcompat/v202/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ java_library(
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
"com/google/idea/sdkcompat/cpp/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.vcs;

import com.intellij.dvcs.repo.Repository;
import com.intellij.dvcs.repo.VcsRepositoryCreator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import javax.annotation.Nullable;

/**
* Compatibility adapter for {@link VcsRepositoryCreator}. Changed to an interface in 2020.2.
* #api201
*/
public abstract class VcsRepositoryCreatorAdapter implements VcsRepositoryCreator {

// #api201: Project parameter necessary to support implementation of createRepositoryIfValid() for
// versions <2020.2.
public VcsRepositoryCreatorAdapter(Project myProject) {}

@Nullable
public abstract Repository createRepository(
Project project, VirtualFile root, Disposable parentDisposable);

@Nullable
@Override
// #api201: Project parameter added in 2020.2
public Repository createRepositoryIfValid(
Project project, VirtualFile root, Disposable parentDisposable) {
return createRepository(project, root, parentDisposable);
}
}

0 comments on commit 076c207

Please sign in to comment.