Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Sep 25, 2023
1 parent 991c7b4 commit e74bf91
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 144 deletions.
10 changes: 5 additions & 5 deletions atom/src/bracket-matcher-view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void BracketMatcherView::updateMatch() {
this->tagHighlighted = highlightTag;
}

optional<Point> BracketMatcherView::findMatchingEndBracket(Point startBracketPosition, char16_t startBracket, char16_t endBracket) {
optional<Point> BracketMatcherView::findMatchingEndBracket(const Point &startBracketPosition, char16_t startBracket, char16_t endBracket) {
if (startBracket == endBracket) return optional<Point>();

if (TreeSitterLanguageMode *languageMode = this->hasSyntaxTree()) {
Expand All @@ -90,7 +90,7 @@ optional<Point> BracketMatcherView::findMatchingEndBracket(Point startBracketPos
}
}

optional<Point> BracketMatcherView::findMatchingStartBracket(Point endBracketPosition, char16_t startBracket, char16_t endBracket) {
optional<Point> BracketMatcherView::findMatchingStartBracket(const Point &endBracketPosition, char16_t startBracket, char16_t endBracket) {
if (startBracket == endBracket) return optional<Point>();

if (TreeSitterLanguageMode *languageMode = this->hasSyntaxTree()) {
Expand All @@ -111,7 +111,7 @@ template <typename T> static Range rangeForNode(T node) {
return Range(startPosition(node), endPosition(node));
}

optional<Point> BracketMatcherView::findMatchingEndBracketWithSyntaxTree(Point bracketPosition, char16_t startBracket, char16_t endBracket, TreeSitterLanguageMode *languageMode) {
optional<Point> BracketMatcherView::findMatchingEndBracketWithSyntaxTree(const Point &bracketPosition, char16_t startBracket, char16_t endBracket, TreeSitterLanguageMode *languageMode) {
optional<Point> result;
const Point bracketEndPosition = bracketPosition.traverse({0, 1});
languageMode->getSyntaxNodeContainingRange(
Expand All @@ -131,7 +131,7 @@ optional<Point> BracketMatcherView::findMatchingEndBracketWithSyntaxTree(Point b
return result;
}

optional<Point> BracketMatcherView::findMatchingStartBracketWithSyntaxTree(Point bracketPosition, char16_t startBracket, char16_t endBracket, TreeSitterLanguageMode *languageMode) {
optional<Point> BracketMatcherView::findMatchingStartBracketWithSyntaxTree(const Point &bracketPosition, char16_t startBracket, char16_t endBracket, TreeSitterLanguageMode *languageMode) {
optional<Point> result;
const Point bracketEndPosition = bracketPosition.traverse({0, 1});
languageMode->getSyntaxNodeContainingRange(
Expand Down Expand Up @@ -206,7 +206,7 @@ std::pair<optional<TSNode>, optional<TSNode>> BracketMatcherView::findContaining
return {startTag, endTag};
}

DisplayMarker *BracketMatcherView::createMarker(Range bufferRange) {
DisplayMarker *BracketMatcherView::createMarker(const Range &bufferRange) {
DisplayMarker *marker = this->editor->markBufferRange(bufferRange);
this->editor->decorateMarker(marker, {Decoration::Type::highlight, "bracket-matcher"});
return marker;
Expand Down
10 changes: 5 additions & 5 deletions atom/src/bracket-matcher-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ struct BracketMatcherView {
~BracketMatcherView();

void updateMatch();
optional<Point> findMatchingEndBracket(Point, char16_t, char16_t);
optional<Point> findMatchingStartBracket(Point, char16_t, char16_t);
optional<Point> findMatchingEndBracketWithSyntaxTree(Point, char16_t, char16_t, TreeSitterLanguageMode *);
optional<Point> findMatchingStartBracketWithSyntaxTree(Point, char16_t, char16_t, TreeSitterLanguageMode *);
optional<Point> findMatchingEndBracket(const Point &, char16_t, char16_t);
optional<Point> findMatchingStartBracket(const Point &, char16_t, char16_t);
optional<Point> findMatchingEndBracketWithSyntaxTree(const Point &, char16_t, char16_t, TreeSitterLanguageMode *);
optional<Point> findMatchingStartBracketWithSyntaxTree(const Point &, char16_t, char16_t, TreeSitterLanguageMode *);
std::pair<optional<Range>, optional<Range>> findMatchingTagNameRangesWithSyntaxTree(TreeSitterLanguageMode *);
std::pair<optional<TSNode>, optional<TSNode>> findContainingTagsWithSyntaxTree(Point, TreeSitterLanguageMode *);
DisplayMarker *createMarker(Range);
DisplayMarker *createMarker(const Range &);
std::tuple<optional<Point>, optional<Point>> findCurrentPair();
TreeSitterLanguageMode *hasSyntaxTree();
};
Expand Down
6 changes: 3 additions & 3 deletions atom/src/cursor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ void Cursor::destroy() {
this->marker->destroy();
}

void Cursor::setScreenPosition(Point screenPosition, optional<bool> options_autoscroll, DisplayLayer::ClipDirection clipDirection) {
void Cursor::setScreenPosition(const Point &screenPosition, optional<bool> options_autoscroll, DisplayLayer::ClipDirection clipDirection) {
this->changePosition(options_autoscroll, [&]() {
this->marker->setHeadScreenPosition(screenPosition, clipDirection);
});
}

void Cursor::setScreenPosition(Point screenPosition, DisplayLayer::ClipDirection clipDirection) {
void Cursor::setScreenPosition(const Point &screenPosition, DisplayLayer::ClipDirection clipDirection) {
this->setScreenPosition(screenPosition, optional<bool>(), clipDirection);
}

Point Cursor::getScreenPosition() {
return this->marker->getHeadScreenPosition();
}

void Cursor::setBufferPosition(Point bufferPosition, optional<bool> options_autoscroll) {
void Cursor::setBufferPosition(const Point &bufferPosition, optional<bool> options_autoscroll) {
this->changePosition(options_autoscroll, [&]() {
this->marker->setHeadBufferPosition(bufferPosition);
});
Expand Down
6 changes: 3 additions & 3 deletions atom/src/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ struct Cursor {
~Cursor();
void destroy();

void setScreenPosition(Point, optional<bool> = {}, DisplayLayer::ClipDirection = DisplayLayer::ClipDirection::closest);
void setScreenPosition(Point, DisplayLayer::ClipDirection);
void setScreenPosition(const Point &, optional<bool> = {}, DisplayLayer::ClipDirection = DisplayLayer::ClipDirection::closest);
void setScreenPosition(const Point &, DisplayLayer::ClipDirection);
Point getScreenPosition();
void setBufferPosition(Point, optional<bool> = {});
void setBufferPosition(const Point &, optional<bool> = {});
Point getBufferPosition();
double getScreenRow();
double getScreenColumn();
Expand Down
6 changes: 3 additions & 3 deletions atom/src/select-next.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void SelectNext::selectNextOccurrence(/* options = {} */) {
}
}

optional<Range> SelectNext::findNextOccurrence(Range scanRange) {
optional<Range> SelectNext::findNextOccurrence(const Range &scanRange) {
optional<Range> foundRange;
this->scanForNextOccurrence(scanRange, [&](TextBuffer::SearchCallbackArgument &argument) {
foundRange = argument.range;
Expand All @@ -52,13 +52,13 @@ optional<Range> SelectNext::findNextOccurrence(Range scanRange) {
return foundRange;
}

void SelectNext::addSelection(Range range) {
void SelectNext::addSelection(const Range &range) {
const bool reversed = this->editor->getLastSelection()->isReversed();
Selection *selection = this->editor->addSelectionForBufferRange(range /* , {reversed} */);
//return this->updateSavedSelections(selection);
}

void SelectNext::scanForNextOccurrence(Range range, TextBuffer::ScanIterator callback) {
void SelectNext::scanForNextOccurrence(const Range &range, TextBuffer::ScanIterator callback) {
Selection *selection = this->editor->getLastSelection();
std::u16string text = escapeRegExp(selection->getText());
if (this->wordSelected) {
Expand Down
6 changes: 3 additions & 3 deletions atom/src/select-next.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ struct SelectNext {
void findAndSelectNext();
void selectWord();
void selectNextOccurrence();
optional<Range> findNextOccurrence(Range);
void addSelection(Range);
void scanForNextOccurrence(Range, TextBuffer::ScanIterator);
optional<Range> findNextOccurrence(const Range &);
void addSelection(const Range &);
void scanForNextOccurrence(const Range &, TextBuffer::ScanIterator);
bool isNonWordCharacter(const std::u16string &);
bool isNonWordCharacterToTheLeft(Selection *);
bool isNonWordCharacterToTheRight(Selection *);
Expand Down
12 changes: 6 additions & 6 deletions atom/src/selection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Range Selection::getScreenRange() {
return this->marker->getScreenRange();
}

void Selection::setScreenRange(Range screenRange, optional<bool> reversed) {
void Selection::setScreenRange(const Range &screenRange, optional<bool> reversed) {
return this->setBufferRange(
this->editor->bufferRangeForScreenRange(screenRange),
optional<bool>(),
Expand All @@ -67,7 +67,7 @@ Range Selection::getBufferRange() {
return this->marker->getBufferRange();
}

void Selection::setBufferRange(Range bufferRange, optional<bool> options_autoscroll, optional<bool> reversed) {
void Selection::setBufferRange(const Range &bufferRange, optional<bool> options_autoscroll, optional<bool> reversed) {
//if (options.reversed == null) options.reversed = this.isReversed();
/*if (!options.preserveFolds)
this.editor.destroyFoldsContainingBufferPositions(
Expand Down Expand Up @@ -132,7 +132,7 @@ std::u16string Selection::getText() {
return this->editor->buffer->getTextInRange(this->getBufferRange());
}

bool Selection::intersectsBufferRange(Range bufferRange) {
bool Selection::intersectsBufferRange(const Range &bufferRange) {
return this->getBufferRange().intersectsWith(bufferRange);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ void Selection::clear(optional<bool> options_autoscroll) {
this->finalize();
}

void Selection::selectToScreenPosition(Point position) {
void Selection::selectToScreenPosition(const Point &position) {
this->modifySelection([&]() {
if (this->initialScreenRange) {
if (position.isLessThan(this->initialScreenRange->start)) {
Expand All @@ -191,7 +191,7 @@ void Selection::selectToScreenPosition(Point position) {
});
}

void Selection::selectToBufferPosition(Point position) {
void Selection::selectToBufferPosition(const Point &position) {
this->modifySelection([&]() { this->cursor->setBufferPosition(position); });
}

Expand Down Expand Up @@ -740,7 +740,7 @@ int Selection::compare(Selection *otherSelection) {
Section: Private Utilities
*/

void Selection::setGoalScreenRange(Range range) {
void Selection::setGoalScreenRange(const Range &range) {
this->goalScreenRange = range;
}

Expand Down
12 changes: 6 additions & 6 deletions atom/src/selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct Selection {
void onDidChangeRange(std::function<void()>);
void onDidDestroy(std::function<void()>);
Range getScreenRange();
void setScreenRange(Range, optional<bool> = {});
void setScreenRange(const Range &, optional<bool> = {});
Range getBufferRange();
void setBufferRange(Range, optional<bool> = {}, optional<bool> = {});
void setBufferRange(const Range &, optional<bool> = {}, optional<bool> = {});
std::pair<double, double> getBufferRowRange();
Point getTailScreenPosition();
Point getTailBufferPosition();
Expand All @@ -43,13 +43,13 @@ struct Selection {
bool isReversed();
bool isSingleScreenLine();
std::u16string getText();
bool intersectsBufferRange(Range);
bool intersectsBufferRange(const Range &);
bool intersectsScreenRowRange(double, double);
bool intersectsScreenRow(double);
bool intersectsWith(Selection *, bool);
void clear(optional<bool> = {});
void selectToScreenPosition(Point position);
void selectToBufferPosition(Point);
void selectToScreenPosition(const Point &);
void selectToBufferPosition(const Point &);
void selectRight(double = 1);
void selectLeft(double = 1);
void selectUp(double = 1);
Expand Down Expand Up @@ -98,7 +98,7 @@ struct Selection {
void addSelectionAbove();
void merge(Selection *);
int compare(Selection *);
void setGoalScreenRange(Range);
void setGoalScreenRange(const Range &);
Range getGoalScreenRange();
void markerDidChange();
void markerDidDestroy();
Expand Down
6 changes: 3 additions & 3 deletions atom/src/syntax-scope-map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ void SyntaxScopeMap::addSelector(const std::string &selector, std::shared_ptr<Re
}, selector);
}

std::shared_ptr<SyntaxScopeMap::Result> SyntaxScopeMap::get(const std::vector<std::string> &nodeTypes, const std::vector<double> &childIndices, bool leafIsNamed) {
std::shared_ptr<Result> result;
SyntaxScopeMap::Result *SyntaxScopeMap::get(const std::vector<std::string> &nodeTypes, const std::vector<double> &childIndices, bool leafIsNamed) {
Result *result = nullptr;
size_t i = nodeTypes.size() - 1;
Table *currentTable = leafIsNamed
? this->namedScopeTable[nodeTypes[i]].get()
Expand All @@ -198,7 +198,7 @@ std::shared_ptr<SyntaxScopeMap::Result> SyntaxScopeMap::get(const std::vector<st
}

if (currentTable->result) {
result = currentTable->result;
result = currentTable->result.get();
}

if (i == 0) break;
Expand Down
2 changes: 1 addition & 1 deletion atom/src/syntax-scope-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SyntaxScopeMap {
~SyntaxScopeMap();

void addSelector(const std::string &, std::shared_ptr<Result>);
std::shared_ptr<Result> get(const std::vector<std::string> &, const std::vector<double> &, bool = true);
Result *get(const std::vector<std::string> &, const std::vector<double> &, bool = true);
};

#endif // SYNTAX_SCOPE_MAP_H_
Loading

0 comments on commit e74bf91

Please sign in to comment.