<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; SciTE: вывод списка процедур/функций, имеющихся в коде]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=693&amp;type=atom" />
	<updated>2007-09-17T18:16:21Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=693</id>
		<entry>
			<title type="html"><![CDATA[SciTE: вывод списка процедур/функций, имеющихся в коде]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=4847#p4847" />
			<content type="html"><![CDATA[<p>Скрипт <strong>FuncProcList.lua</strong>. Если у вас уже установлен этот скрипт, просто скопируйте поверх.<br />Улучшения по сравнению со сборкой <strong>SciTE 1.74 Ru-Board Edition</strong>: убрана расстановка закладок при нажатии F4, убран вывод в список закомментированных функций/процедур, добавлена поддержка VBScript.<br />Автор скрипта - <strong>mozers</strong>.<br /></p><div class="codebox"><pre><code>-- FuncProcList.lua
-- Version: 1.2
-- mozers™ , Maximka (выполняя пожелание ALeXkRU при активном тестировании mimir)
-- Использованы идеи: Grisper и gansA
---------------------------------------------------
-- Вывод списка функций / процедур, имеющихся в коде
-- Для подключения добавьте в свой файл .properties следующие строки:
--   command.name.17.*=List of Functions / Procedures
--   command.17.*=dofile $(SciteDefaultHome)\tools\FuncProcList.lua 
--   command.mode.17.*=subsystem:lua,savebefore:no
--   command.shortcut.17.*=Alt+Shift+F
---------------------------------------------------

local function IsComment(pos)
    local style = editor.StyleAt[pos]
    local lexer = editor.LexerLanguage
    local comment = &quot;&quot;
    if     lexer == &#039;cpp&#039; then comment = &quot;1,2,3&quot;
    elseif lexer == &#039;lua&#039; then comment = &quot;1,2,3&quot;
    elseif lexer == &#039;sql&#039; then comment = &quot;1,2,3&quot;
    elseif lexer == &#039;pascal&#039; then comment = &quot;1,2,3&quot;
    elseif lexer == &#039;ruby&#039; then comment = &quot;2&quot;
    elseif lexer == &#039;perl&#039; then comment = &quot;2&quot;
    elseif lexer == &#039;hypertext&#039; then comment = &quot;9,42,43,44,57,58,59,72,82,92,107,124,125&quot;
    elseif lexer == &#039;xml&#039; then comment = &quot;9,29&quot;
    elseif lexer == &#039;css&#039; then comment = &quot;9&quot;
    else comment = &quot;1&quot;
    end
    if string.find(comment, &#039;[^%d]&#039;..style..&#039;[^%d]&#039;) ~= nil then return true end
    return false
end

-- паттерны для разных языков программирования (корректируйте, дополняйте)
-- шлите ваши варианты на mozers&lt;собачка&gt;mail.ru
local findRegExp = {
--~     [&#039;cxx&#039;]=&quot;\n[^,.&lt;&gt;=\n]-([^%s,.&lt;&gt;=\n]+[(][^.&lt;&gt;=\n)]-[)])%s-%b{}&quot;,
    [&#039;cxx&#039;]=&quot;([^.,&lt;&gt;=\n]-[ :][^.,&lt;&gt;=\n%s]+[(][^.&lt;&gt;=)]-[)])[%s\/}]-%b{}&quot;,
      [&#039;h&#039;]=&quot;([^.,&lt;&gt;=\n]-[ :][^.,&lt;&gt;=\n%s]+[(][^.&lt;&gt;=)]-[)])[%s\/}]-%b{}&quot;,
    [&#039;js&#039;]=&quot;(\n[^,&lt;&gt;\n]-function[^(]-%b())[^{]-%b{}&quot;,
    [&#039;vbs&#039;]=&quot;(\n[SsFf][Uu][BbNn][^\r]-)\r&quot;,
    [&#039;css&#039;]=&quot;([%w.#-_]+)[%s}]-%b{}&quot;,
    [&#039;pas&#039;]=&quot;\nprocedure[^ ]* ([^(]*%b());&quot;
}
local findPattern = findRegExp [props[&quot;FileExt&quot;]]
if findPattern == nil then
-- универсальный паттерн для всех остальных языков программирования
    findPattern = &quot;\n[local ]*[SsFf][Uu][BbNn][^ ]* ([^(]*%b())&quot;
end

-- дальше - банальный поиск заданнго паттерна по всему тексту
--~ editor:MarkerDeleteAll(1)
local textAll = editor:GetText()
local startPos, endPos, findString
local count = 0
startPos = 1
print(&quot;&gt; Список функций / процедур:&quot;)
while true do
    startPos, endPos, findString = string.find(textAll, findPattern, startPos)
    if startPos == nil then break end
    -- убираем переводы строк и лишние пробелы
    findString = string.gsub (findString, &quot;\r\n&quot;, &quot;&quot;)
    findString = string.gsub (findString, &quot;%s+&quot;, &quot; &quot;)
    -- если функция не закомментирована, то выводим ее в список
    if not IsComment(startPos) then
        local line = editor:LineFromPosition(startPos)
        --~ editor:MarkerAdd(line,1)
        print(props[&#039;FileNameExt&#039;]..&#039;:&#039;..(line+1)..&#039;:\t&#039;..findString) 
        count = count + 1
    end
    startPos = endPos + 1
end
if count &gt; 0 then
    trace(&quot;&gt; Найдено: &quot;..count..&quot; функций / процедур\nДвойной щелчок на строке с результатом установит курсор на оригинальную строку&quot;)
else
    trace(&quot;&gt; Функций / процедур не найдено!&quot;)
end</code></pre></div>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2007-09-17T18:16:21Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=4847#p4847</id>
		</entry>
</feed>
