Skip to content

Commit c49c339

Browse files
committed
Rename the Type_Selector AST node to Element_Selector
This better matches the Ruby Sass implementation.
1 parent dc097fd commit c49c339

13 files changed

+35
-35
lines changed

src/ast.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ namespace Sass {
411411
return cpy;
412412
}
413413

414-
Simple_Selector* Type_Selector::unify_with(Simple_Selector* rhs, Context& ctx)
414+
Simple_Selector* Element_Selector::unify_with(Simple_Selector* rhs, Context& ctx)
415415
{
416416
// check if ns can be extended
417417
// true for no ns or universal
@@ -422,7 +422,7 @@ namespace Sass {
422422
if (!rhs->is_universal_ns())
423423
{
424424
// creaty the copy inside (avoid unnecessary copies)
425-
Type_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Type_Selector, *this);
425+
Element_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Element_Selector, *this);
426426
// overwrite the name if star is given as name
427427
if (ts->name() == "*") { ts->name(rhs->name()); }
428428
// now overwrite the namespace name and flag
@@ -436,7 +436,7 @@ namespace Sass {
436436
if (name() == "*" && rhs->name() != "*")
437437
{
438438
// creaty the copy inside (avoid unnecessary copies)
439-
Type_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Type_Selector, *this);
439+
Element_Selector* ts = SASS_MEMORY_NEW(ctx.mem, Element_Selector, *this);
440440
// simply set the new name
441441
ts->name(rhs->name());
442442
// return copy
@@ -446,7 +446,7 @@ namespace Sass {
446446
return this;
447447
}
448448

449-
Compound_Selector* Type_Selector::unify_with(Compound_Selector* rhs, Context& ctx)
449+
Compound_Selector* Element_Selector::unify_with(Compound_Selector* rhs, Context& ctx)
450450
{
451451
// TODO: handle namespaces
452452

@@ -461,11 +461,11 @@ namespace Sass {
461461
// otherwise, this is a tag name
462462
if (name() == "*")
463463
{
464-
if (typeid(*rhs_0) == typeid(Type_Selector))
464+
if (typeid(*rhs_0) == typeid(Element_Selector))
465465
{
466466
// if rhs is universal, just return this tagname + rhs's qualifiers
467467
Compound_Selector* cpy = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, *rhs);
468-
Type_Selector* ts = static_cast<Type_Selector*>(rhs_0);
468+
Element_Selector* ts = static_cast<Element_Selector*>(rhs_0);
469469
(*cpy)[0] = this->unify_with(ts, ctx);
470470
return cpy;
471471
}
@@ -484,7 +484,7 @@ namespace Sass {
484484
return rhs;
485485
}
486486

487-
if (typeid(*rhs_0) == typeid(Type_Selector))
487+
if (typeid(*rhs_0) == typeid(Element_Selector))
488488
{
489489
// if rhs is universal, just return this tagname + rhs's qualifiers
490490
if (rhs_0->name() != "*" && rhs_0->ns() != "*" && rhs_0->name() != name()) return 0;
@@ -1036,14 +1036,14 @@ namespace Sass {
10361036
} else if (last()->head_ && last()->head_->length()) {
10371037
Compound_Selector* rh = last()->head();
10381038
size_t i = 0, L = h->length();
1039-
if (dynamic_cast<Type_Selector*>(h->first())) {
1039+
if (dynamic_cast<Element_Selector*>(h->first())) {
10401040
if (Selector_Qualifier* sq = dynamic_cast<Selector_Qualifier*>(rh->last())) {
10411041
Selector_Qualifier* sqs = new Selector_Qualifier(*sq);
10421042
sqs->name(sqs->name() + (*h)[0]->name());
10431043
(*rh)[rh->length()-1] = sqs;
10441044
for (i = 1; i < L; ++i) *rh << (*h)[i];
1045-
} else if (Type_Selector* ts = dynamic_cast<Type_Selector*>(rh->last())) {
1046-
Type_Selector* tss = new Type_Selector(*ts);
1045+
} else if (Element_Selector* ts = dynamic_cast<Element_Selector*>(rh->last())) {
1046+
Element_Selector* tss = new Element_Selector(*ts);
10471047
tss->name(tss->name() + (*h)[0]->name());
10481048
(*rh)[rh->length()-1] = tss;
10491049
for (i = 1; i < L; ++i) *rh << (*h)[i];

src/ast.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,17 +2048,17 @@ namespace Sass {
20482048
};
20492049

20502050
/////////////////////////////////////////////////////////////////////
2051-
// Type selectors (and the universal selector) -- e.g., div, span, *.
2051+
// Element selectors (and the universal selector) -- e.g., div, span, *.
20522052
/////////////////////////////////////////////////////////////////////
2053-
class Type_Selector : public Simple_Selector {
2053+
class Element_Selector : public Simple_Selector {
20542054
public:
2055-
Type_Selector(ParserState pstate, std::string n)
2055+
Element_Selector(ParserState pstate, std::string n)
20562056
: Simple_Selector(pstate, n)
20572057
{ }
20582058
virtual unsigned long specificity()
20592059
{
20602060
if (name() == "*") return 0;
2061-
else return Constants::Specificity_Type;
2061+
else return Constants::Specificity_Element;
20622062
}
20632063
virtual Simple_Selector* unify_with(Simple_Selector*, Context&);
20642064
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
@@ -2082,7 +2082,7 @@ namespace Sass {
20822082
{
20832083
if (name()[0] == '#') return Constants::Specificity_ID;
20842084
if (name()[0] == '.') return Constants::Specificity_Class;
2085-
else return Constants::Specificity_Type;
2085+
else return Constants::Specificity_Element;
20862086
}
20872087
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
20882088
ATTACH_OPERATIONS()
@@ -2173,7 +2173,7 @@ namespace Sass {
21732173
virtual unsigned long specificity()
21742174
{
21752175
if (is_pseudo_element())
2176-
return Constants::Specificity_Type;
2176+
return Constants::Specificity_Element;
21772177
return Constants::Specificity_Pseudo;
21782178
}
21792179
bool operator==(const Simple_Selector& rhs) const;
@@ -2275,7 +2275,7 @@ namespace Sass {
22752275
const Simple_Selector* base() const {
22762276
if (length() == 0) return 0;
22772277
// ToDo: why is this needed?
2278-
if (dynamic_cast<Type_Selector*>((*this)[0]))
2278+
if (dynamic_cast<Element_Selector*>((*this)[0]))
22792279
return (*this)[0];
22802280
return 0;
22812281
}

src/ast_fwd_decl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace Sass {
7474
class Selector;
7575
class Selector_Schema;
7676
class Selector_Placeholder;
77-
class Type_Selector;
77+
class Element_Selector;
7878
class Selector_Qualifier;
7979
class Attribute_Selector;
8080
class Pseudo_Selector;

src/constants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Sass {
1111
// https://github.com/sass/sass/issues/1495#issuecomment-61189114
1212
extern const unsigned long Specificity_Star = 0;
1313
extern const unsigned long Specificity_Universal = 0;
14-
extern const unsigned long Specificity_Type = 1;
14+
extern const unsigned long Specificity_Element = 1;
1515
extern const unsigned long Specificity_Base = 1000;
1616
extern const unsigned long Specificity_Class = 1000;
1717
extern const unsigned long Specificity_Attr = 1000;

src/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Sass {
1111
// The following list of selectors is by increasing specificity:
1212
extern const unsigned long Specificity_Star;
1313
extern const unsigned long Specificity_Universal;
14-
extern const unsigned long Specificity_Type;
14+
extern const unsigned long Specificity_Element;
1515
extern const unsigned long Specificity_Base;
1616
extern const unsigned long Specificity_Class;
1717
extern const unsigned long Specificity_Attr;

src/debugger.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
199199
std::cerr << (selector->has_line_break() ? " [line-break]": " -");
200200
std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
201201
std::cerr << std::endl;
202-
} else if (dynamic_cast<Type_Selector*>(node)) {
203-
Type_Selector* selector = dynamic_cast<Type_Selector*>(node);
204-
std::cerr << ind << "Type_Selector " << selector;
202+
} else if (dynamic_cast<Element_Selector*>(node)) {
203+
Element_Selector* selector = dynamic_cast<Element_Selector*>(node);
204+
std::cerr << ind << "Element_Selector " << selector;
205205
std::cerr << " (" << pstate_source_position(node) << ")";
206206
std::cerr << " <" << selector->hash() << ">";
207207
std::cerr << " <<" << selector->ns_name() << ">>";

src/eval.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace Sass {
7474
Selector_List* operator()(Complex_Selector*);
7575
Attribute_Selector* operator()(Attribute_Selector*);
7676
// they don't have any specific implementatio (yet)
77-
Type_Selector* operator()(Type_Selector* s) { return s; };
77+
Element_Selector* operator()(Element_Selector* s) { return s; };
7878
Pseudo_Selector* operator()(Pseudo_Selector* s) { return s; };
7979
Wrapped_Selector* operator()(Wrapped_Selector* s) { return s; };
8080
Selector_Qualifier* operator()(Selector_Qualifier* s) { return s; };

src/extend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ namespace Sass {
291291
// TODO: figure out a better way to create a Complex_Selector from scratch
292292
// TODO: There's got to be a better way. This got ugly quick...
293293
Position noPosition(-1, -1, -1);
294-
Type_Selector fakeParent(ParserState("[FAKE]"), "temp");
294+
Element_Selector fakeParent(ParserState("[FAKE]"), "temp");
295295
Compound_Selector fakeHead(ParserState("[FAKE]"), 1 /*size*/);
296296
fakeHead.elements().push_back(&fakeParent);
297297
Complex_Selector fakeParentContainer(ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, &fakeHead /*head*/, NULL /*tail*/);
@@ -654,7 +654,7 @@ namespace Sass {
654654
// TODO: figure out a better way to create a Complex_Selector from scratch
655655
// TODO: There's got to be a better way. This got ugly quick...
656656
Position noPosition(-1, -1, -1);
657-
Type_Selector fakeParent(ParserState("[FAKE]"), "temp");
657+
Element_Selector fakeParent(ParserState("[FAKE]"), "temp");
658658
Compound_Selector fakeHead(ParserState("[FAKE]"), 1 /*size*/);
659659
fakeHead.elements().push_back(&fakeParent);
660660
Complex_Selector fakeParentContainer(ParserState("[FAKE]"), Complex_Selector::ANCESTOR_OF, &fakeHead /*head*/, NULL /*tail*/);
@@ -1976,7 +1976,7 @@ namespace Sass {
19761976
// special case for ruby ass
19771977
if (sl->empty()) {
19781978
// this seems inconsistent but it is how ruby sass seems to remove parentheses
1979-
*cpy_head << SASS_MEMORY_NEW(ctx.mem, Type_Selector, hs->pstate(), ws->name());
1979+
*cpy_head << SASS_MEMORY_NEW(ctx.mem, Element_Selector, hs->pstate(), ws->name());
19801980
}
19811981
// has wrapped selectors
19821982
else {

src/functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ namespace Sass {
18211821
}
18221822

18231823
// Cannot be a Universal selector
1824-
Type_Selector* pType = dynamic_cast<Type_Selector*>(childSeq->head()->first());
1824+
Element_Selector* pType = dynamic_cast<Element_Selector*>(childSeq->head()->first());
18251825
if(pType && pType->name() == "*") {
18261826
std::string msg("Can't append `");
18271827
msg += childSeq->to_string();

src/inspect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ namespace Sass {
887887

888888
}
889889

890-
void Inspect::operator()(Type_Selector* s)
890+
void Inspect::operator()(Element_Selector* s)
891891
{
892892
append_token(s->ns_name(), s);
893893
}

0 commit comments

Comments
 (0)