Java Code Examples for com.intellij.util.EnvironmentUtil#getValue()

The following examples show how to use com.intellij.util.EnvironmentUtil#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the Android SDK that matches the ANDROID_HOME environment variable, provided it exists.
 */
@Nullable
public static IntelliJAndroidSdk fromEnvironment() {
  final String path = EnvironmentUtil.getValue("ANDROID_HOME");
  if (path == null) {
    return null;
  }

  // TODO(skybrian) refresh?
  final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
  if (file == null) {
    return null;
  }

  return fromHome(file);
}
 
Example 2
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the best value of the Android SDK location to use, including possibly querying flutter tools for it.
 */
public static String chooseAndroidHome(@Nullable Project project, boolean askFlutterTools) {
  if (project == null) {
    return EnvironmentUtil.getValue("ANDROID_HOME");
  }

  final IntelliJAndroidSdk intelliJAndroidSdk = fromProject(project);
  if (intelliJAndroidSdk != null) {
    return intelliJAndroidSdk.getHome().getPath();
  }

  // Ask flutter tools.
  if (askFlutterTools) {
    final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project);
    if (flutterSdk != null) {
      final String androidSdkLocation = flutterSdk.queryFlutterConfig("android-sdk", true);
      if (androidSdkLocation != null) {
        return androidSdkLocation;
      }
    }
  }

  return EnvironmentUtil.getValue("ANDROID_HOME");
}
 
Example 3
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the Android SDK that matches the ANDROID_HOME environment variable, provided it exists.
 */
@Nullable
public static IntelliJAndroidSdk fromEnvironment() {
  final String path = EnvironmentUtil.getValue("ANDROID_HOME");
  if (path == null) {
    return null;
  }

  // TODO(skybrian) refresh?
  final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
  if (file == null) {
    return null;
  }

  return fromHome(file);
}
 
Example 4
Source File: IntelliJAndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the best value of the Android SDK location to use, including possibly querying flutter tools for it.
 */
public static String chooseAndroidHome(@Nullable Project project, boolean askFlutterTools) {
  if (project == null) {
    return EnvironmentUtil.getValue("ANDROID_HOME");
  }

  final IntelliJAndroidSdk intelliJAndroidSdk = fromProject(project);
  if (intelliJAndroidSdk != null) {
    return intelliJAndroidSdk.getHome().getPath();
  }

  // Ask flutter tools.
  if (askFlutterTools) {
    final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project);
    if (flutterSdk != null) {
      final String androidSdkLocation = flutterSdk.queryFlutterConfig("android-sdk", true);
      if (androidSdkLocation != null) {
        return androidSdkLocation;
      }
    }
  }

  return EnvironmentUtil.getValue("ANDROID_HOME");
}
 
Example 5
Source File: GaugeUtil.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
private static GaugeSettingsModel getSettingsFromPATH(GaugeSettingsModel model) throws GaugeNotFoundException {
    String path = EnvironmentUtil.getValue("PATH");
    LOG.info("PATH => " + path);
    if (!StringUtils.isEmpty(path)) {
        for (String entry : path.split(File.pathSeparator)) {
            File file = new File(entry, gaugeExecutable());
            if (isValidGaugeExec(file)) {
                LOG.info("executable path from `PATH`: " + file.getAbsolutePath());
                return new GaugeSettingsModel(file.getAbsolutePath(), model.getHomePath(), model.useIntelliJTestRunner());
            }
        }
    }
    String msg = "Could not find executable in `PATH`. Please make sure Gauge is installed." +
            "\nIf Gauge is installed then set the Gauge executable path in settings -> tools -> gauge.";
    throw new GaugeNotFoundException(msg);
}
 
Example 6
Source File: NodeFinder.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public static List<File> listNodeInterpretersFromNvm(String exeFileName) {
    String nvmDirPath = EnvironmentUtil.getValue(NVM_DIR);
    if (StringUtil.isEmpty(nvmDirPath)) {
        return Collections.emptyList();
    }
    File nvmDir = new File(nvmDirPath);
    if (nvmDir.isDirectory() && nvmDir.isAbsolute()) {
        return listNodeInterpretersFromVersionDir(nvmDir, exeFileName);
    }
    return Collections.emptyList();
}
 
Example 7
Source File: AttachOSHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected String getenv(String name) throws Exception {
  if (myHost instanceof LocalAttachHost) {
    return EnvironmentUtil.getValue(name);
  }

  if (myEnvironment == null) {
    myEnvironment = EnvironmentUtil.parseEnv(myHost.getProcessOutput(ENV_COMMAND_LINE).getStdout().split("\n"));
  }

  return myEnvironment.get(name);
}