当前位置: 首页>>代码示例>>Java>>正文


Java EncodingManager.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.encoding.EncodingManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java EncodingManager.getInstance方法的具体用法?Java EncodingManager.getInstance怎么用?Java EncodingManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.encoding.EncodingManager的用法示例。


在下文中一共展示了EncodingManager.getInstance方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Override
public Charset getCharset(Project project) {
  // try to find existing virtual file
  VirtualFile virtualFile = getVirtualFile();
  VirtualFile existing = virtualFile != null && virtualFile.isValid() ? virtualFile : null;
  if (existing == null) {
    LocalFileSystem lfs = LocalFileSystem.getInstance();
    for (File f = myFile; f != null; f = f.getParentFile()) {
      existing = lfs.findFileByIoFile(f);
      if (existing != null && existing.isValid()) {
        break;
      }
    }
  }
  if (existing != null) {
    Charset rc = existing.getCharset();
    if (rc != null) {
      return rc;
    }
  }
  EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : null;
  if (e == null) {
    e = EncodingManager.getInstance();
  }
  return e.getDefaultCharset();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:FilePathImpl.java

示例2: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Override
public Charset getCharset(Project project) {
  // try to find existing virtual file
  VirtualFile existing = myVirtualFile != null && myVirtualFile.isValid() ? myVirtualFile : null;
  if (existing == null) {
    LocalFileSystem lfs = LocalFileSystem.getInstance();
    for (File f = myFile; f != null; f = f.getParentFile()) {
      existing = lfs.findFileByIoFile(f);
      if (existing != null && existing.isValid()) {
        break;
      }
    }
  }
  if (existing != null) {
    Charset rc = existing.getCharset();
    if (rc != null) {
      return rc;
    }
  }
  EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : null;
  if (e == null) {
    e = EncodingManager.getInstance();
  }
  return e.getDefaultCharset();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:FilePathImpl.java

示例3: setUp

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
  super.setUp();

  initApplication();
  setUpProject();

  EncodingManager.getInstance(); // adds listeners
  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();
  InjectedLanguageManagerImpl.pushInjectors(getProject());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:HeavyIdeaTestFixtureImpl.java

示例4: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Override
@NotNull
public Charset getCharset(@Nullable Project project) {
  VirtualFile file = getVirtualFile();
  String path = myPath;
  while ((file == null || !file.isValid()) && !path.isEmpty()) {
    path = PathUtil.getParentPath(path);
    file = LocalFileSystem.getInstance().findFileByPath(path);
  }
  if (file != null) {
    return file.getCharset();
  }
  EncodingManager e = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
  return e.getDefaultCharset();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:LocalFilePath.java

示例5: loadRevisionContentGuessEncoding

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
public static String loadRevisionContentGuessEncoding(@NotNull final VcsFileRevision revision, @Nullable final VirtualFile file,
                                                      @Nullable final Project project) throws VcsException, IOException {
  final byte[] bytes = loadRevisionContent(revision);
  if (file != null) {
    return new String(bytes, file.getCharset());
  }
  EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : null;
  if (e == null) {
    e = EncodingManager.getInstance();
  }

  return CharsetToolkit.bytesToString(bytes, e.getDefaultCharset());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:VcsHistoryUtil.java

示例6: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Override
@Nonnull
public Charset getCharset(@Nullable Project project) {
  VirtualFile file = getVirtualFile();
  String path = myPath;
  while ((file == null || !file.isValid()) && !path.isEmpty()) {
    path = PathUtil.getParentPath(path);
    file = LocalFileSystem.getInstance().findFileByPath(path);
  }
  if (file != null) {
    return file.getCharset();
  }
  EncodingManager e = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
  return e.getDefaultCharset();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:16,代码来源:LocalFilePath.java

示例7: loadRevisionContentGuessEncoding

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
public static String loadRevisionContentGuessEncoding(@Nonnull final VcsFileRevision revision, @Nullable final VirtualFile file,
                                                      @Nullable final Project project) throws VcsException, IOException {
  final byte[] bytes = loadRevisionContent(revision);
  if (file != null) {
    return new String(bytes, file.getCharset());
  }
  EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : null;
  if (e == null) {
    e = EncodingManager.getInstance();
  }

  return CharsetToolkit.bytesToString(bytes, e.getDefaultCharset());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:VcsHistoryUtil.java

示例8: EditorListenerTracker

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
public EditorListenerTracker() {
  EncodingManager.getInstance(); //adds listeners
  EditorEventMulticasterImpl multicaster = (EditorEventMulticasterImpl)EditorFactory.getInstance().getEventMulticaster();
  before = multicaster.getListeners();
  myDefaultProjectInitialized = ((ProjectManagerImpl)ProjectManager.getInstance()).isDefaultProjectInitialized();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:EditorListenerTracker.java

示例9: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@NotNull
@Override
public Charset getCharset(@Nullable Project project) {
  EncodingManager em = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
  return em.getDefaultCharset();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:RemoteFilePath.java

示例10: createJavaParameters

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
/**
 *
 * @param project
 * @param parameters
 * @param coreSettings
 * @param runnerSettings
 * @param runConfiguration used to creation fix if maven home not found
 * @return
 * @throws ExecutionException
 */
public static JavaParameters createJavaParameters(@Nullable final Project project,
                                                  @NotNull final MavenRunnerParameters parameters,
                                                  @Nullable MavenGeneralSettings coreSettings,
                                                  @Nullable MavenRunnerSettings runnerSettings,
                                                  @Nullable MavenRunConfiguration runConfiguration) throws ExecutionException {
  final JavaParameters params = new JavaParameters();

  ApplicationManager.getApplication().assertReadAccessAllowed();

  if (coreSettings == null) {
    coreSettings = project == null ? new MavenGeneralSettings() : MavenProjectsManager.getInstance(project).getGeneralSettings();
  }
  if (runnerSettings == null) {
    runnerSettings = project == null ? new MavenRunnerSettings() : MavenRunner.getInstance(project).getState();
  }

  params.setWorkingDirectory(parameters.getWorkingDirFile());

  params.setJdk(getJdk(project, runnerSettings, project != null && MavenRunner.getInstance(project).getState() == runnerSettings));

  final String mavenHome = resolveMavenHome(coreSettings, project, runConfiguration);
  final String mavenVersion = MavenUtil.getMavenVersion(mavenHome);

  params.getProgramParametersList().add("-Didea.version=" + MavenUtil.getIdeaVersionToPassToMavenProcess());
  if (StringUtil.compareVersionNumbers(mavenVersion, "3.3") >= 0) {
    params.getVMParametersList().addProperty("maven.multiModuleProjectDirectory",
                                             MavenServerUtil.findMavenBasedir(parameters.getWorkingDirFile()).getPath());
  }

  addVMParameters(params.getVMParametersList(), mavenHome, runnerSettings);

  File confFile = MavenUtil.getMavenConfFile(new File(mavenHome));
  if (!confFile.isFile()) {
    throw new ExecutionException("Configuration file is not exists in maven home: " + confFile.getAbsolutePath());
  }

  if (project != null && parameters.isResolveToWorkspace()) {
    try {
      String resolverJar = getArtifactResolverJar(mavenVersion);
      confFile = patchConfFile(confFile, resolverJar);

      File modulesPathsFile = dumpModulesPaths(project);
      params.getVMParametersList().addProperty(MavenModuleMap.PATHS_FILE_PROPERTY, modulesPathsFile.getAbsolutePath());
    }
    catch (IOException e) {
      LOG.error(e);
      throw new ExecutionException("Failed to run maven configuration", e);
    }
  }

  params.getVMParametersList().addProperty("classworlds.conf", confFile.getPath());

  for (String path : getMavenClasspathEntries(mavenHome)) {
    params.getClassPath().add(path);
  }

  params.setEnv(new HashMap<String, String>(runnerSettings.getEnvironmentProperties()));
  params.setPassParentEnvs(runnerSettings.isPassParentEnv());

  params.setMainClass(MAVEN_LAUNCHER_CLASS);
  EncodingManager encodingManager = project == null
                                    ? EncodingManager.getInstance()
                                    : EncodingProjectManager.getInstance(project);
  params.setCharset(encodingManager.getDefaultCharset());

  addMavenParameters(params.getProgramParametersList(), mavenHome, coreSettings, runnerSettings, parameters);

  return params;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:80,代码来源:MavenExternalParameters.java

示例11: getCharset

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入方法依赖的package包/类
@Nonnull
@Override
public Charset getCharset(@Nullable Project project) {
  EncodingManager em = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
  return em.getDefaultCharset();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:RemoteFilePath.java


注:本文中的com.intellij.openapi.vfs.encoding.EncodingManager.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。