• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EncodingManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



EncodingManager类属于com.intellij.openapi.vfs.encoding包,在下文中一共展示了EncodingManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testText

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void testText() throws Exception {
  doTest("Text.txt");
  Charset ascii = CharsetToolkit.forName("US-ASCII");
  VirtualFile myVFile = myFile.getVirtualFile();
  FileDocumentManager.getInstance().saveAllDocuments();
  EncodingManager.getInstance().setEncoding(myVFile, ascii);
  UIUtil.dispatchAllInvocationEvents(); // wait for reload requests to bubble up
  assertEquals(ascii, myVFile.getCharset());
  int start = myEditor.getCaretModel().getOffset();
  type((char)0x445);
  type((char)0x438);
  int end = myEditor.getCaretModel().getOffset();

  Collection<HighlightInfo> infos = doHighlighting();
  HighlightInfo info = assertOneElement(infos);
  assertEquals("Unsupported characters for the charset 'US-ASCII'", info.getDescription());
  assertEquals(start, info.startOffset);
  assertEquals(end, info.endOffset);

  backspace();
  backspace();

  doDoTest(true, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LossyEncodingTest.java


示例2: testUsageViewDoesNotHoldPsiFilesOrDocuments

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void testUsageViewDoesNotHoldPsiFilesOrDocuments() throws Exception {
  PsiFile psiFile = myFixture.addFileToProject("X.java", "public class X{} //iuggjhfg");
  Usage[] usages = new Usage[100];
  for (int i = 0; i < usages.length; i++) {
    usages[i] = createUsage(psiFile,i);
  }

  UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, usages, new UsageViewPresentation(), null);

  Disposer.register(getTestRootDisposable(), usageView);

  ((EncodingManagerImpl)EncodingManager.getInstance()).clearDocumentQueue();
  FileDocumentManager.getInstance().saveAllDocuments();
  UIUtil.dispatchAllInvocationEvents();

  LeakHunter.checkLeak(usageView, PsiFileImpl.class);
  LeakHunter.checkLeak(usageView, Document.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:UsageViewTest.java


示例3: execute

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
protected synchronized void execute(GeneralCommandLine commandLine) throws AuthenticationException {
  try {
    commandLine.withParentEnvironmentType(ParentEnvironmentType.CONSOLE);
    myProcess = commandLine.createProcess();

    myErrThread = new ReadProcessThread(
      new BufferedReader(new InputStreamReader(myProcess.getErrorStream(), EncodingManager.getInstance().getDefaultCharset()))) {
      protected void textAvailable(String s) {
        myErrorText.append(s);
        myErrorRegistry.registerError(s);
        myContainsError = true;
      }
    };
    final Application application = ApplicationManager.getApplication();
    myStdErrFuture = application.executeOnPooledThread(myErrThread);

    myInputStream = myProcess.getInputStream();
    myOutputStream = myProcess.getOutputStream();

    waitForProcess(application);
  }
  catch (Exception e) {
    closeInternal();
    throw new AuthenticationException(e.getLocalizedMessage(), e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ConnectionOnProcess.java


示例4: createMockApplication

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public static void createMockApplication(Disposable parentDisposable) {
  final BlazeMockApplication instance = new BlazeMockApplication(parentDisposable);

  // If there was no previous application,
  // ApplicationManager leaves the MockApplication in place, which can break future tests.
  Application oldApplication = ApplicationManager.getApplication();
  if (oldApplication == null) {
    Disposer.register(
        parentDisposable,
        () -> {
          new ApplicationManager() {
            {
              ourApplication = null;
            }
          };
        });
  }

  ApplicationManager.setApplication(instance, FileTypeManager::getInstance, parentDisposable);
  instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:TestUtils.java


示例5: createMockApplication

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
/**
 * For every #createMockApplication there needs to be a corresponding call to
 * #disposeMockApplication when the test is complete.
 */
public static Disposable createMockApplication() {
  Disposable parentDisposable = getParentDisposableForCleanup();

  final PluginMockApplication instance = new PluginMockApplication(parentDisposable);

  ApplicationManager.setApplication(
      instance,
      new Getter<FileTypeRegistry>() {
        @Override
        public FileTypeRegistry get() {
          return FileTypeManager.getInstance();
        }
      },
      parentDisposable);
  instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
  return parentDisposable;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:22,代码来源:TestUtils.java


示例6: testText

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void testText() throws Exception {
  doTest("Text.txt");
  Charset ascii = CharsetToolkit.forName("US-ASCII");
  EncodingManager.getInstance().setEncoding(myVFile, ascii);
  assertEquals(ascii, myVFile.getCharset());
  int start = myEditor.getCaretModel().getOffset();
  type((char)0x445);
  type((char)0x438);
  int end = myEditor.getCaretModel().getOffset();

  Collection<HighlightInfo> infos = doHighlighting();
  HighlightInfo info = assertOneElement(infos);
  assertEquals("Unsupported characters for the charset 'US-ASCII'", info.getDescription());
  assertEquals(start, info.startOffset);
  assertEquals(end, info.endOffset);

  backspace();
  backspace();
  doTestConfiguredFile(true, false, null);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:LossyEncodingTest.java


示例7: initApplication

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void initApplication() {
  //if (ApplicationManager.getApplication() instanceof MockApplicationEx) return;
  final MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable());
  ApplicationManager.setApplication(instance,
                                    new Getter<FileTypeRegistry>() {
                                      @Override
                                      public FileTypeRegistry get() {
                                        return FileTypeManager.getInstance();
                                      }
                                    },
                                    new Getter<EncodingRegistry>() {
                                      @Override
                                      public EncodingRegistry get() {
                                        return EncodingManager.getInstance();
                                      }
                                    },
                                    getTestRootDisposable());
  getApplication().registerService(EncodingManager.class, EncodingManagerImpl.class);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:PlatformLiteFixture.java


示例8: EditorChangeAction

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public EditorChangeAction(DocumentEx document,
                          int offset,
                          CharSequence oldString,
                          CharSequence newString,
                          long oldTimeStamp) {
  super(document);

  Charset charset = EncodingManager.getInstance().getEncoding(FileDocumentManager.getInstance().getFile(document), false);
  myCharset = charset == null ? Charset.defaultCharset() : charset;

  myOffset = offset;
  myOldString = oldString == null ? "" : compressCharSequence(oldString, myCharset);
  myNewString = newString == null ? "" : compressCharSequence(newString, myCharset);
  myOldTimeStamp = oldTimeStamp;
  myNewTimeStamp = document.getModificationStamp();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:EditorChangeAction.java


示例9: testUsageViewDoesNotHoldPsiFilesOrDocuments

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void testUsageViewDoesNotHoldPsiFilesOrDocuments() throws Exception {
  PsiFile psiFile = createFile("X.java", "public class X{} //iuggjhfg");
  Usage[] usages = new Usage[100];
  for (int i = 0; i < usages.length; i++) {
    usages[i] = createUsage(psiFile,i);
  }

  UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, usages, new UsageViewPresentation(), null);

  Disposer.register(getTestRootDisposable(), usageView);

  ((EncodingManagerImpl)EncodingManager.getInstance()).clearDocumentQueue();
  FileDocumentManager.getInstance().saveAllDocuments();
  UIUtil.dispatchAllInvocationEvents();

  LeakHunter.checkLeak(usageView, PsiFileImpl.class);
  LeakHunter.checkLeak(usageView, Document.class);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:UsageViewTest.java


示例10: 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


示例11: execute

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
protected synchronized void execute(GeneralCommandLine commandLine) throws AuthenticationException {
  try {
    commandLine.setPassParentEnvironment(true);
    myProcess = commandLine.createProcess();

    myErrThread = new ReadProcessThread(
      new BufferedReader(new InputStreamReader(myProcess.getErrorStream(), EncodingManager.getInstance().getDefaultCharset()))) {
      protected void textAvailable(String s) {
        myErrorText.append(s);
        myErrorRegistry.registerError(s);
        myContainsError = true;
      }
    };
    final Application application = ApplicationManager.getApplication();
    myStdErrFuture = application.executeOnPooledThread(myErrThread);

    myInputStream = myProcess.getInputStream();
    myOutputStream = myProcess.getOutputStream();

    waitForProcess(application);
  }
  catch (Exception e) {
    closeInternal();
    throw new AuthenticationException(e.getLocalizedMessage(), e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:ConnectionOnProcess.java


示例12: 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


示例13: testNativeEncoding

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void testNativeEncoding() throws Exception {
  EncodingManager.getInstance().setNative2AsciiForPropertiesFiles(null, true);
  UIUtil.dispatchAllInvocationEvents();
  configureByFile(BASE_PATH + "/" + "NativeEncoding.properties");

  doDoTest(true, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:LossyEncodingTest.java


示例14: 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


示例15: initApplication

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
public void initApplication() {
  //if (ApplicationManager.getApplication() instanceof MockApplicationEx) return;
  final MockApplicationEx instance = new MockApplicationEx(getTestRootDisposable());
  ApplicationManager.setApplication(instance,
                                    new Getter<FileTypeRegistry>() {
                                      @Override
                                      public FileTypeRegistry get() {
                                        return FileTypeManager.getInstance();
                                      }
                                    },
                                    getTestRootDisposable());
  getApplication().registerService(EncodingManager.class, EncodingManagerImpl.class);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PlatformLiteFixture.java


示例16: cachedCharsetFromContent

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
@Nullable("returns null if charset set cannot be determined from content")
private static Charset cachedCharsetFromContent(final VirtualFile virtualFile) {
  if (virtualFile == null) return null;
  final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
  if (document == null) return null;

  return EncodingManager.getInstance().getCachedCharsetFromContent(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:EncodingPanel.java


示例17: doExecute

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
@NotNull
private static OSProcessHandler doExecute(@NotNull String exePath,
                                          @Nullable String workingDirectory,
                                          @Nullable VirtualFile scriptFile,
                                          String[] parameters,
                                          @Nullable Charset charset) throws ExecutionException {
  GeneralCommandLine commandLine = new GeneralCommandLine(exePath);
  if (scriptFile != null) {
    commandLine.addParameter(scriptFile.getPresentableUrl());
  }
  commandLine.addParameters(parameters);

  if (workingDirectory != null) {
    commandLine.setWorkDirectory(workingDirectory);
  }

  LOG.debug("Command line: ", commandLine.getCommandLineString());
  LOG.debug("Command line env: ", commandLine.getEnvironment());

  if (charset == null) {
    charset = EncodingManager.getInstance().getDefaultCharset();
  }
  final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine.createProcess(),
                                                                    commandLine.getCommandLineString(),
                                                                    charset);
  if (LOG.isDebugEnabled()) {
    processHandler.addProcessListener(new ProcessAdapter() {
      @Override
      public void onTextAvailable(ProcessEvent event, Key outputType) {
        LOG.debug(outputType + ": " + event.getText());
      }
    });
  }

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


示例18: tuple

import com.intellij.openapi.vfs.encoding.EncodingManager; //导入依赖的package包/类
@Nullable("null means no luck, otherwise it's tuple(guessed encoding, hint about content if was unable to guess, BOM)")
public static Trinity<Charset, CharsetToolkit.GuessedEncoding, byte[]> guessFromContent(@NotNull VirtualFile virtualFile, @NotNull byte[] content, int length) {
  Charset defaultCharset = ObjectUtils.notNull(EncodingManager.getInstance().getEncoding(virtualFile, true), CharsetToolkit.getDefaultSystemCharset());
  CharsetToolkit toolkit = GUESS_UTF ? new CharsetToolkit(content, defaultCharset) : null;
  String detectedFromBytes = null;
  try {
    if (GUESS_UTF) {
      toolkit.setEnforce8Bit(true);
      Charset charset = toolkit.guessFromBOM();
      if (charset != null) {
        detectedFromBytes = AUTO_DETECTED_FROM_BOM;
        byte[] bom = ObjectUtils.notNull(CharsetToolkit.getMandatoryBom(charset), CharsetToolkit.UTF8_BOM);
        return Trinity.create(charset, null, bom);
      }
      CharsetToolkit.GuessedEncoding guessed = toolkit.guessFromContent(length);
      if (guessed == CharsetToolkit.GuessedEncoding.VALID_UTF8) {
        detectedFromBytes = "auto-detected from bytes";
        return Trinity.create(CharsetToolkit.UTF8_CHARSET, guessed, null); //UTF detected, ignore all directives
      }
      if (guessed == CharsetToolkit.GuessedEncoding.SEVEN_BIT) {
        return Trinity.create(null, guessed, null);
      }
    }
    return null;
  }
  finally {
    setCharsetWasDetectedFromBytes(virtualFile, detectedFromBytes);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:LoadTextUtil.java


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RMPolicyProvider类代码示例发布时间:2022-05-22
下一篇:
Java Uid类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap