Java 类com.intellij.openapi.vfs.encoding.EncodingProjectManager 实例源码

项目:intellij-ce-playground    文件:BinaryContent.java   
@Override
@Nullable
public Document getDocument() {
  if (myDocument == null) {
    if (isBinary()) return null;

    String text = null;
    try {
      Charset charset = ObjectUtils.notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
      text = CharsetToolkit.bytesToString(myBytes, charset);
    }
    catch (IllegalCharsetNameException ignored) { }

    //  Still NULL? only if not supported or an exception was thrown.
    //  Decode a string using the truly default encoding.
    if (text == null) text = new String(myBytes);
    text = LineTokenizer.correctLineSeparators(text);

    myDocument = EditorFactory.getInstance().createDocument(text);
    myDocument.setReadOnly(true);
  }

  return myDocument;
}
项目:intellij-ce-playground    文件:LightPlatformCodeInsightTestCase.java   
@NotNull
private static Document setupFileEditorAndDocument(@NotNull String fileName, @NotNull String fileText) throws IOException {
  EncodingProjectManager.getInstance(getProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
  deleteVFile();
  myVFile = getSourceRoot().createChildData(null, fileName);
  VfsUtil.saveText(myVFile, fileText);
  final FileDocumentManager manager = FileDocumentManager.getInstance();
  final Document document = manager.getDocument(myVFile);
  assertNotNull("Can't create document for '" + fileName + "'", document);
  manager.reloadFromDisk(document);
  document.insertString(0, " ");
  document.deleteString(0, 1);
  myFile = getPsiManager().findFile(myVFile);
  assertNotNull("Can't create PsiFile for '" + fileName + "'. Unknown file type most probably.", myFile);
  assertTrue(myFile.isPhysical());
  myEditor = createEditor(myVFile);
  myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);

  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  return document;
}
项目:intellij-ce-playground    文件:GradleSyncTest.java   
@Test @IdeGuiTest
public void testMismatchingEncodings() throws IOException {
  IdeFrameFixture projectFrame = importSimpleApplication();
  final Project project = projectFrame.getProject();

  execute(new GuiTask() {
    @Override
    protected void executeInEDT() throws Throwable {
      EncodingProjectManager encodings = EncodingProjectManager.getInstance(project);
      encodings.setDefaultCharsetName("ISO-8859-1");
    }
  });

  projectFrame.requestProjectSync().waitForGradleProjectSyncToFinish();

  String expectedMessage = "The project encoding (ISO-8859-1) has been reset to the encoding specified in the Gradle build files (UTF-8).";
  ContentFixture syncMessages = projectFrame.getMessagesToolWindow().getGradleSyncContent();
  syncMessages.findMessage(INFO, firstLineStartingWith(expectedMessage));

  assertEquals("UTF-8", EncodingProjectManager.getInstance(project).getDefaultCharsetName());
}
项目:intellij-ce-playground    文件:EncodingManager.java   
private void applySettings(VirtualFile file) {
  if (file == null) return;
  if (!Utils.isEnabled(CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings())) return;

  // Prevent "setEncoding" calling "saveAll" from causing an endless loop
  isApplyingSettings = true;
  try {
    final String filePath = Utils.getFilePath(myProject, file);
    final List<OutPair> outPairs = SettingsProviderComponent.getInstance().getOutPairs(myProject, filePath);
    final EncodingProjectManager encodingProjectManager = EncodingProjectManager.getInstance(myProject);
    final String charset = Utils.configValueForKey(outPairs, charsetKey);
    if (!charset.isEmpty()) {
      final Charset newCharset = encodingMap.get(charset);
      if (newCharset != null) {
        if (Comparing.equal(newCharset, file.getCharset())) return;
        encodingProjectManager.setEncoding(file, newCharset);
      } else {
        Utils.invalidConfigMessage(myProject, charset, charsetKey, filePath);
      }
    }
  } finally {
    isApplyingSettings = false;
  }
}
项目:tools-idea    文件:LightPlatformCodeInsightTestCase.java   
@NotNull
private static Document setupFileEditorAndDocument(@NotNull String fileName, @NotNull String fileText) throws IOException {
  EncodingProjectManager.getInstance(getProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
  deleteVFile();
  myVFile = getSourceRoot().createChildData(null, fileName);
  VfsUtil.saveText(myVFile, fileText);
  final FileDocumentManager manager = FileDocumentManager.getInstance();
  final Document document = manager.getDocument(myVFile);
  assertNotNull("Can't create document for '" + fileName + "'", document);
  manager.reloadFromDisk(document);
  document.insertString(0, " ");
  document.deleteString(0, 1);
  myFile = getPsiManager().findFile(myVFile);
  assertNotNull("Can't create PsiFile for '" + fileName + "'. Unknown file type most probably.", myFile);
  assertTrue(myFile.isPhysical());
  myEditor = createEditor(myVFile);
  myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);

  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  return document;
}
项目:tools-idea    文件:FilePathImpl.java   
@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();
}
项目:editorconfig-jetbrains    文件:EncodingManager.java   
private void applySettings(VirtualFile file) {
    if (file == null || !file.isInLocalFileSystem()) return;
    // Prevent "setEncoding" calling "saveAll" from causing an endless loop
    isApplyingSettings = true;
    final String filePath = file.getCanonicalPath();
    final List<OutPair> outPairs = SettingsProviderComponent.getInstance().getOutPairs(filePath);
    final EncodingProjectManager encodingProjectManager = EncodingProjectManager.getInstance(project);
    final String charset = Utils.configValueForKey(outPairs, charsetKey);
    if (!charset.isEmpty()) {
        if (encodingMap.containsKey(charset)) {
            encodingProjectManager.setEncoding(file, encodingMap.get(charset));
            LOG.debug(Utils.appliedConfigMessage(charset, charsetKey, filePath));
        } else {
            LOG.warn(Utils.invalidConfigMessage(charset, charsetKey, filePath));
        }
    }
    isApplyingSettings = false;
}
项目:consulo    文件:LightPlatformCodeInsightTestCase.java   
@Nonnull
private static Document setupFileEditorAndDocument(@Nonnull String fileName, @Nonnull String fileText) throws IOException {
  EncodingProjectManager.getInstance(getProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  EncodingProjectManager.getInstance(ProjectManager.getInstance().getDefaultProject()).setEncoding(null, CharsetToolkit.UTF8_CHARSET);
  PostprocessReformattingAspect.getInstance(ourProject).doPostponedFormatting();
  deleteVFile();
  myVFile = getSourceRoot().createChildData(null, fileName);
  VfsUtil.saveText(myVFile, fileText);
  final FileDocumentManager manager = FileDocumentManager.getInstance();
  final Document document = manager.getDocument(myVFile);
  assertNotNull("Can't create document for '" + fileName + "'", document);
  manager.reloadFromDisk(document);
  document.insertString(0, " ");
  document.deleteString(0, 1);
  myFile = getPsiManager().findFile(myVFile);
  assertNotNull("Can't create PsiFile for '" + fileName + "'. Unknown file type most probably.", myFile);
  assertTrue(myFile.isPhysical());
  myEditor = createEditor(myVFile);
  myVFile.setCharset(CharsetToolkit.UTF8_CHARSET);

  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  return document;
}
项目:consulo    文件:BinaryContent.java   
@Override
@SuppressWarnings({"EmptyCatchBlock"})
@Nullable
public Document getDocument() {
  if (myDocument == null) {
    if (isBinary()) return null;

    String text = null;
    try {
      Charset charset = ObjectUtil
              .notNull(myCharset, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
      text = CharsetToolkit.bytesToString(myBytes, charset);
    }
    catch (IllegalCharsetNameException e) {
    }

    //  Still NULL? only if not supported or an exception was thrown.
    //  Decode a string using the truly default encoding.
    if (text == null) text = new String(myBytes);
    text = LineTokenizer.correctLineSeparators(text);

    myDocument = EditorFactory.getInstance().createDocument(text);
    myDocument.setReadOnly(true);
  }
  return myDocument;
}
项目:consulo    文件:FilePathImpl.java   
@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();
}
项目:intellij-ce-playground    文件:LossyEncodingTest.java   
public void testNativeConversion() throws Exception {
  configureByText(StdFileTypes.PROPERTIES, "a=<caret>v");
  EncodingProjectManager.getInstance(getProject()).setNative2AsciiForPropertiesFiles(null, true);
  UIUtil.dispatchAllInvocationEvents();  //reload files

  type('\\');
  type('\\');

  Collection<HighlightInfo> infos = doHighlighting();
  assertEquals(0, infos.size());
}
项目:intellij-ce-playground    文件:CompilerEncodingServiceImpl.java   
public CompilerEncodingServiceImpl(@NotNull Project project) {
  myProject = project;
  myModuleFileEncodings = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Map<Module, Set<Charset>>>() {
    @Override
    public Result<Map<Module, Set<Charset>>> compute() {
      Map<Module, Set<Charset>> result = computeModuleCharsetMap();
      return Result.create(result, ProjectRootManager.getInstance(myProject),
                           ((EncodingProjectManagerImpl)EncodingProjectManager.getInstance(myProject)).getModificationTracker());
    }
  }, false);
}
项目:intellij-ce-playground    文件:CompilerEncodingServiceImpl.java   
@NotNull
@Override
public Collection<Charset> getAllModuleEncodings(@NotNull Module module) {
  final Set<Charset> encodings = myModuleFileEncodings.getValue().get(module);
  if (encodings != null) {
    return encodings;
  }
  return ContainerUtil.createMaybeSingletonList(EncodingProjectManager.getInstance(myProject).getDefaultCharset());
}
项目:intellij-ce-playground    文件:LocalFilePath.java   
@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();
}
项目:intellij-ce-playground    文件:FilePathImpl.java   
@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();
}
项目:intellij-ce-playground    文件:CreatePatchConfigurationPanel.java   
private void initEncodingCombo() {
  final DefaultComboBoxModel encodingsModel = new DefaultComboBoxModel(CharsetToolkit.getAvailableCharsets());
  encodingsModel.insertElementAt(SYSTEM_DEFAULT, 0);
  myEncoding.setModel(encodingsModel);

  final String name = EncodingProjectManager.getInstance(myProject).getDefaultCharsetName();
  if (StringUtil.isEmpty(name)) {
    myEncoding.setSelectedItem(SYSTEM_DEFAULT);
  }
  else {
    myEncoding.setSelectedItem(EncodingProjectManager.getInstance(myProject).getDefaultCharset());
  }
}
项目:intellij-ce-playground    文件:VcsHistoryUtil.java   
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());
}
项目:intellij-ce-playground    文件:PyStructuredDocstringFormatter.java   
@Nullable
private static String runExternalTool(@NotNull final Module module,
                                      @NotNull final HelperPackage formatter,
                                      @NotNull final String docstring) {
  final Sdk sdk = PythonSdkType.findPython2Sdk(module);
  if (sdk == null) return null;

  final String sdkHome = sdk.getHomePath();
  if (sdkHome == null) return null;

  final Charset charset = EncodingProjectManager.getInstance(module.getProject()).getDefaultCharset();

  final ByteBuffer encoded = charset.encode(docstring);
  final byte[] data = new byte[encoded.limit()];
  encoded.get(data);

  final Map<String, String> env = new HashMap<String, String>();
  PythonEnvUtil.setPythonDontWriteBytecode(env);

  final GeneralCommandLine commandLine = formatter.newCommandLine(sdkHome, Lists.<String>newArrayList());
  LOG.debug("Command for launching docstring formatter: " + commandLine.getCommandLineString());

  final ProcessOutput output = PySdkUtil.getProcessOutput(commandLine, new File(sdkHome).getParent(), env, 5000, data, false);
  if (!output.checkSuccess(LOG)) {
    return null;
  }
  return output.getStdout();
}
项目:intellij-ce-playground    文件:AndroidProjectDataService.java   
private static void setIdeEncodingAndAddEncodingMismatchMessage(@NotNull String newEncoding, @NotNull Project project) {
  EncodingProjectManager encodings = EncodingProjectManager.getInstance(project);
  String[] text = {
    String.format("The project encoding (%1$s) has been reset to the encoding specified in the Gradle build files (%2$s).",
                  encodings.getDefaultCharset().displayName(), newEncoding),
    "Mismatching encodings can lead to serious bugs."
  };
  encodings.setDefaultCharsetName(newEncoding);
  NotificationHyperlink openDocHyperlink = new OpenUrlHyperlink("http://tools.android.com/knownissues/encoding", "More Info...");
  ProjectSyncMessages.getInstance(project).add(new Message(UNHANDLED_SYNC_ISSUE_TYPE, INFO, text), openDocHyperlink);
}
项目:intellij-ce-playground    文件:HgEncodingUtil.java   
@NotNull
public static Charset getDefaultCharset(@NotNull Project project) {
  if (HGENCODING != null && HGENCODING.length() > 0 && Charset.isSupported(HGENCODING)) {
    return Charset.forName(HGENCODING);
  }
  Charset defaultCharset = null;
  if (!project.isDisposed()) {
    defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
  }
  return defaultCharset != null ? defaultCharset : Charset.defaultCharset();
}
项目:intellij-ce-playground    文件:DefaultGroovyScriptRunner.java   
private static void addScriptEncodingSettings(final JavaParameters params, final VirtualFile scriptFile, Module module) {
  Charset charset = EncodingProjectManager.getInstance(module.getProject()).getEncoding(scriptFile, true);
  if (charset == null) {
    charset = EncodingManager.getInstance().getDefaultCharset();
    if (!Comparing.equal(CharsetToolkit.getDefaultSystemCharset(), charset)) {
      params.getProgramParametersList().add("--encoding=" + charset.displayName());
    }
  }
  else {
    params.getProgramParametersList().add("--encoding=" + charset.displayName());
  }
}
项目:tools-idea    文件:LossyEncodingTest.java   
public void testNativeConversion() throws Exception {
  configureFromFileText("x.properties","a=<caret>v");
  EncodingProjectManager.getInstance(getProject()).setNative2AsciiForPropertiesFiles(null, true);
  UIUtil.dispatchAllInvocationEvents();  //reload files

  type('\\');
  type('\\');

  Collection<HighlightInfo> infos = doHighlighting();
  assertEquals(0, infos.size());
}
项目:tools-idea    文件:CompilerEncodingServiceImpl.java   
public CompilerEncodingServiceImpl(@NotNull Project project) {
  myProject = project;
  myModuleFileEncodings = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Map<Module, Set<Charset>>>() {
    @Override
    public Result<Map<Module, Set<Charset>>> compute() {
      Map<Module, Set<Charset>> result = computeModuleCharsetMap();
      return Result.create(result, ProjectRootManager.getInstance(myProject),
                           ((EncodingProjectManagerImpl)EncodingProjectManager.getInstance(myProject)).getModificationTracker());
    }
  }, false);
}
项目:tools-idea    文件:CompilerEncodingServiceImpl.java   
@NotNull
@Override
public Collection<Charset> getAllModuleEncodings(@NotNull Module module) {
  final Set<Charset> encodings = myModuleFileEncodings.getValue().get(module);
  if (encodings != null) {
    return encodings;
  }
  return ContainerUtil.createMaybeSingletonList(EncodingProjectManager.getInstance(myProject).getDefaultCharset());
}
项目:tools-idea    文件:VcsHistoryUtil.java   
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());
}
项目:tools-idea    文件:VcsHistoryUtil.java   
public static String loadRevisionContentGuessEncoding(final VcsFileRevision revision, @Nullable final Project project) throws VcsException, IOException {
  final byte[] bytes = loadRevisionContent(revision);

  EncodingManager e = project != null ? EncodingProjectManager.getInstance(project) : null;
  if (e == null) {
    e = EncodingManager.getInstance();
  }

  return CharsetToolkit.bytesToString(bytes, e.getDefaultCharset());
}
项目:tools-idea    文件:HgEncodingUtil.java   
@NotNull
public static Charset getDefaultCharset(@NotNull Project project) {
  if (HGENCODING != null && HGENCODING.length() > 0 && Charset.isSupported(HGENCODING)) {
    return Charset.forName(HGENCODING);
  }
  else {
    Charset defaultCharset = EncodingProjectManager.getInstance(project).getDefaultCharset();
    if (defaultCharset != null) {
      return defaultCharset;
    }
  }
  return Charset.defaultCharset();
}
项目:tools-idea    文件:DefaultGroovyScriptRunner.java   
private static void addScriptEncodingSettings(final JavaParameters params, final VirtualFile scriptFile, Module module) {
  Charset charset = EncodingProjectManager.getInstance(module.getProject()).getEncoding(scriptFile, true);
  if (charset == null) {
    charset = EncodingManager.getInstance().getDefaultCharset();
    if (!Comparing.equal(CharsetToolkit.getDefaultSystemCharset(), charset)) {
      params.getProgramParametersList().add("--encoding=" + charset.displayName());
    }
  }
  else {
    params.getProgramParametersList().add("--encoding=" + charset.displayName());
  }
}
项目:consulo    文件:CompilerEncodingServiceImpl.java   
public CompilerEncodingServiceImpl(@Nonnull Project project) {
  myProject = project;
  myModuleFileEncodings = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Map<Module, Set<Charset>>>() {
    @Override
    public Result<Map<Module, Set<Charset>>> compute() {
      Map<Module, Set<Charset>> result = computeModuleCharsetMap();
      return Result.create(result, ProjectRootManager.getInstance(myProject),
                           ((EncodingProjectManagerImpl)EncodingProjectManager.getInstance(myProject)).getModificationTracker());
    }
  }, false);
}
项目:consulo    文件:CompilerEncodingServiceImpl.java   
@Nonnull
@Override
public Collection<Charset> getAllModuleEncodings(@Nonnull Module module) {
  final Set<Charset> encodings = myModuleFileEncodings.getValue().get(module);
  if (encodings != null) {
    return encodings;
  }
  return ContainerUtil.createMaybeSingletonList(EncodingProjectManager.getInstance(myProject).getDefaultCharset());
}
项目:consulo    文件:LocalFilePath.java   
@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();
}
项目:consulo    文件:VcsHistoryUtil.java   
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());
}
项目:consulo-java    文件:LossyEncodingTest.java   
public void testNativeConversion() throws Exception {
  configureFromFileText("x.properties","a=<caret>v");
  EncodingProjectManager.getInstance(getProject()).setNative2AsciiForPropertiesFiles(null, true);
  UIUtil.dispatchAllInvocationEvents();  //reload files

  type('\\');
  type('\\');

  Collection<HighlightInfo> infos = doHighlighting();
  assertEquals(0, infos.size());
}
项目:intellij-ce-playground    文件:JavaParameters.java   
public void setDefaultCharset(final Project project) {
  Charset encoding = EncodingProjectManager.getInstance(project).getDefaultCharset();
  setCharset(encoding);
}
项目:intellij-ce-playground    文件:CompilerEncodingServiceImpl.java   
@Override
@Nullable
public Charset getPreferredModuleEncoding(@NotNull Module module) {
  final Set<Charset> encodings = myModuleFileEncodings.getValue().get(module);
  return ContainerUtil.getFirstItem(encodings, EncodingProjectManager.getInstance(myProject).getDefaultCharset());
}
项目:intellij-ce-playground    文件:EncodingEnvironmentUtil.java   
private static Charset getCharset(Project project) {
  return (project != null ? EncodingProjectManager.getInstance(project) : EncodingManager.getInstance()).getDefaultCharset();
}
项目:intellij-ce-playground    文件:RemoteFilePath.java   
@NotNull
@Override
public Charset getCharset(@Nullable Project project) {
  EncodingManager em = project == null ? EncodingManager.getInstance() : EncodingProjectManager.getInstance(project);
  return em.getDefaultCharset();
}
项目:intellij-ce-playground    文件:PydevConsoleRunner.java   
@NotNull
private static Charset getProjectDefaultCharset(@NotNull Project project) {
  return EncodingProjectManager.getInstance(project).getDefaultCharset();
}
项目:intellij-ce-playground    文件:ResourceTypeInspectionTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();

  //noinspection StatementWithEmptyBody
  if (getName().equals("testNotAndroid")) {
    // Don't add an Android facet here; we're testing that we're a no-op outside of Android projects
    // since the inspection is registered at the .java source type level
    return;
  }

  // Module must have Android facet or resource type inspection will become a no-op
  if (AndroidFacet.getInstance(myModule) == null) {
    String sdkPath = AndroidTestBase.getDefaultTestSdkPath();
    String platform = AndroidTestBase.getDefaultPlatformDir();
    AndroidTestCase.addAndroidFacet(myModule, sdkPath, platform, true);
    Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk();
    assertNotNull(sdk);
    @SuppressWarnings("SpellCheckingInspection") SdkModificator sdkModificator = sdk.getSdkModificator();
    ExternalAnnotationsSupport.attachJdkAnnotations(sdkModificator);
    sdkModificator.commitChanges();
  }

  // Required by testLibraryRevocablePermissions (but placing it there leads to
  // test ordering issues)
  myFixture.addFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML,
                             "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                             "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
                             "    package=\"test.pkg.permissiontest\">\n" +
                             "\n" +
                             "    <uses-sdk android:minSdkVersion=\"17\" android:targetSdkVersion=\"23\" />" +
                             "\n" +
                             "    <permission\n" +
                             "        android:name=\"my.normal.P1\"\n" +
                             "        android:protectionLevel=\"normal\" />\n" +
                             "\n" +
                             "    <permission\n" +
                             "        android:name=\"my.dangerous.P2\"\n" +
                             "        android:protectionLevel=\"dangerous\" />\n" +
                             "\n" +
                             "    <uses-permission android:name=\"my.normal.P1\" />\n" +
                             "    <uses-permission android:name=\"my.dangerous.P2\" />\n" +
                             "\n" +
                             "</manifest>\n");
  myOldCharset = EncodingProjectManager.getInstance(getProject()).getDefaultCharsetName();
  EncodingProjectManager.getInstance(getProject()).setDefaultCharsetName("UTF-8");
}
项目:intellij-ce-playground    文件:ResourceTypeInspectionTest.java   
@Override
public void tearDown() throws Exception {
  EncodingProjectManager.getInstance(getProject()).setDefaultCharsetName(myOldCharset);
  super.tearDown();
}