ASTManipulator上的Less4j Compiler NullPointerException

时间:2014-03-06 13:25:42

标签: java less

我有一个styles.less父文件,它有一些对较少模块的引用。 首先,我有一个较少的文件和一些变量,而且我正在制作一些模块少的文件,所以我有一些概述。

我遇到的问题是编译较少的文件时,较少的编译会抛出一个nullpointer异常。当我使用验证器或grunt时,文件就越少。

以下情况失败。

styles.less

@import "core/_settings";
@import "shared-components/_messages";

_settings.less

@breakpoint-two: ~"only screen and (min-width: 767px)";
@breakpoint-three: ~"only screen and (min-width: 960px)";

_messages.less

.message {
    text-align: center;
    list-style: none;
    margin: 0 0 @spacing 0;
    a{
        color: @color-black;
        &:hover {opacity: .5}
    }
}

.message--include {
    display: block;
    font-weight: 600;
    line-height: 1.5rem;
    margin-bottom: 0.25rem;
    padding: 0.75rem;
    vertical-align: baseline;

    @media @breakpoint-three {
        padding: 1rem 1.5rem;
    }

    p { margin: 0; }
}

编译器在媒体查询上抛出错误。

java.lang.NullPointerException
    at com.github.sommeri.less4j.core.compiler.stages.ASTManipulator.replace(ASTManipulator.java:38)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveIfVariableReference(ReferencesSolver.java:169)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:103)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:105)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:105)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:101)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:66)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver.compileReferencedMixin(MixinsSolver.java:72)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver.access$000(MixinsSolver.java:30)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver$1.run(MixinsSolver.java:52)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver$1.run(MixinsSolver.java:47)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInOriginalDataSnapshot(InScopeSnapshotRunner.java:104)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInOriginalDataSnapshot(InScopeSnapshotRunner.java:79)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver.resolveMixinReference(MixinsSolver.java:47)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver.access$500(MixinsSolver.java:30)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver$2.run(MixinsSolver.java:143)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.stages.MixinsSolver.buildMixinReferenceReplacement(MixinsSolver.java:127)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveMixinReferences(ReferencesSolver.java:130)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:82)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:101)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:101)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:101)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveNonMixinReferences(ReferencesSolver.java:101)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.unsafeDoSolveReferences(ReferencesSolver.java:85)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.access$000(ReferencesSolver.java:35)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver$1.run(ReferencesSolver.java:59)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:44)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:24)
    at com.github.sommeri.less4j.core.compiler.scopes.InScopeSnapshotRunner.runInLocalDataSnapshot(InScopeSnapshotRunner.java:15)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.doSolveReferences(ReferencesSolver.java:55)
    at com.github.sommeri.less4j.core.compiler.stages.ReferencesSolver.solveReferences(ReferencesSolver.java:50)
    at com.github.sommeri.less4j.core.compiler.LessToCssCompiler.resolveReferences(LessToCssCompiler.java:126)
    at com.github.sommeri.less4j.core.compiler.LessToCssCompiler.compileToCss(LessToCssCompiler.java:47)
    at com.github.sommeri.less4j.core.ThreadUnsafeLessCompiler.doCompile(ThreadUnsafeLessCompiler.java:84)
    at com.github.sommeri.less4j.core.ThreadUnsafeLessCompiler.compile(ThreadUnsafeLessCompiler.java:71)
    at com.github.sommeri.less4j.core.ThreadUnsafeLessCompiler.compile(ThreadUnsafeLessCompiler.java:63)
    at de.agilecoders.wicket.less.LessCacheManager.getCss(LessCacheManager.java:93)
    at de.agilecoders.wicket.less.LessResourceStream.getString(LessResourceStream.java:70)
    at org.apache.wicket.util.resource.AbstractStringResourceStream.getInputStream(AbstractStringResourceStream.java:172)
    at org.apache.wicket.request.resource.PackageResource.newResourceResponse(PackageResource.java:303)
    at org.apache.wicket.request.resource.AbstractResource.respond(AbstractResource.java:498)
    at org.apache.wicket.request.handler.resource.ResourceRequestHandler.respond(ResourceRequestHandler.java:75)
    at org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler.respond(ResourceReferenceRequestHandler.java:108)
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861)
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

我也试过了less4j的命令行版本,但是我有相同的结果。任何人都可以指出为什么会这样吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

less4j的作者承认了这个问题并在1.4.1中解决了这个问题。 有关详细信息,请参阅https://github.com/SomMeri/less4j/issues/196