3
3
import com .intellij .patterns .PlatformPatterns ;
4
4
import com .intellij .patterns .XmlAttributeValuePattern ;
5
5
import com .intellij .patterns .XmlPatterns ;
6
+ import org .intellij .lang .annotations .RegExp ;
6
7
7
8
/**
8
9
* @author Daniel Espendiller <daniel@espendiller.net>
9
10
*/
10
11
public class DoctrineMetadataPattern {
11
12
13
+ @ RegExp
14
+ private static final String DOCTRINE_MAPPING = "doctrine-[\\ w+-]*-*mapping" ;
15
+
12
16
/**
13
17
* <doctrine-mapping|doctrine-*-mapping>
14
18
* <entity name="Class\Name"/>
@@ -26,7 +30,7 @@ public static XmlAttributeValuePattern getXmlModelClass() {
26
30
.withParent (XmlPatterns
27
31
.xmlTag ().withName (PlatformPatterns .string ().oneOf ("document" , "entity" ))
28
32
.withParent (XmlPatterns
29
- .xmlTag ().withName (PlatformPatterns .string ().matches ("doctrine-[ \\ w+-]*-*mapping" ))
33
+ .xmlTag ().withName (PlatformPatterns .string ().matches (DOCTRINE_MAPPING ))
30
34
)
31
35
)
32
36
);
@@ -46,7 +50,47 @@ public static XmlAttributeValuePattern getXmlRepositoryClass() {
46
50
.withParent (XmlPatterns
47
51
.xmlTag ().withName (PlatformPatterns .string ().oneOf ("document" , "entity" ))
48
52
.withParent (XmlPatterns
49
- .xmlTag ().withName (PlatformPatterns .string ().matches ("doctrine-[\\ w+-]*-*mapping" ))
53
+ .xmlTag ().withName (PlatformPatterns .string ().matches (DOCTRINE_MAPPING ))
54
+ )
55
+ )
56
+ );
57
+ }
58
+
59
+ /**
60
+ * <reference-one target-document="Foo"/>
61
+ * <reference-many target-document="Foo"/>
62
+ * <embed-many target-document="Foo"/>
63
+ * <embed-one target-document="Foo"/>
64
+ */
65
+ public static XmlAttributeValuePattern getXmlTargetDocumentClass () {
66
+ return XmlPatterns
67
+ .xmlAttributeValue ()
68
+ .withParent (XmlPatterns
69
+ .xmlAttribute ("target-document" )
70
+ .withParent (XmlPatterns
71
+ .xmlTag ().withName (PlatformPatterns .string ().oneOf ("reference-one" , "reference-many" , "embed-many" , "embed-one" ))
72
+ .withParent (XmlPatterns
73
+ .xmlTag ().withName (PlatformPatterns .string ().matches (DOCTRINE_MAPPING ))
74
+ )
75
+ )
76
+ );
77
+ }
78
+
79
+ /**
80
+ * <one-to-one target-entity="Foo">
81
+ * <one-to-many target-entity="Foo">
82
+ * <many-to-one target-entity="Foo">
83
+ * <many-to-many target-entity="Foo">
84
+ */
85
+ public static XmlAttributeValuePattern getXmlTargetEntityClass () {
86
+ return XmlPatterns
87
+ .xmlAttributeValue ()
88
+ .withParent (XmlPatterns
89
+ .xmlAttribute ("target-entity" )
90
+ .withParent (XmlPatterns
91
+ .xmlTag ().withName (PlatformPatterns .string ().oneOf ("one-to-one" , "one-to-many" , "many-to-one" , "many-to-many" ))
92
+ .withParent (XmlPatterns
93
+ .xmlTag ().withName (PlatformPatterns .string ().matches (DOCTRINE_MAPPING ))
50
94
)
51
95
)
52
96
);
0 commit comments