当前位置: 首页>>代码示例>>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;未经允许,请勿转载。