detect deprecated methods
If a method in an include is marked deprecated, make sure that
the documentation is marked deprecated.
It's OK for the documentation to mark something deprecated that
is not marked as such in the includes since the documentation may
be ahead of the includes.
Fix a couple of mistakes found around deprecated methods.
Docs-Preview: https://skia.org/?cl=114184
TBR=caryclark@google.com
Bug: skia:6898
Change-Id: I2bb4c293d7bf28e5d12f9ae01b7be49ce48b9ee4
Reviewed-on: https://skia-review.googlesource.com/114184
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp
index c69af7a..9006176 100644
--- a/tools/bookmaker/includeParser.cpp
+++ b/tools/bookmaker/includeParser.cpp
@@ -9,6 +9,9 @@
#include "SkOSFile.h"
#include "SkOSPath.h"
+const char IncludeParser::gAttrDeprecated[] = "SK_ATTR_DEPRECATED";
+const size_t IncludeParser::kAttrDeprecatedLen = sizeof(gAttrDeprecated) - 1;
+
const IncludeKey kKeyWords[] = {
{ "", KeyWord::kNone, KeyProperty::kNone },
{ "SK_API", KeyWord::kSK_API, KeyProperty::kModifier },
@@ -329,7 +332,8 @@
}
}
if (!def) {
- if ("SK_ATTR_DEPRECATED" == token.fName) {
+ if (gAttrDeprecated == token.fName) {
+ fAttrDeprecated = &token;
break;
}
if (0 == token.fName.find("SkDEBUGCODE")) {
@@ -353,6 +357,9 @@
if (MarkType::kDefinedBy == def->fMarkType) {
def->fParent->fVisited = true;
}
+ if (token.fDeprecated && !def->fDeprecated) {
+ fFailed = !def->reportError<bool>("expect bmh to be marked deprecated");
+ }
} else {
SkDebugf("method differs from bmh: %s\n", fullName.c_str());
fFailed = true;
@@ -1749,7 +1756,8 @@
child->fStart, fLastObject->fLineCount);
if (!checkDeprecated.eof()) {
checkDeprecated.skipWhiteSpace();
- if (checkDeprecated.startsWith("SK_ATTR_DEPRECATED")) {
+ if (checkDeprecated.startsWith(gAttrDeprecated)) {
+ fAttrDeprecated = child;
break;
}
}
@@ -1759,7 +1767,8 @@
std::advance(tokenIter, child->fParentIndex);
tokenIter = std::prev(tokenIter);
TextParser previousToken(&*tokenIter);
- if (previousToken.startsWith("SK_ATTR_DEPRECATED")) {
+ if (previousToken.startsWith(gAttrDeprecated)) {
+ fAttrDeprecated = &*tokenIter;
break;
}
if (Bracket::kPound == child->fParent->fBracket &&
@@ -1774,6 +1783,11 @@
if (!this->parseMethod(child, markupDef)) {
return child->reportError<bool>("failed to parse method");
}
+ if (fAttrDeprecated) {
+ Definition* lastMethod = &markupDef->fTokens.back();
+ lastMethod->fDeprecated = true;
+ fAttrDeprecated = nullptr;
+ }
break;
case Bracket::kSlashSlash:
case Bracket::kSlashStar:
@@ -2047,35 +2061,7 @@
']' == test ? Bracket::kSquare : Bracket::kBrace) == this->topBracket()) {
this->popBracket();
if (!fInFunction) {
- bool deprecatedMacro = false;
- if (')' == test) {
- auto iter = fParent->fTokens.end();
- bool lookForWord = false;
- while (fParent->fTokens.begin() != iter) {
- --iter;
- if (lookForWord) {
- if (Definition::Type::kWord != iter->fType) {
- break;
- }
- string word(iter->fContentStart, iter->length());
- if ("SK_ATTR_EXTERNALLY_DEPRECATED" == word) {
- deprecatedMacro = true;
- // remove macro paren (would confuse method parsing later)
- fParent->fTokens.pop_back();
- fParent->fChildren.pop_back();
- }
- break;
- }
- if (Definition::Type::kBracket != iter->fType) {
- break;
- }
- if (Bracket::kParen != iter->fBracket) {
- break;
- }
- lookForWord = true;
- }
- }
- fInFunction = ')' == test && !deprecatedMacro;
+ fInFunction = ')' == test;
} else {
fInFunction = '}' != test;
}