Skip to content

Commit

Permalink
Rename Element_Selector to Type_Selector
Browse files Browse the repository at this point in the history
Reverts sass#2101
  • Loading branch information
mgreter committed Nov 26, 2016
1 parent bf2528b commit 5b2be92
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
20 changes: 10 additions & 10 deletions src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ namespace Sass {
return cpy;
}

Simple_Selector* Element_Selector::unify_with(Simple_Selector* rhs, Context& ctx)
Simple_Selector* Type_Selector::unify_with(Simple_Selector* rhs, Context& ctx)
{
// check if ns can be extended
// true for no ns or universal
Expand All @@ -441,7 +441,7 @@ namespace Sass {
if (!rhs->is_universal_ns())
{
// creaty the copy inside (avoid unnecessary copies)
Element_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Element_Selector, *this);
Type_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Type_Selector, *this);
// overwrite the name if star is given as name
if (ts->name() == "*") { ts->name(rhs->name()); }
// now overwrite the namespace name and flag
Expand All @@ -455,7 +455,7 @@ namespace Sass {
if (name() == "*" && rhs->name() != "*")
{
// creaty the copy inside (avoid unnecessary copies)
Element_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Element_Selector, *this);
Type_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Type_Selector, *this);
// simply set the new name
ts->name(rhs->name());
// return copy
Expand All @@ -465,7 +465,7 @@ namespace Sass {
return this;
}

Compound_Selector* Element_Selector::unify_with(Compound_Selector* rhs, Context& ctx)
Compound_Selector* Type_Selector::unify_with(Compound_Selector* rhs, Context& ctx)
{
// TODO: handle namespaces

Expand All @@ -480,11 +480,11 @@ namespace Sass {
// otherwise, this is a tag name
if (name() == "*")
{
if (typeid(*rhs_0) == typeid(Element_Selector))
if (typeid(*rhs_0) == typeid(Type_Selector))
{
// if rhs is universal, just return this tagname + rhs's qualifiers
Compound_Selector* cpy = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, *rhs);
Element_Selector* ts = static_cast<Element_Selector*>(rhs_0);
Type_Selector* ts = static_cast<Type_Selector*>(rhs_0);
(*cpy)[0] = this->unify_with(ts, ctx);
return cpy;
}
Expand All @@ -503,7 +503,7 @@ namespace Sass {
return rhs;
}

if (typeid(*rhs_0) == typeid(Element_Selector))
if (typeid(*rhs_0) == typeid(Type_Selector))
{
// if rhs is universal, just return this tagname + rhs's qualifiers
if (rhs_0->name() != "*" && rhs_0->ns() != "*" && rhs_0->name() != name()) return 0;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ namespace Sass {
} else if (last()->head_ && last()->head_->length()) {
Compound_Selector* rh = last()->head();
size_t i = 0, L = h->length();
if (dynamic_cast<Element_Selector*>(h->first())) {
if (dynamic_cast<Type_Selector*>(h->first())) {
if (Class_Selector* sq = dynamic_cast<Class_Selector*>(rh->last())) {
Class_Selector* sqs = SASS_MEMORY_NEW(ctx.mem, Class_Selector, *sq);
sqs->name(sqs->name() + (*h)[0]->name());
Expand All @@ -1072,8 +1072,8 @@ namespace Sass {
(*rh)[rh->length()-1] = sqs;
rh->pstate(h->pstate());
for (i = 1; i < L; ++i) *rh << (*h)[i];
} else if (Element_Selector* ts = dynamic_cast<Element_Selector*>(rh->last())) {
Element_Selector* tss = SASS_MEMORY_NEW(ctx.mem, Element_Selector, *ts);
} else if (Type_Selector* ts = dynamic_cast<Type_Selector*>(rh->last())) {
Type_Selector* tss = SASS_MEMORY_NEW(ctx.mem, Type_Selector, *ts);
tss->name(tss->name() + (*h)[0]->name());
tss->pstate((*h)[0]->pstate());
(*rh)[rh->length()-1] = tss;
Expand Down
6 changes: 3 additions & 3 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2063,9 +2063,9 @@ namespace Sass {
/////////////////////////////////////////////////////////////////////
// Element selectors (and the universal selector) -- e.g., div, span, *.
/////////////////////////////////////////////////////////////////////
class Element_Selector : public Simple_Selector {
class Type_Selector : public Simple_Selector {
public:
Element_Selector(ParserState pstate, std::string n)
Type_Selector(ParserState pstate, std::string n)
: Simple_Selector(pstate, n)
{ }
virtual unsigned long specificity()
Expand Down Expand Up @@ -2313,7 +2313,7 @@ namespace Sass {
const Simple_Selector* base() const {
if (length() == 0) return 0;
// ToDo: why is this needed?
if (dynamic_cast<Element_Selector*>((*this)[0]))
if (dynamic_cast<Type_Selector*>((*this)[0]))
return (*this)[0];
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast_fwd_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Sass {
class Selector;
class Selector_Schema;
class Placeholder_Selector;
class Element_Selector;
class Type_Selector;
class Class_Selector;
class Id_Selector;
class Attribute_Selector;
Expand Down
6 changes: 3 additions & 3 deletions src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
std::cerr << (selector->has_line_break() ? " [line-break]": " -");
std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
std::cerr << std::endl;
} else if (dynamic_cast<Element_Selector*>(node)) {
Element_Selector* selector = dynamic_cast<Element_Selector*>(node);
std::cerr << ind << "Element_Selector " << selector;
} else if (dynamic_cast<Type_Selector*>(node)) {
Type_Selector* selector = dynamic_cast<Type_Selector*>(node);
std::cerr << ind << "Type_Selector " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " <<" << selector->ns_name() << ">>";
Expand Down
2 changes: 1 addition & 1 deletion src/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Sass {
Selector_List* operator()(Complex_Selector*);
Attribute_Selector* operator()(Attribute_Selector*);
// they don't have any specific implementatio (yet)
Element_Selector* operator()(Element_Selector* s) { return s; };
Type_Selector* operator()(Type_Selector* s) { return s; };
Pseudo_Selector* operator()(Pseudo_Selector* s) { return s; };
Wrapped_Selector* operator()(Wrapped_Selector* s) { return s; };
Class_Selector* operator()(Class_Selector* s) { return s; };
Expand Down
8 changes: 4 additions & 4 deletions src/extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ namespace Sass {
// TODO: figure out a better way to create a Complex_Selector from scratch
// TODO: There's got to be a better way. This got ugly quick...
Position noPosition(-1, -1, -1);
Element_Selector fakeParent(ParserState("[FAKE]"), "temp");
Type_Selector fakeParent(ParserState("[FAKE]"), "temp");
Compound_Selector fakeHead(ParserState("[FAKE]"), 1 /*size*/);
fakeHead.elements().push_back(&fakeParent);
Complex_Selector fakeParentContainer(ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, &fakeHead /*head*/, NULL /*tail*/);
Expand Down Expand Up @@ -654,7 +654,7 @@ namespace Sass {
// TODO: figure out a better way to create a Complex_Selector from scratch
// TODO: There's got to be a better way. This got ugly quick...
Position noPosition(-1, -1, -1);
Element_Selector fakeParent(ParserState("[FAKE]"), "temp");
Type_Selector fakeParent(ParserState("[FAKE]"), "temp");
Compound_Selector fakeHead(ParserState("[FAKE]"), 1 /*size*/);
fakeHead.elements().push_back(&fakeParent);
Complex_Selector fakeParentContainer(ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, &fakeHead /*head*/, NULL /*tail*/);
Expand Down Expand Up @@ -1959,7 +1959,7 @@ namespace Sass {
// special case for ruby ass
if (sl->empty()) {
// this seems inconsistent but it is how ruby sass seems to remove parentheses
*cpy_head << SASS_MEMORY_NEW(ctx.mem, Element_Selector, hs->pstate(), ws->name());
*cpy_head << SASS_MEMORY_NEW(ctx.mem, Type_Selector, hs->pstate(), ws->name());
}
// has wrapped selectors
else {
Expand All @@ -1978,7 +1978,7 @@ namespace Sass {
Compound_Selector* ws_ss = ws_cs->first()->head();
if (!(
dynamic_cast<Pseudo_Selector*>(ws_ss->first()) ||
dynamic_cast<Element_Selector*>(ws_ss->first()) ||
dynamic_cast<Type_Selector*>(ws_ss->first()) ||
dynamic_cast<Placeholder_Selector*>(ws_ss->first())
)) continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,7 @@ namespace Sass {
}

// Cannot be a Universal selector
Element_Selector* pType = dynamic_cast<Element_Selector*>(childSeq->head()->first());
Type_Selector* pType = dynamic_cast<Type_Selector*>(childSeq->head()->first());
if(pType && pType->name() == "*") {
std::string msg("Can't append `");
msg += childSeq->to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ namespace Sass {

}

void Inspect::operator()(Element_Selector* s)
void Inspect::operator()(Type_Selector* s)
{
append_token(s->ns_name(), s);
}
Expand Down
2 changes: 1 addition & 1 deletion src/inspect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace Sass {
// selectors
virtual void operator()(Selector_Schema*);
virtual void operator()(Placeholder_Selector*);
virtual void operator()(Element_Selector*);
virtual void operator()(Type_Selector*);
virtual void operator()(Class_Selector*);
virtual void operator()(Id_Selector*);
virtual void operator()(Attribute_Selector*);
Expand Down
4 changes: 2 additions & 2 deletions src/operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace Sass {
// selectors
virtual T operator()(Selector_Schema* x) = 0;
virtual T operator()(Placeholder_Selector* x) = 0;
virtual T operator()(Element_Selector* x) = 0;
virtual T operator()(Type_Selector* x) = 0;
virtual T operator()(Class_Selector* x) = 0;
virtual T operator()(Id_Selector* x) = 0;
virtual T operator()(Attribute_Selector* x) = 0;
Expand Down Expand Up @@ -154,7 +154,7 @@ namespace Sass {
// selectors
T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Placeholder_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Element_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Class_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Id_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
Expand Down
6 changes: 3 additions & 3 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ namespace Sass {
// parse type selector
else if (lex< re_type_selector >(false))
{
(*seq) << SASS_MEMORY_NEW(ctx.mem, Element_Selector, pstate, lexed);
(*seq) << SASS_MEMORY_NEW(ctx.mem, Type_Selector, pstate, lexed);
}
// peek for abort conditions
else if (peek< spaces >()) break;
Expand Down Expand Up @@ -820,10 +820,10 @@ namespace Sass {
return SASS_MEMORY_NEW(ctx.mem, Id_Selector, pstate, lexed);
}
else if (lex< quoted_string >()) {
return SASS_MEMORY_NEW(ctx.mem, Element_Selector, pstate, unquote(lexed));
return SASS_MEMORY_NEW(ctx.mem, Type_Selector, pstate, unquote(lexed));
}
else if (lex< alternatives < variable, number, static_reference_combinator > >()) {
return SASS_MEMORY_NEW(ctx.mem, Element_Selector, pstate, lexed);
return SASS_MEMORY_NEW(ctx.mem, Type_Selector, pstate, lexed);
}
else if (peek< pseudo_not >()) {
return parse_negated_selector();
Expand Down

0 comments on commit 5b2be92

Please sign in to comment.