1 21 22 package org.armedbear.j; 23 24 public final class ObjCTag extends LocalTag 25 { 26 public ObjCTag(String name, Position pos) 27 { 28 super(name, pos); 29 canonicalSignature = parseCanonicalSignatureForMethod(); 30 } 31 32 public String getMethodName() 33 { 34 int index = name.indexOf(':'); 35 return index >= 0 ? name.substring(0, index) : name; 36 } 37 38 public String getLongName() 39 { 40 return canonicalSignature; 41 } 42 43 public String toString() 44 { 45 return name; 46 } 47 48 public String getSidebarText() 49 { 50 return name; 51 } 52 53 private String parseCanonicalSignatureForMethod() 54 { 55 FastStringBuffer sb = new FastStringBuffer(); 56 Position pos = getPosition().copy(); 57 pos.setOffset(0); 58 while (Character.isWhitespace(pos.getChar())) 59 if (!pos.next()) 60 return null; 61 char lastChar = 0; 62 char c; 63 while ((c = pos.getChar()) != '{') { 64 if (c == '/') { 65 if (!pos.next()) 66 return null; 67 skipComment(pos); 68 if (pos.atEnd()) 69 return null; 70 continue; 71 } 72 if (c == '\n' || c == '\t') 73 c = ' '; 74 if (c != ' ' || lastChar != ' ') { 75 sb.append(c); 76 lastChar = c; 77 } 78 if (!pos.next()) 79 return null; 80 } 81 return sb.toString().trim(); 82 } 83 84 private static void skipComment(Position pos) 87 { 88 char c = pos.getChar(); 89 if (!pos.next()) 90 return; 91 if (c == '/') { 92 while ((c = pos.getChar()) != '\n') 93 if (!pos.next()) 94 return; 95 pos.next(); 96 } else if (c == '*') { 97 while (!pos.lookingAt("*/")) 98 if (!pos.next()) 99 return; 100 pos.skip(2); 101 } 102 } 103 } 104 | Popular Tags |