Method.st
changeset 12948 f238e8b26110
parent 12913 142c9566a768
child 13100 d5333b6746d1
equal deleted inserted replaced
12947:253994db9599 12948:f238e8b26110
   350     "return the methods comment.
   350     "return the methods comment.
   351      This is done by searching for and returning the first comment
   351      This is done by searching for and returning the first comment
   352      from the methods source (excluding any double-quotes).
   352      from the methods source (excluding any double-quotes).
   353      Returns nil if there is no comment (or source is not available)."
   353      Returns nil if there is no comment (or source is not available)."
   354 
   354 
   355     |src comment comments parser|
   355     |src|
   356 
   356 
   357     src := self source.
   357     src := self source.
   358     src isNil ifTrue:[^ nil].
   358     src isNil ifTrue:[^ nil].
   359 
   359     ^ self programmingLanguage parserClass methodCommentFromSource:src
   360     parser := Parser for:src in:nil.
   360 
   361     parser ignoreErrors:true; ignoreWarnings:true; saveComments:true.
   361     "
   362     parser parseMethodSpec.
   362      (Method compiledMethodAt:#comment) comment  
   363 
       
   364     comments := parser comments.
       
   365     comments size ~~ 0 ifTrue:[
       
   366         comment := comments first asString.
       
   367         (comment withoutSpaces endsWith:'}') ifTrue:[
       
   368             "if first comment is a pragma, take next comment"
       
   369             comment := comments at:2 ifAbsent:nil.
       
   370             comment notNil ifTrue:[
       
   371                 comment := comment string.
       
   372             ].
       
   373         ].
       
   374     ].
       
   375     ^ comment.
       
   376 
       
   377     "
       
   378      (Method compiledMethodAt:#comment) comment
       
   379      (Object class compiledMethodAt:#infoPrinting:) comment
   363      (Object class compiledMethodAt:#infoPrinting:) comment
   380     "
   364     "
   381 
   365 
   382     "Modified: / 17.2.1998 / 14:50:00 / cg"
   366     "Modified: / 23-02-1998 / 10:26:08 / stefan"
   383     "Modified: / 23.2.1998 / 10:26:08 / stefan"
   367     "Modified: / 17-07-2010 / 14:23:56 / cg"
   384 !
   368 !
   385 
   369 
   386 getPackage
   370 getPackage
   387     "return the package-ID of the method"
   371     "return the package-ID of the method"
   388 
   372 
  3010 ! !
  2994 ! !
  3011 
  2995 
  3012 !Method class methodsFor:'documentation'!
  2996 !Method class methodsFor:'documentation'!
  3013 
  2997 
  3014 version
  2998 version
  3015     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.350 2010-05-04 15:49:48 cg Exp $'
  2999     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.351 2010-07-17 12:24:14 cg Exp $'
  3016 !
  3000 !
  3017 
  3001 
  3018 version_CVS
  3002 version_CVS
  3019     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.350 2010-05-04 15:49:48 cg Exp $'
  3003     ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.351 2010-07-17 12:24:14 cg Exp $'
  3020 ! !
  3004 ! !
  3021 
  3005 
  3022 Method initialize!
  3006 Method initialize!