SyntaxElement.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 30 Jan 2012 17:49:41 +0000
branchjv
changeset 12128 a7ff7d66ee85
parent 12125 0c49a3b13e43
child 12287 400a99059170
permissions -rw-r--r--
Improvements in LintHighlighter, few fixes

"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
"{ Package: 'stx:libtool' }"

Magnitude subclass:#SyntaxElement
	instanceVariableNames:'start stop type value next prev'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-CodeView-Syntax'
!

!SyntaxElement class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2010 by Jan Vrany, SWING Research Group. CTU in Prague
              All Rights Reserved

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the 'Software'), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"
! !

!SyntaxElement class methodsFor:'instance creation'!

from: start to: stop

    ^self new
        start: start;
        stop: stop.

    "Created: / 14-02-2010 / 13:13:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

from: start to: stop type: type

    ^self new
        start: start;
        stop: stop;
        type: type

    "Created: / 14-02-2010 / 14:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

from: start to: stop type: type value: value

    ^self new
        start: start;
        stop: stop;
        type: type;
        value: value

    "Created: / 14-02-2010 / 17:41:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SyntaxElement methodsFor:'accessing'!

firstElementInChain
    |first prev|

    first := self.
    [ (prev := first previousElement) notNil ] whileTrue:[
        first := prev.
    ].
    ^ first

    "Created: / 21-08-2011 / 09:51:35 / cg"
!

next
    ^ next
!

next:aSyntaxElement
    next := aSyntaxElement.
    next prev: self.

    "Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

nextElement
    ^ next

    "Created: / 21-08-2011 / 09:47:11 / cg"
!

nextElement:aSyntaxElement
    next := aSyntaxElement.
    next prev: self.

    "Modified: / 14-02-2010 / 17:44:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Created: / 21-08-2011 / 09:47:15 / cg"
!

prev
    ^ prev
!

prev:aSyntaxElement
    prev := aSyntaxElement.
!

previousElement
    ^ prev

    "Created: / 21-08-2011 / 09:47:23 / cg"
!

previousElement:aSyntaxElement
    prev := aSyntaxElement.

    "Created: / 21-08-2011 / 09:47:28 / cg"
!

start
    ^ start
!

start:anInteger
    start := anInteger.
!

stop
    ^ stop
!

stop:anInteger
    stop := anInteger.
!

type
    ^ type
!

type:aSymbol
    type := aSymbol.
!

value
    ^ value
!

value:anObject
    value := anObject.
! !

!SyntaxElement methodsFor:'comparing'!

< anObject

    anObject isNumber ifTrue:[^stop < anObject].
    anObject class == self class ifFalse:[^false].

    ^stop < anObject start

    "Created: / 14-02-2010 / 13:39:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

= anObject

    anObject class == self class ifFalse:[^false].

    ^start == (anObject start) and:
        [stop == (anObject stop) and:
            [type == (anObject type)]].

    "Created: / 14-02-2010 / 13:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

hash

    ^start hash bitXor:[stop hash bitXor:[type hash]].

    "Created: / 14-02-2010 / 13:30:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SyntaxElement methodsFor:'double dispatching'!

lessFromInteger:anInteger

    ^stop < anInteger

    "Created: / 14-02-2010 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SyntaxElement methodsFor:'printing & storing'!

printOn:aStream
    "append a printed representation if the receiver to the argument, aStream"

    super printOn:aStream.
    aStream nextPutAll:'('.
    type printOn: aStream.
    aStream nextPutAll:' -> '.    
    value printOn:aStream.
    aStream nextPut:$).

    "Modified: / 25-06-2010 / 13:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 21-08-2011 / 09:33:51 / cg"
! !

!SyntaxElement methodsFor:'queries'!

isSelector
    ^ type == #selector

    "Created: / 21-08-2011 / 09:09:19 / cg"
!

isSelf
    ^ type == #self

    "Created: / 21-08-2011 / 09:31:20 / cg"
!

isVariable
    ^ type == #variable

    "Created: / 21-08-2011 / 09:09:00 / cg"
!

isVariableOrSelf
    ^ self isVariable or:[self isSelf]

    "Created: / 21-08-2011 / 09:31:33 / cg"
! !

!SyntaxElement class methodsFor:'documentation'!

version
    ^ '$Id: SyntaxElement.st 7854 2012-01-30 17:49:41Z vranyj1 $'
!

version_CVS
    ^ '§Header: /cvs/stx/stx/libtool/SyntaxElement.st,v 1.3 2011/08/21 10:25:36 cg Exp §'
!

version_SVN
    ^ '$Id: SyntaxElement.st 7854 2012-01-30 17:49:41Z vranyj1 $'
! !