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


Java IEncodingProvider.Runtime方法代码示例

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


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

示例1: initializeEncoding

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
protected void initializeEncoding() {
  final IResourceServiceProvider.Registry serviceProviderRegistry = IResourceServiceProvider.Registry.INSTANCE;
  Object _get = serviceProviderRegistry.getExtensionToFactoryMap().get("xtext");
  final IResourceServiceProvider serviceProvider = ((IResourceServiceProvider) _get);
  String _elvis = null;
  if (this.grammarEncoding != null) {
    _elvis = this.grammarEncoding;
  } else {
    String _encoding = this.configuration.getCode().getEncoding();
    _elvis = _encoding;
  }
  final String encoding = _elvis;
  if (((serviceProvider != null) && (encoding != null))) {
    final IEncodingProvider encodingProvider = serviceProvider.<IEncodingProvider>get(IEncodingProvider.class);
    if ((encodingProvider instanceof IEncodingProvider.Runtime)) {
      ((IEncodingProvider.Runtime)encodingProvider).setDefaultEncoding(encoding);
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:XtextGenerator.java

示例2: fileEncodingSetup

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
public void fileEncodingSetup(final Collection<LanguageAccess> langs, final String encoding) {
  for (final LanguageAccess lang : langs) {
    IEncodingProvider _encodingProvider = lang.getEncodingProvider();
    final IEncodingProvider provider = _encodingProvider;
    boolean _matched = false;
    if (provider instanceof IEncodingProvider.Runtime) {
      _matched=true;
      ((IEncodingProvider.Runtime)provider).setDefaultEncoding(encoding);
    }
    if (!_matched) {
      this.forceDebugLog((((("Couldn\'t set encoding \'" + encoding) + "\' for provider \'") + provider) + 
        "\'. Only subclasses of IEncodingProvider.Runtime are supported."));
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:StandaloneBuilder.java

示例3: configureIEncodingProvider

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
public void configureIEncodingProvider(final Binder binder) {
  AnnotatedBindingBuilder<IEncodingProvider> _bind = binder.<IEncodingProvider>bind(IEncodingProvider.class);
  IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
  final Procedure1<IEncodingProvider.Runtime> _function = (IEncodingProvider.Runtime it) -> {
    it.setDefaultEncoding(this.code.getEncoding());
  };
  IEncodingProvider.Runtime _doubleArrow = ObjectExtensions.<IEncodingProvider.Runtime>operator_doubleArrow(_runtime, _function);
  _bind.toInstance(_doubleArrow);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:DefaultGeneratorModule.java

示例4: testTraceIsCreated

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
@Test
public void testTraceIsCreated() throws Exception {
	File file = null;
	try {

		JavaIoFileSystemAccess fileSystemAccess = new JavaIoFileSystemAccess(
				IResourceServiceProvider.Registry.INSTANCE, new IEncodingProvider.Runtime(),
				new TraceFileNameProvider(), new TraceRegionSerializer());

		File tmpDir = configureFileSystemAccess(fileSystemAccess);
		SourceRelativeURI uri = new SourceRelativeURI(URI.createURI("foo/bar"));
		CharSequenceTraceWrapper wrapper = new CharSequenceTraceWrapper();
		fileSystemAccess.generateFile("tmp/X", wrapper.wrapWithTraceData("XX", uri, 0, 10, 0, 1));

		file = new File(tmpDir, "tmp/X");
		assertTrue(file.exists());
		assertTrue(file.isFile());
		assertEquals("XX", fileSystemAccess.readTextFile("tmp/X"));

		file = new File(tmpDir, "tmp/.X._trace");
		assertTrue(file.exists());
		assertTrue(file.isFile());

	} finally {
		if (file != null)
			file.delete();
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:29,代码来源:JavaIoFileSystemAccessTest.java

示例5: setUp

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
	super.setUp();
	with(UnicodeTestLanguageStandaloneSetup.class);
	IEncodingProvider.Runtime encodingProvider = get(IEncodingProvider.Runtime.class);
	encodingProvider.setDefaultEncoding(getCharsetForTest().name());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:UnicodeTest.java

示例6: bindIEncodingProvider

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
protected Class<? extends IEncodingProvider> bindIEncodingProvider() {
  return IEncodingProvider.Runtime.class;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:StandaloneBuilderModule.java

示例7: bindRuntimeEncodingProvider

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
/**
 * @since 2.8
 */
public Class<? extends IEncodingProvider.Runtime> bindRuntimeEncodingProvider() {
	return EclipseProjectPropertiesEncodingProvider.class;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:7,代码来源:DefaultRuntimeModule.java

示例8: testDirsAndFilesAreCreated

import org.eclipse.xtext.parser.IEncodingProvider; //导入方法依赖的package包/类
@Test
public void testDirsAndFilesAreCreated() throws Exception {
	File dir = null;
	File textFile = null;
	File binFile = null;
	try {
		JavaIoFileSystemAccess fileSystemAccess = new JavaIoFileSystemAccess(
				IResourceServiceProvider.Registry.INSTANCE, new IEncodingProvider.Runtime());

		File tmpDir = configureFileSystemAccess(fileSystemAccess);
		fileSystemAccess.generateFile("tmp/X", "XX");
		fileSystemAccess.generateFile("tmp/Y", new StringInputStream("\1\2\3"));

		dir = new File(tmpDir, "tmp");
		assertTrue(dir.exists());
		assertTrue(dir.isDirectory());

		textFile = new File(dir, "X");
		assertTrue(textFile.exists());
		assertTrue(textFile.isFile());
		assertEquals("XX", fileSystemAccess.readTextFile("tmp/X"));

		binFile = new File(dir, "Y");
		assertTrue(binFile.exists());
		assertFalse(fileSystemAccess.isFile("tmp", IFileSystemAccess.DEFAULT_OUTPUT)); // isFile evaluates to false for directories
		assertTrue(fileSystemAccess.isFile("tmp/Y", IFileSystemAccess.DEFAULT_OUTPUT));
		assertTrue(binFile.isFile());
		InputStream stream = fileSystemAccess.readBinaryFile("tmp/Y");
		try {
			assertEquals("\1\2\3", new String(ByteStreams.toByteArray(stream)));
		} finally {
			stream.close();
		}

	} finally {
		try {
			if (textFile != null)
				textFile.delete();
		} finally {
			try {
				if (binFile != null)
					binFile.delete();
			} finally {
				if (dir != null)
					dir.delete();
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:50,代码来源:JavaIoFileSystemAccessTest.java


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