com.intellij.openapi.util.io.FileUtil.findFirstThatExist()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中com.intellij.openapi.util.io.FileUtil.findFirstThatExist()方法的一些代码示例,展示了FileUtil.findFirstThatExist()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.findFirstThatExist()方法的具体详情如下:
包路径:com.intellij.openapi.util.io.FileUtil
类名称:FileUtil
方法名:findFirstThatExist

FileUtil.findFirstThatExist介绍

暂无

代码示例

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

@Nullable
public static VirtualFile suggestSdkDirectory() {
 if (SystemInfo.isWindows) {
  return ObjectUtils.chooseNotNull(LocalFileSystem.getInstance().findFileByPath("C:\\Go"),
                   LocalFileSystem.getInstance().findFileByPath("C:\\cygwin"));
 }
 if (SystemInfo.isMac || SystemInfo.isLinux) {
  String fromEnv = suggestSdkDirectoryPathFromEnv();
  if (fromEnv != null) {
   return LocalFileSystem.getInstance().findFileByPath(fromEnv);
  }
  VirtualFile usrLocal = LocalFileSystem.getInstance().findFileByPath("/usr/local/go");
  if (usrLocal != null) return usrLocal;
 }
 if (SystemInfo.isMac) {
  String macPorts = "/opt/local/lib/go";
  String homeBrew = "/usr/local/Cellar/go";
  File file = FileUtil.findFirstThatExist(macPorts, homeBrew);
  if (file != null) {
   return LocalFileSystem.getInstance().findFileByIoFile(file);
  }
 }
 return null;
}

代码示例来源:origin: ballerina-platform/ballerina-lang

@Nullable
public static VirtualFile suggestSdkDirectory() {
  if (SystemInfo.isWindows) {
    return ObjectUtils.chooseNotNull(LocalFileSystem.getInstance().findFileByPath("C:\\ballerina"), null);
  }
  if (SystemInfo.isMac || SystemInfo.isLinux) {
    String fromEnv = suggestSdkDirectoryPathFromEnv();
    if (fromEnv != null) {
      return LocalFileSystem.getInstance().findFileByPath(fromEnv);
    }
    VirtualFile usrLocal = LocalFileSystem.getInstance().findFileByPath("/usr/local/ballerina");
    if (usrLocal != null) {
      return usrLocal;
    }
  }
  if (SystemInfo.isMac) {
    String macPorts = "/opt/local/lib/ballerina";
    String homeBrew = "/usr/local/Cellar/ballerina";
    File file = FileUtil.findFirstThatExist(macPorts, homeBrew);
    if (file != null) {
      return LocalFileSystem.getInstance().findFileByIoFile(file);
    }
  }
  return null;
}

代码示例来源:origin: Haehnchen/idea-php-toolbox

@Test
public void testParameterRegistrarMappedAsObject() {
  File testFile = FileUtil.findFirstThatExist("src/test/java/de/espend/idea/php/toolbox/tests/utils/fixtures/ide-toolbox.metadata.json");
  JsonRegistrar next = JsonParseUtil.getDeserializeConfig(testFile).getRegistrar().iterator().next();
  Map<String, Object> parameters = next.getParameters();
  assertTrue((Boolean) parameters.get("foo"));
  assertEquals(1.0, parameters.get("bar"));
  assertEquals("bobby car", parameters.get("car"));
}

代码示例来源:origin: Haehnchen/idea-php-toolbox

@Test
public void testGetProviderJsonFromFile() {
  File testFile = FileUtil.findFirstThatExist("src/test/java/de/espend/idea/php/toolbox/tests/utils/fixtures/ide-toolbox.metadata.json");
  Map<String, Collection<JsonRawLookupElement>> elements = JsonParseUtil.getProviderJsonRawLookupElements(JsonParseUtil.getDeserializeConfig(testFile).getProviders());
  assertTrue(elements.keySet().contains("date_format"));
  JsonRawLookupElement date_format = elements.get("date_format").iterator().next();
  assertEquals("d", date_format.getLookupString());
  // defaults
  assertEquals("com.jetbrains.php.PhpIcons.METHOD", date_format.getIcon());
  assertEquals("(TailTest)", date_format.getTailText());
  assertEquals("test", date_format.getTarget());
  Collection<JsonRawLookupElement> source1 = elements.get("source_2");
  JsonRawLookupElement source1Item = source1.iterator().next();
  assertEquals("d", source1Item.getLookupString());
}

代码示例来源:origin: Haehnchen/idea-php-toolbox

@Test
public void testGetRegistrarJsonFromFileWithShortcut() {
  File testFile = FileUtil.findFirstThatExist("src/test/java/de/espend/idea/php/toolbox/tests/utils/fixtures/ide-toolbox.metadata.json");
  Collection<JsonRegistrar> elements = JsonParseUtil.getDeserializeConfig(testFile).getRegistrar();
  JsonRegistrar next = elements.iterator().next();
  JsonSignature object = ContainerUtil.find(next.getSignatures(), new MyFunctionJsonSignatureCondition("apple"));
  assertNotNull(object);
  assertEquals(object.hashCode(), ContainerUtil.find(next.getSignatures(), new MyFunctionJsonSignatureCondition("apple")).hashCode());
  assertTrue(ContainerUtil.filter(next.getSignatures(), jsonSignature -> "apple".equals(jsonSignature.getClassName()) && "car".equals(jsonSignature.getMethod())).size() > 0);
}

代码示例来源:origin: Haehnchen/idea-php-toolbox

@Test
public void testGetRegistrarJsonFromFile() {
  File testFile = FileUtil.findFirstThatExist("src/test/java/de/espend/idea/php/toolbox/tests/utils/fixtures/ide-toolbox.metadata.json");
  Collection<JsonRegistrar> elements = JsonParseUtil.getDeserializeConfig(testFile).getRegistrar();
  JsonRegistrar next = elements.iterator().next();
  assertTrue(ContainerUtil.filter(next.getSignatures(), new MyFunctionJsonSignatureCondition("foo")).size() > 0);
  assertTrue(ContainerUtil.filter(next.getSignatures(), new MyFunctionJsonSignatureCondition("date")).size() > 0);
  assertTrue(ContainerUtil.filter(next.getSignatures(), jsonSignature -> {
    return "DateTime".equals(jsonSignature.getClassName());
  }).size() > 0);
}

代码示例来源:origin: Haehnchen/idea-php-toolbox

@Test
public void testConfigDeserialize() {
  JsonConfigFile elements = null;
  try {
    File file = FileUtil.findFirstThatExist("src/test/java/de/espend/idea/php/toolbox/tests/utils/fixtures/ide-toolbox.metadata.json");
    elements = JsonParseUtil.getDeserializeConfig(StreamUtil.readText(new FileInputStream(file), Charset.defaultCharset()));
  } catch (IOException e) {
    e.printStackTrace();
  }
  List<JsonProvider> registrar = new ArrayList<>(elements.getProviders());
  assertEquals("date_format", registrar.get(0).getName());
  Collection<JsonRawLookupElement> dateFromatProvider = registrar.get(0).getItems();
  JsonRawLookupElement item = ContainerUtil.find(dateFromatProvider, new MyJsonRawLookupElementStringCondition("d"));
  assertNotNull(item);
  assertEquals(item.hashCode(), ContainerUtil.find(dateFromatProvider, new MyJsonRawLookupElementStringCondition("d")).hashCode());
  assertNotNull(ContainerUtil.find(dateFromatProvider, new MyJsonRawLookupElementStringCondition("car")));
  assertNotNull(ContainerUtil.find(dateFromatProvider, new MyJsonRawLookupElementStringCondition("apple")));
  assertEquals("source_1", registrar.get(1).getName());
  assertEquals("return", registrar.get(1).getSource().getContributor());
  assertEquals("\\Twig_Environment::getExtension", registrar.get(1).getSource().getParameter());
  assertEquals("source_2", registrar.get(2).getName());
  assertTrue(registrar.get(2).getItems().size() > 0);
}

相关文章