00001 /*----------------------------------------------------------------------------*/ 00002 /* */ 00003 /* Copyright (c) 2004-2009 William Data Systems Ltd. and Geoff Stevens. */ 00004 /* All rights reserved. */ 00005 /* */ 00006 /* This program and the accompanying materials are made available under */ 00007 /* the terms of the Common Public License v1.0 which accompanies this */ 00008 /* distribution. A copy is also available at the following address: */ 00009 /* http://www.opensource.org/licenses/cpl1.0.php */ 00010 /* */ 00011 /* Redistribution and use in source and binary forms, with or without */ 00012 /* modification, are permitted provided that the following conditions */ 00013 /* are met: */ 00014 /* */ 00015 /* Redistributions of source code must retain the above copyright */ 00016 /* notice, this list of conditions and the following disclaimer. */ 00017 /* */ 00018 /* Redistributions in binary form must reproduce the above copyright */ 00019 /* notice, this list of conditions and the following disclaimer in the */ 00020 /* documentation and/or other materials provided with the distribution. */ 00021 /* */ 00022 /* Neither the name or trademarks of William Data Systems nor the names */ 00023 /* of its contributors may be used to endorse or promote products */ 00024 /* derived from this software without specific prior written permission. */ 00025 /* */ 00026 /* DISCLAIMER */ 00027 /* */ 00028 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */ 00029 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */ 00030 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */ 00031 /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */ 00032 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ 00033 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00034 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */ 00035 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */ 00036 /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00037 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */ 00038 /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00039 /* */ 00040 /*----------------------------------------------------------------------------*/ 00041 -- Find classes 00042 -- 00043 -- Tiny but crucial 00044 -- 00045 00046 ::CLASS classfinder PUBLIC 00047 00048 00049 -- replace class names in an array of strings with HTML references 00050 -- to the class documentation 00051 -- @param d - document in which string found 00052 -- @param text - array of text in which to replace class names 00053 -- @return array of substituted text 00054 ::METHOD classnamesa CLASS 00055 use arg d, text 00056 na = .queue~new 00057 do i over text 00058 na~queue(self~classnames(d, i)) 00059 end 00060 return na 00061 00062 -- replace class names in a string with HTML references 00063 -- to the class documentation 00064 -- @param d - document in which string found 00065 -- @param text - text in which to replace class names 00066 -- @return substituted text 00067 ::METHOD classnames CLASS 00068 use arg d, text 00069 newtext = '' 00070 do j = 1 to text~words 00071 w = text~word(j) 00072 if w~left(1) <> '.' 00073 then do 00074 newtext = newtext w 00075 iterate 00076 end 00077 cn = w~translate(' ',';.,') 00078 cn = cn~strip~translate 00079 rdc = self~findclass(cn, d, d~reqfiles) 00080 if rdc <> .nil 00081 then do 00082 newtext = newtext '<a href="'rdc~hdocurl'#'rdc~hdocanchor'">'w'</a>' 00083 end 00084 else newtext = newtext w 00085 end 00086 return newtext 00087 00088 -- locate declaration of class 00089 -- @param classname - target class name, uppercase 00090 -- @param document - current document 00091 -- @param reqfiles - queue of candidate files in which to look up possible declarations 00092 -- @return .rdclass object 00093 -- @return .nil - can't locate class object 00094 ::METHOD findclass CLASS 00095 use strict arg classname, document, reqfiles 00096 00097 seenfiles = .set~new 00098 00099 -- recursively search requires space 00100 rdc = self~findclassr(classname, document, reqfiles, seenfiles) 00101 00102 -- okay, finally lookup in global index if we can't locate it elsewhere 00103 if rdc = .nil 00104 then rdc = document~globalix~classix[classname] 00105 00106 return rdc 00107 00108 -- recursive locate declaration of class 00109 -- @param classname - target class name, uppercase 00110 -- @param document - current document 00111 -- @param reqfiles - queue of candidate files in which to look up possible declarations 00112 -- @param seenfiles - .set of .files already searched 00113 -- @return .rdclass object 00114 -- @return .nil - can't locate class object 00115 ::METHOD findclassr CLASS PRIVATE 00116 use strict arg classname, document, reqfiles, seenfiles 00117 00118 seenfiles[document] = document 00119 00120 -- lookup in this document 00121 if document~classix~hasindex(classname) 00122 then do 00123 -- class is in this file 00124 rdc = document~classix[classname] 00125 return rdc 00126 end 00127 00128 -- lookup in supplied file list 00129 do f over reqfiles 00130 00131 if seenfiles~hasindex(f~document) 00132 then iterate 00133 00134 rdc = self~findclassr(classname, f~document, f~document~reqfiles, seenfiles) 00135 if rdc <> .nil 00136 then return rdc 00137 00138 end 00139 return .nil 00140 00141 -- locate declaration of routine 00142 -- @param routinename - target routine name, uppercase 00143 -- @param document - current document 00144 -- @param reqfiles - queue of candidate files in which to look up possible declarations 00145 -- @return .rdprocedure of routine 00146 -- @return .nil - can't locate class object 00147 ::METHOD findroutine CLASS 00148 use strict arg routinename, document, reqfiles 00149 00150 seenfiles = .set~new 00151 00152 -- recursively search requires space 00153 rdp = self~findroutiner(routinename, document, reqfiles, seenfiles) 00154 00155 -- okay, finally lookup in global index if we can't locate it elsewhere 00156 if rdp = .nil 00157 then rdp = document~globalix~routinix[routinename] 00158 00159 return rdp 00160 00161 -- recursive locate declaration of class 00162 -- @param classname - target class name, uppercase 00163 -- @param document - current document 00164 -- @param reqfiles - queue of candidate files in which to look up possible declarations 00165 -- @param seenfiles - .set of .files already searched 00166 -- @return .rdprocedure object 00167 -- @return .nil - can't locate class object 00168 ::METHOD findroutiner CLASS PRIVATE 00169 use strict arg routinename, document, reqfiles, seenfiles 00170 00171 seenfiles[document] = document 00172 00173 -- lookup in this document 00174 rdp = document~routinix[routinename] 00175 if rdp <> .nil 00176 then return rdp 00177 00178 -- lookup in supplied file list 00179 do f over reqfiles 00180 00181 if seenfiles~hasindex(f~document) 00182 then iterate 00183 00184 rdp = self~findroutiner(routinename, f~document, f~document~reqfiles, seenfiles) 00185 if rdp <> .nil 00186 then return rdp 00187 00188 end 00189 return .nil 00190
|
Generated on 31 Aug 2010 05:20:01 for RexxLiterate by
![]() |