Java Code Examples for org.eclipse.xtext.preferences.IPreferenceValues#getPreference()
The following examples show how to use
org.eclipse.xtext.preferences.IPreferenceValues#getPreference() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4JSSimpleFormattingPreferenceProvider.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public IPreferenceValues getPreferenceValues(Resource context) { final IPreferenceValues preferenceValues = super.getPreferenceValues(context); return new IPreferenceValues() { @Override public String getPreference(PreferenceKey key) { if (key == N4JSFormatterPreferenceKeys.FORMAT_PARENTHESIS) { return Boolean.TRUE.toString(); // TODO make this configurable, see super-class } if (key == N4JSFormatterPreferenceKeys.FORMAT_SURROUND_PAREN_CONTENT_WITH_SPACE) { return Boolean.FALSE.toString(); // TODO make this configurable, see super-class } return preferenceValues.getPreference(key); } }; }
Example 2
Source File: XtendTaskTagProvider.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public TaskTags getTaskTags(final Resource resource) { TaskTags _xblockexpression = null; { final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource); PreferenceKey _preferenceKey = new PreferenceKey(JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX"); final String namePref = prefs.getPreference(_preferenceKey); PreferenceKey _preferenceKey_1 = new PreferenceKey(JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL"); final String prioritiesPref = prefs.getPreference(_preferenceKey_1); PreferenceKey _preferenceKey_2 = new PreferenceKey(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED); final String caseSensitivePref = prefs.getPreference(_preferenceKey_2); final List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(namePref, prioritiesPref); TaskTags _taskTags = new TaskTags(); final Procedure1<TaskTags> _function = (TaskTags it) -> { List<TaskTag> _taskTags_1 = it.getTaskTags(); Iterables.<TaskTag>addAll(_taskTags_1, tags); it.setCaseSensitive(caseSensitivePref.equals(JavaCore.ENABLED)); }; _xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function); } return _xblockexpression; }
Example 3
Source File: FormatterPreferenceValuesProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public IPreferenceValues getPreferenceValues(final Resource resource) { final IPreferenceValues preferenceValues = internalGetRawPreferenceValues(resource); final String indent = whitespaceInfo.getIndentationInformation(resource.getURI()).getIndentString(); final String lineSep = whitespaceInfo.getLineSeparatorInformation(resource.getURI()).getLineSeparator(); return new IPreferenceValues() { @Override public String getPreference(PreferenceKey key) { if (key == FormatterPreferenceKeys.indentation) { return indent; } if (key == FormatterPreferenceKeys.lineSeparator) { return lineSep; } return preferenceValues.getPreference(key); } }; }
Example 4
Source File: SarlTaskTagProvider.java From sarl with Apache License 2.0 | 6 votes |
@Override public TaskTags getTaskTags(Resource resource) { final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource); final String namePref = prefs.getPreference(new PreferenceKey( JavaCore.COMPILER_TASK_TAGS, "TODO,FIXME,XXX")); //$NON-NLS-1$ final String prioritiesPref = prefs.getPreference(new PreferenceKey( JavaCore.COMPILER_TASK_PRIORITIES, "NORMAL,HIGH,NORMAL")); //$NON-NLS-1$ final String caseSensitivePref = prefs.getPreference(new PreferenceKey( JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED)); final List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(namePref, prioritiesPref); final TaskTags taskTags = new TaskTags(); taskTags.setCaseSensitive(caseSensitivePref.equals(JavaCore.ENABLED)); taskTags.getTaskTags().addAll(tags); return taskTags; }
Example 5
Source File: ImportSpacerUserPreferenceHelper.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Compute user preference regarding space between import specifiers and curly brace. */ public String getSpacingPreference(Resource resource) { IPreferenceValues prefValues = formattingPreferenceProvider.getPreferenceValues(resource); String spacePreference = prefValues.getPreference( N4JSFormatterPreferenceKeys.FORMAT_SURROUND_IMPORT_LIST_WITH_SPACE); return Boolean.valueOf(spacePreference) ? " " : ""; }
Example 6
Source File: FormattingUserPreferenceHelper.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Compute user preference regarding space between import specifiers and curly brace. */ public String getSpacingPreference(Resource resource) { IPreferenceValues prefValues = formattingPreferenceProvider.getPreferenceValues(resource); String spacePreference = prefValues.getPreference( N4JSFormatterPreferenceKeys.FORMAT_SURROUND_IMPORT_LIST_WITH_SPACE); return Boolean.valueOf(spacePreference) ? " " : ""; }
Example 7
Source File: PreferenceTaskTagProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public TaskTags getTaskTags(Resource resource) { IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource); String names = prefs.getPreference(PreferenceTaskTagProvider.TAGS_KEY); String priorities = prefs.getPreference(PreferenceTaskTagProvider.PRIORITIES_KEY); TaskTags taskTags = new TaskTags(); taskTags.setCaseSensitive(Boolean.valueOf(prefs.getPreference(PreferenceTaskTagProvider.CASE_SENSITIVE_KEY))); List<TaskTag> tags = PreferenceTaskTagProvider.parseTags(names, priorities); taskTags.getTaskTags().addAll(tags); return taskTags; }
Example 8
Source File: N4JSPreferenceAccess.java From n4js with Eclipse Public License 1.0 | 3 votes |
/** * @param resource * the current resource, this will be used to calculate the preference store to access (e.g. if there are * project specific preferences configured). * @param compilerID * the compiler id * @param compilerProperty * the compiler property to ask for * @param defaultDescriptor * the descriptor containing the default values to be used as fall back if there isn't a value in the * preference store * @return the preference value found in the preference store or any other values provider or the default value out * of the default descriptor */ public String getPreference(Resource resource, String compilerID, CompilerProperties compilerProperty, CompilerDescriptor defaultDescriptor) { IPreferenceValues preferences = valuesProvider.getPreferenceValues(resource); PreferenceKey key = new PreferenceKey(compilerProperty.getKey(compilerID), String.valueOf(compilerProperty.getValueInCompilerDescriptor(defaultDescriptor, compilerID))); return preferences.getPreference(key); }