aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/src/erl_comment_scan.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/syntax_tools/src/erl_comment_scan.erl')
-rw-r--r--lib/syntax_tools/src/erl_comment_scan.erl18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/syntax_tools/src/erl_comment_scan.erl b/lib/syntax_tools/src/erl_comment_scan.erl
index df1449da4e..09ce21a428 100644
--- a/lib/syntax_tools/src/erl_comment_scan.erl
+++ b/lib/syntax_tools/src/erl_comment_scan.erl
@@ -14,8 +14,7 @@
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
%% USA
%%
-%% $Id$
-%%
+%% =====================================================================
%% @copyright 1997-2006 Richard Carlsson
%% @author Richard Carlsson <[email protected]>
%% @end
@@ -29,6 +28,11 @@
%% =====================================================================
+
+-type comment() :: {integer(), integer(), integer(), [string()]}.
+-type commentLine() :: {integer(), integer(), integer(), string()}.
+
+%% =====================================================================
%% @spec file(FileName::file:filename()) -> [Comment]
%%
%% Comment = {Line, Column, Indentation, Text}
@@ -59,6 +63,8 @@
%% error occurred, where `Reason' is an atom corresponding to
%% a Posix error code; see the module {@link //kernel/file} for details.
+-spec file(file:filename()) -> [comment()].
+
file(Name) ->
Name1 = filename(Name),
case catch {ok, file:read_file(Name1)} of
@@ -80,7 +86,7 @@ file(Name) ->
%% =====================================================================
-%% string(string()) -> [Comment]
+%% @spec string(string()) -> [Comment]
%%
%% Comment = {Line, Column, Indentation, Text}
%% Line = integer()
@@ -94,6 +100,8 @@ file(Name) ->
%%
%% @see file/1
+-spec string(string()) -> [comment()].
+
string(Text) ->
lists:reverse(join_lines(scan_lines(Text))).
@@ -116,6 +124,8 @@ string(Text) ->
%% to (but not including) the line-terminating newline. For details on
%% `Line', `Column' and `Indent', see {@link file/1}.
+-spec scan_lines(string()) -> [commentLine()].
+
scan_lines(Text) ->
scan_lines(Text, 1, 0, 0, []).
@@ -231,6 +241,8 @@ scan_char([], _L, _Col, Ack) ->
%%
%% @see scan_lines/1
+-spec join_lines([commentLine()]) -> [comment()].
+
join_lines([{L, Col, Ind, Txt} | Lines]) ->
join_lines(Lines, [Txt], L, Col, Ind);
join_lines([]) ->