Link Here
|
683 |
boolean tokenWhiteSpace = this.scanner.tokenizeWhiteSpace; |
683 |
boolean tokenWhiteSpace = this.scanner.tokenizeWhiteSpace; |
684 |
this.scanner.tokenizeWhiteSpace = true; |
684 |
this.scanner.tokenizeWhiteSpace = true; |
685 |
|
685 |
|
686 |
// Verify that there are whitespaces after tag |
686 |
try { |
687 |
boolean isCompletionParser = (this.kind & COMPLETION_PARSER) != 0; |
687 |
// Verify that there are whitespaces after tag |
688 |
if (this.scanner.currentCharacter != ' ' && !ScannerHelper.isWhitespace(this.scanner.currentCharacter)) { |
688 |
boolean isCompletionParser = (this.kind & COMPLETION_PARSER) != 0; |
689 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(start, this.scanner.getCurrentTokenEndPosition()); |
689 |
if (this.scanner.currentCharacter != ' ' && !ScannerHelper.isWhitespace(this.scanner.currentCharacter)) { |
690 |
if (!isCompletionParser) { |
690 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(start, this.scanner.getCurrentTokenEndPosition()); |
691 |
this.scanner.currentPosition = start; |
691 |
if (!isCompletionParser) { |
692 |
this.index = start; |
692 |
this.scanner.currentPosition = start; |
693 |
} |
693 |
this.index = start; |
694 |
this.currentTokenType = -1; |
694 |
} |
695 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
695 |
this.currentTokenType = -1; |
696 |
return false; |
696 |
return false; |
697 |
} |
|
|
698 |
|
699 |
// Get first non whitespace token |
700 |
this.identifierPtr = -1; |
701 |
this.identifierLengthPtr = -1; |
702 |
boolean hasMultiLines = this.scanner.currentPosition > (this.lineEnd+1); |
703 |
boolean isTypeParam = false; |
704 |
boolean valid = true, empty = true; |
705 |
boolean mayBeGeneric = this.sourceLevel >= ClassFileConstants.JDK1_5; |
706 |
int token = -1; |
707 |
nextToken: while (true) { |
708 |
this.currentTokenType = -1; |
709 |
try { |
710 |
token = readToken(); |
711 |
} catch (InvalidInputException e) { |
712 |
valid = false; |
713 |
} |
714 |
switch (token) { |
715 |
case TerminalTokens.TokenNameIdentifier : |
716 |
if (valid) { |
717 |
// store param name id |
718 |
pushIdentifier(true, false); |
719 |
start = this.scanner.getCurrentTokenStartPosition(); |
720 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
721 |
break nextToken; |
722 |
} |
723 |
// fall through next case to report error |
724 |
case TerminalTokens.TokenNameLESS: |
725 |
if (valid && mayBeGeneric) { |
726 |
// store '<' in identifiers stack as we need to add it to tag element (bug 79809) |
727 |
pushIdentifier(true, true); |
728 |
start = this.scanner.getCurrentTokenStartPosition(); |
729 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
730 |
isTypeParam = true; |
731 |
break nextToken; |
732 |
} |
733 |
// fall through next case to report error |
734 |
default: |
735 |
if (token == TerminalTokens.TokenNameLEFT_SHIFT) isTypeParam = true; |
736 |
if (valid && !hasMultiLines) start = this.scanner.getCurrentTokenStartPosition(); |
737 |
valid = false; |
738 |
if (!hasMultiLines) { |
739 |
empty = false; |
740 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
741 |
break; |
742 |
} |
743 |
end = this.lineEnd; |
744 |
// when several lines, fall through next case to report problem immediately |
745 |
case TerminalTokens.TokenNameWHITESPACE: |
746 |
if (this.scanner.currentPosition > (this.lineEnd+1)) hasMultiLines = true; |
747 |
if (valid) break; |
748 |
// if not valid fall through next case to report error |
749 |
case TerminalTokens.TokenNameEOF: |
750 |
if (this.reportProblems) |
751 |
if (empty) |
752 |
this.sourceParser.problemReporter().javadocMissingParamName(start, end, this.sourceParser.modifiers); |
753 |
else if (mayBeGeneric && isTypeParam) |
754 |
this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
755 |
else |
756 |
this.sourceParser.problemReporter().javadocInvalidParamTagName(start, end); |
757 |
if (!isCompletionParser) { |
758 |
this.scanner.currentPosition = start; |
759 |
this.index = start; |
760 |
} |
761 |
this.currentTokenType = -1; |
762 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
763 |
return false; |
764 |
} |
697 |
} |
765 |
} |
698 |
|
766 |
|
699 |
// Get first non whitespace token |
767 |
// Scan more tokens for type parameter declaration |
700 |
this.identifierPtr = -1; |
768 |
if (isTypeParam && mayBeGeneric) { |
701 |
this.identifierLengthPtr = -1; |
769 |
// Get type parameter name |
702 |
boolean hasMultiLines = this.scanner.currentPosition > (this.lineEnd+1); |
|
|
703 |
boolean isTypeParam = false; |
704 |
boolean valid = true, empty = true; |
705 |
boolean mayBeGeneric = this.sourceLevel >= ClassFileConstants.JDK1_5; |
706 |
int token = -1; |
770 |
nextToken: while (true) { |
707 |
nextToken: while (true) { |
771 |
this.currentTokenType = -1; |
708 |
this.currentTokenType = -1; |
772 |
try { |
709 |
try { |
Link Here
|
775 |
valid = false; |
712 |
valid = false; |
776 |
} |
713 |
} |
777 |
switch (token) { |
714 |
switch (token) { |
|
|
715 |
case TerminalTokens.TokenNameIdentifier : |
716 |
if (valid) { |
717 |
// store param name id |
718 |
pushIdentifier(true, false); |
719 |
start = this.scanner.getCurrentTokenStartPosition(); |
720 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
721 |
break nextToken; |
722 |
} |
723 |
// fall through next case to report error |
724 |
case TerminalTokens.TokenNameLESS: |
725 |
if (valid && mayBeGeneric) { |
726 |
// store '<' in identifiers stack as we need to add it to tag element (bug 79809) |
727 |
pushIdentifier(true, true); |
728 |
start = this.scanner.getCurrentTokenStartPosition(); |
729 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
730 |
isTypeParam = true; |
731 |
break nextToken; |
732 |
} |
733 |
// fall through next case to report error |
734 |
default: |
735 |
if (token == TerminalTokens.TokenNameLEFT_SHIFT) isTypeParam = true; |
736 |
if (valid && !hasMultiLines) start = this.scanner.getCurrentTokenStartPosition(); |
737 |
valid = false; |
738 |
if (!hasMultiLines) { |
739 |
empty = false; |
740 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
741 |
break; |
742 |
} |
743 |
end = this.lineEnd; |
744 |
// when several lines, fall through next case to report problem immediately |
778 |
case TerminalTokens.TokenNameWHITESPACE: |
745 |
case TerminalTokens.TokenNameWHITESPACE: |
779 |
if (valid && this.scanner.currentPosition <= (this.lineEnd+1)) break; |
746 |
if (this.scanner.currentPosition > (this.lineEnd+1)) hasMultiLines = true; |
|
|
747 |
if (valid) break; |
780 |
// if not valid fall through next case to report error |
748 |
// if not valid fall through next case to report error |
781 |
case TerminalTokens.TokenNameEOF: |
749 |
case TerminalTokens.TokenNameEOF: |
782 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
750 |
if (this.reportProblems) |
|
|
751 |
if (empty) |
752 |
this.sourceParser.problemReporter().javadocMissingParamName(start, end, this.sourceParser.modifiers); |
753 |
else if (mayBeGeneric && isTypeParam) |
754 |
this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
755 |
else |
756 |
this.sourceParser.problemReporter().javadocInvalidParamTagName(start, end); |
783 |
if (!isCompletionParser) { |
757 |
if (!isCompletionParser) { |
784 |
this.scanner.currentPosition = start; |
758 |
this.scanner.currentPosition = start; |
785 |
this.index = start; |
759 |
this.index = start; |
786 |
} |
760 |
} |
787 |
this.currentTokenType = -1; |
761 |
this.currentTokenType = -1; |
788 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
|
|
789 |
return false; |
762 |
return false; |
790 |
case TerminalTokens.TokenNameIdentifier : |
763 |
} |
791 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
764 |
} |
792 |
if (valid) { |
765 |
|
793 |
// store param name id |
766 |
// Scan more tokens for type parameter declaration |
794 |
pushIdentifier(false, false); |
767 |
if (isTypeParam && mayBeGeneric) { |
795 |
break nextToken; |
768 |
// Get type parameter name |
796 |
} |
769 |
nextToken: while (true) { |
797 |
break; |
770 |
this.currentTokenType = -1; |
798 |
default: |
771 |
try { |
799 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
772 |
token = readToken(); |
|
|
773 |
} catch (InvalidInputException e) { |
774 |
valid = false; |
775 |
} |
776 |
switch (token) { |
777 |
case TerminalTokens.TokenNameWHITESPACE: |
778 |
if (valid && this.scanner.currentPosition <= (this.lineEnd+1)) break; |
779 |
// if not valid fall through next case to report error |
780 |
case TerminalTokens.TokenNameEOF: |
781 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
782 |
if (!isCompletionParser) { |
783 |
this.scanner.currentPosition = start; |
784 |
this.index = start; |
785 |
} |
786 |
this.currentTokenType = -1; |
787 |
return false; |
788 |
case TerminalTokens.TokenNameIdentifier : |
789 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
790 |
if (valid) { |
791 |
// store param name id |
792 |
pushIdentifier(false, false); |
793 |
break nextToken; |
794 |
} |
795 |
break; |
796 |
default: |
797 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
798 |
valid = false; |
799 |
break; |
800 |
} |
801 |
} |
802 |
|
803 |
// Get last character of type parameter declaration |
804 |
boolean spaces = false; |
805 |
nextToken: while (true) { |
806 |
this.currentTokenType = -1; |
807 |
try { |
808 |
token = readToken(); |
809 |
} catch (InvalidInputException e) { |
800 |
valid = false; |
810 |
valid = false; |
801 |
break; |
811 |
} |
|
|
812 |
switch (token) { |
813 |
case TerminalTokens.TokenNameWHITESPACE: |
814 |
if (this.scanner.currentPosition > (this.lineEnd+1)) { |
815 |
// do not accept type parameter declaration on several lines |
816 |
hasMultiLines = true; |
817 |
valid = false; |
818 |
} |
819 |
spaces = true; |
820 |
if (valid) break; |
821 |
// if not valid fall through next case to report error |
822 |
case TerminalTokens.TokenNameEOF: |
823 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
824 |
if (!isCompletionParser) { |
825 |
this.scanner.currentPosition = start; |
826 |
this.index = start; |
827 |
} |
828 |
this.currentTokenType = -1; |
829 |
return false; |
830 |
case TerminalTokens.TokenNameGREATER: |
831 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
832 |
if (valid) { |
833 |
// store '>' in identifiers stack as we need to add it to tag element (bug 79809) |
834 |
pushIdentifier(false, true); |
835 |
break nextToken; |
836 |
} |
837 |
break; |
838 |
default: |
839 |
if (!spaces) end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
840 |
valid = false; |
841 |
break; |
842 |
} |
802 |
} |
843 |
} |
803 |
} |
844 |
} |
804 |
|
845 |
|
805 |
// Get last character of type parameter declaration |
846 |
// Verify that tag name is well followed by white spaces |
806 |
boolean spaces = false; |
847 |
if (valid) { |
807 |
nextToken: while (true) { |
|
|
808 |
this.currentTokenType = -1; |
848 |
this.currentTokenType = -1; |
|
|
849 |
int restart = this.scanner.currentPosition; |
809 |
try { |
850 |
try { |
810 |
token = readToken(); |
851 |
token = readToken(); |
811 |
} catch (InvalidInputException e) { |
852 |
} catch (InvalidInputException e) { |
812 |
valid = false; |
853 |
valid = false; |
813 |
} |
854 |
} |
814 |
switch (token) { |
855 |
if (token == TerminalTokens.TokenNameWHITESPACE) { |
815 |
case TerminalTokens.TokenNameWHITESPACE: |
856 |
this.scanner.currentPosition = restart; |
816 |
if (this.scanner.currentPosition > (this.lineEnd+1)) { |
857 |
this.index = restart; |
817 |
// do not accept type parameter declaration on several lines |
858 |
return pushParamName(isTypeParam); |
818 |
hasMultiLines = true; |
|
|
819 |
valid = false; |
820 |
} |
821 |
spaces = true; |
822 |
if (valid) break; |
823 |
// if not valid fall through next case to report error |
824 |
case TerminalTokens.TokenNameEOF: |
825 |
if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
826 |
if (!isCompletionParser) { |
827 |
this.scanner.currentPosition = start; |
828 |
this.index = start; |
829 |
} |
830 |
this.currentTokenType = -1; |
831 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
832 |
return false; |
833 |
case TerminalTokens.TokenNameGREATER: |
834 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
835 |
if (valid) { |
836 |
// store '>' in identifiers stack as we need to add it to tag element (bug 79809) |
837 |
pushIdentifier(false, true); |
838 |
break nextToken; |
839 |
} |
840 |
break; |
841 |
default: |
842 |
if (!spaces) end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
843 |
valid = false; |
844 |
break; |
845 |
} |
859 |
} |
846 |
} |
860 |
} |
847 |
} |
861 |
// Report problem |
848 |
|
|
|
849 |
// Verify that tag name is well followed by white spaces |
850 |
if (valid) { |
851 |
this.currentTokenType = -1; |
862 |
this.currentTokenType = -1; |
852 |
int restart = this.scanner.currentPosition; |
863 |
if (isCompletionParser) return false; |
853 |
try { |
864 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
854 |
token = readToken(); |
865 |
while ((token=readToken()) != TerminalTokens.TokenNameWHITESPACE && token != TerminalTokens.TokenNameEOF) { |
855 |
} catch (InvalidInputException e) { |
866 |
this.currentTokenType = -1; |
856 |
valid = false; |
867 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
857 |
} |
|
|
858 |
if (token == TerminalTokens.TokenNameWHITESPACE) { |
859 |
this.scanner.currentPosition = restart; |
860 |
this.index = restart; |
861 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
862 |
return pushParamName(isTypeParam); |
863 |
} |
868 |
} |
864 |
} |
869 |
if (this.reportProblems) |
865 |
|
870 |
if (mayBeGeneric && isTypeParam) |
866 |
// Report problem |
871 |
this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
867 |
this.currentTokenType = -1; |
872 |
else |
868 |
if (isCompletionParser) return false; |
873 |
this.sourceParser.problemReporter().javadocInvalidParamTagName(start, end); |
869 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
874 |
this.scanner.currentPosition = start; |
870 |
while ((token=readToken()) != TerminalTokens.TokenNameWHITESPACE && token != TerminalTokens.TokenNameEOF) { |
875 |
this.index = start; |
871 |
this.currentTokenType = -1; |
876 |
this.currentTokenType = -1; |
872 |
end = hasMultiLines ? this.lineEnd: this.scanner.getCurrentTokenEndPosition(); |
877 |
return false; |
|
|
878 |
} finally { |
879 |
// we have to make sure that this is reset to the previous value even if an exception occurs |
880 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
873 |
} |
881 |
} |
874 |
if (this.reportProblems) |
|
|
875 |
if (mayBeGeneric && isTypeParam) |
876 |
this.sourceParser.problemReporter().javadocInvalidParamTypeParameter(start, end); |
877 |
else |
878 |
this.sourceParser.problemReporter().javadocInvalidParamTagName(start, end); |
879 |
this.scanner.currentPosition = start; |
880 |
this.index = start; |
881 |
this.currentTokenType = -1; |
882 |
this.scanner.tokenizeWhiteSpace = tokenWhiteSpace; |
883 |
return false; |
884 |
} |
882 |
} |
885 |
|
883 |
|
886 |
/* |
884 |
/* |