MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / matchLeft

Method matchLeft

MiniZincIDE/codeeditor.cpp:477–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475}
476
477int CodeEditor::matchLeft(QTextBlock block, QChar b, int i, int nLeft)
478{
479 QChar match;
480 switch (b.toLatin1()) {
481 case '(' : match = ')'; break;
482 case '{' : match = '}'; break;
483 case '[' : match = ']'; break;
484 default: break; // should not happen
485 }
486
487 while (block.isValid()) {
488 BracketData* bd = static_cast<BracketData*>(block.userData());
489 QVector<Bracket>& brackets = bd->brackets;
490 int docPos = block.position();
491 for (; i<brackets.size(); i++) {
492 Bracket& b = brackets[i];
493 if (b.b=='(' || b.b=='{' || b.b=='[') {
494 nLeft++;
495 } else if (b.b==match && nLeft==0) {
496 return docPos+b.pos;
497 } else {
498 nLeft--;
499 }
500 }
501 block = block.next();
502 i = 0;
503 }
504 return -1;
505}
506
507int CodeEditor::matchRight(QTextBlock block, QChar b, int i, int nRight)
508{

Callers

nothing calls this directly

Calls 3

isValidMethod · 0.80
nextMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected