org.eclipse.xtext.preferences.PreferenceKey Java Examples

The following examples show how to use org.eclipse.xtext.preferences.PreferenceKey. 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: XtextConfigurableIssueCodes.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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_FRAGMENT_AS_FIRST_RULE, 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_JAVAPACKAGE_NAME, SeverityConverter.SEVERITY_IGNORE));
	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));
	acceptor.accept(create(USAGE_OF_DEPRECATED_RULE, SeverityConverter.SEVERITY_WARNING));
	
}
 
Example #2
Source File: ConfigurableIssueSeveritiesProvider.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public String getPreference(PreferenceKey key) {
	if (key != null) {
		final Severity severity = this.overridingSeverities.get(key.getId());
		if (severity != null) {
			switch (severity) {
			case ERROR:
				return SeverityConverter.SEVERITY_ERROR;
			case IGNORE:
				return SeverityConverter.SEVERITY_IGNORE;
			case INFO:
				return SeverityConverter.SEVERITY_INFO;
			case WARNING:
				return SeverityConverter.SEVERITY_WARNING;
			default:
			}
		}
	}
	return this.original.getPreference(key);
}
 
Example #3
Source File: XbaseValidationConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected Combo addJavaDelegatingComboBox(String prefKey, String label, Composite parent, int indent) {
	PreferenceKey preferenceKey = issueCodeProvider.getConfigurableIssueCodes().get(prefKey);
	if (preferenceKey == null) {
		throw new IllegalArgumentException(prefKey
				+ " not registered in the corresponding ConfigurableIssueCodesProvider");
	}
	String javaIssueCode = preferenceKey.getDefaultValue();
	if (!javaIssueCode.startsWith(JavaCore.PLUGIN_ID)) {
		throw new IllegalArgumentException(prefKey + Messages.XbaseValidationConfigurationBlock_not_java_message);
	}
	String[] values = new String[] { SeverityConverter.SEVERITY_ERROR, SeverityConverter.SEVERITY_WARNING,
			SeverityConverter.SEVERITY_INFO, SeverityConverter.SEVERITY_IGNORE, javaIssueCode };
	String javaValue = javaValue(javaIssueCode);
	String[] valueLabels = new String[] { org.eclipse.xtext.ui.validation.Messages.ValidationConfigurationBlock_error,
			org.eclipse.xtext.ui.validation.Messages.ValidationConfigurationBlock_warning, org.eclipse.xtext.ui.validation.Messages.ValidationConfigurationBlock_info,
			org.eclipse.xtext.ui.validation.Messages.ValidationConfigurationBlock_ignore,
			NLS.bind(Messages.XbaseValidationConfigurationBlock_java_label, javaValue) };
	Combo comboBox = addComboBox(parent, label, prefKey, indent, values, valueLabels);
	return comboBox;
}
 
Example #4
Source File: XtendTaskTagProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #5
Source File: N4JSSimpleFormattingPreferenceProvider.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@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 #6
Source File: SarlTaskTagProvider.java    From sarl with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: FormatterPreferenceValuesProvider.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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 #8
Source File: FormattingDataFactory.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
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());
  }
}
 
Example #9
Source File: XtendConfigurableIssueCodes.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	super.initialize(iAcceptor);
	iAcceptor.accept(create(IssueCodes.SINGLE_DISPATCH_FUNCTION, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.DISPATCH_PLAIN_FUNCTION_NAME_CLASH, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.DISPATCH_FUNCTIONS_DIFFERENT_PRIMITIVE_ARGS, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.INVALID_OPERATOR_SIGNATURE, SeverityConverter.SEVERITY_ERROR));
	iAcceptor.accept(createDelegate(IssueCodes.UNUSED_PRIVATE_MEMBER, JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER));
	iAcceptor.accept(createDelegate(IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC, JavaCore.COMPILER_PB_INVALID_JAVADOC, SeverityConverter.SEVERITY_IGNORE));
	iAcceptor.accept(create(IssueCodes.API_TYPE_INFERENCE, SeverityConverter.SEVERITY_IGNORE));
	iAcceptor.accept(create(IssueCodes.IMPLICIT_RETURN, SeverityConverter.SEVERITY_IGNORE));
	iAcceptor.accept(create(IssueCodes.ORPHAN_ELEMENT, SeverityConverter.SEVERITY_IGNORE));
	iAcceptor.accept(create(IssueCodes.WRONG_FILE, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.UNNECESSARY_MODIFIER, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.MODIFIER_DOES_NOT_MATCH_TYPENAME, SeverityConverter.SEVERITY_WARNING));
	iAcceptor.accept(create(IssueCodes.TERNARY_EXPRESSION_NOT_ALLOWED, SeverityConverter.SEVERITY_IGNORE));		
	// overwrite xbase default
	iAcceptor.accept(create(org.eclipse.xtext.validation.IssueCodes.COPY_JAVA_PROBLEMS, SeverityConverter.SEVERITY_ERROR));
}
 
Example #10
Source File: ConfigurableIssueCodesProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: EclipsePreferencesProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IPreferenceValues getPreferenceValues(Resource context) {
	final IProject project = getProject(context);
	final IPreferenceStore store = project != null ?
		access.getContextPreferenceStore(project) :
		access.getPreferenceStore();
		
	final Map<String, String> preferenceCache = Maps.newHashMap();
	
	return new IPreferenceValues() {
		@Override
		public String getPreference(PreferenceKey key) {
			try {
				String id = key.getId();
				String string = preferenceCache.get(id);
				if (string == null) {
					string = store.getString(id);
					preferenceCache.put(id, string);
				}
				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();
			}
		}
	};
}
 
Example #12
Source File: ConfigurableIssueCodesPreferenceStoreInitializer.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void initialize(IPreferenceStoreAccess preferenceStoreAccess) {
	IPreferenceStore preferenceStore = preferenceStoreAccess.getWritablePreferenceStore();
	for (PreferenceKey prefKey : issueCodesProvider.getConfigurableIssueCodes().values()) {
		preferenceStore.setDefault(prefKey.getId(), prefKey.getDefaultValue());
	}
}
 
Example #13
Source File: UIConfigurableIssueSeveritiesProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void setSeverity(String code, Severity severity) {
	if (!Strings.isNullOrEmpty(code)) {
		final PreferenceKey key = this.issueCodesProvider.getConfigurableIssueCodes().get(code);
		if (key != null) {
			if (severity == null) {
				this.overridingSeverities.remove(key.getId());
			} else {
				this.overridingSeverities.put(key.getId(), severity);
			}
		}
	}
}
 
Example #14
Source File: XbaseConfigurableIssueCodes.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@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()));
}
 
Example #15
Source File: UIConfigurableIssueSeveritiesProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void setAllSeverities(Severity severity) {
	this.overridingSeverities.clear();
	if (severity != null) {
		for (final PreferenceKey key : this.issueCodesProvider.getConfigurableIssueCodes().values()) {
			if (key != null) {
				this.overridingSeverities.put(key.getId(), severity);
			}
		}
	}
}
 
Example #16
Source File: ConfigurableIssueSeveritiesProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void setSeverity(String code, Severity severity) {
	if (!Strings.isNullOrEmpty(code)) {
		final PreferenceKey key = this.issueCodesProvider.getConfigurableIssueCodes().get(code);
		if (key != null) {
			if (severity == null) {
				this.overridingSeverities.remove(key.getId());
			} else {
				this.overridingSeverities.put(key.getId(), severity);
			}
		}
	}
}
 
Example #17
Source File: ConfigurableIssueSeveritiesProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public void setAllSeverities(Severity severity) {
	this.overridingSeverities.clear();
	if (severity != null) {
		for (final PreferenceKey key : this.issueCodesProvider.getConfigurableIssueCodes().values()) {
			if (key != null) {
				this.overridingSeverities.put(key.getId(), severity);
			}
		}
	}
}
 
Example #18
Source File: ConfigurableIssueCodesProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.14
 */
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	iAcceptor.accept(create(IssueCodes.COPY_JAVA_PROBLEMS, SeverityConverter.SEVERITY_IGNORE));
}
 
Example #19
Source File: ValidatorFragment2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.14
 */
protected GeneratedJavaFileAccess generateIssueProvider() {
  final GeneratedJavaFileAccess javaFile = this.fileAccessFactory.createGeneratedJavaFile(this.getConfigurableIssueCodesProviderClass());
  StringConcatenationClient _client = new StringConcatenationClient() {
    @Override
    protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
      _builder.append("@SuppressWarnings(\"restriction\")");
      _builder.newLine();
      _builder.append("public class ");
      TypeReference _configurableIssueCodesProviderClass = ValidatorFragment2.this.getConfigurableIssueCodesProviderClass();
      _builder.append(_configurableIssueCodesProviderClass);
      _builder.append(" extends ");
      TypeReference _superConfigurableIssueCodesProviderClass = ValidatorFragment2.this.getSuperConfigurableIssueCodesProviderClass();
      _builder.append(_superConfigurableIssueCodesProviderClass);
      _builder.append(" {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("protected static final String ISSUE_CODE_PREFIX = \"");
      String _runtimeBasePackage = ValidatorFragment2.this._xtextGeneratorNaming.getRuntimeBasePackage(ValidatorFragment2.this.getGrammar());
      _builder.append(_runtimeBasePackage, "\t");
      _builder.append(".\";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      {
        if (ValidatorFragment2.this.generateDeprecationValidation) {
          _builder.append("\t");
          _builder.append("public static final String DEPRECATED_MODEL_PART = ISSUE_CODE_PREFIX + \"deprecatedModelPart\";");
          _builder.newLine();
        }
      }
      _builder.newLine();
      _builder.append("\t");
      _builder.append("@Override");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("protected void initialize(");
      _builder.append(IAcceptor.class, "\t");
      _builder.append("<");
      _builder.append(PreferenceKey.class, "\t");
      _builder.append("> acceptor) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("super.initialize(acceptor);");
      _builder.newLine();
      {
        if (ValidatorFragment2.this.generateDeprecationValidation) {
          _builder.append("\t\t");
          _builder.append("acceptor.accept(create(DEPRECATED_MODEL_PART, ");
          _builder.append(SeverityConverter.class, "\t\t");
          _builder.append(".SEVERITY_WARNING));");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
    }
  };
  javaFile.setContent(_client);
  return javaFile;
}
 
Example #20
Source File: ConfigurableIssueCodesProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.14
 */
protected final PreferenceKey create(String id, String defaultValue) {
	return new PreferenceKey(id, defaultValue);
}
 
Example #21
Source File: ConfigurableIssueCodesProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @return all configurable issue codes.
 */
public Map<String, PreferenceKey> getConfigurableIssueCodes() {
	return issueCodes;
}
 
Example #22
Source File: Preferences.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public String getPreference(PreferenceKey key) {
	return getValue(key.getId());
}
 
Example #23
Source File: HelloWorldConfigurableIssueCodesProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> acceptor) {
	super.initialize(acceptor);
	acceptor.accept(create(DEPRECATED_MODEL_PART, SeverityConverter.SEVERITY_WARNING));
}
 
Example #24
Source File: SARLPreferenceStoreInitializer.java    From sarl with Apache License 2.0 4 votes vote down vote up
private void setupIssueCodesDefaults(IPreferenceStoreAccess preferenceStoreAccess) {
	final IPreferenceStore store = preferenceStoreAccess.getWritablePreferenceStore();
	for (final PreferenceKey prefKey : this.issueCodes.getConfigurableIssueCodes().values()) {
		store.setDefault(prefKey.getId(), prefKey.getDefaultValue());
	}
}
 
Example #25
Source File: StandardSarlConfigurableIssueCodesProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> acceptor) {
	super.initialize(acceptor);

	// Override the Xbase configuration
	acceptor.accept(create(
			org.eclipse.xtext.xbase.validation.IssueCodes.VARIABLE_NAME_SHADOWING,
			SeverityConverter.SEVERITY_WARNING));
	acceptor.accept(create(
			org.eclipse.xtext.xbase.validation.IssueCodes.VARIABLE_NAME_DISCOURAGED,
			SeverityConverter.SEVERITY_WARNING));
	acceptor.accept(create(
			org.eclipse.xtext.xbase.validation.IssueCodes.RAW_TYPE,
			SeverityConverter.SEVERITY_WARNING));

	// Override the Xtend configuration
	acceptor.accept(create(
			org.eclipse.xtend.core.validation.IssueCodes.WRONG_PACKAGE,
			SeverityConverter.SEVERITY_WARNING));
	acceptor.accept(create(
			org.eclipse.xtend.core.validation.IssueCodes.MISSING_OVERRIDE,
			SeverityConverter.SEVERITY_IGNORE));
	acceptor.accept(create(
			org.eclipse.xtend.core.validation.IssueCodes.MISSING_ABSTRACT,
			SeverityConverter.SEVERITY_WARNING));

	// Add warnings from SARL
	acceptor.accept(create(
			IssueCodes.REDUNDANT_INTERFACE_IMPLEMENTATION,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.DISCOURAGED_BOOLEAN_EXPRESSION,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.DISCOURAGED_CAPACITY_DEFINITION,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.DISCOURAGED_FUNCTION_NAME,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.UNREACHABLE_BEHAVIOR_UNIT,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.UNUSED_AGENT_CAPACITY,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.REDUNDANT_CAPACITY_USE,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.RETURN_TYPE_SPECIFICATION_IS_RECOMMENDED,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.DISCOURAGED_OCCURRENCE_READONLY_USE,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.USED_RESERVED_SARL_ANNOTATION,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.MANUAL_INLINE_DEFINITION,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.DISCOURAGED_LOOP_BREAKING_KEYWORD_USE,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.POTENTIAL_FIELD_SYNCHRONIZATION_PROBLEM,
			SeverityConverter.SEVERITY_WARNING));

	acceptor.accept(create(
			IssueCodes.POTENTIAL_INEFFICIENT_VALUE_CONVERSION,
			SeverityConverter.SEVERITY_WARNING));
}
 
Example #26
Source File: IssueSeverities.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IssueSeverities(IPreferenceValues preferenceValues, Map<String, PreferenceKey> configurableIssueCodes, SeverityConverter converter) {
	this.preferenceValues = preferenceValues;
	this.configurableIssueCodes = configurableIssueCodes;
	this.converter = converter;
}
 
Example #27
Source File: RuntimeTestSetup.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	super.initialize(iAcceptor);
	iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_ERROR));
	iAcceptor.accept(create(org.eclipse.xtend.core.validation.IssueCodes.ORPHAN_ELEMENT, SeverityConverter.SEVERITY_WARNING));
}
 
Example #28
Source File: RuntimeTestSetup.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	super.initialize(iAcceptor);
	iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_ERROR));
	iAcceptor.accept(create(org.eclipse.xtend.core.validation.IssueCodes.ORPHAN_ELEMENT, SeverityConverter.SEVERITY_WARNING));
}
 
Example #29
Source File: XbaseInjectorProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	super.initialize(iAcceptor);
	iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_ERROR));
}
 
Example #30
Source File: XbaseInjectorProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void initialize(IAcceptor<PreferenceKey> iAcceptor) {
	super.initialize(iAcceptor);
	iAcceptor.accept(create(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, SeverityConverter.SEVERITY_ERROR));
}