當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.toCanonicalPath方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.toCanonicalPath方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.toCanonicalPath方法的具體用法?Java FileUtil.toCanonicalPath怎麽用?Java FileUtil.toCanonicalPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.toCanonicalPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scanForModifiedClasses

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public Map<String, HotSwapFile> scanForModifiedClasses( DebuggerSession session, HotSwapProgress progress )
{
  DebuggerManagerThreadImpl.assertIsManagerThread();

  Map<String, HotSwapFile> modifiedClasses = new HashMap<>();

  List<File> outputRoots = new ArrayList<>();
  ApplicationManager.getApplication().runReadAction(
    () -> {
       VirtualFile[] allDirs = OrderEnumerator.orderEntries( getIjProject() ).getAllSourceRoots();
       for( VirtualFile dir : allDirs )
       {
         outputRoots.add( new File( dir.getPath() ) );
       }
     } );
  long timeStamp = getTimeStamp( session );
  for( File root : outputRoots )
  {
    String rootPath = FileUtil.toCanonicalPath( root.getPath() );
    collectModifiedClasses( root, rootPath, modifiedClasses, progress, timeStamp );
  }
  setTimeStamp( session, System.currentTimeMillis() );
  return modifiedClasses;
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:25,代碼來源:HotSwapComponent.java

示例2: getOutputDir

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Nullable
public static File getOutputDir(@Nullable File moduleOutput, ResourceRootConfiguration config, @Nullable String outputDirectory) {
  if(outputDirectory != null) {
    moduleOutput = JpsPathUtil.urlToFile(outputDirectory);
  }

  if (moduleOutput == null) {
    return null;
  }
  String targetPath = config.targetPath;
  if (StringUtil.isEmptyOrSpaces(targetPath)) {
    return moduleOutput;
  }
  final File targetPathFile = new File(targetPath);
  final File outputFile = targetPathFile.isAbsolute() ? targetPathFile : new File(moduleOutput, targetPath);
  return new File(FileUtil.toCanonicalPath(outputFile.getPath()));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:MavenResourcesTarget.java

示例3: loadProject

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static void loadProject(final JpsProject project, Map<String, String> pathVariables, String projectPath) throws IOException {
  File file = new File(FileUtil.toCanonicalPath(projectPath));
  if (file.isFile() && projectPath.endsWith(".ipr")) {
    new JpsProjectLoader(project, pathVariables, file.getParentFile()).loadFromIpr(file);
  }
  else {
    File dotIdea = new File(file, PathMacroUtil.DIRECTORY_STORE_NAME);
    File directory;
    if (dotIdea.isDirectory()) {
      directory = dotIdea;
    }
    else if (file.isDirectory() && file.getName().equals(PathMacroUtil.DIRECTORY_STORE_NAME)) {
      directory = file;
    }
    else {
      throw new IOException("Cannot find IntelliJ IDEA project files at " + projectPath);
    }
    new JpsProjectLoader(project, pathVariables, directory.getParentFile()).loadFromDirectory(directory);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:JpsProjectLoader.java

示例4: canonicalizePath

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static String canonicalizePath(@NotNull String url, @NotNull Url baseUrl, boolean baseUrlIsFile) {
  String path = url;
  if (url.charAt(0) != '/') {
    String basePath = baseUrl.getPath();
    if (baseUrlIsFile) {
      int lastSlashIndex = basePath.lastIndexOf('/');
      StringBuilder pathBuilder = new StringBuilder();
      if (lastSlashIndex == -1) {
        pathBuilder.append('/');
      }
      else {
        pathBuilder.append(basePath, 0, lastSlashIndex + 1);
      }
      path = pathBuilder.append(url).toString();
    }
    else {
      path = basePath + '/' + url;
    }
  }
  path = FileUtil.toCanonicalPath(path, '/');
  return path;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:SourceResolver.java

示例5: validate

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public boolean validate(GradleProjectSettings settings) throws ConfigurationException {
  if (myGradleHomePathField == null) return true;

  String gradleHomePath = FileUtil.toCanonicalPath(myGradleHomePathField.getText());
  if (myUseLocalDistributionButton != null && myUseLocalDistributionButton.isSelected()) {
    if (StringUtil.isEmpty(gradleHomePath)) {
      myGradleHomeSettingType = LocationSettingType.UNKNOWN;
      throw new ConfigurationException(GradleBundle.message("gradle.home.setting.type.explicit.empty", gradleHomePath));
    }
    else if (!myInstallationManager.isGradleSdkHome(new File(gradleHomePath))) {
      myGradleHomeSettingType = LocationSettingType.EXPLICIT_INCORRECT;
      new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType, 0).run();
      throw new ConfigurationException(GradleBundle.message("gradle.home.setting.type.explicit.incorrect", gradleHomePath));
    }
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:IdeaGradleProjectSettingsControlBuilder.java

示例6: updateJavaParameters

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public <T extends RunConfigurationBase> void updateJavaParameters(
    final T configuration, final JavaParameters params, final RunnerSettings runnerSettings
) throws ExecutionException {
    if (runnerSettings != null || !isApplicableFor(configuration)) {
        return;
    }
    final Project project = configuration.getProject();
    final ParametersList vmParameters = params.getVMParametersList();

    if (!vmParameters.hasParameter("-ea")) {
        vmParameters.add("-ea");
    }
    if (vmParameters.getParameters().stream().noneMatch(param -> param.startsWith("-Dplatformhome="))) {
        final VirtualFile platformRootDirectory = findPlatformRootDirectory(project);

        if (platformRootDirectory != null) {
            vmParameters.add("-Dplatformhome=" + platformRootDirectory.getPath());
        }
    }
    if (!params.getEnv().containsKey(HYBRIS_DATA_DIR_ENV)) {
        final HybrisProjectSettings settings = HybrisProjectSettingsComponent.getInstance(project).getState();

        final String hybrisDataDirPath = FileUtil.toCanonicalPath(
            project.getBasePath() + '/' + settings.getHybrisDirectory() + '/' + HybrisConstants.HYBRIS_DATA_DIRECTORY);

        if (hybrisDataDirPath != null) {
            params.addEnv(HYBRIS_DATA_DIR_ENV, hybrisDataDirPath);
        }
    }
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:32,代碼來源:HybrisJUnitExtension.java

示例7: GradleResourceRootDescriptor

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public GradleResourceRootDescriptor(@NotNull GradleResourcesTarget target,
                                    ResourceRootConfiguration config,
                                    int indexInPom,
                                    boolean overwrite) {
  myTarget = target;
  myConfig = config;
  final String path = FileUtil.toCanonicalPath(config.directory);
  myFile = new File(path);
  myId = path;
  myIndexInPom = indexInPom;
  myOverwrite = overwrite;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:GradleResourceRootDescriptor.java

示例8: getConfigPath

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
/**
 * Allows to build file system path to the target gradle sub-project given the root project path.
 *
 * @param subProject       target sub-project which config path we're interested in
 * @param rootProjectPath  path to root project's directory which contains 'build.gradle'
 * @return                 path to the given sub-project's directory which contains 'build.gradle'
 */
@NotNull
public static String getConfigPath(@NotNull GradleProject subProject, @NotNull String rootProjectPath) {
  try {
    GradleScript script = subProject.getBuildScript();
    if (script != null) {
      File file = script.getSourceFile();
      if (file != null) {
        if (file.isFile()) {
          // The file points to 'build.gradle' at the moment but we keep it's parent dir path instead.
          file = file.getParentFile();
        }
        return ExternalSystemApiUtil.toCanonicalPath(file.getCanonicalPath());
      }
    }
  }
  catch (Exception e) {
    // As said by gradle team: 'One thing I'm interested in is whether you have any thoughts about how the tooling API should
    // deal with missing details from the model - for example, when asking for details about the build scripts when using
    // a version of Gradle that does not supply that information. Currently, you'll get a `UnsupportedOperationException`
    // when you call the `getBuildScript()` method'.
    //
    // So, just ignore it and assume that the user didn't define any custom build file name.
  }
  File rootProjectParent = new File(rootProjectPath);
  StringBuilder buffer = new StringBuilder(FileUtil.toCanonicalPath(rootProjectParent.getAbsolutePath()));
  Stack<String> stack = ContainerUtilRt.newStack();
  for (GradleProject p = subProject; p != null; p = p.getParent()) {
    stack.push(p.getName());
  }

  // pop root project
  stack.pop();
  while (!stack.isEmpty()) {
    buffer.append(ExternalSystemConstants.PATH_SEPARATOR).append(stack.pop());
  }
  return buffer.toString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:45,代碼來源:GradleUtil.java

示例9: isModified

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public boolean isModified() {
  DistributionType distributionType = myInitialSettings.getDistributionType();
  if (myUseBundledDistributionButton != null &&
      myUseBundledDistributionButton.isSelected() &&
      distributionType != DistributionType.BUNDLED) {
    return true;
  }

  if (myUseWrapperButton != null && myUseWrapperButton.isSelected() && distributionType != DistributionType.DEFAULT_WRAPPED) {
    return true;
  }

  if (myUseWrapperWithVerificationButton != null &&
      myUseWrapperWithVerificationButton.isSelected() &&
      distributionType != DistributionType.WRAPPED) {
    return true;
  }

  if (myUseLocalDistributionButton != null && myUseLocalDistributionButton.isSelected() && distributionType != DistributionType.LOCAL) {
    return true;
  }

  if (myGradleJdkComboBox != null && !StringUtil.equals(myGradleJdkComboBox.getSelectedValue(), myInitialSettings.getGradleJvm())) {
    return true;
  }

  if (myGradleHomePathField == null) return false;
  String gradleHome = FileUtil.toCanonicalPath(myGradleHomePathField.getText());
  if (StringUtil.isEmpty(gradleHome)) {
    return !StringUtil.isEmpty(myInitialSettings.getGradleHome());
  }
  else {
    return !gradleHome.equals(myInitialSettings.getGradleHome());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:37,代碼來源:IdeaGradleProjectSettingsControlBuilder.java

示例10: decode

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public File decode(ArtifactLocation artifactLocation) {
  if (artifactLocation.isMainWorkspaceSourceArtifact()) {
    return pathResolver.resolveToFile(artifactLocation.relativePath);
  }
  String path =
      Paths.get(
              blazeInfo.getExecutionRoot().getPath(),
              artifactLocation.getExecutionRootRelativePath())
          .toString();
  // doesn't require file-system operations -- no attempt to resolve symlinks.
  return new File(FileUtil.toCanonicalPath(path));
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:14,代碼來源:ArtifactLocationDecoderImpl.java

示例11: derivePackagePrefix

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static String derivePackagePrefix(File file, SourceFolder parentFolder) {
  String parentPackagePrefix = parentFolder.getPackagePrefix();
  String parentPath = VirtualFileManager.extractPath(parentFolder.getUrl());
  String relativePath =
      FileUtil.toCanonicalPath(
          FileUtil.getRelativePath(parentPath, file.getPath(), File.separatorChar));
  if (Strings.isNullOrEmpty(relativePath)) {
    return parentPackagePrefix;
  }
  relativePath = relativePath.replaceAll(File.separator, ".");
  return Strings.isNullOrEmpty(parentPackagePrefix)
      ? relativePath
      : parentPackagePrefix + "." + relativePath;
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:15,代碼來源:JavaSourceFolderProvider.java

示例12: getCanonicalSdkHome

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Nullable
private String getCanonicalSdkHome() {
  final AndroidFacet facet = getFacet();

  if (facet == null) {
    return null;
  }
  final Sdk sdk = ModuleRootManager.getInstance(facet.getModule()).getSdk();

  if (sdk == null) {
    return null;
  }
  final String homePath = sdk.getHomePath();
  return homePath != null ? FileUtil.toCanonicalPath(homePath) : null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:ProGuardConfigFilesPanel.java

示例13: MavenResourceRootDescriptor

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public MavenResourceRootDescriptor(@NotNull MavenResourcesTarget target,
                                   ResourceRootConfiguration config,
                                   int indexInPom,
                                   boolean overwrite) {
  myTarget = target;
  myConfig = config;
  final String path = FileUtil.toCanonicalPath(config.directory);
  myFile = new File(path);
  myId = path;
  myIndexInPom = indexInPom;
  myOverwrite = overwrite;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:MavenResourceRootDescriptor.java

示例14: getParsedValueResourceFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public List<ResourceEntry> getParsedValueResourceFile(@NotNull File file) throws IOException {
  final String path = FileUtil.toCanonicalPath(file.getPath());
  List<ResourceEntry> entries = myParsedValueResourceFiles.get(path);

  if (entries == null) {
    entries = parseValueResourceFile(file);
    myParsedValueResourceFiles.put(path, entries);
  }
  return entries;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:AndroidBuildDataCache.java

示例15: testExternalAar

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testExternalAar() throws Exception {
  setRepositoryPath(new File(myDir, "__repo").getPath());
  FileUtil.copyDir(new File(AndroidTestCase.getTestDataPath() + "/maven/myaar"), new File(getRepositoryPath(), "com/myaar/1.0"));
  FileUtil.copyDir(new File(AndroidTestCase.getTestDataPath() + "/maven/myjar"), new File(getRepositoryPath(), "com/myjar/1.0"));

  AndroidFacetImporterBase.ANDROID_SDK_PATH_TEST = AndroidTestCase.getDefaultTestSdkPath();
  try {
    importProject(getPomContent("apk", "module", "") +
                  "<dependencies>" +
                  "  <dependency>" +
                  "    <groupId>com</groupId>\n" +
                  "    <artifactId>myaar</artifactId>\n" +
                  "    <version>1.0</version>\n" +
                  "    <type>aar</type>" +
                  "  </dependency>" +
                  "</dependencies>");

    assertModules("module");
    final Module module = getModule("module");
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    assertNotNull(facet);
    assertFalse(facet.isLibraryProject());

    final OrderEntry[] deps = ModuleRootManager.getInstance(module).getOrderEntries();
    assertEquals(4, deps.length);
    assertInstanceOf(deps[0], ModuleJdkOrderEntry.class);
    assertEquals("< Maven Android API 17 Platform >", deps[0].getPresentableName());
    assertInstanceOf(deps[1], ModuleSourceOrderEntry.class);
    assertInstanceOf(deps[2], LibraryOrderEntry.class);
    assertEquals(deps[2].getPresentableName(), "Maven: com:myaar:aar:1.0");
    final Library aarLib = ((LibraryOrderEntry)deps[2]).getLibrary();
    assertNotNull(aarLib);
    final String[] dep2Urls = aarLib.getUrls(OrderRootType.CLASSES);
    assertEquals(3, dep2Urls.length);
    String classesJarDep = null;
    String myJarDep = null;
    String resDep = null;

    for (String url : dep2Urls) {
      if (url.contains("classes.jar")) {
        classesJarDep = url;
      }
      else if (url.contains("myjar.jar")) {
        myJarDep = url;
      }
      else {
        resDep = url;
      }
    }
    final String extractedAarDirPath = FileUtil.toCanonicalPath(myDir.getPath() + "/project/gen-external-apklibs/com_myaar_1.0");
    assertEquals(VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, extractedAarDirPath + "/classes.jar") +
                 JarFileSystem.JAR_SEPARATOR, classesJarDep);
    assertEquals(VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, extractedAarDirPath + "/libs/myjar.jar") +
                 JarFileSystem.JAR_SEPARATOR, myJarDep);
    assertEquals(VfsUtilCore.pathToUrl(extractedAarDirPath + "/res"), resDep);

    assertInstanceOf(deps[3], LibraryOrderEntry.class);
    assertEquals(deps[3].getPresentableName(), "Maven: com:myjar:1.0");
    final Library jarLib = ((LibraryOrderEntry)deps[3]).getLibrary();
    assertNotNull(jarLib);
    final String[] dep3Urls = jarLib.getUrls(OrderRootType.CLASSES);
    assertEquals(1, dep3Urls.length);
    assertTrue(dep3Urls[0].endsWith("com/myjar/1.0/myjar-1.0.jar!/"));
  }
  finally {
    AndroidFacetImporterBase.ANDROID_SDK_PATH_TEST = null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:69,代碼來源:AndroidFacetImporterTest.java


注:本文中的com.intellij.openapi.util.io.FileUtil.toCanonicalPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。