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


Java EncodingManager类代码示例

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


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


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