blob: 9e36dc0d1c77f169b4c0d5f5cd587c802f953b2d [file] [log] [blame]
/**
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* 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
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*
* This copyright notice shows up in the generated Java code
*/
package org.eclipse.osbp.xtext.table.validation;
import com.google.common.base.Objects;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.osbp.xtext.table.TableDSLPackage;
import org.eclipse.osbp.xtext.table.TableModel;
import org.eclipse.osbp.xtext.table.validation.AbstractTableDSLValidator;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.JvmType;
import org.eclipse.xtext.common.types.JvmTypeParameter;
import org.eclipse.xtext.common.types.util.TypeReferences;
import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.xbase.typesystem.util.CommonTypeComputationServices;
import org.tepi.filtertable.FilterTable;
import org.vaadin.hene.popupbutton.PopupButton;
/**
* Custom validation rules.
*
* see http://www.eclipse.org/Xtext/documentation.html#validation
*/
@SuppressWarnings("all")
public class TableDSLValidator extends AbstractTableDSLValidator {
public final static String CODE__MISSING__L_RUNTIME_COMMON = "0_108";
public final static String CODE__MISSING__DATATYPE_LIB = "0_109";
public final static String CODE__MISSING__XBASE_LIB = "0_111";
public final static String CODE__MISSING__JDK_1_5 = "0_112";
@Check
public void checkClassPath(final TableModel tableModel) {
CommonTypeComputationServices _services = this.getServices();
TypeReferences typeReferences = _services.getTypeReferences();
JvmType _findDeclaredType = typeReferences.findDeclaredType(List.class, tableModel);
final JvmGenericType listType = ((JvmGenericType) _findDeclaredType);
boolean _or = false;
boolean _equals = Objects.equal(listType, null);
if (_equals) {
_or = true;
} else {
EList<JvmTypeParameter> _typeParameters = listType.getTypeParameters();
boolean _isEmpty = _typeParameters.isEmpty();
_or = _isEmpty;
}
if (_or) {
this.error("Couldn\'t find a JDK 1.5 or higher on the project\'s classpath.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
TableDSLValidator.CODE__MISSING__JDK_1_5);
}
JvmType _findDeclaredType_1 = typeReferences.findDeclaredType(PopupButton.class, tableModel);
boolean _equals_1 = Objects.equal(_findDeclaredType_1, null);
if (_equals_1) {
this.error("Couldn\'t find a the mandatory library \'popupbutton.osgi\' on the project\'s classpath.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
"");
}
JvmType _findDeclaredType_2 = typeReferences.findDeclaredType(FilterTable.class, tableModel);
boolean _equals_2 = Objects.equal(_findDeclaredType_2, null);
if (_equals_2) {
this.error("Couldn\'t find a the mandatory library \'filteringtable.osgi\' on the project\'s classpath.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
"");
}
JvmType _findDeclaredType_3 = typeReferences.findDeclaredType(
"org.eclipse.osbp.runtime.common.annotations.Dispose", tableModel);
boolean _equals_3 = Objects.equal(_findDeclaredType_3, null);
if (_equals_3) {
this.error("Couldn\'t find the mandatory library \'org.eclipse.osbp.runtime.common\' on the project\'s classpath.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
TableDSLValidator.CODE__MISSING__L_RUNTIME_COMMON);
}
JvmType _findDeclaredType_4 = typeReferences.findDeclaredType(
"org.eclipse.osbp.dsl.common.datatypes.IDatatypeConstants", tableModel);
boolean _equals_4 = Objects.equal(_findDeclaredType_4, null);
if (_equals_4) {
this.warning("Couldn\'t find the optional library \'org.eclipse.osbp.dsl.datatype.lib\' on the project\'s classpath. This may cause resolving problems.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
TableDSLValidator.CODE__MISSING__DATATYPE_LIB);
}
JvmType _findDeclaredType_5 = typeReferences.findDeclaredType("javax.validation.Valid", tableModel);
boolean _equals_5 = Objects.equal(_findDeclaredType_5, null);
if (_equals_5) {
this.error("Couldn\'t find the library \'javax.validation\' on the project\'s classpath. This may cause resolving problems.", tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
TableDSLValidator.CODE__MISSING__DATATYPE_LIB);
}
}
}