tools/JavaSourcePartitioner.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 06 Sep 2013 00:16:38 +0100
branchdevelopment
changeset 2711 a00302fe5083
parent 2482 109ed9ecf4f7
child 2731 13f5be2bf83b
permissions -rw-r--r--
Added version_CVS to all classes and build files regenerated & cleaned. This is necessary step before updating CVS.

"{ Package: 'stx:libjava/tools' }"

JavaParserII subclass:#JavaSourcePartitioner
	instanceVariableNames:'imports partitions'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Parser-Utils'
!

!JavaSourcePartitioner class methodsFor:'documentation'!

documentation
"
    A special parser that takes a compilation unit source
    code and return an array of partitions.

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]
        JavaSourcePartition


"
! !

!JavaSourcePartitioner class methodsFor:'accessing'!

ignoredNames
        "Answer a collection of instance-variables that should not be automatically initialized with productions, but that are used internal to the composite parser."

    ^super ignoredNames , #(imports partitions)

    "Created: / 04-04-2013 / 00:29:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaSourcePartitioner methodsFor:'accessing'!

partitions
    ^ partitions
! !

!JavaSourcePartitioner methodsFor:'grammar'!

importDeclaration
    "
    ^ ((self importKW) , (self staticKW) optional , qualifiedNameForImport 
        , (self tokenFor:';')).
    "

    ^ super importDeclaration ==> [:nodes|
        nodes second notNil ifTrue:[
            imports isNil ifTrue:[imports := Set new].
            imports add: (nodes at: 3)
        ]
    ]

    "Created: / 04-04-2013 / 00:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaSourcePartitioner methodsFor:'grammar-classes'!

formalParameters 

"/        ^ (self tokenFor: '(') ,
"/        formalParameterDecls optional ,
"/        (self tokenFor: ')')

    ^super formalParameters ==> [:nodes|nodes second]

    "Created: / 04-04-2013 / 00:42:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaSourcePartitioner methodsFor:'grammar-classes-method'!

constructorDeclaration

"/        ^ constructorModifiers optional , 
"/           typeParameters optional , 
"/           self constructorNameIdentifier,
"/           formalParameters ,
"/           throws optional , 
"/           block
"/"/           (self tokenFor: '{' ) , 
"/"/                        explicitConstructorInvocation optional ,
"/"/                        blockStatement star ,
"/"/           (self tokenFor: '}')
    ^super constructorDeclaration  ==> [:nodes|
        | part |

        part := JavaSourcePartition  newMethod.
        part start: (nodes first first startPosition) stop: (nodes last stopPosition).

        partitions isNil ifTrue:[partitions := OrderedCollection new].
        partitions add: part.
    ].

    "Created: / 04-04-2013 / 00:22:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

methodNotConstructorDeclaration

"/        ^ methodModifiers,
"/           typeParameters optional,
"/           ((self  voidKW) / type),
"/           self methodNameIdentifier,
"/           formalParameters ,
"/           emptySquaredParenthesis star ,
"/           throws optional,
"/           (block / (self tokenFor: ';'))

    ^super methodNotConstructorDeclaration ==> [:nodes|
        | part |

        part := JavaSourcePartition  newMethod.
        part start: (nodes first first startPosition) stop: (nodes last stopPosition).
        part selector: (nodes at: 4) , '(' , (nodes at: 5) , (nodes at: 3).

        partitions isNil ifTrue:[partitions := OrderedCollection new].
        partitions add: part.
    ].

    "Created: / 04-04-2013 / 00:23:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaSourcePartitioner class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '§Id§'
! !