You are on page 1of 51

-


, 6539

: . .
: . .
: . .

-, 2011 .

. ,
, JetBrains
MPS,
().

. , , ,
,
, , .
, ,
,
(, XML-).
.
, .
JetBrains MPS, , ,
( ),
.

. VII
, 1215 2011 ,
.
. , .
JetBrains MPS, , ,
( ),
. , .
004.4'232
: - , , , , .
: 50 .
: 13 .

............................................................................................ 1
........................................................................................... 3
............................................................................................... 5
1. -
...................................................................... 8
1.1. - ................... 8
1.2. ................................................ 12
1.3. .. 14
2. ...................... 17
2.1. ........................................................... 17
2.2. ........................................... 18
2.2.1. .......................... 18
2.2.2. .......... 19
2.3.

............................................ 21

2.3.1. ............. 21
2.3.2. .................................................. 23
2.3.3. ............. 24
2.3.4. ....................... 26
2.3.5. ............ 33
2.4. ........................................ 34
2.4.1. ...................................... 34
2.4.2. ........ 37
2.4.3.

40
3

3. JetBrains MPS .................................... 42


3.1. .................................... 42
3.2. ........................................... 43
3.3. ........................ 44
3.4. .......................................... 45
........................................................................................ 48
.......................................................................................... 49

. - [4, 6]. ,
, JetBrains MPS [12], ().

(Subversion, Git, Mercurial .),
, , , ,
.
,
(IntelliJ IDEA, Eclipse, NetBeans, PyCharm,
. .), ,
,
, , .
.
,
- .
. :

1.
() .
2.

.
3.

.
4.
JetBrains MPS
.
, JetBrains MPS
, 2011 , .
VIII
, (1215 2011 ,
) [12].
. 50 ,
, . 1 : - , JetBrains MPS, . 2
, . 3 6

JetBrains MPS.

.

.
. 1.1 - JetBrains
MPS.
. 1.2. MPS
.
. 1.3. ,
MPS.

- (Domain Specific Language, DSL) , .


.
:
SQL ;
XML: XPath, XSLT, XQuery;
.
-

(Language-

Oriented Programming) [4, 6] , .


8

,

.
:
1. ;
2. ;
3. ;
4. .
, . ,

, . -
:
1. ;
2. -
;
3. ;
4.
.
, -
9

.

.


: , . : , ,
. , ,
- . - ,

.
,
. , . , .


.

. [6]
, .
,
- , [10].
10

-
.
.

. , ,
.
.
, .. , .
,
. .
,
. , . ,
.
, [9],

().
, ,
. JetBrains MPS [12]
( MPS).
11

- : ,
[4]. , .
, . , .

,
, . MPS .

, , . MPS.
(, ).
, , . ,
, , .
, :
( ), ,
[ ];
,
:
12

[ ];

(
[

]);

).

:
, ;
;
(,
).
, . . 1
baseLanguage, Java
JetBrains MPS. . 2 . (
), ,
, . . 3
XML, MPS .
. 2 . 3
, , ,
.

. 1.

13

#200 LocalVarDeclaration
initializer

isFinal = true

#202 StaticMethodCall
name = y
type

#201 IntType

methodDecl
[max(int, int)]

class [Math]
actualArgument
#203 IntConstant
value = 5

#204 LocalVarReference
varDeclaration #190

. 2.

<node type="LocalVarDeclaration" id="200">


<property name="isFinal" value="true" />
<property name="name" value="y" />
<node role="type" type="IntegerType" id="201" />
<node role="initializer" type="StaticMethodCall" id="202">
<link role="methodDeclaration"
targetNodeId="java.lang.~Math.max(int,int):int" resolveInfo="max" />
<link role="class" targetNodeId="java.lang.~Math" resolveInfo="Math" />
<node role="actualArgument" type="IntConstant" id="203">
<property name="value" value="5" />
</node>
<node role="actualArgument" type="LocalVarReference" id="204">
<link role="varDeclaration" targetNodeId="190" resolveInfo="x" />
</node>
</node>
</node>

. 3. XML


, 14

.

, .

, . , , ,
diff, diff3 [7]. , , XML-. .
1. , ,
XML-).
2. XML-
, .
3. ,

, - () .
, .
, , ,
.
[2, 5, 8]
,
, , . 15

, , .
, [8], . ,
,
.
,
. , ( ) , , . ,
, , . .
,
,
.
,
, .

16

, .
. 2.1 , .
. 2.2
.
. 2.3 , , .
. 2.4 .

. :

,
;
(
, );
.

[ ] [ ] . , [ ]
17

[ ].

.
. ,
.
, .
1. ().
2. ().
3. (, ).
4. (, ).
5. (, ,

a. ( [ ]

). :

[ ]);

b. ( [ ]

[ ]).


: .
, .

1.
.
/
.

18

2. ,
,
.
3. ,
. .
4. ,
, .
5. :
.
[3] (
). , ,
, ,
.
. 4:
, ;
,

. ,

, ,
2.
A

. 4.


, ,
19

.
( 1) ( ) ,

, -. 35 .
( 3 4, ) (

),

-. ( 5) ,
(

),

35 ,

))

. ,

. , . , ,
( ), .
(

))

).


. ,
, ( ,
20

). (

),

.
:

. -

, .

M1

M2

. 5.

: :

, -

B .
. 5.
, .
21

1. . ,
,
,
.
. ,
,
, ,
, .

.
2. . ,

.
, ,
. ,

),
.
3. , ,
,
,
.
,
.

. 6.

22

M1

M2

. 6.

, [ [
[

]]

[ [

]]

, , , ,
,
, , , .
.
, .
1.
. ,
23

, ,
.
2. .
,
, .
3. ( )
. , ,
.
4. .
(

),


, ,
.
5. ,
.

,
, , . , , .
, , , . . .
, . .
24

, , ,
. : .
.
1. .
.

2. .
,

, .

,
, .

, (

).

(, ), .

.
, : , ,
.

( ),

:
.

(. 7, ). ,

. -

. -

. ,

(. 7, ).

(. 7, ).

,
25

.
:

, . , , ,

(. 7, ).

A
D

. 7. ,

, 4 . 24,
, , , ,
. , , .
26

:
, a = a * 7; a = a
+ 2;, -.
, , .
, , , . . 8, .
, .
,

,
. , :

,
, , , , ,
- .

, .
, , , ;
, .

27

. 8.


. , , . 8,
. ,
. X ,

. 8, . ,
, . 8, . , ,

. -

: , ,
.
28

, , , .
1. .
:
(. 9, ), (.
9, ), (. 9, ).
: , .
)

. 9.

2.
. :
(. 10, ) (.
10, ).
: ,
, .
,
, ,
, .

29

. 10.

3. . . 11. , , , , ,
.

. 11.

4.
. , 2, .
a. (. 12, ). , , .
,
, ,
.
b.
(. 12, ). ,
30

. , .
)

. 12.

5.
. .
a. , , (. 13, ). .
b. (.
13, ). , ,
. ,
, , .
c. (.
13, ). ,
,
. , , , , .
d. ,

(. 13, ).
, , , , -

31

. , , .
)

. 13.

6. .
.
a. (. 14, ).
.
b.
(. 14, ). ,
,
, 0.
c.
(. 14, ).
.
)

. 14.

32

.
1.
. . 2.2.2.
2. . ,
.
3. .
(

), -

.
.

( ) ,

. , (

) .

). -

, (

).

,
(

( ). ,

, (

).

),

. , 33

( )

) . ,

, ,
, . 2.2.2,
(

).


( ) ,
, .
,
.


.
1. . ,
. , ,
,
. ,
. .
15.
34

2. . ,
. , .

. . 15.
3. . ,
( , ,
). ,
. ,
, .
, ,
, .
. 16.
4. . ,
. . ,
,
. ,
, ,
. . 16.
5. . ,
. ,
. ,
( ),
,
, . .
. 17.

35

. 15.

+ /

= ?

. 16.

36

. 17.


.
, , .
.
.

,
. -
. , -
, , . ,
, ,
37

, .
1. .
. ,
.

, ,
. ,
.

, ,
, . ,

.
2. .
. ,
.

, .
,
. , ,
. ,
.

, ,
, . ,

38

. ,
.
3. .
,
. ,
, , .
,
,
, .
,
, , ,
.
, ,
, , .
4. .
,
. , ,
, .
,
,
, .
,
, , ,
.
, ,
, , .
5. .

,
39

. , ,
, .

,
,
, . ,

, ,
. , .
, , , , .

, . 2.2.2. . ,
, .
( ),

.
, , ( ), , ( ),

. ,
, ( ),
, ,
. ,
,

40

( ), ,

.
,
. 2.2.2, , ,

. . ,

) .

, , ,
. 2.2.2,
| |.

41

),

- JetBrains
MPS.
. 3.1 , .
. 3.2
.
. 3.3
.
. 3.4
.

JetBrains MPS , baseLanguage ( Java)


, . ModelChange . apply, , , getOppositeChange,
,
. ChangeSetBuilder ChangeSet, . MergeContext : ,
( ChangeSet),
, 42

, , , . ModelChangesManager ,

.


, . 18.
, : , , ,
.

. 18. .

, . 19. .
: , ,
. : ,
,

.
, .
43

. 19.


, . , . 20, , ,
, , ,
, ,
. , : (local), (remote), (with conflicts)
(both modified). , :
; ;
.

44

. 20. .

, . 21,
.
, . ,
, .

. 21.


, .
,
45

, . 22. , , .

. 22.

, ,
.
( ,
).
. 23.

46

. 23.

47

:
1.
() .
2.

.
3. ,
,

.
4. JetBrains
MPS,
.
MPS Apache 2.0 [11]. [13].
:

;


/ .

48

1. , . .
-
//
, 1. . :
, 2011. . 228229.
2. Asklund U. Identifying conflicts during structural merge // Nordic
Workshop on Programming Environment Research '94. Lund,
Sweden, 1994. pp. 231242.
3. Bergroth L. A survey of longest common subsequence algorithms //
String Processing and Information Retrieval. - A Curuna, Spain,
2000. pp. 3948. ISBN 0-7695-0746-8.
4. Dmitriev S. Language Oriented Programming: The Next
Programming Paradigm. JetBrains, November 2004.
http://www.onboard.jetbrains.com/is1/articles/04/10/lop/.
5. La Fontaine R. Merging XML files: a new approach providing
intelligent merge of XML data sets // XML Europe. Barcelona,
Spain, 2002.
6. Fowler M. Language Workbenches: The Killer-App for Domain
Specific Languages?. June 12, 2005.
http://www.martinfowler.com/articles/languageWorkbench.html.
7. Johnson M. K. Diff, patch and friends // Linux Journal. August
1996. 1996(28es).
8. Lindholm T. A. Three-way Merge for XML Documents // ACM
symposium on Document engineering. - New York, NY, USA : ACM,
2004. Vol. DocEng '04. pp. 110.
9. Simonyi C. The death of computer languages, the birth of IntentionalProgramming // Microsoft Research. 1995.
http://citeseer.nj.nec.com/simonyi95death.html
49

10. Solomatov K. DSL Adoption with JetBrains MPS //DZone, Architect Zone. 2009
11. Apache Software Foundation, The. Apache License, 2.0.
http://www.apache.org/licenses/LICENSE-2.0
12.JetBrains. JetBrains MPS.
http://www.jetbrains.com/mps/
13. JetBrains. JetBrains
MPS. http://git.jetbrains.org/?p=mps/mps.git
git://git.jetbrains.org/mps/mps.git

50