Tools__CodeCritics.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 19 Jul 2017 09:42:32 +0200
branchjv
changeset 17619 edb119820fcb
parent 12431 9f0c59c742d5
child 18532 cccb41254edf
permissions -rw-r--r--
Issue #154: Set window style using `#beToolWindow` to indicate that the minirunner window is kind of support tool rather than some X11 specific code (which does not work on Windows of course) See https://swing.fit.cvut.cz/projects/stx-jv/ticket/154
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2007 by eXept Software AG
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ NameSpace: Tools }"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#CodeCritics
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'code critics'
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Interface-Browsers-New'
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!CodeCritics class methodsFor:'documentation'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 COPYRIGHT (c) 2007 by eXept Software AG
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    extracted critics from the browser
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    For now, not much is found here - however, it will eventually grow and should collect
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    the critics in the parser as well.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [author:]
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
        Claus Gittinger (cg@exept.de)
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!CodeCritics class methodsFor:'critics'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
checkCodeQuality:code
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ^ (self new code:code) checkCodeQuality
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "Created: / 27-03-2007 / 21:41:50 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!CodeCritics methodsFor:'accessing'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
code:something
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    code := something.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!CodeCritics methodsFor:'critics'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
7780
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    66
checkBadIndentationOfReturns
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    67
    "we want returns to be indented correctly"
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    code asCollectionOfLines keysAndValuesDo:[:lineNr :eachLine |
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        |lineString column|
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
        lineString := eachLine string.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        (lineString withoutLeadingSeparators startsWith:'^') ifTrue:[
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
            column := lineString indexOf:$^.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
            (column-1) \\ 4 ~~ 0 ifTrue:[
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
                self addCritic:'bad indentation' line:lineNr.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
            ].
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        ]
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    ].
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "Created: / 27-03-2007 / 21:41:10 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
checkCodeQuality
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    self checkBadIndentationOfReturns.
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ^ critics
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    "Created: / 27-03-2007 / 21:42:11 / cg"
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
7780
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    91
!CodeCritics methodsFor:'helpers'!
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    92
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    93
addCritic:msg line:lineNr
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    94
    critics isNil ifTrue:[
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    95
        critics := OrderedCollection new.
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    96
    ].
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    97
    critics add:(lineNr -> msg)
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    98
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
    99
    "Created: / 27-03-2007 / 21:47:09 / cg"
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   100
! !
e6a87f5b97a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7770
diff changeset
   101
7770
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!CodeCritics class methodsFor:'documentation'!
7443f9e5b084 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   104
version_CVS
12123
4bde08cebd48 trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 10033
diff changeset
   105
    ^ '§Header: /cvs/stx/stx/libtool/Tools__CodeCritics.st,v 1.3 2011/07/03 13:31:36 cg Exp §'
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   106
!
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   107
12431
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   108
version_HG
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   109
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   110
    ^ '$Changeset: <not expanded> $'
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   111
!
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   112
10033
Claus Gittinger <cg@exept.de>
parents: 7780
diff changeset
   113
version_SVN
12128
a7ff7d66ee85 Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12123
diff changeset
   114
    ^ '$Id: Tools__CodeCritics.st 7854 2012-01-30 17:49:41Z vranyj1 $'
12431
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   115
! !
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   116