List of usage examples for org.eclipse.jdt.core JavaCore CORE_ENCODING
String CORE_ENCODING
To view the source code for org.eclipse.jdt.core JavaCore CORE_ENCODING.
Click Source Link
From source file:com.codenvy.ide.ext.java.BaseTest.java
License:Open Source License
public BaseTest() { options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.CORE_ENCODING, "UTF-8"); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_7); options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED); options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.DISABLED); }
From source file:nz.ac.vuw.ecs.kcassell.GroovyTestProject.java
License:Apache License
public IFile createGroovyType(IPackageFragment pack, String cuName, String source) throws CoreException { StringBuffer buf = new StringBuffer(); if (!pack.getElementName().equals("")) { buf.append("package " + pack.getElementName() + ";" + System.getProperty("line.separator")); buf.append(System.getProperty("line.separator")); }//from w w w.j a v a 2 s. c o m buf.append(source); IContainer folder = (IContainer) pack.getResource(); String encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true); InputStream stream; try { stream = new ByteArrayInputStream( encoding == null ? buf.toString().getBytes() : buf.toString().getBytes(encoding)); } catch (UnsupportedEncodingException e) { throw new CoreException(new Status(IStatus.ERROR, "org.codehaus.groovy.eclipse.tests", IStatus.ERROR, "failed to create a groovy type", e)); } return createFile(folder, cuName, stream); }
From source file:org.ecipse.che.plugin.testing.testng.server.BaseTest.java
License:Open Source License
public BaseTest() { options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); options.put(JavaCore.CORE_ENCODING, "UTF-8"); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_8); options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED); options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.DISABLED); }
From source file:org.eclipse.che.jdt.JavaProjectService.java
License:Open Source License
@Inject public JavaProjectService(EventService eventService, LocalFSMountStrategy fsMountStrategy, @Named("che.java.codeassistant.index.dir") String temp) { eventService.subscribe(new VirtualFileEventSubscriber()); this.fsMountStrategy = fsMountStrategy; tempDir = temp;/*w ww. j av a 2 s. c o m*/ options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7); options.put(JavaCore.CORE_ENCODING, "UTF-8"); options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_7); options.put(CompilerOptions.OPTION_TargetPlatform, JavaCore.VERSION_1_7); options.put(AssistOptions.OPTION_PerformVisibilityCheck, AssistOptions.ENABLED); options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_TaskTags, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.WARNING); options.put(CompilerOptions.OPTION_SuppressWarnings, CompilerOptions.DISABLED); options.put(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); options.put(JavaCore.COMPILER_PB_UNUSED_PARAMETER_INCLUDE_DOC_COMMENT_REFERENCE, JavaCore.ENABLED); options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, JavaCore.ENABLED); options.put(CompilerOptions.OPTION_Process_Annotations, JavaCore.ENABLED); options.put(CompilerOptions.OPTION_GenerateClassFiles, JavaCore.ENABLED); cache = CacheBuilder.newBuilder().expireAfterAccess(4, TimeUnit.HOURS) .removalListener(new RemovalListener<String, JavaProject>() { @Override public void onRemoval(RemovalNotification<String, JavaProject> notification) { JavaProject value = notification.getValue(); if (value != null) { closeProject(value); deleteDependencyDirectory(value.getWsId(), value.getProjectPath()); } } }).build(); }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public Hashtable getDefaultOptions() { Hashtable defaultOptions = new Hashtable(10); // see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings // If modified, also modify the method getDefaultOptionsNoInitialization() IEclipsePreferences defaultPreferences = getDefaultPreferences(); // initialize preferences to their default Iterator iterator = this.optionNames.iterator(); while (iterator.hasNext()) { String propertyName = (String) iterator.next(); String value = defaultPreferences.get(propertyName, null); if (value != null) defaultOptions.put(propertyName, value); }//from w ww . jav a2 s . c o m // get encoding through resource plugin defaultOptions.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding()); // backward compatibility addDeprecatedOptions(defaultOptions); return defaultOptions; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public String getOption(String optionName) { if (JavaCore.CORE_ENCODING.equals(optionName)) { return JavaCore.getEncoding(); }/*from w w w . jav a2s .c o m*/ // backward compatibility if (isDeprecatedOption(optionName)) { return JavaCore.ERROR; } int optionLevel = getOptionLevel(optionName); if (optionLevel != UNKNOWN_OPTION) { IPreferencesService service = Platform.getPreferencesService(); String value = service.get(optionName, null, this.preferencesLookup); if (value == null && optionLevel == DEPRECATED_OPTION) { // May be a deprecated option, retrieve the new value in compatible options String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName); value = service.get(compatibleOptions[0], null, this.preferencesLookup); } return value == null ? null : value.trim(); } return null; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public Hashtable getOptions() { // return cached options if already computed Hashtable cachedOptions; // use a local variable to avoid race condition (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=256329 ) if ((cachedOptions = this.optionsCache) != null) { return new Hashtable(cachedOptions); }//from w ww . j av a 2 s . c o m if (!Platform.isRunning()) { this.optionsCache = getDefaultOptionsNoInitialization(); return new Hashtable(this.optionsCache); } // init Hashtable options = new Hashtable(10); IPreferencesService service = Platform.getPreferencesService(); // set options using preferences service lookup Iterator iterator = this.optionNames.iterator(); while (iterator.hasNext()) { String propertyName = (String) iterator.next(); String propertyValue = service.get(propertyName, null, this.preferencesLookup); if (propertyValue != null) { options.put(propertyName, propertyValue); } } // set deprecated options using preferences service lookup Iterator deprecatedEntries = this.deprecatedOptions.entrySet().iterator(); while (deprecatedEntries.hasNext()) { Entry entry = (Entry) deprecatedEntries.next(); String propertyName = (String) entry.getKey(); String propertyValue = service.get(propertyName, null, this.preferencesLookup); if (propertyValue != null) { options.put(propertyName, propertyValue); String[] compatibleOptions = (String[]) entry.getValue(); for (int co = 0, length = compatibleOptions.length; co < length; co++) { String compatibleOption = compatibleOptions[co]; if (!options.containsKey(compatibleOption)) options.put(compatibleOption, propertyValue); } } } // get encoding through resource plugin options.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding()); // backward compatibility addDeprecatedOptions(options); Util.fixTaskTags(options); // store built map in cache this.optionsCache = new Hashtable(options); // return built map return options; }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
public void setOptions(Hashtable newOptions) { Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions); IEclipsePreferences defaultPreferences = getDefaultPreferences(); IEclipsePreferences instancePreferences = getInstancePreferences(); if (newOptions == null) { try {/*from ww w . j a va 2s.c om*/ instancePreferences.clear(); } catch (BackingStoreException e) { // ignore } } else { Enumeration keys = newOptions.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); int optionLevel = getOptionLevel(key); if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option if (key.equals(JavaCore.CORE_ENCODING)) { if (cachedValue != null) { cachedValue.put(key, JavaCore.getEncoding()); } continue; // skipped, contributed by resource prefs } String value = (String) newOptions.get(key); String defaultValue = defaultPreferences.get(key, null); // Store value in preferences if (defaultValue != null && defaultValue.equals(value)) { value = null; } storePreference(key, value, instancePreferences); } try { // persist options instancePreferences.flush(); } catch (BackingStoreException e) { // ignore } } // update cache Util.fixTaskTags(cachedValue); this.optionsCache = cachedValue; }
From source file:org.grails.ide.eclipse.core.internal.classpath.GrailsPluginUtil.java
License:Open Source License
private static InputStream createInputStream(IProject dependent, String textToAdd) throws CoreException { String encoding = JavaCore.create(dependent).getOption(JavaCore.CORE_ENCODING, true); InputStream stream;/*from ww w . j a v a 2 s . c o m*/ try { stream = new ByteArrayInputStream( encoding == null ? textToAdd.getBytes() : textToAdd.getBytes(encoding)); } catch (UnsupportedEncodingException e) { throw new CoreException(new Status(IStatus.ERROR, GrailsCoreActivator.PLUGIN_ID, IStatus.ERROR, "failed to add plugin dependency", e)); } return stream; }
From source file:test.TestProject.java
License:Apache License
public IFile createGroovyType(IPackageFragment pack, String cuName, String source) throws CoreException { StringBuffer buf = new StringBuffer(); if (!pack.getElementName().equals("")) { //buf.append("package " + pack.getElementName() + ";" + System.getProperty("line.separator")); buf.append("package " + pack.getElementName() + System.getProperty("line.separator")); buf.append(System.getProperty("line.separator")); }/*from w w w. j ava 2 s .c o m*/ buf.append(source); IContainer folder = (IContainer) pack.getResource(); String encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true); InputStream stream; try { stream = new ByteArrayInputStream( encoding == null ? buf.toString().getBytes() : buf.toString().getBytes(encoding)); } catch (UnsupportedEncodingException e) { throw new CoreException(new Status(IStatus.ERROR, "org.codehaus.groovy.eclipse.tests", IStatus.ERROR, "failed to create a groovy type", e)); } return createFile(folder, cuName, stream); }