Removed unneccessary, refactored out code left in as comments for review

pull/1192/merge
SEATURCH 9 years ago committed by Don Ho
parent d96f8890f7
commit e800e7efbf

@ -143,7 +143,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
openFound = findText("<", searchStartPoint, 0, 0); openFound = findText("<", searchStartPoint, 0, 0);
styleAt = _pEditView->execute(SCI_GETSTYLEAT, openFound.start); styleAt = _pEditView->execute(SCI_GETSTYLEAT, openFound.start);
searchStartPoint = openFound.start - 1; searchStartPoint = openFound.start - 1;
} while (openFound.success && (styleAt == SCE_H_DOUBLESTRING || styleAt == SCE_H_SINGLESTRING || styleAt == SCE_H_COMMENT /*insideComment(openFound.start)*/) && searchStartPoint > 0); } while (openFound.success && (styleAt == SCE_H_DOUBLESTRING || styleAt == SCE_H_SINGLESTRING || styleAt == SCE_H_COMMENT ) && searchStartPoint > 0);
if (openFound.success && styleAt != SCE_H_CDATA) if (openFound.success && styleAt != SCE_H_CDATA)
{ {
@ -155,7 +155,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
closeFound = findText(">", searchStartPoint, caret, 0); closeFound = findText(">", searchStartPoint, caret, 0);
styleAt = _pEditView->execute(SCI_GETSTYLEAT, closeFound.start); styleAt = _pEditView->execute(SCI_GETSTYLEAT, closeFound.start);
searchStartPoint = closeFound.end; searchStartPoint = closeFound.end;
} while (closeFound.success && (styleAt == SCE_H_DOUBLESTRING || styleAt == SCE_H_SINGLESTRING || styleAt == SCE_H_COMMENT/* insideComment(closeFound.start)*/) && searchStartPoint <= caret); } while (closeFound.success && (styleAt == SCE_H_DOUBLESTRING || styleAt == SCE_H_SINGLESTRING || styleAt == SCE_H_COMMENT) && searchStartPoint <= caret);
if (!closeFound.success) if (!closeFound.success)
{ {
@ -282,7 +282,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
std::string tagName; std::string tagName;
nextChar = _pEditView->execute(SCI_GETCHARAT, position); nextChar = _pEditView->execute(SCI_GETCHARAT, position);
// Checking for " or ' is actually wrong here, but it means it works better with invalid XML // Checking for " or ' is actually wrong here, but it means it works better with invalid XML
while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' /*&& !insideComment(position)*/) while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' )
{ {
tagName.push_back((char)nextChar); tagName.push_back((char)nextChar);
++position; ++position;
@ -381,34 +381,6 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags)
return tagFound; return tagFound;
} }
bool XmlMatchedTagsHighlighter::insideComment(int pos) {
bool foundComment = false;
int cur = pos-1;
int nextChar, nextChar2, nextChar3;
//int styleAt = _pEditView->execute(SCI_GETSTYLEAT, pos);
while (cur > 3 && !foundComment) {
nextChar = _pEditView->execute(SCI_GETCHARAT, cur);
if (nextChar == '-') {
nextChar2 = _pEditView->execute(SCI_GETCHARAT, cur-1);
if (nextChar2 == '-') {
nextChar3 = _pEditView->execute(SCI_GETCHARAT, cur-2);
if (nextChar3 == '!') {
foundComment = true;
break;
}
}
}
else if (nextChar == '>') {
// check if it's closing comment tag
if (_pEditView->execute(SCI_GETCHARAT, cur-2) == '-' && _pEditView->execute(SCI_GETCHARAT, cur-1) == '-')
return false;
}
cur--;
}
return foundComment;
}
XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findOpenTag(const std::string& tagName, int start, int end) XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findOpenTag(const std::string& tagName, int start, int end)
{ {
std::string search("<"); std::string search("<");
@ -429,7 +401,7 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findOpenTag(con
{ {
nextChar = _pEditView->execute(SCI_GETCHARAT, result.end); nextChar = _pEditView->execute(SCI_GETCHARAT, result.end);
styleAt = _pEditView->execute(SCI_GETSTYLEAT, result.start); styleAt = _pEditView->execute(SCI_GETSTYLEAT, result.start);
if (styleAt != SCE_H_CDATA && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_COMMENT /*!insideComment(result.start)*/) if (styleAt != SCE_H_CDATA && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_COMMENT )
{ {
// We've got an open tag for this tag name (i.e. nextChar was space or '>') // We've got an open tag for this tag name (i.e. nextChar was space or '>')
// Now we need to find the end of the start tag. // Now we need to find the end of the start tag.
@ -499,7 +471,7 @@ int XmlMatchedTagsHighlighter::findCloseAngle(int startPosition, int endPosition
{ {
int style = _pEditView->execute(SCI_GETSTYLEAT, closeAngle.start); int style = _pEditView->execute(SCI_GETSTYLEAT, closeAngle.start);
// As long as we're not in an attribute ( <TAGNAME attrib="val>ue"> is VALID XML. ) // As long as we're not in an attribute ( <TAGNAME attrib="val>ue"> is VALID XML. )
if (style != SCE_H_DOUBLESTRING && style != SCE_H_SINGLESTRING && style != SCE_H_COMMENT /*!insideComment(closeAngle.start)*/) if (style != SCE_H_DOUBLESTRING && style != SCE_H_SINGLESTRING && style != SCE_H_COMMENT)
{ {
returnPosition = closeAngle.start; returnPosition = closeAngle.start;
isValidClose = true; isValidClose = true;
@ -548,7 +520,7 @@ XmlMatchedTagsHighlighter::FindResult XmlMatchedTagsHighlighter::findCloseTag(co
searchStart = result.start - 1; searchStart = result.start - 1;
} }
if (styleAt != SCE_H_CDATA && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_COMMENT/* !insideComment(result.start)*/) // If what we found was in CDATA section, it's not a valid tag. if (styleAt != SCE_H_CDATA && styleAt != SCE_H_SINGLESTRING && styleAt != SCE_H_DOUBLESTRING && styleAt != SCE_H_COMMENT) // If what we found was in CDATA section, it's not a valid tag.
{ {
// Common case - '>' follows the tag name directly // Common case - '>' follows the tag name directly
if (nextChar == '>') if (nextChar == '>')

Loading…
Cancel
Save