Skip to content

Commit

Permalink
[2020.3 compat] Add compatibility class for VMOptions
Browse files Browse the repository at this point in the history
VMoptions [started to return Path](JetBrains/intellij-community@c11cdea#diff-297f3fbe14cedd57aa946f58e4b40010d9b4f4f40d5b84eec33f4ab99f0b9a91R61) instead of File. We mimic the old behavior for sdk versions < 203.

PiperOrigin-RevId: 355359166
  • Loading branch information
AlexeyGy authored and copybara-github committed Feb 16, 2021
1 parent 4927cdb commit 1798560
Show file tree
Hide file tree
Showing 8 changed files with 90 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 @@ -8,6 +8,7 @@ java_library(
name = "v193",
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/diagnostic/**",
"com/google/idea/sdkcompat/formatter/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/python/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.google.idea.sdkcompat.diagnostic;

import com.intellij.diagnostic.VMOptions;
import java.io.File;
import java.nio.file.Path;
import org.jetbrains.annotations.Nullable;

/**
* Compat for {@code VMOptions}. {@link com.intellij.diagnostic.VMOptions#getWriteFile} changed its
* return type from File to Path in 2020.3. #api202
*/
public class VMOptionsCompat {

private VMOptionsCompat() {}

// #api202: Method return type changed in 2020.3 from File to Path
@Nullable
public static Path getWriteFile() {
File file = VMOptions.getWriteFile();
return file == null ? null : file.toPath();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v201/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ java_library(
name = "v201",
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/diagnostic/**",
"com/google/idea/sdkcompat/formatter/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/python/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.google.idea.sdkcompat.diagnostic;

import com.intellij.diagnostic.VMOptions;
import java.io.File;
import java.nio.file.Path;
import org.jetbrains.annotations.Nullable;

/**
* Compat for {@code VMOptions}. {@link com.intellij.diagnostic.VMOptions#getWriteFile} changed its
* return type from File to Path in 2020.3. #api202
*/
public class VMOptionsCompat {

private VMOptionsCompat() {}

// #api202: Method return type changed in 2020.3 from File to Path
@Nullable
public static Path getWriteFile() {
File file = VMOptions.getWriteFile();
return file == null ? null : file.toPath();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v202/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ java_library(
name = "v202",
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/diagnostic/**",
"com/google/idea/sdkcompat/formatter/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/python/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.google.idea.sdkcompat.diagnostic;

import com.intellij.diagnostic.VMOptions;
import java.io.File;
import java.nio.file.Path;
import org.jetbrains.annotations.Nullable;

/**
* Compat for {@code VMOptions}. {@link com.intellij.diagnostic.VMOptions#getWriteFile} changed its
* return type from File to Path in 2020.3. #api202
*/
public class VMOptionsCompat {

private VMOptionsCompat() {}

// #api202: Method return type changed in 2020.3 from File to Path
@Nullable
public static Path getWriteFile() {
File file = VMOptions.getWriteFile();
return file == null ? null : file.toPath();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v203/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ java_library(
name = "v203",
srcs = glob([
"com/google/idea/sdkcompat/general/**",
"com/google/idea/sdkcompat/diagnostic/**",
"com/google/idea/sdkcompat/formatter/**",
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/python/**",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.google.idea.sdkcompat.diagnostic;

import com.intellij.diagnostic.VMOptions;
import java.nio.file.Path;
import org.jetbrains.annotations.Nullable;

/**
* Compat for {@code VMOptions}. {@link VMOptions#getWriteFile} changed its return type from File to
* Path in 2020.3. #api202
*/
public class VMOptionsCompat {

private VMOptionsCompat() {}

// #api202: Method return type changed in 2020.3 from File to Path
@Nullable
public static Path getWriteFile() {
return VMOptions.getWriteFile();
}
}

0 comments on commit 1798560

Please sign in to comment.