KickJava   Java API By Example, From Geeks To Geeks.

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


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

22
23 package org.armedbear.j;
24
25 public final class RubyTag extends LocalTag
26 {
27     public RubyTag(String JavaDoc name, Position pos, int type)
28     {
29         super(name, pos, type);
30     }
31
32     public String JavaDoc getLongName()
33     {
34         if (name.startsWith("class "))
35             return name;
36         String JavaDoc s = signature.trim();
37         if (s.startsWith("def ") || s.startsWith("def\t"))
38             s = s.substring(4).trim();
39         // Strip comment if any.
40
int index = s.indexOf('#');
41         if (index >= 0)
42             s = s.substring(0, index).trim();
43         index = s.indexOf(')');
44         if (index >= 0)
45             s = s.substring(0, index+1);
46         if (s.endsWith("("))
47             s = s.substring(0, s.length()-1);
48         return s;
49     }
50 }
51
Popular Tags