本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}