@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); } }; }
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> newFormattingData(final HiddenLeafs leafs, final PreferenceKey key, final FormattingDataInit it) { if (key instanceof BlankLineKey) { return _newFormattingData(leafs, (BlankLineKey)key, it); } else if (key instanceof NewLineKey) { return _newFormattingData(leafs, (NewLineKey)key, it); } else if (key instanceof NewLineOrPreserveKey) { return _newFormattingData(leafs, (NewLineOrPreserveKey)key, it); } else if (key instanceof WhitespaceKey) { return _newFormattingData(leafs, (WhitespaceKey)key, it); } else if (key == null) { return _newFormattingData(leafs, (Void)null, it); } else if (key != null) { return _newFormattingData(leafs, key, it); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(leafs, key, it).toString()); } }
@Override protected void initialize(IAcceptor<PreferenceKey> acceptor) { acceptor.accept(create(INVALID_ACTION_USAGE, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(EMPTY_ENUM_LITERAL, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(EMPTY_KEYWORD, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(SPACES_IN_KEYWORD, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(INVALID_HIDDEN_TOKEN, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(INVALID_HIDDEN_TOKEN_FRAGMENT, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(INVALID_PACKAGE_REFERENCE_INHERITED, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(CROSS_REFERENCE_IN_ALTERNATIVES, SeverityConverter.SEVERITY_ERROR)); acceptor.accept(create(INVALID_METAMODEL_NAME, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(INVALID_PACKAGE_REFERENCE_EXTERNAL, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(INVALID_PACKAGE_REFERENCE_NOT_ON_CLASSPATH, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(INVALID_TERMINALRULE_NAME, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(DUPLICATE_ENUM_LITERAL, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(BIDIRECTIONAL_REFERENCE, SeverityConverter.SEVERITY_WARNING)); acceptor.accept(create(DISCOURAGED_RULE_NAME, SeverityConverter.SEVERITY_WARNING)); }
@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); } }; }
public IPreferenceValues getPreferenceValues(Resource context) { final IProject project = getProject(context); final IPreferenceStore store = project != null ? access.getContextPreferenceStore(project) : access.getPreferenceStore(); @SuppressWarnings("deprecation") final Map<String, String> computingMap = new MapMaker().makeComputingMap( new Function<String, String>() { public String apply(String input) { return store.getString(input); } }); return new IPreferenceValues() { public String getPreference(PreferenceKey key) { try { final String string = computingMap.get(key.getId()); return org.eclipse.jface.preference.IPreferenceStore.STRING_DEFAULT_DEFAULT.equals(string) ? key.getDefaultValue() : string; } catch (Exception e) { log.error("Error getting preference for key '"+key.getId()+"'.", e); return key.getDefaultValue(); } } }; }
/** * Values are provided from loaded properties file * * @param properties * the settings for the project (usually found in the preference-store) can be <code>null</code> */ public PropertiesFileBasedValuesProvider(Properties properties) { final Properties props = new Properties(properties); values = new IPreferenceValues() { @Override public String getPreference(PreferenceKey key) { return props.getProperty(key.getId(), key.getDefaultValue()); } }; }
@Override protected void initialize(IAcceptor<PreferenceKey> iAcceptor) { iAcceptor.accept(create(IssueCodes.NULL_SAFE_FEATURE_CALL_OF_PRIMITIVE_VALUED_FEATURE, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(createDelegate(IssueCodes.INSTANCE_ACCESS_TO_STATIC_MEMBER, COMPILER_PB_STATIC_ACCESS_RECEIVER)); iAcceptor.accept(create(IssueCodes.UNHANDLED_EXCEPTION, SeverityConverter.SEVERITY_IGNORE)); iAcceptor.accept(create(IssueCodes.EQUALS_WITH_NULL, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(createDelegate(IssueCodes.FORBIDDEN_REFERENCE, COMPILER_PB_FORBIDDEN_REFERENCE)); iAcceptor.accept(createDelegate(IssueCodes.DISCOURAGED_REFERENCE, COMPILER_PB_DISCOURAGED_REFERENCE)); iAcceptor.accept(create(IssueCodes.IMPORT_WILDCARD_DEPRECATED, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(createDelegate(IssueCodes.OBSOLETE_INSTANCEOF, COMPILER_PB_UNNECESSARY_TYPE_CHECK)); iAcceptor.accept(createDelegate(IssueCodes.OBSOLETE_CAST, COMPILER_PB_UNNECESSARY_TYPE_CHECK)); iAcceptor.accept(createDelegate(IssueCodes.IMPORT_UNUSED, COMPILER_PB_UNUSED_IMPORT)); iAcceptor.accept(createDelegate(IssueCodes.UNUSED_LOCAL_VARIABLE, COMPILER_PB_UNUSED_LOCAL)); iAcceptor.accept(create(IssueCodes.IMPORT_DUPLICATE, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(create(IssueCodes.VARIABLE_NAME_DISCOURAGED, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(create(IssueCodes.IMPORT_UNRESOLVED, SeverityConverter.SEVERITY_ERROR)); iAcceptor.accept(create(IssueCodes.JAVA_STYLE_TYPE_CAST, SeverityConverter.SEVERITY_ERROR)); iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(create(IssueCodes.CONSTANT_BOOLEAN_CONDITION, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(create(IssueCodes.UNREACHABLE_CASE, SeverityConverter.SEVERITY_ERROR)); iAcceptor.accept(create(IssueCodes.UNREACHABLE_IF_BLOCK, SeverityConverter.SEVERITY_ERROR)); iAcceptor.accept(create(IssueCodes.INCOMPLETE_CASES_ON_ENUM, SeverityConverter.SEVERITY_WARNING)); iAcceptor.accept(create(IssueCodes.OPERATION_WITHOUT_PARENTHESES, SeverityConverter.SEVERITY_IGNORE)); iAcceptor.accept(create(IssueCodes.COPY_JAVA_PROBLEMS, SeverityConverter.SEVERITY_IGNORE)); iAcceptor.accept(createDelegate(IssueCodes.DEPRECATED_MEMBER_REFERENCE, COMPILER_PB_DEPRECATION)); iAcceptor.accept(create(IssueCodes.DUPLICATE_TYPE, SeverityConverter.SEVERITY_ERROR)); iAcceptor.accept(create(IssueCodes.UNQUALIFIED_SUPER_CALL, getUnqualifiedSuperCallSeverity())); iAcceptor.accept(create(IssueCodes.ABSTRACT_METHOD_INVOCATION, getAbstractMethodInvocationSeverity())); }
public ConfigurableIssueCodesProvider() { final Map<String, PreferenceKey> map = Maps.newLinkedHashMap(); initialize(new IAcceptor<PreferenceKey>() { @Override public void accept(PreferenceKey prefKey) { map.put(prefKey.getId(), prefKey); } }); this.issueCodes = ImmutableMap.copyOf(map); }
@Override public void initialize(IPreferenceStoreAccess access) { IPreferenceStore store = access.getWritablePreferenceStore(); for (PreferenceKey prefKey : SadlPreferences.preferences()) { store.setDefault(prefKey.getId(), prefKey.getDefaultValue()); } }
/** Puts key-value pair */ public void put(PreferenceKey key, Object value) { put(key.getId(), value.toString()); }
@Override public String getPreference(PreferenceKey key) { return getValue(key.getId()); }
@SuppressWarnings("javadoc") public N4JSIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { super(preferenceValues, configurableIssueCodes, converter); this.configurableIssueCodes = configurableIssueCodes; }
@SuppressWarnings("javadoc") public N4MFIssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { super(preferenceValues, configurableIssueCodes, converter); this.configurableIssueCodes = configurableIssueCodes; }
protected PreferenceKey createDelegate(String id, String delegationKey) { return createDelegate(id, delegationKey, SeverityConverter.SEVERITY_WARNING); }
protected PreferenceKey createDelegate(String id, String delegationKey, String defaultSeverity) { String encodedDelegation = XbaseSeverityConverter.encodeDefaultSeverity(delegationKey, defaultSeverity); return create(id, encodedDelegation); }
public void cfg(final PreferenceKey key) { this.key = key; }
protected Function1<? super FormattableDocument, ? extends Iterable<FormattingData>> _newFormattingData(final HiddenLeafs leafs, final PreferenceKey key, final FormattingDataInit it) { Class<? extends PreferenceKey> _class = key.getClass(); String _plus = ("Unknown configuration key kind: " + _class); throw new RuntimeException(_plus); }
@Override protected void initialize(IAcceptor<PreferenceKey> iAcceptor) { super.initialize(iAcceptor); iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_ERROR)); }
public IssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) { this.preferenceValues = preferenceValues; this.configurableIssueCodes = configurableIssueCodes; this.converter = converter; }
/** * @since 2.14 */ protected void initialize(IAcceptor<PreferenceKey> iAcceptor) { iAcceptor.accept(create(IssueCodes.COPY_JAVA_PROBLEMS, SeverityConverter.SEVERITY_IGNORE)); }
/** * @since 2.14 */ protected final PreferenceKey create(String id, String defaultValue) { return new PreferenceKey(id, defaultValue); }
/** * @return all configurable issue codes. */ public Map<String, PreferenceKey> getConfigurableIssueCodes() { return issueCodes; }
public static final List<PreferenceKey> preferences() { return Arrays.asList(allKeys); }
/** * @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); }