01: /*
02: * LispTag.java
03: *
04: * Copyright (C) 2002-2003 Peter Graves
05: * $Id: LispTag.java,v 1.3 2003/10/11 00:12:01 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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: public LispTag(String name, Position pos) {
26: super (name, pos);
27: }
28:
29: public LispTag(String name, Position pos, int type) {
30: super (name, pos, type);
31: }
32:
33: public String getLongName() {
34: String s = signature.trim();
35:
36: if (s.startsWith("("))
37: s = s.substring(1).trim();
38:
39: // First word should be "defun" or "defvar" or ...
40: int end = 0;
41: final int limit = s.length();
42: for (int i = 0; i < limit; i++) {
43: char c = s.charAt(i);
44: if (c == ' ' || c == '\t') {
45: end = i;
46: break;
47: }
48: }
49: String d = s.substring(0, end);
50:
51: if (d.equals("defgeneric") || d.equals("defmethod"))
52: return signature;
53:
54: s = s.substring(end).trim();
55: end = s.length();
56: FastStringBuffer sb = new FastStringBuffer('(');
57: sb.append(d);
58: sb.append(' ');
59: for (int i = 0; i < end; i++) {
60: char c = s.charAt(i);
61: if (c == ' ' || c == '\t') {
62: sb.append(s.substring(0, i));
63: sb.append(" ...");
64: return sb.toString();
65: }
66: if (c == ')') {
67: sb.append(s.substring(0, i + 1));
68: return sb.toString();
69: }
70: }
71: sb.append(s.substring(0, end));
72: sb.append(" ...");
73: return sb.toString();
74: }
75: }
|