-
Notifications
You must be signed in to change notification settings - Fork 47
/
GuiceModulesValidator.xtend
31 lines (26 loc) · 1.37 KB
/
GuiceModulesValidator.xtend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*******************************************************************************
* Copyright (c) 2012 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.xtext.guicemodules.validation
import com.google.inject.BindingAnnotation
import com.google.inject.Inject
import org.eclipse.xtext.common.types.util.TypeReferences
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.xbase.annotations.validation.XbaseWithAnnotationsValidator
import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation
import static org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotationsPackage.Literals.*
import org.eclipse.xtext.common.types.JvmAnnotationType
class GuiceModulesValidator extends XbaseWithAnnotationsValidator {
@Inject extension TypeReferences
@Check def checkAnnotationIsBindingAnnotation(XAnnotation it) {
switch type : annotationType {
JvmAnnotationType:
if(!type.annotations.exists[ annotation.is(BindingAnnotation) ])
error("The annotation is not annotated with @BindingAnnotation", XANNOTATION__ANNOTATION_TYPE)
}
}
}