org.eclipse.xtext.validation.FeatureBasedDiagnostic Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.xtext.validation;
import java.util.List;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import com.google.common.collect.Lists;
/**
* A diagnostic that is typically associated with a feature.
*/
public class FeatureBasedDiagnostic extends AbstractValidationDiagnostic {
private final EStructuralFeature feature;
private final int index;
/**
* @param issueData optional user data. May not contain null
entries.
*/
public FeatureBasedDiagnostic(int severity, String message, EObject source, EStructuralFeature feature, int index, CheckType checkType, String issueCode, String... issueData) {
super(severity, message, source, checkType, issueCode, issueData);
if (feature != null && source != null) {
if (source.eClass().getEStructuralFeature(feature.getName()) != feature) {
throw new IllegalArgumentException("The sources EClass '" + source.eClass().getName() + "' does not expose the feature '" + feature.getEContainingClass().getName() + "." + feature.getName() + "'");
}
}
this.feature = feature;
this.index = index;
}
public List> getData() {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy