SomMeri / less4j

Less language is an extension of css and less4j compiles it into regular css. Less adds several dynamic features into css: variables, expressions, nested rules, and so on. Less was designed to be compatible with css and any correct css file is also correct less file.
145 stars 47 forks source link

"Unexpected selector part type NESTED_SELECTOR_APPENDER. Anything but simple selector should have been removed from tree." #232

Closed gdelhumeau closed 9 years ago

gdelhumeau commented 9 years ago

Hello.

I am integrating Less4j into XWiki.

However, I have an exception:

com.github.sommeri.less4j.core.problems.BugHappened: Bug, please report issue: Unexpected selector part type NESTED_SELECTOR_APPENDER. Anything but simple selector should have been removed from tree. 
 Offending place: 102:1

Source code that I try to compile (the coding style is bad because it is a generated file):

//
// Flamingo main LESS file
// --------------------------------------------------

// Imports ====================================================================
@import "before-bootstrap"; // Fixes that must be included BEFORE bootstrap
@import "bootstrap/bootstrap.less"; // Bootstrap
@import "variables"; // Bootstrap variables overrided by flamingo
@import "accordion";
@import "action-menus";
@import "admin";
@import "annotations";
@import "buttons";
@import "edit";
@import "forms";
@import "general";
@import "grid";
@import "headers";
@import "layout";
@import "livetable";
@import "messages";
@import "misc";
@import "panels";
@import "type";
@import "vertical-menus";
@import "xlist";

// Velocity Content =============================================================
//
// As the main LESS file for this skin, we can use Velocity.
// ------------------------------------------------------------------------------

// Here we initialize some variables that can be used in other LESS files

        // Colors from the new flamingo theme class
                                  @text-color: #333333;
                                          @body-bg: #F5F5F5;
                                          @xwiki-page-content-bg: #FFFFFF;
                                                    @link-color: #0088CC;
                                          @brand-primary: #0088CC;
                                          @brand-success: #008000;
                                          @brand-info: #336699;
                                          @brand-warning: #D09000;
                                          @brand-danger: #CC3333;
                                                                                                                @btn-default-color: #4D5860;
                                          @btn-default-bg: #ECECEC;
                                          @btn-primary-color: #FFFFFF;
                                          @btn-primary-bg: #0088CC;
                                          @btn-success-color: #FFFFFF;
                                          @btn-success-bg: #4D9244;
                                                                                                                @navbar-default-color: #FFFFFF;
                                          @navbar-default-bg: #222222;
                                          @navbar-default-link-color: #FFFFFF;
                                          @navbar-default-link-hover-color: #FFFFFF;
                                          @navbar-default-link-hover-bg: #2A2A2A;
                                          @navbar-default-link-active-color: #FFFFFF;
                                          @navbar-default-link-active-bg: #2A2A2A;
                                                    @dropdown-bg: #FFFFFF;
                                                    @dropdown-link-color: #333333;
                                          @dropdown-link-hover-color: #333333;
                                          @dropdown-link-hover-bg: #ECECEC;
                                                                                                                          @panel-bg: #F5F5F5;
                                          @panel-default-text: #333333;
                                                    @xwiki-border-color:                  #E8E8E8;
  @xwiki-panel-header-bg:               #ECECEC;
  @xwiki-panel-header-text:             #4D5860;
  @xwiki-background-secondary-color:    #F3F3F3;
  @xwiki-page-header-bg-color:          #FFFFFF;
  @xwiki-page-header-bg-image:          '';
  @xwiki-page-header-bg-position:       'top';

@icon-font-path:                      "/xwiki/bin/webjars/resources/path?value=bootstrap/3.2.0/fonts/";

@xwiki-accordion-title-bar-background:"/xwiki/resources/icons/xwiki/accordion.png";

@xwiki-silk-icon-folder:              "/xwiki/resources/icons/silk/folder.png";
@xwiki-silk-icon-page-white-text:     "/xwiki/resources/icons/silk/page_white_text.png";
@xwiki-silk-icon-comment:             "/xwiki/resources/icons/silk/comment.png";
@xwiki-silk-icon-attachment:          "/xwiki/resources/icons/silk/attach.png";
@xwiki-silk-icon-bullet-add:          "/xwiki/resources/icons/silk/bullet_add.png";
@xwiki-silk-icon-chart-organization:  "/xwiki/resources/icons/silk/chart_organisation.png";

@xwiki-icon-parent-edit:              "/xwiki/resources/icons/xwiki/parent_edit.gif";
@xwiki-icon-edit-section:             "/xwiki/resources/icons/xwiki/edit%2Dsection.png";
@xwiki-icon-spinner:                  "/xwiki/resources/icons/xwiki/spinner.gif";

// ==============================================================================
// NOT SENT TO THE BROWSER FROM THIS POINT
// ==============================================================================
.not-sent-to-the-browser-from-this-point{
  color: red;
}
    .colortheme-pageContentBackgroundColor{
        color: @xwiki-page-content-bg;
    }
    .colortheme-borderColor{
        color: @xwiki-border-color;
    }
    .colortheme-panelHeaderBackgroundColor{
        color: @panel-default-heading-bg;
    }
    .colortheme-textColor{
        color: @text-color;
    }
    .colortheme-linkColor{
        color: @link-color;
    }
    .colortheme-titleColor{
        color: @headings-color;
    }
    .colortheme-pageBackgroundColor{
        color: @body-bg;
    }
    .colortheme-menuBackgroundColor{
        color: @navbar-default-bg;
    }
    .colortheme-menuLinkColor{
        color: @navbar-inverse-link-color;
    }
    .colortheme-menuSelectedEntryBackgroundColor{
        color: @navbar-default-link-active-bg;
    }
    .colortheme-menuSelectedEntryLinkColor{
        color: @navbar-default-link-active-color;
    }
    .colortheme-panelBackgroundColor{
        color: @panel-bg;
    }
    .colortheme-buttonPrimaryTextColor{
        color: @btn-primary-color;
    }
    .colortheme-buttonPrimaryBackgroundColor{
        color: @btn-primary-bg;
    }
    .colortheme-buttonSecondaryTextColor{
        color: @btn-default-color;
    }
    .colortheme-buttonSecondaryBackgroundColor{
        color: @btn-default-bg;
    }
    .colortheme-menuAddEntryLinkColor{
        color: @btn-success-color;
    }
    .colortheme-menuAddEntryBackgroundColor{
        color: @btn-success-bg;
    }
    .colortheme-highlightColor{
        color: @nav-link-hover-bg;
    }
    .colortheme-notificationSuccessColor{
        color: @brand-success;
    }
    .colortheme-notificationInfoColor{
        color: @brand-info;
    }
    .colortheme-notificationWarningColor{
        color: @brand-warning;
    }
    .colortheme-notificationErrorColor{
        color: @brand-danger;
    }

Thanks, Guillaume

SomMeri commented 9 years ago

The problem is caused by one of the imported files - if I remove imports and add missing variable everything compiles. The error does not says which one, I will add that print into BugHappened event.

Could you please put breakpoint into BugHappened and see what file is returned by offendingNode.getSourceLine()? It would help greatly if I could get line 102 of that file.

gdelhumeau commented 9 years ago

The file is: https://github.com/twbs/bootstrap/blob/v3.2.0/less/mixins/vendor-prefixes.less#L102

The line 102 is:

&::-moz-placeholder           { color: @color;   // Firefox
SomMeri commented 9 years ago

One way to reproduce the problem:

@import (reference) "less/bootstrap.less"; 
.placeholder();

Important notes:

Following construction works correctly:

.placeholder(@color: @input-color-placeholder) {
  &::-moz-placeholder  { 
    color: @color;   
    opacity: 1; 
  } 
}
@input-color-placeholder: red;

.placeholder();

Following construction works correctly too:

@import "less/mixins/vendor-prefixes.less"; // Bootstrap
@input-color-placeholder:red;

.placeholder();
SomMeri commented 9 years ago

Smallest reproduce so far:

.placeholder() {
  &::-webkit-input-placeholder  { color: red; }
}
.modal-footer {
  &:extend(.clearfix all); 
}
.placeholder();

Error is reported on line 2:

Offending place: .../bootstrap-3.2.0-less/flamingo-m.less 2:1
SomMeri commented 9 years ago

The issue I could reproduce is now fixed, so I'm closing the issue. If the current master or the next release does not fix your problem, please re-open.

SomMeri commented 9 years ago

I released new version 1.8.4, your problem should be fixed there. If it is not, please re-open this issue.