1 11 package org.eclipse.jdt.internal.compiler; 12 13 import org.eclipse.jdt.core.compiler.CharOperation; 14 import org.eclipse.jdt.internal.compiler.parser.JavadocParser; 15 import org.eclipse.jdt.internal.compiler.parser.Parser; 16 import org.eclipse.jdt.internal.compiler.parser.ScannerHelper; 17 import org.eclipse.jdt.internal.compiler.parser.TerminalTokens; 18 19 public class SourceJavadocParser extends JavadocParser { 20 21 int categoriesPtr = -1; 23 char[][] categories = CharOperation.NO_CHAR_CHAR; 24 25 public SourceJavadocParser(Parser sourceParser) { 26 super(sourceParser); 27 this.kind = SOURCE_PARSER | TEXT_VERIF; 28 } 29 30 public boolean checkDeprecation(int commentPtr) { 31 this.categoriesPtr = -1; 32 boolean result = super.checkDeprecation(commentPtr); 33 if (this.categoriesPtr > -1) { 34 System.arraycopy(this.categories, 0, this.categories = new char[this.categoriesPtr+1][], 0, this.categoriesPtr+1); 35 } else { 36 this.categories = CharOperation.NO_CHAR_CHAR; 37 } 38 return result; 39 } 40 41 44 protected boolean parseIdentifierTag(boolean report) { 45 int end = this.lineEnd+1; 46 if (super.parseIdentifierTag(report) && this.index <= end) { 47 if (this.tagValue == TAG_CATEGORY_VALUE) { 48 int length = this.categories.length; 50 if (++this.categoriesPtr >= length) { 51 System.arraycopy(this.categories, 0, this.categories = new char[length+5][], 0, length); 52 length += 5; 53 } 54 this.categories[this.categoriesPtr] = this.identifierStack[this.identifierPtr--]; 55 consumeToken(); 57 while (this.index < end) { 58 if (readTokenSafely() == TerminalTokens.TokenNameIdentifier && (this.scanner.currentCharacter == ' ' || ScannerHelper.isWhitespace(this.scanner.currentCharacter))) { 59 if (this.index > (this.lineEnd+1)) break; 60 if (++this.categoriesPtr >= length) { 62 System.arraycopy(this.categories, 0, this.categories = new char[length+5][], 0, length); 63 length += 5; 64 } 65 this.categories[this.categoriesPtr] = this.scanner.getCurrentIdentifierSource(); 66 consumeToken(); 67 } else { 68 break; 70 } 71 } 72 this.index = end; 74 this.scanner.currentPosition = end; 75 consumeToken(); 76 } 77 return true; 78 } 79 return false; 80 } 81 82 85 protected void parseSimpleTag() { 86 87 char first = this.source[this.index++]; 90 if (first == '\\' && this.source[this.index] == 'u') { 91 int c1, c2, c3, c4; 92 int pos = this.index; 93 this.index++; 94 while (this.source[this.index] == 'u') 95 this.index++; 96 if (!(((c1 = ScannerHelper.getNumericValue(this.source[this.index++])) > 15 || c1 < 0) 97 || ((c2 = ScannerHelper.getNumericValue(this.source[this.index++])) > 15 || c2 < 0) 98 || ((c3 = ScannerHelper.getNumericValue(this.source[this.index++])) > 15 || c3 < 0) 99 || ((c4 = ScannerHelper.getNumericValue(this.source[this.index++])) > 15 || c4 < 0))) { 100 first = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); 101 } else { 102 this.index = pos; 103 } 104 } 105 106 switch (first) { 108 case 'd': if ((readChar() == 'e') && 110 (readChar() == 'p') && (readChar() == 'r') && 111 (readChar() == 'e') && (readChar() == 'c') && 112 (readChar() == 'a') && (readChar() == 't') && 113 (readChar() == 'e') && (readChar() == 'd')) { 114 char c = readChar(); 116 if (ScannerHelper.isWhitespace(c) || c == '*') { 117 this.tagValue = TAG_DEPRECATED_VALUE; 118 this.deprecated = true; 119 } 120 } 121 break; 122 case 'c': if ((readChar() == 'a') && 124 (readChar() == 't') && (readChar() == 'e') && 125 (readChar() == 'g') && (readChar() == 'o') && 126 (readChar() == 'r') && (readChar() == 'y')) { 127 char c = readChar(); 129 if (ScannerHelper.isWhitespace(c) || c == '*') { 130 this.tagValue = TAG_CATEGORY_VALUE; 131 if (this.scanner.source == null) { 132 this.scanner.setSource(this.source); 133 } 134 this.scanner.resetTo(this.index, this.scanner.eofPosition); 135 parseIdentifierTag(false); } 137 } 138 break; 139 } 140 } 141 142 } 143 | Popular Tags |