Skip to content

Commit

Permalink
Shell: Do not assume that all parts of a node are enclosed in the node
Browse files Browse the repository at this point in the history
For instance, heredocs are made of two parts, and the second part is not
within the bounds of the first one.
  • Loading branch information
alimpfard authored and awesomekling committed Apr 29, 2021
1 parent cf4935e commit 7c8d39e
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions Userland/Shell/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,6 @@ void And::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetad

HitTestResult And::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
Expand Down Expand Up @@ -508,9 +505,6 @@ void ListConcatenate::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi

HitTestResult ListConcatenate::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

bool first = true;
for (auto& element : m_list) {
auto result = element->hit_test_position(offset);
Expand Down Expand Up @@ -570,9 +564,6 @@ void Background::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlig

HitTestResult Background::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

return m_command->hit_test_position(offset);
}

Expand Down Expand Up @@ -665,9 +656,6 @@ RefPtr<Value> BraceExpansion::run(RefPtr<Shell> shell)

HitTestResult BraceExpansion::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

for (auto& entry : m_entries) {
auto result = entry.hit_test_position(offset);
if (result.matching_node) {
Expand Down Expand Up @@ -730,9 +718,6 @@ void CastToCommand::highlight_in_editor(Line::Editor& editor, Shell& shell, High

HitTestResult CastToCommand::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_inner->hit_test_position(offset);
if (!result.closest_node_with_semantic_meaning)
result.closest_node_with_semantic_meaning = this;
Expand Down Expand Up @@ -812,9 +797,6 @@ void CastToList::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlig

HitTestResult CastToList::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (!m_inner)
return {};

Expand Down Expand Up @@ -966,9 +948,6 @@ void DoubleQuotedString::highlight_in_editor(Line::Editor& editor, Shell& shell,

HitTestResult DoubleQuotedString::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

return m_inner->hit_test_position(offset);
}

Expand Down Expand Up @@ -1014,9 +993,6 @@ void DynamicEvaluate::highlight_in_editor(Line::Editor& editor, Shell& shell, Hi

HitTestResult DynamicEvaluate::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

return m_inner->hit_test_position(offset);
}

Expand Down Expand Up @@ -1102,9 +1078,6 @@ void FunctionDeclaration::highlight_in_editor(Line::Editor& editor, Shell& shell

HitTestResult FunctionDeclaration::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (!m_block)
return {};

Expand Down Expand Up @@ -1275,9 +1248,6 @@ void ForLoop::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightM

HitTestResult ForLoop::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (m_iterated_expression) {
if (auto result = m_iterated_expression->hit_test_position(offset); result.matching_node)
return result;
Expand Down Expand Up @@ -1676,9 +1646,6 @@ void Execute::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightM

HitTestResult Execute::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_command->hit_test_position(offset);
if (!result.closest_node_with_semantic_meaning)
result.closest_node_with_semantic_meaning = this;
Expand Down Expand Up @@ -1770,9 +1737,6 @@ void IfCond::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMe

HitTestResult IfCond::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (auto result = m_condition->hit_test_position(offset); result.matching_node)
return result;

Expand Down Expand Up @@ -1883,9 +1847,6 @@ Vector<Line::CompletionSuggestion> ImmediateExpression::complete_for_editor(Shel

HitTestResult ImmediateExpression::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (m_function.position.contains(offset))
return { this, this, this };

Expand Down Expand Up @@ -1943,9 +1904,6 @@ void Join::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMeta

HitTestResult Join::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (result.matching_node)
return result;
Expand Down Expand Up @@ -2105,9 +2063,6 @@ void MatchExpr::highlight_in_editor(Line::Editor& editor, Shell& shell, Highligh

HitTestResult MatchExpr::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_matched_expr->hit_test_position(offset);
if (result.matching_node)
return result;
Expand Down Expand Up @@ -2170,9 +2125,6 @@ void Or::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMetada

HitTestResult Or::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
Expand Down Expand Up @@ -2268,9 +2220,6 @@ void Pipe::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMeta

HitTestResult Pipe::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
Expand Down Expand Up @@ -2327,9 +2276,6 @@ void PathRedirectionNode::highlight_in_editor(Line::Editor& editor, Shell& shell

HitTestResult PathRedirectionNode::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_path->hit_test_position(offset);
if (!result.closest_node_with_semantic_meaning)
result.closest_node_with_semantic_meaning = this;
Expand Down Expand Up @@ -2442,9 +2388,6 @@ void Range::highlight_in_editor(Line::Editor& editor, Shell& shell, HighlightMet

HitTestResult Range::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_start->hit_test_position(offset);
if (result.matching_node) {
if (!result.closest_command_node)
Expand Down Expand Up @@ -2565,9 +2508,6 @@ void Sequence::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlight

HitTestResult Sequence::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

for (auto& entry : m_entries) {
auto result = entry.hit_test_position(offset);
if (result.matching_node) {
Expand Down Expand Up @@ -2621,9 +2561,6 @@ void Subshell::highlight_in_editor(Line::Editor& editor, Shell& shell, Highlight

HitTestResult Subshell::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (m_block)
return m_block->hit_test_position(offset);

Expand Down Expand Up @@ -2713,9 +2650,6 @@ void SimpleVariable::highlight_in_editor(Line::Editor& editor, Shell& shell, Hig

HitTestResult SimpleVariable::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (m_slice && m_slice->position().contains(offset))
return m_slice->hit_test_position(offset);

Expand Down Expand Up @@ -2783,9 +2717,6 @@ Vector<Line::CompletionSuggestion> SpecialVariable::complete_for_editor(Shell&,

HitTestResult SpecialVariable::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

if (m_slice && m_slice->position().contains(offset))
return m_slice->hit_test_position(offset);

Expand Down Expand Up @@ -2902,9 +2833,6 @@ Vector<Line::CompletionSuggestion> Juxtaposition::complete_for_editor(Shell& she

HitTestResult Juxtaposition::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (!result.closest_node_with_semantic_meaning)
result.closest_node_with_semantic_meaning = this;
Expand Down Expand Up @@ -2991,9 +2919,6 @@ void StringPartCompose::highlight_in_editor(Line::Editor& editor, Shell& shell,

HitTestResult StringPartCompose::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

auto result = m_left->hit_test_position(offset);
if (result.matching_node)
return result;
Expand Down Expand Up @@ -3219,9 +3144,6 @@ void VariableDeclarations::highlight_in_editor(Line::Editor& editor, Shell& shel

HitTestResult VariableDeclarations::hit_test_position(size_t offset) const
{
if (!position().contains(offset))
return {};

for (auto decl : m_variables) {
auto result = decl.value->hit_test_position(offset);
if (result.matching_node)
Expand Down

0 comments on commit 7c8d39e

Please sign in to comment.