📄 docimpl.java
字号:
whitespaceBuf.setLength(0); String paramName="", paramValue=""; Map tags=new HashMap(); tags.put("inline", new LinkedList()); tags.put("first", new LinkedList()); tags.put("all", new LinkedList()); final char EOL=(char)-1; for (int i=rawDocStart; i<=endIndex; ++i) { char c=(i<endIndex)?comment[i]:EOL; char peek=(i<endIndex-1)?comment[i+1]:EOL; switch (state){ case STATE_BEGOFLINE: if (i==firstSentenceEnd) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); } if (Parser.isWhitespace(c)) { // ignore } else if (c=='*') { // ignore, but go to STATE_TEXT if (peek!='*' && peek!='@' && peek!=EOL) { state=STATE_WHITESPACE; } } else if (c=='@' || (c=='{' && peek=='@') || c==EOL) { if (bufLength()>0) { addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false); setBufLength(0); } if (c=='{') { ++i; state=STATE_INLINEPARAM; } else { state=STATE_PARAM; } } else { state=STATE_TEXT; appendToBuf(whitespaceBuf); whitespaceBuf.setLength(0); appendToBuf(c); } break; case STATE_WHITESPACE: if (i==firstSentenceEnd) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); } if (c=='\n') { whitespaceBuf.append(c); state=STATE_BEGOFLINE; } else if (Parser.isWhitespace(c)) { whitespaceBuf.append(c); } else if (c=='@' || (c=='{' && peek=='@') || c==EOL) { if (bufLength()>0) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); } if (c=='{') { ++i; state=STATE_INLINEPARAM; } else { state=STATE_PARAM; } } else { appendToBuf(whitespaceBuf); whitespaceBuf.setLength(0); appendToBuf(c); state=STATE_TEXT; } break; case STATE_PARAMWRAP: if (c=='\n') { appendToBuf(c); } else if (Parser.isWhitespace(c)) { // ignore } else if (c=='*') { // ignore, but go to STATE_TEXT /* if (i<endIndex && comment[i+1]!='*' && comment[i+1]!='@') { state=STATE_PARAMVALUE; } */ } else if (c=='@' || c==EOL) { paramValue=bufToString(); AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); if (c=='{') { ++i; state=STATE_INLINEPARAM; } else { state=STATE_PARAM; } } else { state=STATE_PARAMVALUE; appendToBuf(c); } break; case STATE_PARAM: if (!(c==EOL || Parser.isWhitespace(c))) { appendToBuf(c); } else if (c=='\n') { paramName=bufToString(); setBufLength(0); state=STATE_PARAMWRAP; } else { paramName=bufToString(); setBufLength(0); state=STATE_PARAMVALUE; } break; case STATE_INLINEPARAM: if (c=='}') { // tag without value paramName=bufToString(); AbstractTagImpl newTag = addTag(tags, paramName, "", i<firstSentenceEnd, contextClass, contextMember, contextTag, true); if (null != newTag) { contextTag = newTag; } state=prevState; setBufLength(0); } else if (!(c==EOL || Parser.isWhitespace(c))) { appendToBuf(c); } else if (c=='\n') { paramName=bufToString(); setBufLength(0); state=STATE_INLINEPARAMVALUE_BOL; } else { paramName=bufToString(); setBufLength(0); state=STATE_INLINEPARAMVALUE; } break; case STATE_PARAMVALUE: if (c==EOL) { paramValue=bufToString(); AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } } else if (c=='\n') { appendToBuf(c); state=STATE_PARAMWRAP; } else { appendToBuf(c); } break; case STATE_INLINEPARAMVALUE: if (c=='\n') { appendToBuf(c); state=STATE_INLINEPARAMVALUE_BOL; } else if (c==EOL || c=='}') { paramValue=bufToString(); AbstractTagImpl newTag = addTag(tags, paramName, paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, true); if (null != newTag) { contextTag = newTag; } state=prevState; setBufLength(0); } else { appendToBuf(c); } break; case STATE_INLINEPARAMVALUE_BOL: if (Parser.isWhitespace(c)) { // ignore } else if (c=='*') { // ignore, but go to STATE_TEXT if (i<endIndex && peek!='*') { state=STATE_IPV_WHITESPACE; } } else if (c==EOL) { if (bufLength()>0) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } } } else { state=STATE_INLINEPARAMVALUE; appendToBuf(whitespaceBuf); whitespaceBuf.setLength(0); appendToBuf(c); } break; case STATE_IPV_WHITESPACE: if (c=='\n') { whitespaceBuf.append(c); state=STATE_INLINEPARAMVALUE_BOL; } else if (Parser.isWhitespace(c)) { whitespaceBuf.append(c); } else if (c==EOL) { if (bufLength()>0) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); } } else { appendToBuf(whitespaceBuf); whitespaceBuf.setLength(0); appendToBuf(c); state=STATE_INLINEPARAMVALUE; } break; case STATE_TEXT: if (i==firstSentenceEnd) { AbstractTagImpl newTag = addTag(tags, "text", bufToString(), true, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } setBufLength(0); } if (c==EOL) { paramValue=bufToString(); AbstractTagImpl newTag = addTag(tags, "text", paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } } else if (c=='\n') { appendToBuf(c); state=STATE_BEGOFLINE; } else if (c=='{' && peek=='@') { paramValue=bufToString(); AbstractTagImpl newTag = addTag(tags, "text", paramValue, i<firstSentenceEnd, contextClass, contextMember, contextTag, false); if (null != newTag) { contextTag = newTag; } ++i; setBufLength(0); state=STATE_INLINEPARAM; } else { appendToBuf(c); } break; default: throw new Error("illegal state "+state); } } if (null == contextMember && null != boilerplateComment && Main.getInstance().isCopyLicenseText()) { addTag(tags, "@boilerplate", boilerplateComment, false, contextClass, null, null, false); } Map rc=new HashMap(); for (Iterator it=tags.keySet().iterator(); it.hasNext(); ) { String key=(String)it.next(); Tag[] templateArr; List list=(List)tags.get(key); if ("see".equals(key)) templateArr=new SeeTag[list.size()]; else if ("param".equals(key)) templateArr=new ParamTag[list.size()]; else if ("serialField".equals(key)) templateArr=new SerialFieldTag[list.size()]; else if ("throws".equals(key) || "exception".equals(key)) templateArr=new ThrowsTag[list.size()]; else { templateArr=new Tag[list.size()]; } rc.put(key, list.toArray(templateArr)); } return rc; } private ClassDocImpl getContextClass() { if (isClass() || isInterface()) { return (ClassDocImpl)this; } else if (isField() || isMethod() || isConstructor()) { return (ClassDocImpl)((MemberDocImpl)this).containingClass(); } else { return null; } } private MemberDocImpl getContextMember() { if (isField() || isMethod() || isConstructor()) { return (MemberDocImpl)this; } else { return null; } } protected static AbstractTagImpl addTag(Map tags, String name, String value, boolean isFirstSentence, ClassDocImpl contextClass, MemberDocImpl contextMember, AbstractTagImpl contextTag, boolean isInline) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -