KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > j > LispTag


1 /*
2  * LispTag.java
3  *
4  * Copyright (C) 2002-2003 Peter Graves
5  * $Id: LispTag.java,v 1.3 2003/10/11 00:12:01 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.j;
23
24 public final class LispTag extends LocalTag
25 {
26     public LispTag(String JavaDoc name, Position pos)
27     {
28         super(name, pos);
29     }
30
31     public LispTag(String JavaDoc name, Position pos, int type)
32     {
33         super(name, pos, type);
34     }
35
36     public String JavaDoc getLongName()
37     {
38         String JavaDoc s = signature.trim();
39
40         if (s.startsWith("("))
41             s = s.substring(1).trim();
42
43         // First word should be "defun" or "defvar" or ...
44
int end = 0;
45         final int limit = s.length();
46         for (int i = 0; i < limit; i++) {
47             char c = s.charAt(i);
48             if (c == ' ' || c == '\t') {
49                 end = i;
50                 break;
51             }
52         }
53         String JavaDoc d = s.substring(0, end);
54
55         if (d.equals("defgeneric") || d.equals("defmethod"))
56             return signature;
57
58         s = s.substring(end).trim();
59         end = s.length();
60         FastStringBuffer sb = new FastStringBuffer('(');
61         sb.append(d);
62         sb.append(' ');
63         for (int i = 0; i < end; i++) {
64             char c = s.charAt(i);
65             if (c == ' ' || c == '\t') {
66                 sb.append(s.substring(0, i));
67                 sb.append(" ...");
68                 return sb.toString();
69             }
70             if (c == ')') {
71                 sb.append(s.substring(0, i+1));
72                 return sb.toString();
73             }
74         }
75         sb.append(s.substring(0, end));
76         sb.append(" ...");
77         return sb.toString();
78     }
79 }
80
Popular Tags