Skip to content

Add Mixin proposals#17

Closed
mrmlnc wants to merge 2 commits intomicrosoft:masterfrom
mrmlnc:mixin-proposals
Closed

Add Mixin proposals#17
mrmlnc wants to merge 2 commits intomicrosoft:masterfrom
mrmlnc:mixin-proposals

Conversation

@mrmlnc
Copy link
Contributor

@mrmlnc mrmlnc commented Nov 27, 2016

Source: #16

This PR adds:

  • Proposals for Mixins only after @include keyword

2016-11-27_17-36-47

@mrmlnc
Copy link
Contributor Author

mrmlnc commented Nov 27, 2016

Hmmm, I don't see ability to handling nested selectors for Mixins in Less.

.mixin(@a: 1, @b) { content: @a + @b; }; .| // SimpleSelector
.mixin(@a: 1, @b) { content: @a + @b; }; .test { .|} // Declarations
.mixin(@a: 1, @b) { content: @a + @b; }; .test { .| // Nothing

In case with Declarations we need determinate property before/after, property value and more specific case:

.test {
  color: #fff;
  .|
  content: 123;
}

@aeschli
Copy link
Collaborator

aeschli commented Nov 28, 2016

@mrmlnc Thank a lot!
I had recreate the commit to merge the changes. Also I made a few (mostly cosmetic) changes.

@mrmlnc
Copy link
Contributor Author

mrmlnc commented Nov 28, 2016

@aeschli,

Yeap, that's good 👍. But what to do with Mixins in Less? We have three contexts and one of them does not exist in the AST.

In my plugins I use the current string for comparison textBeforeCurrentWord because AST may not have Node for the current word.

@aeschli
Copy link
Collaborator

aeschli commented Nov 28, 2016

For LESS we need to override 'parseRuleset' to detect rulesets with selectors that are valid mixin declarations and annotate the selector identifier.
On the reference side, we get MixinReference Nodes already for .abc and #abc. What is the 3rd context?

@mrmlnc
Copy link
Contributor Author

mrmlnc commented Nov 28, 2016

Now AST contains all Mixins in the Less file. Sorry, I was not entirely correct.

The problem is that Mixin can be called in different contexts:

  1. SimpleSelector
.mixin() {}
.m|
  1. Declarations
.mixin() {}
.test {
  .m|
}
  1. Just case, not context. Here getNodeAtOffset returns null.
.mixin() {}
.test {
  .m|
// without }

Also, the problem is that we cannot determine: MixinReference before us or Selector. Because the selector becomes MixinReference only when I add ().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants