From 277e697f7d9258983e52042757baac09b4fe1908 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Fri, 30 Aug 2013 08:37:27 +0300 Subject: Refactor the debug window hierarchy section (#12471) Various parts of the hierarchy section are split out to separate classes to permit reusing some of them in other parts of the debug window. Change-Id: I32ed562bc9d95df2d3c899d9a17a60d45aa703fd --- .../client/debug/internal/AnalyzeLayoutsPanel.java | 267 ++++++++++++ .../client/debug/internal/ConnectorInfoPanel.java | 107 +++++ .../client/debug/internal/HierarchyPanel.java | 138 ++++++ .../client/debug/internal/HierarchySection.java | 474 ++------------------- .../vaadin/client/debug/internal/Highlight.java | 15 - .../debug/internal/OptimizedWidgetsetPanel.java | 137 ++++++ .../debug/internal/SelectConnectorListener.java | 37 ++ 7 files changed, 728 insertions(+), 447 deletions(-) create mode 100644 client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java create mode 100644 client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java create mode 100644 client/src/com/vaadin/client/debug/internal/HierarchyPanel.java create mode 100644 client/src/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java create mode 100644 client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java diff --git a/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java b/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java new file mode 100644 index 0000000000..7561bc2c03 --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/AnalyzeLayoutsPanel.java @@ -0,0 +1,267 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.Style.TextDecoration; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.MouseOutEvent; +import com.google.gwt.event.dom.client.MouseOutHandler; +import com.google.gwt.event.dom.client.MouseOverEvent; +import com.google.gwt.event.dom.client.MouseOverHandler; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConfiguration; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ComputedStyle; +import com.vaadin.client.ConnectorMap; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.SimpleTree; +import com.vaadin.client.Util; +import com.vaadin.client.ValueMap; + +/** + * Analyze layouts view panel of the debug window. + * + * @since 7.1.4 + */ +public class AnalyzeLayoutsPanel extends FlowPanel { + + private List listeners = new ArrayList(); + + public void update() { + clear(); + add(new Label("Analyzing layouts...")); + List runningApplications = ApplicationConfiguration + .getRunningApplications(); + for (ApplicationConnection applicationConnection : runningApplications) { + applicationConnection.analyzeLayouts(); + } + } + + public void meta(ApplicationConnection ac, ValueMap meta) { + clear(); + JsArray valueMapArray = meta + .getJSValueMapArray("invalidLayouts"); + int size = valueMapArray.length(); + + if (size > 0) { + SimpleTree root = new SimpleTree("Layouts analyzed, " + size + + " top level problems"); + for (int i = 0; i < size; i++) { + printLayoutError(ac, valueMapArray.get(i), root); + } + root.open(false); + add(root); + } else { + add(new Label("Layouts analyzed, no top level problems")); + } + + Set zeroHeightComponents = new HashSet(); + Set zeroWidthComponents = new HashSet(); + findZeroSizeComponents(zeroHeightComponents, zeroWidthComponents, + ac.getUIConnector()); + if (zeroHeightComponents.size() > 0 || zeroWidthComponents.size() > 0) { + add(new HTML("

Client side notifications

" + + " The following relative sized components were " + + "rendered to a zero size container on the client side." + + " Note that these are not necessarily invalid " + + "states, but reported here as they might be.")); + if (zeroHeightComponents.size() > 0) { + add(new HTML("

Vertically zero size:

")); + printClientSideDetectedIssues(zeroHeightComponents, ac); + } + if (zeroWidthComponents.size() > 0) { + add(new HTML("

Horizontally zero size:

")); + printClientSideDetectedIssues(zeroWidthComponents, ac); + } + } + + } + + private void printClientSideDetectedIssues( + Set zeroSized, ApplicationConnection ac) { + + // keep track of already highlighted parents + HashSet parents = new HashSet(); + + for (final ComponentConnector connector : zeroSized) { + final ServerConnector parent = connector.getParent(); + final String parentId = parent.getConnectorId(); + + final Label errorDetails = new Label(Util.getSimpleName(connector) + + "[" + connector.getConnectorId() + "]" + " inside " + + Util.getSimpleName(parent)); + + if (parent instanceof ComponentConnector) { + final ComponentConnector parentConnector = (ComponentConnector) parent; + if (!parents.contains(parentId)) { + parents.add(parentId); + Highlight.show(parentConnector, "yellow"); + } + + errorDetails.addMouseOverHandler(new MouseOverHandler() { + @Override + public void onMouseOver(MouseOverEvent event) { + Highlight.hideAll(); + Highlight.show(parentConnector, "yellow"); + Highlight.show(connector); + errorDetails.getElement().getStyle() + .setTextDecoration(TextDecoration.UNDERLINE); + } + }); + errorDetails.addMouseOutHandler(new MouseOutHandler() { + @Override + public void onMouseOut(MouseOutEvent event) { + Highlight.hideAll(); + errorDetails.getElement().getStyle() + .setTextDecoration(TextDecoration.NONE); + } + }); + errorDetails.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + fireSelectEvent(connector); + } + }); + + } + + Highlight.show(connector); + add(errorDetails); + + } + } + + private void printLayoutError(ApplicationConnection ac, ValueMap valueMap, + SimpleTree root) { + final String pid = valueMap.getString("id"); + + // find connector + final ComponentConnector connector = (ComponentConnector) ConnectorMap + .get(ac).getConnector(pid); + + if (connector == null) { + root.add(new SimpleTree("[" + pid + "] NOT FOUND")); + return; + } + + Highlight.show(connector); + + final SimpleTree errorNode = new SimpleTree( + Util.getSimpleName(connector) + " id: " + pid); + errorNode.addDomHandler(new MouseOverHandler() { + @Override + public void onMouseOver(MouseOverEvent event) { + Highlight.showOnly(connector); + ((Widget) event.getSource()).getElement().getStyle() + .setTextDecoration(TextDecoration.UNDERLINE); + } + }, MouseOverEvent.getType()); + errorNode.addDomHandler(new MouseOutHandler() { + @Override + public void onMouseOut(MouseOutEvent event) { + Highlight.hideAll(); + ((Widget) event.getSource()).getElement().getStyle() + .setTextDecoration(TextDecoration.NONE); + } + }, MouseOutEvent.getType()); + + errorNode.addDomHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + if (event.getNativeEvent().getEventTarget().cast() == errorNode + .getElement().getChild(1).cast()) { + fireSelectEvent(connector); + } + } + }, ClickEvent.getType()); + + VerticalPanel errorDetails = new VerticalPanel(); + + if (valueMap.containsKey("heightMsg")) { + errorDetails.add(new Label("Height problem: " + + valueMap.getString("heightMsg"))); + } + if (valueMap.containsKey("widthMsg")) { + errorDetails.add(new Label("Width problem: " + + valueMap.getString("widthMsg"))); + } + if (errorDetails.getWidgetCount() > 0) { + errorNode.add(errorDetails); + } + if (valueMap.containsKey("subErrors")) { + HTML l = new HTML( + "Expand this node to show problems that may be dependent on this problem."); + errorDetails.add(l); + JsArray suberrors = valueMap + .getJSValueMapArray("subErrors"); + for (int i = 0; i < suberrors.length(); i++) { + ValueMap value = suberrors.get(i); + printLayoutError(ac, value, errorNode); + } + + } + root.add(errorNode); + } + + private void findZeroSizeComponents( + Set zeroHeightComponents, + Set zeroWidthComponents, + ComponentConnector connector) { + Widget widget = connector.getWidget(); + ComputedStyle computedStyle = new ComputedStyle(widget.getElement()); + if (computedStyle.getIntProperty("height") == 0) { + zeroHeightComponents.add(connector); + } + if (computedStyle.getIntProperty("width") == 0) { + zeroWidthComponents.add(connector); + } + List children = connector.getChildren(); + for (ServerConnector serverConnector : children) { + if (serverConnector instanceof ComponentConnector) { + findZeroSizeComponents(zeroHeightComponents, + zeroWidthComponents, + (ComponentConnector) serverConnector); + } + } + } + + public void addListener(SelectConnectorListener listener) { + listeners.add(listener); + } + + public void removeListener(SelectConnectorListener listener) { + listeners.remove(listener); + } + + private void fireSelectEvent(ServerConnector connector) { + for (SelectConnectorListener listener : listeners) { + listener.select(connector, null); + } + } + +} diff --git a/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java b/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java new file mode 100644 index 0000000000..fc7b55497e --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/ConnectorInfoPanel.java @@ -0,0 +1,107 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.JsArrayObject; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.Util; +import com.vaadin.client.VConsole; +import com.vaadin.client.metadata.NoDataException; +import com.vaadin.client.metadata.Property; +import com.vaadin.client.ui.AbstractConnector; +import com.vaadin.shared.AbstractComponentState; +import com.vaadin.shared.communication.SharedState; + +/** + * Connector information view panel of the debug window. + * + * @since 7.1.4 + */ +public class ConnectorInfoPanel extends FlowPanel { + + /** + * Update the panel to show information about a connector. + * + * @param connector + */ + public void update(ServerConnector connector) { + SharedState state = connector.getState(); + + Set ignoreProperties = new HashSet(); + ignoreProperties.add("id"); + + String html = getRowHTML("Id", connector.getConnectorId()); + html += getRowHTML("Connector", Util.getSimpleName(connector)); + + if (connector instanceof ComponentConnector) { + ComponentConnector component = (ComponentConnector) connector; + + ignoreProperties.addAll(Arrays.asList("caption", "description", + "width", "height")); + + AbstractComponentState componentState = component.getState(); + + html += getRowHTML("Widget", + Util.getSimpleName(component.getWidget())); + html += getRowHTML("Caption", componentState.caption); + html += getRowHTML("Description", componentState.description); + html += getRowHTML("Width", componentState.width + " (actual: " + + component.getWidget().getOffsetWidth() + "px)"); + html += getRowHTML("Height", componentState.height + " (actual: " + + component.getWidget().getOffsetHeight() + "px)"); + } + + try { + JsArrayObject properties = AbstractConnector + .getStateType(connector).getPropertiesAsArray(); + for (int i = 0; i < properties.size(); i++) { + Property property = properties.get(i); + String name = property.getName(); + if (!ignoreProperties.contains(name)) { + html += getRowHTML(property.getDisplayName(), + property.getValue(state)); + } + } + } catch (NoDataException e) { + html += "
Could not read state, error has been logged to the console
"; + VConsole.error(e); + } + + clear(); + add(new HTML(html)); + } + + private String getRowHTML(String caption, Object value) { + return "
" + caption + + "" + + Util.escapeHTML(String.valueOf(value)) + "
"; + } + + /** + * Clear the contents of the panel. + */ + public void clearContents() { + clear(); + } +} diff --git a/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java b/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java new file mode 100644 index 0000000000..759dbf00dd --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java @@ -0,0 +1,138 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.DoubleClickEvent; +import com.google.gwt.event.dom.client.DoubleClickHandler; +import com.google.gwt.event.dom.client.HasDoubleClickHandlers; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.SimplePanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConfiguration; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.SimpleTree; +import com.vaadin.client.Util; + +/** + * Hierarchy view panel of the debug window. This class can be used in various + * debug window sections to show the current connector hierarchy. + * + * @since 7.1.4 + */ +public class HierarchyPanel extends FlowPanel { + + // TODO separate click listeners for simple selection and doubleclick + private List listeners = new ArrayList(); + + public void update() { + clear(); + // TODO Clearing and rebuilding the contents is not optimal for UX as + // any previous expansions are lost. + SimplePanel trees = new SimplePanel(); + + for (ApplicationConnection application : ApplicationConfiguration + .getRunningApplications()) { + ServerConnector uiConnector = application.getUIConnector(); + Widget connectorTree = buildConnectorTree(uiConnector); + + trees.add(connectorTree); + } + + add(trees); + } + + private Widget buildConnectorTree(final ServerConnector connector) { + String connectorString = Util.getConnectorString(connector); + + List children = connector.getChildren(); + + Widget widget; + if (children == null || children.isEmpty()) { + // Leaf node, just add a label + Label label = new Label(connectorString); + label.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + Highlight.showOnly(connector); + showServerDebugInfo(connector); + } + }); + widget = label; + } else { + SimpleTree tree = new SimpleTree(connectorString) { + @Override + protected void select(ClickEvent event) { + super.select(event); + Highlight.showOnly(connector); + showServerDebugInfo(connector); + } + }; + for (ServerConnector child : children) { + tree.add(buildConnectorTree(child)); + } + widget = tree; + } + + if (widget instanceof HasDoubleClickHandlers) { + HasDoubleClickHandlers has = (HasDoubleClickHandlers) widget; + has.addDoubleClickHandler(new DoubleClickHandler() { + @Override + public void onDoubleClick(DoubleClickEvent event) { + fireSelectEvent(connector); + } + }); + } + + return widget; + } + + public void addListener(SelectConnectorListener listener) { + listeners.add(listener); + } + + public void removeListener(SelectConnectorListener listener) { + listeners.remove(listener); + } + + private void fireSelectEvent(ServerConnector connector) { + for (SelectConnectorListener listener : listeners) { + listener.select(connector, null); + } + } + + /** + * Outputs debug information on the server - usually in the console of an + * IDE, with a clickable reference to the relevant code location. + * + * @since 7.1 + * @param connector + * show debug info for this connector + */ + static void showServerDebugInfo(ServerConnector connector) { + if (connector != null) { + connector.getConnection().getUIConnector() + .showServerDebugInfo(connector); + } + } + +} diff --git a/client/src/com/vaadin/client/debug/internal/HierarchySection.java b/client/src/com/vaadin/client/debug/internal/HierarchySection.java index 90c9086d7d..616bf70c38 100644 --- a/client/src/com/vaadin/client/debug/internal/HierarchySection.java +++ b/client/src/com/vaadin/client/debug/internal/HierarchySection.java @@ -15,23 +15,9 @@ */ package com.vaadin.client.debug.internal; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.google.gwt.core.client.JsArray; -import com.google.gwt.dom.client.Style.TextDecoration; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.DoubleClickEvent; -import com.google.gwt.event.dom.client.DoubleClickHandler; -import com.google.gwt.event.dom.client.HasDoubleClickHandlers; import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.MouseOutEvent; -import com.google.gwt.event.dom.client.MouseOutHandler; -import com.google.gwt.event.dom.client.MouseOverEvent; -import com.google.gwt.event.dom.client.MouseOverHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -40,28 +26,15 @@ import com.google.gwt.user.client.Event.NativePreviewHandler; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; -import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.SimplePanel; -import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ComputedStyle; -import com.vaadin.client.ConnectorMap; -import com.vaadin.client.JsArrayObject; import com.vaadin.client.ServerConnector; -import com.vaadin.client.SimpleTree; import com.vaadin.client.Util; -import com.vaadin.client.VConsole; import com.vaadin.client.ValueMap; -import com.vaadin.client.metadata.NoDataException; -import com.vaadin.client.metadata.Property; -import com.vaadin.client.ui.AbstractConnector; -import com.vaadin.client.ui.UnknownComponentConnector; -import com.vaadin.shared.AbstractComponentState; -import com.vaadin.shared.communication.SharedState; /** * Provides functionality for examining the UI component hierarchy. @@ -73,7 +46,15 @@ public class HierarchySection implements Section { private final DebugButton tabButton = new DebugButton(Icon.HIERARCHY, "Examine component hierarchy"); - private final FlowPanel content = new FlowPanel(); + private final SimplePanel content = new SimplePanel(); + + // TODO highlighting logic is split between these, should be refactored + private final FlowPanel helpPanel = new FlowPanel(); + private final ConnectorInfoPanel infoPanel = new ConnectorInfoPanel(); + private final HierarchyPanel hierarchyPanel = new HierarchyPanel(); + private final OptimizedWidgetsetPanel widgetsetPanel = new OptimizedWidgetsetPanel(); + private final AnalyzeLayoutsPanel analyzeLayoutsPanel = new AnalyzeLayoutsPanel(); + private final FlowPanel controls = new FlowPanel(); private final Button find = new DebugButton(Icon.HIGHLIGHT, @@ -125,79 +106,40 @@ public class HierarchySection implements Section { } }); + hierarchyPanel.addListener(new SelectConnectorListener() { + @Override + public void select(ServerConnector connector, Element element) { + printState(connector, true); + } + }); + + analyzeLayoutsPanel.addListener(new SelectConnectorListener() { + @Override + public void select(ServerConnector connector, Element element) { + printState(connector, true); + } + }); + content.setStylePrimaryName(VDebugWindow.STYLENAME + "-hierarchy"); + initializeHelpPanel(); + content.setWidget(helpPanel); + } + + private void initializeHelpPanel() { HTML info = new HTML(showHierarchy.getHTML() + " " + showHierarchy.getTitle() + "
" + find.getHTML() + " " + find.getTitle() + "
" + analyze.getHTML() + " " + analyze.getTitle() + "
" + generateWS.getHTML() + " " + generateWS.getTitle() + "
"); info.setStyleName(VDebugWindow.STYLENAME + "-info"); - content.add(info); + helpPanel.add(info); } private void showHierarchy() { Highlight.hideAll(); - content.clear(); - - // TODO Clearing and rebuilding the contents is not optimal for UX as - // any previous expansions are lost. - SimplePanel trees = new SimplePanel(); - - for (ApplicationConnection application : ApplicationConfiguration - .getRunningApplications()) { - ServerConnector uiConnector = application.getUIConnector(); - Widget connectorTree = buildConnectorTree(uiConnector); - - trees.add(connectorTree); - } - - content.add(trees); - } - - private Widget buildConnectorTree(final ServerConnector connector) { - String connectorString = Util.getConnectorString(connector); - - List children = connector.getChildren(); - - Widget widget; - if (children == null || children.isEmpty()) { - // Leaf node, just add a label - Label label = new Label(connectorString); - label.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - Highlight.showOnly(connector); - Highlight.showServerDebugInfo(connector); - } - }); - widget = label; - } else { - SimpleTree tree = new SimpleTree(connectorString) { - @Override - protected void select(ClickEvent event) { - super.select(event); - Highlight.showOnly(connector); - Highlight.showServerDebugInfo(connector); - } - }; - for (ServerConnector child : children) { - tree.add(buildConnectorTree(child)); - } - widget = tree; - } - - if (widget instanceof HasDoubleClickHandlers) { - HasDoubleClickHandlers has = (HasDoubleClickHandlers) widget; - has.addDoubleClickHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - printState(connector, true); - } - }); - } - - return widget; + hierarchyPanel.update(); + content.setWidget(hierarchyPanel); } @Override @@ -226,302 +168,19 @@ public class HierarchySection implements Section { } private void generateWidgetset() { - - content.clear(); - HTML h = new HTML("Getting used connectors"); - content.add(h); - - String s = ""; - for (ApplicationConnection ac : ApplicationConfiguration - .getRunningApplications()) { - ApplicationConfiguration conf = ac.getConfiguration(); - s += "

Used connectors for " + conf.getServiceUrl() + "

"; - - for (String connectorName : getUsedConnectorNames(conf)) { - s += connectorName + "
"; - } - - s += "

To make an optimized widgetset based on these connectors, do:

"; - s += "

1. Add to your widgetset.gwt.xml file:

"; - s += ""; - - s += "

2. Add the following java file to your project:

"; - s += ""; - s += "

3. Recompile widgetset

"; - - } - - h.setHTML(s); - } - - private Set getUsedConnectorNames( - ApplicationConfiguration configuration) { - int tag = 0; - Set usedConnectors = new HashSet(); - while (true) { - String serverSideClass = configuration - .getServerSideClassNameForTag(tag); - if (serverSideClass == null) { - break; - } - Class connectorClass = configuration - .getConnectorClassByEncodedTag(tag); - if (connectorClass == null) { - break; - } - - if (connectorClass != UnknownComponentConnector.class) { - usedConnectors.add(connectorClass.getName()); - } - tag++; - if (tag > 10000) { - // Sanity check - VConsole.error("Search for used connector classes was forcefully terminated"); - break; - } - } - return usedConnectors; - } - - public String generateOptimizedWidgetSet(Set usedConnectors) { - String s = "import java.util.HashSet;\n"; - s += "import java.util.Set;\n"; - - s += "import com.google.gwt.core.ext.typeinfo.JClassType;\n"; - s += "import com.vaadin.client.ui.ui.UIConnector;\n"; - s += "import com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory;\n"; - s += "import com.vaadin.shared.ui.Connect.LoadStyle;\n\n"; - - s += "public class OptimizedConnectorBundleLoaderFactory extends\n"; - s += " ConnectorBundleLoaderFactory {\n"; - s += " private Set eagerConnectors = new HashSet();\n"; - s += " {\n"; - for (String c : usedConnectors) { - s += " eagerConnectors.add(" + c - + ".class.getName());\n"; - } - s += " }\n"; - s += "\n"; - s += " @Override\n"; - s += " protected LoadStyle getLoadStyle(JClassType connectorType) {\n"; - s += " if (eagerConnectors.contains(connectorType.getQualifiedBinaryName())) {\n"; - s += " return LoadStyle.EAGER;\n"; - s += " } else {\n"; - s += " // Loads all other connectors immediately after the initial view has\n"; - s += " // been rendered\n"; - s += " return LoadStyle.DEFERRED;\n"; - s += " }\n"; - s += " }\n"; - s += "}\n"; - - return s; + widgetsetPanel.update(); + content.setWidget(widgetsetPanel); } private void analyzeLayouts() { - content.clear(); - content.add(new Label("Analyzing layouts...")); - List runningApplications = ApplicationConfiguration - .getRunningApplications(); - for (ApplicationConnection applicationConnection : runningApplications) { - applicationConnection.analyzeLayouts(); - } + analyzeLayoutsPanel.update(); + content.setWidget(analyzeLayoutsPanel); } @Override public void meta(ApplicationConnection ac, ValueMap meta) { - content.clear(); - JsArray valueMapArray = meta - .getJSValueMapArray("invalidLayouts"); - int size = valueMapArray.length(); - - if (size > 0) { - SimpleTree root = new SimpleTree("Layouts analyzed, " + size - + " top level problems"); - for (int i = 0; i < size; i++) { - printLayoutError(ac, valueMapArray.get(i), root); - } - root.open(false); - content.add(root); - } else { - content.add(new Label("Layouts analyzed, no top level problems")); - } - - Set zeroHeightComponents = new HashSet(); - Set zeroWidthComponents = new HashSet(); - findZeroSizeComponents(zeroHeightComponents, zeroWidthComponents, - ac.getUIConnector()); - if (zeroHeightComponents.size() > 0 || zeroWidthComponents.size() > 0) { - content.add(new HTML("

Client side notifications

" - + " The following relative sized components were " - + "rendered to a zero size container on the client side." - + " Note that these are not necessarily invalid " - + "states, but reported here as they might be.")); - if (zeroHeightComponents.size() > 0) { - content.add(new HTML( - "

Vertically zero size:

")); - printClientSideDetectedIssues(zeroHeightComponents, ac); - } - if (zeroWidthComponents.size() > 0) { - content.add(new HTML( - "

Horizontally zero size:

")); - printClientSideDetectedIssues(zeroWidthComponents, ac); - } - } - - } - - private void printClientSideDetectedIssues( - Set zeroSized, ApplicationConnection ac) { - - // keep track of already highlighted parents - HashSet parents = new HashSet(); - - for (final ComponentConnector connector : zeroSized) { - final ServerConnector parent = connector.getParent(); - final String parentId = parent.getConnectorId(); - - final Label errorDetails = new Label(Util.getSimpleName(connector) - + "[" + connector.getConnectorId() + "]" + " inside " - + Util.getSimpleName(parent)); - - if (parent instanceof ComponentConnector) { - final ComponentConnector parentConnector = (ComponentConnector) parent; - if (!parents.contains(parentId)) { - parents.add(parentId); - Highlight.show(parentConnector, "yellow"); - } - - errorDetails.addMouseOverHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - Highlight.hideAll(); - Highlight.show(parentConnector, "yellow"); - Highlight.show(connector); - errorDetails.getElement().getStyle() - .setTextDecoration(TextDecoration.UNDERLINE); - } - }); - errorDetails.addMouseOutHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - Highlight.hideAll(); - errorDetails.getElement().getStyle() - .setTextDecoration(TextDecoration.NONE); - } - }); - errorDetails.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - printState(connector, true); - } - }); - - } - - Highlight.show(connector); - content.add(errorDetails); - - } - } - - private void printLayoutError(ApplicationConnection ac, ValueMap valueMap, - SimpleTree root) { - final String pid = valueMap.getString("id"); - - // find connector - final ComponentConnector connector = (ComponentConnector) ConnectorMap - .get(ac).getConnector(pid); - - if (connector == null) { - root.add(new SimpleTree("[" + pid + "] NOT FOUND")); - return; - } - - Highlight.show(connector); - - final SimpleTree errorNode = new SimpleTree( - Util.getSimpleName(connector) + " id: " + pid); - errorNode.addDomHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - Highlight.showOnly(connector); - ((Widget) event.getSource()).getElement().getStyle() - .setTextDecoration(TextDecoration.UNDERLINE); - } - }, MouseOverEvent.getType()); - errorNode.addDomHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - Highlight.hideAll(); - ((Widget) event.getSource()).getElement().getStyle() - .setTextDecoration(TextDecoration.NONE); - } - }, MouseOutEvent.getType()); - - errorNode.addDomHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - if (event.getNativeEvent().getEventTarget().cast() == errorNode - .getElement().getChild(1).cast()) { - printState(connector, true); - } - } - }, ClickEvent.getType()); - - VerticalPanel errorDetails = new VerticalPanel(); - - if (valueMap.containsKey("heightMsg")) { - errorDetails.add(new Label("Height problem: " - + valueMap.getString("heightMsg"))); - } - if (valueMap.containsKey("widthMsg")) { - errorDetails.add(new Label("Width problem: " - + valueMap.getString("widthMsg"))); - } - if (errorDetails.getWidgetCount() > 0) { - errorNode.add(errorDetails); - } - if (valueMap.containsKey("subErrors")) { - HTML l = new HTML( - "Expand this node to show problems that may be dependent on this problem."); - errorDetails.add(l); - JsArray suberrors = valueMap - .getJSValueMapArray("subErrors"); - for (int i = 0; i < suberrors.length(); i++) { - ValueMap value = suberrors.get(i); - printLayoutError(ac, value, errorNode); - } - - } - root.add(errorNode); - } - - private void findZeroSizeComponents( - Set zeroHeightComponents, - Set zeroWidthComponents, - ComponentConnector connector) { - Widget widget = connector.getWidget(); - ComputedStyle computedStyle = new ComputedStyle(widget.getElement()); - if (computedStyle.getIntProperty("height") == 0) { - zeroHeightComponents.add(connector); - } - if (computedStyle.getIntProperty("width") == 0) { - zeroWidthComponents.add(connector); - } - List children = connector.getChildren(); - for (ServerConnector serverConnector : children) { - if (serverConnector instanceof ComponentConnector) { - findZeroSizeComponents(zeroHeightComponents, - zeroWidthComponents, - (ComponentConnector) serverConnector); - } - } + // show the results of analyzeLayouts + analyzeLayoutsPanel.meta(ac, meta); } @Override @@ -561,60 +220,11 @@ public class HierarchySection implements Section { private void printState(ServerConnector connector, boolean serverDebug) { Highlight.showOnly(connector); if (serverDebug) { - Highlight.showServerDebugInfo(connector); + HierarchyPanel.showServerDebugInfo(connector); } - SharedState state = connector.getState(); - - Set ignoreProperties = new HashSet(); - ignoreProperties.add("id"); - - String html = getRowHTML("Id", connector.getConnectorId()); - html += getRowHTML("Connector", Util.getSimpleName(connector)); - - if (connector instanceof ComponentConnector) { - ComponentConnector component = (ComponentConnector) connector; - - ignoreProperties.addAll(Arrays.asList("caption", "description", - "width", "height")); - - AbstractComponentState componentState = component.getState(); - - html += getRowHTML("Widget", - Util.getSimpleName(component.getWidget())); - html += getRowHTML("Caption", componentState.caption); - html += getRowHTML("Description", componentState.description); - html += getRowHTML("Width", componentState.width + " (actual: " - + component.getWidget().getOffsetWidth() + "px)"); - html += getRowHTML("Height", componentState.height + " (actual: " - + component.getWidget().getOffsetHeight() + "px)"); - } - - try { - JsArrayObject properties = AbstractConnector - .getStateType(connector).getPropertiesAsArray(); - for (int i = 0; i < properties.size(); i++) { - Property property = properties.get(i); - String name = property.getName(); - if (!ignoreProperties.contains(name)) { - html += getRowHTML(property.getDisplayName(), - property.getValue(state)); - } - } - } catch (NoDataException e) { - html += "
Could not read state, error has been logged to the console
"; - VConsole.error(e); - } - - content.clear(); - content.add(new HTML(html)); - } - - private String getRowHTML(String caption, Object value) { - return "
" + caption - + "" - + Util.escapeHTML(String.valueOf(value)) + "
"; + infoPanel.update(connector); + content.setWidget(infoPanel); } private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { @@ -634,7 +244,7 @@ public class HierarchySection implements Section { .getNativeEvent().getClientX(), event.getNativeEvent() .getClientY()); if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { - content.clear(); + infoPanel.clear(); return; } @@ -654,7 +264,7 @@ public class HierarchySection implements Section { return; } } - content.clear(); + infoPanel.clear(); } if (event.getTypeInt() == Event.ONCLICK) { Highlight.hideAll(); diff --git a/client/src/com/vaadin/client/debug/internal/Highlight.java b/client/src/com/vaadin/client/debug/internal/Highlight.java index 3c1af445a9..f2695f58ca 100644 --- a/client/src/com/vaadin/client/debug/internal/Highlight.java +++ b/client/src/com/vaadin/client/debug/internal/Highlight.java @@ -207,19 +207,4 @@ public class Highlight { } } - /** - * Outputs debug information on the server - usually in the console of an - * IDE, with a clickable reference to the relevant code location. - * - * @since 7.1 - * @param connector - * show debug info for this connector - */ - static void showServerDebugInfo(ServerConnector connector) { - if (connector != null) { - connector.getConnection().getUIConnector() - .showServerDebugInfo(connector); - } - } - } diff --git a/client/src/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java b/client/src/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java new file mode 100644 index 0000000000..a8d8aad888 --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/OptimizedWidgetsetPanel.java @@ -0,0 +1,137 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import java.util.HashSet; +import java.util.Set; + +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.vaadin.client.ApplicationConfiguration; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.VConsole; +import com.vaadin.client.ui.UnknownComponentConnector; + +/** + * Optimized widgetset view panel of the debug window. + * + * @since 7.1.4 + */ +public class OptimizedWidgetsetPanel extends FlowPanel { + + /** + * Update the panel contents based on the connectors that have been used so + * far on this execution of the application. + */ + public void update() { + clear(); + HTML h = new HTML("Getting used connectors"); + add(h); + + String s = ""; + for (ApplicationConnection ac : ApplicationConfiguration + .getRunningApplications()) { + ApplicationConfiguration conf = ac.getConfiguration(); + s += "

Used connectors for " + conf.getServiceUrl() + "

"; + + for (String connectorName : getUsedConnectorNames(conf)) { + s += connectorName + "
"; + } + + s += "

To make an optimized widgetset based on these connectors, do:

"; + s += "

1. Add to your widgetset.gwt.xml file:

"; + s += ""; + + s += "

2. Add the following java file to your project:

"; + s += ""; + s += "

3. Recompile widgetset

"; + + } + + h.setHTML(s); + } + + private Set getUsedConnectorNames( + ApplicationConfiguration configuration) { + int tag = 0; + Set usedConnectors = new HashSet(); + while (true) { + String serverSideClass = configuration + .getServerSideClassNameForTag(tag); + if (serverSideClass == null) { + break; + } + Class connectorClass = configuration + .getConnectorClassByEncodedTag(tag); + if (connectorClass == null) { + break; + } + + if (connectorClass != UnknownComponentConnector.class) { + usedConnectors.add(connectorClass.getName()); + } + tag++; + if (tag > 10000) { + // Sanity check + VConsole.error("Search for used connector classes was forcefully terminated"); + break; + } + } + return usedConnectors; + } + + public String generateOptimizedWidgetSet(Set usedConnectors) { + String s = "import java.util.HashSet;\n"; + s += "import java.util.Set;\n"; + + s += "import com.google.gwt.core.ext.typeinfo.JClassType;\n"; + s += "import com.vaadin.client.ui.ui.UIConnector;\n"; + s += "import com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory;\n"; + s += "import com.vaadin.shared.ui.Connect.LoadStyle;\n\n"; + + s += "public class OptimizedConnectorBundleLoaderFactory extends\n"; + s += " ConnectorBundleLoaderFactory {\n"; + s += " private Set eagerConnectors = new HashSet();\n"; + s += " {\n"; + for (String c : usedConnectors) { + s += " eagerConnectors.add(" + c + + ".class.getName());\n"; + } + s += " }\n"; + s += "\n"; + s += " @Override\n"; + s += " protected LoadStyle getLoadStyle(JClassType connectorType) {\n"; + s += " if (eagerConnectors.contains(connectorType.getQualifiedBinaryName())) {\n"; + s += " return LoadStyle.EAGER;\n"; + s += " } else {\n"; + s += " // Loads all other connectors immediately after the initial view has\n"; + s += " // been rendered\n"; + s += " return LoadStyle.DEFERRED;\n"; + s += " }\n"; + s += " }\n"; + s += "}\n"; + + return s; + } + +} diff --git a/client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java b/client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java new file mode 100644 index 0000000000..409f9d14ce --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/SelectConnectorListener.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import com.google.gwt.user.client.Element; +import com.vaadin.client.ServerConnector; + +/** + * Listener for the selection of a connector in the debug window. + * + * @since 7.1.4 + */ +public interface SelectConnectorListener { + /** + * Listener method called when a connector has been selected. If a specific + * element of the connector was selected, it is also given. + * + * @param connector + * selected connector + * @param element + * selected element of the connector or null if unknown + */ + public void select(ServerConnector connector, Element element); +} \ No newline at end of file -- cgit v1.2.3 From 8d4518822770c79893aa06cfa22d275931f5b422 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 29 Aug 2013 14:26:04 +0300 Subject: Preserve open nodes in debug window hierarchy over refresh (#12472) Change-Id: Ib64f40db6e5568e236db410b0ad0ec2960be37f7 --- client/src/com/vaadin/client/SimpleTree.java | 8 ++++ .../client/debug/internal/HierarchyPanel.java | 50 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/client/src/com/vaadin/client/SimpleTree.java b/client/src/com/vaadin/client/SimpleTree.java index 7370496cb8..edfa23fb13 100644 --- a/client/src/com/vaadin/client/SimpleTree.java +++ b/client/src/com/vaadin/client/SimpleTree.java @@ -116,6 +116,14 @@ public class SimpleTree extends ComplexPanel implements HasDoubleClickHandlers { } } + public boolean isOpen() { + return "-".equals(handle.getInnerHTML()); + } + + public String getCaption() { + return text.getInnerText(); + } + public SimpleTree(String caption) { this(); setText(caption); diff --git a/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java b/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java index 759dbf00dd..755f076b7a 100644 --- a/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java +++ b/client/src/com/vaadin/client/debug/internal/HierarchyPanel.java @@ -16,6 +16,7 @@ package com.vaadin.client.debug.internal; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import com.google.gwt.event.dom.client.ClickEvent; @@ -24,11 +25,13 @@ import com.google.gwt.event.dom.client.DoubleClickEvent; import com.google.gwt.event.dom.client.DoubleClickHandler; import com.google.gwt.event.dom.client.HasDoubleClickHandlers; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.FastStringSet; import com.vaadin.client.ServerConnector; import com.vaadin.client.SimpleTree; import com.vaadin.client.Util; @@ -45,15 +48,21 @@ public class HierarchyPanel extends FlowPanel { private List listeners = new ArrayList(); public void update() { + // Try to keep track of currently open nodes and reopen them + FastStringSet openNodes = FastStringSet.create(); + Iterator it = iterator(); + while (it.hasNext()) { + collectOpenNodes(it.next(), openNodes); + } + clear(); - // TODO Clearing and rebuilding the contents is not optimal for UX as - // any previous expansions are lost. + SimplePanel trees = new SimplePanel(); for (ApplicationConnection application : ApplicationConfiguration .getRunningApplications()) { ServerConnector uiConnector = application.getUIConnector(); - Widget connectorTree = buildConnectorTree(uiConnector); + Widget connectorTree = buildConnectorTree(uiConnector, openNodes); trees.add(connectorTree); } @@ -61,7 +70,35 @@ public class HierarchyPanel extends FlowPanel { add(trees); } - private Widget buildConnectorTree(final ServerConnector connector) { + /** + * Adds the captions of all open (non-leaf) nodes in the hierarchy tree + * recursively. + * + * @param widget + * the widget in which to search for open nodes (if SimpleTree) + * @param openNodes + * the set in which open nodes should be added + */ + private void collectOpenNodes(Widget widget, FastStringSet openNodes) { + if (widget instanceof SimpleTree) { + SimpleTree tree = (SimpleTree) widget; + if (tree.isOpen()) { + openNodes.add(tree.getCaption()); + } else { + // no need to look inside closed nodes + return; + } + } + if (widget instanceof HasWidgets) { + Iterator it = ((HasWidgets) widget).iterator(); + while (it.hasNext()) { + collectOpenNodes(it.next(), openNodes); + } + } + } + + private Widget buildConnectorTree(final ServerConnector connector, + FastStringSet openNodes) { String connectorString = Util.getConnectorString(connector); List children = connector.getChildren(); @@ -88,7 +125,10 @@ public class HierarchyPanel extends FlowPanel { } }; for (ServerConnector child : children) { - tree.add(buildConnectorTree(child)); + tree.add(buildConnectorTree(child, openNodes)); + } + if (openNodes.contains(connectorString)) { + tree.open(false); } widget = tree; } -- cgit v1.2.3 From 09d7d2799cd4f17084b611155cdbf0650f7a0acc Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 29 Aug 2013 14:27:00 +0300 Subject: Add TestBenchSection for the debug window (#12445) Change-Id: I552885348368f497b8b572614301127fe0460d26 --- .../vaadin/client/ApplicationConfiguration.java | 2 + .../src/com/vaadin/client/debug/internal/Icon.java | 2 + .../client/debug/internal/TestBenchSection.java | 307 +++++++++++++++++++++ 3 files changed, 311 insertions(+) create mode 100644 client/src/com/vaadin/client/debug/internal/TestBenchSection.java diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index da8f521799..f27f9d65d2 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -41,6 +41,7 @@ import com.vaadin.client.debug.internal.LogSection; import com.vaadin.client.debug.internal.NetworkSection; import com.vaadin.client.debug.internal.ProfilerSection; import com.vaadin.client.debug.internal.Section; +import com.vaadin.client.debug.internal.TestBenchSection; import com.vaadin.client.debug.internal.VDebugWindow; import com.vaadin.client.metadata.BundleLoadCallback; import com.vaadin.client.metadata.ConnectorBundleLoader; @@ -578,6 +579,7 @@ public class ApplicationConfiguration implements EntryPoint { window.addSection((Section) GWT.create(InfoSection.class)); window.addSection((Section) GWT.create(HierarchySection.class)); window.addSection((Section) GWT.create(NetworkSection.class)); + window.addSection((Section) GWT.create(TestBenchSection.class)); if (Profiler.isEnabled()) { window.addSection((Section) GWT.create(ProfilerSection.class)); } diff --git a/client/src/com/vaadin/client/debug/internal/Icon.java b/client/src/com/vaadin/client/debug/internal/Icon.java index cc2ef3b348..9ef6d833e2 100644 --- a/client/src/com/vaadin/client/debug/internal/Icon.java +++ b/client/src/com/vaadin/client/debug/internal/Icon.java @@ -32,6 +32,8 @@ public enum Icon { LOG(""), // OPTIMIZE(""), // HIERARCHY(""), // + // TODO create more appropriate icon + SELECTOR("≣"), // MENU(""), // NETWORK(""), // ANALYZE(""), // diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java new file mode 100644 index 0000000000..613ae3abac --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -0,0 +1,307 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.debug.internal; + +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.MouseOutEvent; +import com.google.gwt.event.dom.client.MouseOutHandler; +import com.google.gwt.event.dom.client.MouseOverEvent; +import com.google.gwt.event.dom.client.MouseOverHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Event.NativePreviewEvent; +import com.google.gwt.user.client.Event.NativePreviewHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConfiguration; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ComponentLocator; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.Util; +import com.vaadin.client.ValueMap; + +/** + * Provides functionality for picking selectors for Vaadin TestBench. + * + * @since 7.1.4 + * @author Vaadin Ltd + */ +public class TestBenchSection implements Section { + + /** + * Selector widget showing a selector in a program-usable form. + */ + private static class SelectorWidget extends HTML { + private static int selectorIndex = 1; + final private String path; + + public SelectorWidget(final String path) { + this.path = path; + String html = "
" + + Util.escapeHTML("WebElement element" + (selectorIndex++) + + " = getDriver().findElement(By.vaadin(\"" + path + + "\"));") + "
"; + setHTML(html); + + addMouseOverHandler(new MouseOverHandler() { + @Override + public void onMouseOver(MouseOverEvent event) { + for (ApplicationConnection a : ApplicationConfiguration + .getRunningApplications()) { + Element element = new ComponentLocator(a) + .getElementByPath(SelectorWidget.this.path); + ComponentConnector connector = Util + .getConnectorForElement(a, a.getUIConnector() + .getWidget(), element); + if (connector == null) { + connector = Util.getConnectorForElement(a, + RootPanel.get(), element); + } + if (connector != null) { + Highlight.showOnly(connector); + break; + } + } + } + }); + addMouseOutHandler(new MouseOutHandler() { + @Override + public void onMouseOut(MouseOutEvent event) { + Highlight.hideAll(); + } + }); + } + } + + private final DebugButton tabButton = new DebugButton(Icon.SELECTOR, + "Pick Vaadin TestBench selectors"); + + private final FlowPanel content = new FlowPanel(); + + private final HierarchyPanel hierarchyPanel = new HierarchyPanel(); + private final FlowPanel selectorPanel = new FlowPanel(); + + private final FlowPanel controls = new FlowPanel(); + + private final Button find = new DebugButton(Icon.HIGHLIGHT, + "Select a component on the page to inspect it"); + private final Button refreshHierarchy = new DebugButton(Icon.HIERARCHY, + "Refresh the connector hierarchy tree"); + + private HandlerRegistration highlightModeRegistration = null; + + public TestBenchSection() { + controls.add(refreshHierarchy); + refreshHierarchy.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); + refreshHierarchy.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + hierarchyPanel.update(); + } + }); + + controls.add(find); + find.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); + find.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + toggleFind(); + } + }); + + hierarchyPanel.addListener(new SelectConnectorListener() { + @Override + public void select(ServerConnector connector, Element element) { + pickSelector(connector, element); + } + }); + + content.setStylePrimaryName(VDebugWindow.STYLENAME + "-testbench"); + content.add(hierarchyPanel); + content.add(selectorPanel); + } + + @Override + public DebugButton getTabButton() { + return tabButton; + } + + @Override + public Widget getControls() { + return controls; + } + + @Override + public Widget getContent() { + return content; + } + + @Override + public void show() { + + } + + @Override + public void hide() { + stopFind(); + } + + @Override + public void meta(ApplicationConnection ac, ValueMap meta) { + // NOP + } + + @Override + public void uidl(ApplicationConnection ac, ValueMap uidl) { + // NOP + } + + private boolean isFindMode() { + return (highlightModeRegistration != null); + } + + private void toggleFind() { + if (isFindMode()) { + stopFind(); + } else { + startFind(); + } + } + + private void startFind() { + Highlight.hideAll(); + if (!isFindMode()) { + highlightModeRegistration = Event + .addNativePreviewHandler(highlightModeHandler); + find.addStyleDependentName(VDebugWindow.STYLENAME_ACTIVE); + } + } + + private void stopFind() { + if (isFindMode()) { + highlightModeRegistration.removeHandler(); + highlightModeRegistration = null; + find.removeStyleDependentName(VDebugWindow.STYLENAME_ACTIVE); + } + } + + private void pickSelector(ServerConnector connector, Element element) { + String path = findTestBenchSelector(connector, element); + + if (null != path && !path.isEmpty()) { + selectorPanel.add(new SelectorWidget(path)); + } + } + + private String findTestBenchSelector(ServerConnector connector, + Element element) { + String path = null; + ApplicationConnection connection = connector.getConnection(); + if (connection != null) { + if (null == element) { + // try to find the root element of the connector + if (connector instanceof ComponentConnector) { + Widget widget = ((ComponentConnector) connector) + .getWidget(); + if (widget != null) { + element = widget.getElement(); + } + } + } + if (null != element) { + path = new ComponentLocator(connection) + .getPathForElement(element); + } + } + return path; + } + + private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { + + @Override + public void onPreviewNativeEvent(NativePreviewEvent event) { + + if (event.getTypeInt() == Event.ONKEYDOWN + && event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ESCAPE) { + stopFind(); + Highlight.hideAll(); + return; + } + if (event.getTypeInt() == Event.ONMOUSEMOVE + || event.getTypeInt() == Event.ONCLICK) { + Element eventTarget = Util.getElementFromPoint(event + .getNativeEvent().getClientX(), event.getNativeEvent() + .getClientY()); + if (VDebugWindow.get().getElement().isOrHasChild(eventTarget)) { + return; + } + + // make sure that not finding the highlight element only + Highlight.hideAll(); + eventTarget = Util.getElementFromPoint(event.getNativeEvent() + .getClientX(), event.getNativeEvent().getClientY()); + ComponentConnector connector = findConnector(eventTarget); + + if (event.getTypeInt() == Event.ONMOUSEMOVE) { + if (connector != null) { + Highlight.showOnly(connector); + event.cancel(); + event.consume(); + event.getNativeEvent().stopPropagation(); + return; + } + } else if (event.getTypeInt() == Event.ONCLICK) { + event.cancel(); + event.consume(); + event.getNativeEvent().stopPropagation(); + if (connector != null) { + Highlight.showOnly(connector); + pickSelector(connector, eventTarget); + return; + } + } + } + event.cancel(); + } + + }; + + private ComponentConnector findConnector(Element element) { + for (ApplicationConnection a : ApplicationConfiguration + .getRunningApplications()) { + ComponentConnector connector = Util.getConnectorForElement(a, a + .getUIConnector().getWidget(), element); + if (connector == null) { + connector = Util.getConnectorForElement(a, RootPanel.get(), + element); + } + if (connector != null) { + return connector; + } + } + return null; + } + +} -- cgit v1.2.3 From 486d9d3d57822edb1add2872fa9037912e692221 Mon Sep 17 00:00:00 2001 From: Marko Gronroos Date: Wed, 4 Sep 2013 17:57:31 +0300 Subject: Added a target to publish to local Maven repository. Change-Id: Ifa1f6b12c1ce9f6d65f707673d3a20e31857064f --- publish.xml | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/publish.xml b/publish.xml index 008451a2f8..c2b8369b15 100644 --- a/publish.xml +++ b/publish.xml @@ -13,8 +13,6 @@ - - @@ -25,6 +23,9 @@ + + + Installing ${src} to ${target} @@ -39,7 +40,7 @@ - + @@ -70,4 +71,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 6ab9e2d060d865f9ecd918209b0620a95a63f6a6 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Tue, 3 Sep 2013 09:20:49 +0300 Subject: Allow different locator strategies #12485 Refactored the ComponentLocator class to allow for implementing different locator strategies. Change-Id: I93f3decbce4d4361cc605bcf0ce4379a187c482c --- .../com/vaadin/client/ApplicationConnection.java | 57 +- client/src/com/vaadin/client/ComponentLocator.java | 700 +-------------------- .../client/componentlocator/ComponentLocator.java | 131 ++++ .../componentlocator/LegacyLocatorStrategy.java | 637 +++++++++++++++++++ .../client/componentlocator/LocatorStrategy.java | 34 + .../client/debug/internal/TestBenchSection.java | 2 +- client/src/com/vaadin/client/ui/SubPartAware.java | 4 +- .../componentlocator/TestDetachedNotPresent.html | 62 ++ .../componentlocator/TestDetachedNotPresent.html | 62 -- 9 files changed, 903 insertions(+), 786 deletions(-) create mode 100644 client/src/com/vaadin/client/componentlocator/ComponentLocator.java create mode 100644 client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java create mode 100644 client/src/com/vaadin/client/componentlocator/LocatorStrategy.java create mode 100644 uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html delete mode 100644 uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 0d9c859ee8..3200b3ab38 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -72,6 +72,7 @@ import com.vaadin.client.communication.JsonEncoder; import com.vaadin.client.communication.PushConnection; import com.vaadin.client.communication.RpcManager; import com.vaadin.client.communication.StateChangeEvent; +import com.vaadin.client.componentlocator.ComponentLocator; import com.vaadin.client.extensions.AbstractExtensionConnector; import com.vaadin.client.metadata.ConnectorBundleLoader; import com.vaadin.client.metadata.Method; @@ -496,38 +497,38 @@ public class ApplicationConnection { private native void initializeTestbenchHooks( ComponentLocator componentLocator, String TTAppId) /*-{ - var ap = this; - var client = {}; - client.isActive = $entry(function() { - return ap.@com.vaadin.client.ApplicationConnection::hasActiveRequest()() - || ap.@com.vaadin.client.ApplicationConnection::isExecutingDeferredCommands()(); - }); - var vi = ap.@com.vaadin.client.ApplicationConnection::getVersionInfo()(); - if (vi) { - client.getVersionInfo = function() { - return vi; - } - } + var ap = this; + var client = {}; + client.isActive = $entry(function() { + return ap.@com.vaadin.client.ApplicationConnection::hasActiveRequest()() + || ap.@com.vaadin.client.ApplicationConnection::isExecutingDeferredCommands()(); + }); + var vi = ap.@com.vaadin.client.ApplicationConnection::getVersionInfo()(); + if (vi) { + client.getVersionInfo = function() { + return vi; + } + } - client.getProfilingData = $entry(function() { - var pd = [ - ap.@com.vaadin.client.ApplicationConnection::lastProcessingTime, + client.getProfilingData = $entry(function() { + var pd = [ + ap.@com.vaadin.client.ApplicationConnection::lastProcessingTime, ap.@com.vaadin.client.ApplicationConnection::totalProcessingTime - ]; - pd = pd.concat(ap.@com.vaadin.client.ApplicationConnection::serverTimingInfo); - pd[pd.length] = ap.@com.vaadin.client.ApplicationConnection::bootstrapTime; - return pd; - }); + ]; + pd = pd.concat(ap.@com.vaadin.client.ApplicationConnection::serverTimingInfo); + pd[pd.length] = ap.@com.vaadin.client.ApplicationConnection::bootstrapTime; + return pd; + }); - client.getElementByPath = $entry(function(id) { - return componentLocator.@com.vaadin.client.ComponentLocator::getElementByPath(Ljava/lang/String;)(id); - }); - client.getPathForElement = $entry(function(element) { - return componentLocator.@com.vaadin.client.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element); - }); - client.initializing = false; + client.getElementByPath = $entry(function(id) { + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPath(Ljava/lang/String;)(id); + }); + client.getPathForElement = $entry(function(element) { + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element); + }); + client.initializing = false; - $wnd.vaadin.clients[TTAppId] = client; + $wnd.vaadin.clients[TTAppId] = client; }-*/; private static native final int calculateBootstrapTime() diff --git a/client/src/com/vaadin/client/ComponentLocator.java b/client/src/com/vaadin/client/ComponentLocator.java index af934470c2..ef7ccc3b65 100644 --- a/client/src/com/vaadin/client/ComponentLocator.java +++ b/client/src/com/vaadin/client/ComponentLocator.java @@ -15,706 +15,20 @@ */ package com.vaadin.client; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.HasWidgets; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ui.SubPartAware; -import com.vaadin.client.ui.VCssLayout; -import com.vaadin.client.ui.VGridLayout; -import com.vaadin.client.ui.VOverlay; -import com.vaadin.client.ui.VTabsheetPanel; -import com.vaadin.client.ui.VUI; -import com.vaadin.client.ui.VWindow; -import com.vaadin.client.ui.orderedlayout.Slot; -import com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout; -import com.vaadin.client.ui.window.WindowConnector; -import com.vaadin.shared.AbstractComponentState; -import com.vaadin.shared.Connector; -import com.vaadin.shared.communication.SharedState; - /** * ComponentLocator provides methods for generating a String locator for a given * DOM element and for locating a DOM element using a String locator. + * + * @since 5.4 + * @deprecated Moved to com.vaadin.client.componentlocator.ComponentLocator */ -public class ComponentLocator { - - /** - * Separator used in the String locator between a parent and a child widget. - */ - private static final String PARENTCHILD_SEPARATOR = "/"; - - /** - * Separator used in the String locator between the part identifying the - * containing widget and the part identifying the target element within the - * widget. - */ - private static final String SUBPART_SEPARATOR = "#"; - - /** - * String that identifies the root panel when appearing first in the String - * locator. - */ - private static final String ROOT_ID = "Root"; - - /** - * Reference to ApplicationConnection instance. - */ - private ApplicationConnection client; - +public class ComponentLocator extends com.vaadin.client.componentlocator.ComponentLocator { /** * Construct a ComponentLocator for the given ApplicationConnection. - * - * @param client - * ApplicationConnection instance for the application. + * + * @param client ApplicationConnection instance for the application. */ public ComponentLocator(ApplicationConnection client) { - this.client = client; - } - - /** - * Generates a String locator which uniquely identifies the target element. - * The {@link #getElementByPath(String)} method can be used for the inverse - * operation, i.e. locating an element based on the return value from this - * method. - *

- * Note that getElementByPath(getPathForElement(element)) == element is not - * always true as {@link #getPathForElement(Element)} can return a path to - * another element if the widget determines an action on the other element - * will give the same result as the action on the target element. - *

- * - * @since 5.4 - * @param targetElement - * The element to generate a path for. - * @return A String locator that identifies the target element or null if a - * String locator could not be created. - */ - public String getPathForElement(Element targetElement) { - String pid = null; - - targetElement = getElement(targetElement); - - Element e = targetElement; - - while (true) { - pid = ConnectorMap.get(client).getConnectorId(e); - if (pid != null) { - break; - } - - e = DOM.getParent(e); - if (e == null) { - break; - } - } - - Widget w = null; - if (pid != null) { - // If we found a Paintable then we use that as reference. We should - // find the Paintable for all but very special cases (like - // overlays). - w = ((ComponentConnector) ConnectorMap.get(client) - .getConnector(pid)).getWidget(); - - /* - * Still if the Paintable contains a widget that implements - * SubPartAware, we want to use that as a reference - */ - Widget targetParent = findParentWidget(targetElement, w); - while (targetParent != w && targetParent != null) { - if (targetParent instanceof SubPartAware) { - /* - * The targetParent widget is a child of the Paintable and - * the first parent (of the targetElement) that implements - * SubPartAware - */ - w = targetParent; - break; - } - targetParent = targetParent.getParent(); - } - } - if (w == null) { - // Check if the element is part of a widget that is attached - // directly to the root panel - RootPanel rootPanel = RootPanel.get(); - int rootWidgetCount = rootPanel.getWidgetCount(); - for (int i = 0; i < rootWidgetCount; i++) { - Widget rootWidget = rootPanel.getWidget(i); - if (rootWidget.getElement().isOrHasChild(targetElement)) { - // The target element is contained by this root widget - w = findParentWidget(targetElement, rootWidget); - break; - } - } - if (w != null) { - // We found a widget but we should still see if we find a - // SubPartAware implementor (we cannot find the Paintable as - // there is no link from VOverlay to its paintable/owner). - Widget subPartAwareWidget = findSubPartAwareParentWidget(w); - if (subPartAwareWidget != null) { - w = subPartAwareWidget; - } - } - } - - if (w == null) { - // Containing widget not found - return null; - } - - // Determine the path for the target widget - String path = getPathForWidget(w); - if (path == null) { - /* - * No path could be determined for the target widget. Cannot create - * a locator string. - */ - return null; - } - - // The parent check is a work around for Firefox 15 which fails to - // compare elements properly (#9534) - if (w.getElement() == targetElement) { - /* - * We are done if the target element is the root of the target - * widget. - */ - return path; - } else if (w instanceof SubPartAware) { - /* - * If the widget can provide an identifier for the targetElement we - * let it do that - */ - String elementLocator = ((SubPartAware) w) - .getSubPartName(targetElement); - if (elementLocator != null) { - return path + SUBPART_SEPARATOR + elementLocator; - } - } - /* - * If everything else fails we use the DOM path to identify the target - * element - */ - String domPath = getDOMPathForElement(targetElement, w.getElement()); - if (domPath == null) { - return path; - } else { - return path + domPath; - } - } - - /** - * Returns the element passed to the method. Or in case of Firefox 15, - * returns the real element that is in the DOM instead of the element passed - * to the method (which is the same element but not ==). - * - * @param targetElement - * the element to return - * @return the element passed to the method - */ - private Element getElement(Element targetElement) { - if (targetElement == null) { - return null; - } - - if (!BrowserInfo.get().isFirefox()) { - return targetElement; - } - - if (BrowserInfo.get().getBrowserMajorVersion() != 15) { - return targetElement; - } - - // Firefox 15, you make me sad - if (targetElement.getNextSibling() != null) { - return (Element) targetElement.getNextSibling() - .getPreviousSibling(); - } - if (targetElement.getPreviousSibling() != null) { - return (Element) targetElement.getPreviousSibling() - .getNextSibling(); - } - // No siblings so this is the only child - return (Element) targetElement.getParentNode().getChild(0); - } - - /** - * Finds the first widget in the hierarchy (moving upwards) that implements - * SubPartAware. Returns the SubPartAware implementor or null if none is - * found. - * - * @param w - * The widget to start from. This is returned if it implements - * SubPartAware. - * @return The first widget (upwards in hierarchy) that implements - * SubPartAware or null - */ - private Widget findSubPartAwareParentWidget(Widget w) { - - while (w != null) { - if (w instanceof SubPartAware) { - return w; - } - w = w.getParent(); - } - return null; - } - - /** - * Returns the first widget found when going from {@code targetElement} - * upwards in the DOM hierarchy, assuming that {@code ancestorWidget} is a - * parent of {@code targetElement}. - * - * @param targetElement - * @param ancestorWidget - * @return The widget whose root element is a parent of - * {@code targetElement}. - */ - private Widget findParentWidget(Element targetElement, Widget ancestorWidget) { - /* - * As we cannot resolve Widgets from the element we start from the - * widget and move downwards to the correct child widget, as long as we - * find one. - */ - if (ancestorWidget instanceof HasWidgets) { - for (Widget w : ((HasWidgets) ancestorWidget)) { - if (w.getElement().isOrHasChild(targetElement)) { - return findParentWidget(targetElement, w); - } - } - } - - // No children found, this is it - return ancestorWidget; - } - - /** - * Locates an element based on a DOM path and a base element. - * - * @param baseElement - * The base element which the path is relative to - * @param path - * String locator (consisting of domChild[x] parts) that - * identifies the element - * @return The element identified by path, relative to baseElement or null - * if the element could not be found. - */ - private Element getElementByDOMPath(Element baseElement, String path) { - String parts[] = path.split(PARENTCHILD_SEPARATOR); - Element element = baseElement; - - for (String part : parts) { - if (part.startsWith("domChild[")) { - String childIndexString = part.substring("domChild[".length(), - part.length() - 1); - - if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { - if (element.hasChildNodes()) { - Element e = element.getFirstChildElement().cast(); - String cn = e.getClassName(); - if (cn != null - && (cn.equals("v-expand") || cn - .contains("v-has-caption"))) { - element = e; - } - } - } - - try { - int childIndex = Integer.parseInt(childIndexString); - element = DOM.getChild(element, childIndex); - } catch (Exception e) { - return null; - } - - if (element == null) { - return null; - } - - } - } - - return element; + super(client); } - - /** - * Generates a String locator using domChild[x] parts for the element - * relative to the baseElement. - * - * @param element - * The target element - * @param baseElement - * The starting point for the locator. The generated path is - * relative to this element. - * @return A String locator that can be used to locate the target element - * using {@link #getElementByDOMPath(Element, String)} or null if - * the locator String cannot be created. - */ - private String getDOMPathForElement(Element element, Element baseElement) { - Element e = element; - String path = ""; - while (true) { - int childIndex = -1; - Element siblingIterator = e; - while (siblingIterator != null) { - childIndex++; - siblingIterator = siblingIterator.getPreviousSiblingElement() - .cast(); - } - - path = PARENTCHILD_SEPARATOR + "domChild[" + childIndex + "]" - + path; - - JavaScriptObject parent = e.getParentElement(); - if (parent == null) { - return null; - } - // The parent check is a work around for Firefox 15 which fails to - // compare elements properly (#9534) - if (parent == baseElement) { - break; - } - - e = parent.cast(); - } - - return path; - } - - /** - * Locates an element using a String locator (path) which identifies a DOM - * element. The {@link #getPathForElement(Element)} method can be used for - * the inverse operation, i.e. generating a string expression for a DOM - * element. - * - * @since 5.4 - * @param path - * The String locater which identifies the target element. - * @return The DOM element identified by {@code path} or null if the element - * could not be located. - */ - public Element getElementByPath(String path) { - /* - * Path is of type "targetWidgetPath#componentPart" or - * "targetWidgetPath". - */ - String parts[] = path.split(SUBPART_SEPARATOR, 2); - String widgetPath = parts[0]; - Widget w = getWidgetFromPath(widgetPath); - if (w == null || !Util.isAttachedAndDisplayed(w)) { - return null; - } - - if (parts.length == 1) { - int pos = widgetPath.indexOf("domChild"); - if (pos == -1) { - return w.getElement(); - } - - // Contains dom reference to a sub element of the widget - String subPath = widgetPath.substring(pos); - return getElementByDOMPath(w.getElement(), subPath); - } else if (parts.length == 2) { - if (w instanceof SubPartAware) { - return ((SubPartAware) w).getSubPartElement(parts[1]); - } - } - - return null; - } - - /** - * Creates a locator String for the given widget. The path can be used to - * locate the widget using {@link #getWidgetFromPath(String)}. - * - * Returns null if no path can be determined for the widget or if the widget - * is null. - * - * @param w - * The target widget - * @return A String locator for the widget - */ - private String getPathForWidget(Widget w) { - if (w == null) { - return null; - } - String elementId = w.getElement().getId(); - if (elementId != null && !elementId.isEmpty() - && !elementId.startsWith("gwt-uid-")) { - // Use PID_S+id if the user has set an id but do not use it for auto - // generated id:s as these might not be consistent - return "PID_S" + elementId; - } else if (w instanceof VUI) { - return ""; - } else if (w instanceof VWindow) { - Connector windowConnector = ConnectorMap.get(client) - .getConnector(w); - List subWindowList = client.getUIConnector() - .getSubWindows(); - int indexOfSubWindow = subWindowList.indexOf(windowConnector); - return PARENTCHILD_SEPARATOR + "VWindow[" + indexOfSubWindow + "]"; - } else if (w instanceof RootPanel) { - return ROOT_ID; - } - - Widget parent = w.getParent(); - - String basePath = getPathForWidget(parent); - if (basePath == null) { - return null; - } - String simpleName = Util.getSimpleName(w); - - /* - * Check if the parent implements Iterable. At least VPopupView does not - * implement HasWdgets so we cannot check for that. - */ - if (!(parent instanceof Iterable)) { - // Parent does not implement Iterable so we cannot find out which - // child this is - return null; - } - - Iterator i = ((Iterable) parent).iterator(); - int pos = 0; - while (i.hasNext()) { - Object child = i.next(); - if (child == w) { - return basePath + PARENTCHILD_SEPARATOR + simpleName + "[" - + pos + "]"; - } - String simpleName2 = Util.getSimpleName(child); - if (simpleName.equals(simpleName2)) { - pos++; - } - } - - return null; - } - - /** - * Locates the widget based on a String locator. - * - * @param path - * The String locator that identifies the widget. - * @return The Widget identified by the String locator or null if the widget - * could not be identified. - */ - private Widget getWidgetFromPath(String path) { - Widget w = null; - String parts[] = path.split(PARENTCHILD_SEPARATOR); - - for (int i = 0; i < parts.length; i++) { - String part = parts[i]; - - if (part.equals(ROOT_ID)) { - w = RootPanel.get(); - } else if (part.equals("")) { - w = client.getUIConnector().getWidget(); - } else if (w == null) { - String id = part; - // Must be old static pid (PID_S*) - ServerConnector connector = ConnectorMap.get(client) - .getConnector(id); - if (connector == null) { - // Lookup by component id - // TODO Optimize this - connector = findConnectorById(client.getUIConnector(), - id.substring(5)); - } - - if (connector instanceof ComponentConnector) { - w = ((ComponentConnector) connector).getWidget(); - } else { - // Not found - return null; - } - } else if (part.startsWith("domChild[")) { - // The target widget has been found and the rest identifies the - // element - break; - } else if (w instanceof Iterable) { - // W identifies a widget that contains other widgets, as it - // should. Try to locate the child - Iterable parent = (Iterable) w; - - // Part is of type "VVerticalLayout[0]", split this into - // VVerticalLayout and 0 - String[] split = part.split("\\[", 2); - String widgetClassName = split[0]; - String indexString = split[1].substring(0, - split[1].length() - 1); - int widgetPosition = Integer.parseInt(indexString); - - // AbsolutePanel in GridLayout has been removed -> skip it - if (w instanceof VGridLayout - && "AbsolutePanel".equals(widgetClassName)) { - continue; - } - - // FlowPane in CSSLayout has been removed -> skip it - if (w instanceof VCssLayout - && "VCssLayout$FlowPane".equals(widgetClassName)) { - continue; - } - - // ChildComponentContainer and VOrderedLayout$Slot have been - // replaced with Slot - if (w instanceof VAbstractOrderedLayout - && ("ChildComponentContainer".equals(widgetClassName) || "VOrderedLayout$Slot" - .equals(widgetClassName))) { - widgetClassName = "Slot"; - } - - if (w instanceof VTabsheetPanel && widgetPosition != 0) { - // TabSheetPanel now only contains 1 connector => the index - // is always 0 which indicates the widget in the active tab - widgetPosition = 0; - } - if (w instanceof VOverlay - && "VCalendarPanel".equals(widgetClassName)) { - // Vaadin 7.1 adds a wrapper for datefield popups - parent = (Iterable) ((Iterable) parent).iterator() - .next(); - } - /* - * The new grid and ordered layotus do not contain - * ChildComponentContainer widgets. This is instead simulated by - * constructing a path step that would find the desired widget - * from the layout and injecting it as the next search step - * (which would originally have found the widget inside the - * ChildComponentContainer) - */ - if ((w instanceof VGridLayout) - && "ChildComponentContainer".equals(widgetClassName) - && i + 1 < parts.length) { - - HasWidgets layout = (HasWidgets) w; - - String nextPart = parts[i + 1]; - String[] nextSplit = nextPart.split("\\[", 2); - String nextWidgetClassName = nextSplit[0]; - - // Find the n:th child and count the number of children with - // the same type before it - int nextIndex = 0; - for (Widget child : layout) { - boolean matchingType = nextWidgetClassName.equals(Util - .getSimpleName(child)); - if (matchingType && widgetPosition == 0) { - // This is the n:th child that we looked for - break; - } else if (widgetPosition < 0) { - // Error if we're past the desired position without - // a match - return null; - } else if (matchingType) { - // If this was another child of the expected type, - // increase the count for the next step - nextIndex++; - } - - // Don't count captions - if (!(child instanceof VCaption)) { - widgetPosition--; - } - } - - // Advance to the next step, this time checking for the - // actual child widget - parts[i + 1] = nextWidgetClassName + '[' + nextIndex + ']'; - continue; - } - - // Locate the child - Iterator iterator; - - /* - * VWindow and VContextMenu workarounds for backwards - * compatibility - */ - if (widgetClassName.equals("VWindow")) { - List windows = client.getUIConnector() - .getSubWindows(); - List windowWidgets = new ArrayList( - windows.size()); - for (WindowConnector wc : windows) { - windowWidgets.add(wc.getWidget()); - } - iterator = windowWidgets.iterator(); - } else if (widgetClassName.equals("VContextMenu")) { - return client.getContextMenu(); - } else { - iterator = (Iterator) parent.iterator(); - } - - boolean ok = false; - - // Find the widgetPosition:th child of type "widgetClassName" - while (iterator.hasNext()) { - - Widget child = iterator.next(); - String simpleName2 = Util.getSimpleName(child); - - if (!widgetClassName.equals(simpleName2) - && child instanceof Slot) { - /* - * Support legacy tests without any selector for the - * Slot widget (i.e. /VVerticalLayout[0]/VButton[0]) by - * directly checking the stuff inside the slot - */ - child = ((Slot) child).getWidget(); - simpleName2 = Util.getSimpleName(child); - } - - if (widgetClassName.equals(simpleName2)) { - if (widgetPosition == 0) { - w = child; - ok = true; - break; - } - widgetPosition--; - - } - } - - if (!ok) { - // Did not find the child - return null; - } - } else { - // W identifies something that is not a "HasWidgets". This - // should not happen as all widget containers should implement - // HasWidgets. - return null; - } - } - - return w; - } - - private ServerConnector findConnectorById(ServerConnector root, String id) { - SharedState state = root.getState(); - if (state instanceof AbstractComponentState - && id.equals(((AbstractComponentState) state).id)) { - return root; - } - for (ServerConnector child : root.getChildren()) { - ServerConnector found = findConnectorById(child, id); - if (found != null) { - return found; - } - } - - return null; - } - } diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java new file mode 100644 index 0000000000..a7afeaad9c --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -0,0 +1,131 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +import com.google.gwt.user.client.Element; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.BrowserInfo; + +/** + * ComponentLocator provides methods for generating a String locator for a given + * DOM element and for locating a DOM element using a String locator. + *

+ * The main use for this class is locating components for automated testing purposes. + * + * @since 7.2, moved from {@link com.vaadin.client.ComponentLocator} + */ +public class ComponentLocator { + + private final LegacyLocatorStrategy legacyLocatorStrategy = new LegacyLocatorStrategy( + this); + + /** + * Reference to ApplicationConnection instance. + */ + + private ApplicationConnection client; + + /** + * Construct a ComponentLocator for the given ApplicationConnection. + * + * @param client + * ApplicationConnection instance for the application. + */ + public ComponentLocator(ApplicationConnection client) { + this.client = client; + } + + /** + * Generates a String locator which uniquely identifies the target element. + * The {@link #getElementByPath(String)} method can be used for the inverse + * operation, i.e. locating an element based on the return value from this + * method. + *

+ * Note that getElementByPath(getPathForElement(element)) == element is not + * always true as #getPathForElement(Element) can return a path to another + * element if the widget determines an action on the other element will give + * the same result as the action on the target element. + *

+ * + * @since 5.4 + * @param targetElement + * The element to generate a path for. + * @return A String locator that identifies the target element or null if a + * String locator could not be created. + */ + public String getPathForElement(Element targetElement) { + return legacyLocatorStrategy + .getPathForElement(getElement(targetElement)); + } + + /** + * Returns the element passed to the method. Or in case of Firefox 15, + * returns the real element that is in the DOM instead of the element passed + * to the method (which is the same element but not ==). + * + * @param targetElement + * the element to return + * @return the element passed to the method + */ + private Element getElement(Element targetElement) { + if (targetElement == null) { + return null; + } + + if (!BrowserInfo.get().isFirefox()) { + return targetElement; + } + + if (BrowserInfo.get().getBrowserMajorVersion() != 15) { + return targetElement; + } + + // Firefox 15, you make me sad + if (targetElement.getNextSibling() != null) { + return (Element) targetElement.getNextSibling() + .getPreviousSibling(); + } + if (targetElement.getPreviousSibling() != null) { + return (Element) targetElement.getPreviousSibling() + .getNextSibling(); + } + // No siblings so this is the only child + return (Element) targetElement.getParentNode().getChild(0); + } + + /** + * Locates an element using a String locator (path) which identifies a DOM + * element. The {@link #getPathForElement(Element)} method can be used for + * the inverse operation, i.e. generating a string expression for a DOM + * element. + * + * @since 5.4 + * @param path + * The String locator which identifies the target element. + * @return The DOM element identified by {@code path} or null if the element + * could not be located. + */ + public Element getElementByPath(String path) { + return legacyLocatorStrategy.getElementByPath(path); + } + + /** + * @return the application connection + */ + ApplicationConnection getClient() { + return client; + } +} diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java new file mode 100644 index 0000000000..dd67ddbc43 --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -0,0 +1,637 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.HasWidgets; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ConnectorMap; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.Util; +import com.vaadin.client.VCaption; +import com.vaadin.client.ui.SubPartAware; +import com.vaadin.client.ui.VCssLayout; +import com.vaadin.client.ui.VGridLayout; +import com.vaadin.client.ui.VOverlay; +import com.vaadin.client.ui.VTabsheetPanel; +import com.vaadin.client.ui.VUI; +import com.vaadin.client.ui.VWindow; +import com.vaadin.client.ui.orderedlayout.Slot; +import com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout; +import com.vaadin.client.ui.window.WindowConnector; +import com.vaadin.shared.AbstractComponentState; +import com.vaadin.shared.Connector; +import com.vaadin.shared.communication.SharedState; + +/** + * The LegacyLocatorStrategy class handles the legacy locator syntax that was + * introduced in version 5.4 of the framework. The legacy locator strategy is + * always used if no other strategy claims responsibility for a locator string. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class LegacyLocatorStrategy implements LocatorStrategy { + private final ComponentLocator componentLocator; + /** + * Separator used in the String locator between a parent and a child widget. + */ + static final String PARENTCHILD_SEPARATOR = "/"; + /** + * Separator used in the String locator between the part identifying the + * containing widget and the part identifying the target element within the + * widget. + */ + static final String SUBPART_SEPARATOR = "#"; + /** + * String that identifies the root panel when appearing first in the String + * locator. + */ + static final String ROOT_ID = "Root"; + + public LegacyLocatorStrategy(ComponentLocator componentLocator) { + this.componentLocator = componentLocator; + } + + @Override + public String getPathForElement(Element targetElement) { + ComponentConnector connector = Util.findPaintable( + componentLocator.getClient(), targetElement); + + Widget w = null; + if (connector != null) { + // If we found a Paintable then we use that as reference. We should + // find the Paintable for all but very special cases (like + // overlays). + w = connector.getWidget(); + + /* + * Still if the Paintable contains a widget that implements + * SubPartAware, we want to use that as a reference + */ + Widget targetParent = findParentWidget(targetElement, w); + while (targetParent != w && targetParent != null) { + if (targetParent instanceof SubPartAware) { + /* + * The targetParent widget is a child of the Paintable and + * the first parent (of the targetElement) that implements + * SubPartAware + */ + w = targetParent; + break; + } + targetParent = targetParent.getParent(); + } + } + if (w == null) { + // Check if the element is part of a widget that is attached + // directly to the root panel + RootPanel rootPanel = RootPanel.get(); + int rootWidgetCount = rootPanel.getWidgetCount(); + for (int i = 0; i < rootWidgetCount; i++) { + Widget rootWidget = rootPanel.getWidget(i); + if (rootWidget.getElement().isOrHasChild(targetElement)) { + // The target element is contained by this root widget + w = findParentWidget(targetElement, rootWidget); + break; + } + } + if (w != null) { + // We found a widget but we should still see if we find a + // SubPartAware implementor (we cannot find the Paintable as + // there is no link from VOverlay to its paintable/owner). + Widget subPartAwareWidget = findSubPartAwareParentWidget(w); + if (subPartAwareWidget != null) { + w = subPartAwareWidget; + } + } + } + + if (w == null) { + // Containing widget not found + return null; + } + + // Determine the path for the target widget + String path = getPathForWidget(w); + if (path == null) { + /* + * No path could be determined for the target widget. Cannot create + * a locator string. + */ + return null; + } + + // The parent check is a work around for Firefox 15 which fails to + // compare elements properly (#9534) + if (w.getElement() == targetElement) { + /* + * We are done if the target element is the root of the target + * widget. + */ + return path; + } else if (w instanceof SubPartAware) { + /* + * If the widget can provide an identifier for the targetElement we + * let it do that + */ + String elementLocator = ((SubPartAware) w) + .getSubPartName(targetElement); + if (elementLocator != null) { + return path + LegacyLocatorStrategy.SUBPART_SEPARATOR + + elementLocator; + } + } + /* + * If everything else fails we use the DOM path to identify the target + * element + */ + String domPath = getDOMPathForElement(targetElement, w.getElement()); + if (domPath == null) { + return path; + } else { + return path + domPath; + } + } + + @Override + public Element getElementByPath(String path) { + /* + * Path is of type "targetWidgetPath#componentPart" or + * "targetWidgetPath". + */ + String parts[] = path.split(LegacyLocatorStrategy.SUBPART_SEPARATOR, 2); + String widgetPath = parts[0]; + Widget w = getWidgetFromPath(widgetPath); + if (w == null || !Util.isAttachedAndDisplayed(w)) { + return null; + } + + if (parts.length == 1) { + int pos = widgetPath.indexOf("domChild"); + if (pos == -1) { + return w.getElement(); + } + + // Contains dom reference to a sub element of the widget + String subPath = widgetPath.substring(pos); + return getElementByDOMPath(w.getElement(), subPath); + } else if (parts.length == 2) { + if (w instanceof SubPartAware) { + return ((SubPartAware) w).getSubPartElement(parts[1]); + } + } + return null; + } + + /** + * Finds the first widget in the hierarchy (moving upwards) that implements + * SubPartAware. Returns the SubPartAware implementor or null if none is + * found. + * + * @param w + * The widget to start from. This is returned if it implements + * SubPartAware. + * @return The first widget (upwards in hierarchy) that implements + * SubPartAware or null + */ + Widget findSubPartAwareParentWidget(Widget w) { + + while (w != null) { + if (w instanceof SubPartAware) { + return w; + } + w = w.getParent(); + } + return null; + } + + /** + * Returns the first widget found when going from {@code targetElement} + * upwards in the DOM hierarchy, assuming that {@code ancestorWidget} is a + * parent of {@code targetElement}. + * + * @param targetElement + * @param ancestorWidget + * @return The widget whose root element is a parent of + * {@code targetElement}. + */ + private Widget findParentWidget(Element targetElement, Widget ancestorWidget) { + /* + * As we cannot resolve Widgets from the element we start from the + * widget and move downwards to the correct child widget, as long as we + * find one. + */ + if (ancestorWidget instanceof HasWidgets) { + for (Widget w : ((HasWidgets) ancestorWidget)) { + if (w.getElement().isOrHasChild(targetElement)) { + return findParentWidget(targetElement, w); + } + } + } + + // No children found, this is it + return ancestorWidget; + } + + /** + * Locates an element based on a DOM path and a base element. + * + * @param baseElement + * The base element which the path is relative to + * @param path + * String locator (consisting of domChild[x] parts) that + * identifies the element + * @return The element identified by path, relative to baseElement or null + * if the element could not be found. + */ + private Element getElementByDOMPath(Element baseElement, String path) { + String parts[] = path.split(PARENTCHILD_SEPARATOR); + Element element = baseElement; + + for (String part : parts) { + if (part.startsWith("domChild[")) { + String childIndexString = part.substring("domChild[".length(), + part.length() - 1); + + if (Util.findWidget(baseElement, null) instanceof VAbstractOrderedLayout) { + if (element.hasChildNodes()) { + Element e = element.getFirstChildElement().cast(); + String cn = e.getClassName(); + if (cn != null + && (cn.equals("v-expand") || cn + .contains("v-has-caption"))) { + element = e; + } + } + } + + try { + int childIndex = Integer.parseInt(childIndexString); + element = DOM.getChild(element, childIndex); + } catch (Exception e) { + return null; + } + + if (element == null) { + return null; + } + + } + } + + return element; + } + + /** + * Generates a String locator using domChild[x] parts for the element + * relative to the baseElement. + * + * @param element + * The target element + * @param baseElement + * The starting point for the locator. The generated path is + * relative to this element. + * @return A String locator that can be used to locate the target element + * using + * {@link #getElementByDOMPath(com.google.gwt.user.client.Element, String)} + * or null if the locator String cannot be created. + */ + private String getDOMPathForElement(Element element, Element baseElement) { + Element e = element; + String path = ""; + while (true) { + int childIndex = -1; + Element siblingIterator = e; + while (siblingIterator != null) { + childIndex++; + siblingIterator = siblingIterator.getPreviousSiblingElement() + .cast(); + } + + path = PARENTCHILD_SEPARATOR + "domChild[" + childIndex + "]" + + path; + + JavaScriptObject parent = e.getParentElement(); + if (parent == null) { + return null; + } + // The parent check is a work around for Firefox 15 which fails to + // compare elements properly (#9534) + if (parent == baseElement) { + break; + } + + e = parent.cast(); + } + + return path; + } + + /** + * Creates a locator String for the given widget. The path can be used to + * locate the widget using {@link #getWidgetFromPath(String)}. + *

+ * Returns null if no path can be determined for the widget or if the widget + * is null. + * + * @param w + * The target widget + * @return A String locator for the widget + */ + private String getPathForWidget(Widget w) { + if (w == null) { + return null; + } + String elementId = w.getElement().getId(); + if (elementId != null && !elementId.isEmpty() + && !elementId.startsWith("gwt-uid-")) { + // Use PID_S+id if the user has set an id but do not use it for auto + // generated id:s as these might not be consistent + return "PID_S" + elementId; + } else if (w instanceof VUI) { + return ""; + } else if (w instanceof VWindow) { + Connector windowConnector = ConnectorMap.get( + componentLocator.getClient()).getConnector(w); + List subWindowList = componentLocator.getClient() + .getUIConnector().getSubWindows(); + int indexOfSubWindow = subWindowList.indexOf(windowConnector); + return PARENTCHILD_SEPARATOR + "VWindow[" + indexOfSubWindow + "]"; + } else if (w instanceof RootPanel) { + return ROOT_ID; + } + + Widget parent = w.getParent(); + + String basePath = getPathForWidget(parent); + if (basePath == null) { + return null; + } + String simpleName = Util.getSimpleName(w); + + /* + * Check if the parent implements Iterable. At least VPopupView does not + * implement HasWdgets so we cannot check for that. + */ + if (!(parent instanceof Iterable)) { + // Parent does not implement Iterable so we cannot find out which + // child this is + return null; + } + + Iterator i = ((Iterable) parent).iterator(); + int pos = 0; + while (i.hasNext()) { + Object child = i.next(); + if (child == w) { + return basePath + PARENTCHILD_SEPARATOR + simpleName + "[" + + pos + "]"; + } + String simpleName2 = Util.getSimpleName(child); + if (simpleName.equals(simpleName2)) { + pos++; + } + } + + return null; + } + + /** + * Locates the widget based on a String locator. + * + * @param path + * The String locator that identifies the widget. + * @return The Widget identified by the String locator or null if the widget + * could not be identified. + */ + private Widget getWidgetFromPath(String path) { + Widget w = null; + String parts[] = path.split(PARENTCHILD_SEPARATOR); + + for (int i = 0; i < parts.length; i++) { + String part = parts[i]; + + if (part.equals(ROOT_ID)) { + w = RootPanel.get(); + } else if (part.equals("")) { + w = componentLocator.getClient().getUIConnector().getWidget(); + } else if (w == null) { + String id = part; + // Must be old static pid (PID_S*) + ServerConnector connector = ConnectorMap.get( + componentLocator.getClient()).getConnector(id); + if (connector == null) { + // Lookup by component id + // TODO Optimize this + connector = findConnectorById(componentLocator.getClient() + .getUIConnector(), id.substring(5)); + } + + if (connector instanceof ComponentConnector) { + w = ((ComponentConnector) connector).getWidget(); + } else { + // Not found + return null; + } + } else if (part.startsWith("domChild[")) { + // The target widget has been found and the rest identifies the + // element + break; + } else if (w instanceof Iterable) { + // W identifies a widget that contains other widgets, as it + // should. Try to locate the child + Iterable parent = (Iterable) w; + + // Part is of type "VVerticalLayout[0]", split this into + // VVerticalLayout and 0 + String[] split = part.split("\\[", 2); + String widgetClassName = split[0]; + String indexString = split[1].substring(0, + split[1].length() - 1); + int widgetPosition = Integer.parseInt(indexString); + + // AbsolutePanel in GridLayout has been removed -> skip it + if (w instanceof VGridLayout + && "AbsolutePanel".equals(widgetClassName)) { + continue; + } + + // FlowPane in CSSLayout has been removed -> skip it + if (w instanceof VCssLayout + && "VCssLayout$FlowPane".equals(widgetClassName)) { + continue; + } + + // ChildComponentContainer and VOrderedLayout$Slot have been + // replaced with Slot + if (w instanceof VAbstractOrderedLayout + && ("ChildComponentContainer".equals(widgetClassName) || "VOrderedLayout$Slot" + .equals(widgetClassName))) { + widgetClassName = "Slot"; + } + + if (w instanceof VTabsheetPanel && widgetPosition != 0) { + // TabSheetPanel now only contains 1 connector => the index + // is always 0 which indicates the widget in the active tab + widgetPosition = 0; + } + if (w instanceof VOverlay + && "VCalendarPanel".equals(widgetClassName)) { + // Vaadin 7.1 adds a wrapper for datefield popups + parent = (Iterable) ((Iterable) parent).iterator() + .next(); + } + /* + * The new grid and ordered layotus do not contain + * ChildComponentContainer widgets. This is instead simulated by + * constructing a path step that would find the desired widget + * from the layout and injecting it as the next search step + * (which would originally have found the widget inside the + * ChildComponentContainer) + */ + if ((w instanceof VGridLayout) + && "ChildComponentContainer".equals(widgetClassName) + && i + 1 < parts.length) { + + HasWidgets layout = (HasWidgets) w; + + String nextPart = parts[i + 1]; + String[] nextSplit = nextPart.split("\\[", 2); + String nextWidgetClassName = nextSplit[0]; + + // Find the n:th child and count the number of children with + // the same type before it + int nextIndex = 0; + for (Widget child : layout) { + boolean matchingType = nextWidgetClassName.equals(Util + .getSimpleName(child)); + if (matchingType && widgetPosition == 0) { + // This is the n:th child that we looked for + break; + } else if (widgetPosition < 0) { + // Error if we're past the desired position without + // a match + return null; + } else if (matchingType) { + // If this was another child of the expected type, + // increase the count for the next step + nextIndex++; + } + + // Don't count captions + if (!(child instanceof VCaption)) { + widgetPosition--; + } + } + + // Advance to the next step, this time checking for the + // actual child widget + parts[i + 1] = nextWidgetClassName + '[' + nextIndex + ']'; + continue; + } + + // Locate the child + Iterator iterator; + + /* + * VWindow and VContextMenu workarounds for backwards + * compatibility + */ + if (widgetClassName.equals("VWindow")) { + List windows = componentLocator + .getClient().getUIConnector().getSubWindows(); + List windowWidgets = new ArrayList( + windows.size()); + for (WindowConnector wc : windows) { + windowWidgets.add(wc.getWidget()); + } + iterator = windowWidgets.iterator(); + } else if (widgetClassName.equals("VContextMenu")) { + return componentLocator.getClient().getContextMenu(); + } else { + iterator = (Iterator) parent.iterator(); + } + + boolean ok = false; + + // Find the widgetPosition:th child of type "widgetClassName" + while (iterator.hasNext()) { + + Widget child = iterator.next(); + String simpleName2 = Util.getSimpleName(child); + + if (!widgetClassName.equals(simpleName2) + && child instanceof Slot) { + /* + * Support legacy tests without any selector for the + * Slot widget (i.e. /VVerticalLayout[0]/VButton[0]) by + * directly checking the stuff inside the slot + */ + child = ((Slot) child).getWidget(); + simpleName2 = Util.getSimpleName(child); + } + + if (widgetClassName.equals(simpleName2)) { + if (widgetPosition == 0) { + w = child; + ok = true; + break; + } + widgetPosition--; + + } + } + + if (!ok) { + // Did not find the child + return null; + } + } else { + // W identifies something that is not a "HasWidgets". This + // should not happen as all widget containers should implement + // HasWidgets. + return null; + } + } + + return w; + } + + private ServerConnector findConnectorById(ServerConnector root, String id) { + SharedState state = root.getState(); + if (state instanceof AbstractComponentState + && id.equals(((AbstractComponentState) state).id)) { + return root; + } + for (ServerConnector child : root.getChildren()) { + ServerConnector found = findConnectorById(child, id); + if (found != null) { + return found; + } + } + + return null; + } +} diff --git a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java new file mode 100644 index 0000000000..53cff10d4f --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +import com.google.gwt.user.client.Element; + +/** + * This interface should be implemented by all locator strategies. A locator + * strategy is responsible for generating and decoding a string that identifies + * an element in the DOM. A strategy can implement its own syntax for the + * locator string, which may be completely different from any other strategy's + * syntax. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public interface LocatorStrategy { + String getPathForElement(Element targetElement); + + Element getElementByPath(String path); +} diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java index 613ae3abac..a283b18912 100644 --- a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -35,10 +35,10 @@ import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ComponentLocator; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.ValueMap; +import com.vaadin.client.componentlocator.ComponentLocator; /** * Provides functionality for picking selectors for Vaadin TestBench. diff --git a/client/src/com/vaadin/client/ui/SubPartAware.java b/client/src/com/vaadin/client/ui/SubPartAware.java index a7d72fab01..36959e7b1f 100644 --- a/client/src/com/vaadin/client/ui/SubPartAware.java +++ b/client/src/com/vaadin/client/ui/SubPartAware.java @@ -17,7 +17,7 @@ package com.vaadin.client.ui; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ComponentLocator; +import com.vaadin.client.componentlocator.ComponentLocator; /** * Interface implemented by {@link Widget}s which can provide identifiers for at @@ -59,4 +59,4 @@ public interface SubPartAware { */ String getSubPartName(Element subElement); -} \ No newline at end of file +} diff --git a/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html new file mode 100644 index 0000000000..24e5e992ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/componentlocator/TestDetachedNotPresent.html @@ -0,0 +1,62 @@ + + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item040,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item829,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item2103,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item134,6
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]37,9
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
+ + \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html b/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html deleted file mode 100644 index 24e5e992ca..0000000000 --- a/uitest/src/com/vaadin/tests/gwtadapter/componentlocator/TestDetachedNotPresent.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.Tables?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item040,10
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item829,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item2103,3
mouseClickvaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item134,6
contextmenuvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]
assertElementPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
mouseClickvaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[2]/domChild[0]37,9
assertElementNotPresentvaadin=runcomvaadintestscomponentstableTables::Root/VContextMenu[0]#option015,8
- - \ No newline at end of file -- cgit v1.2.3 From 72db2044ea2844c5c7a49a704a507f32af5755ed Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Wed, 4 Sep 2013 15:27:38 +0300 Subject: Implemented the extensions to ComponentLocator needed for TB4 #12485 Change-Id: I8c7db91967003290bbff4e703235aa36d5e9e1f3 --- .../com/vaadin/client/ApplicationConnection.java | 3 + .../client/componentlocator/ComponentLocator.java | 45 ++- .../componentlocator/LegacyLocatorStrategy.java | 13 + .../client/componentlocator/LocatorStrategy.java | 56 ++++ .../VaadinFinderLocatorStrategy.java | 357 +++++++++++++++++++++ 5 files changed, 472 insertions(+), 2 deletions(-) create mode 100644 client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 3200b3ab38..e038f37689 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -523,6 +523,9 @@ public class ApplicationConnection { client.getElementByPath = $entry(function(id) { return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPath(Ljava/lang/String;)(id); }); + client.getElementByPathStartingAt = $entry(function(id, element) { + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/user/client/Element;)(id, element); + }); client.getPathForElement = $entry(function(element) { return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element); }); diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index a7afeaad9c..c1f117d992 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -15,6 +15,9 @@ */ package com.vaadin.client.componentlocator; +import java.util.Arrays; +import java.util.List; + import com.google.gwt.user.client.Element; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; @@ -23,12 +26,14 @@ import com.vaadin.client.BrowserInfo; * ComponentLocator provides methods for generating a String locator for a given * DOM element and for locating a DOM element using a String locator. *

- * The main use for this class is locating components for automated testing purposes. + * The main use for this class is locating components for automated testing + * purposes. * * @since 7.2, moved from {@link com.vaadin.client.ComponentLocator} */ public class ComponentLocator { + private final List locatorStrategies; private final LegacyLocatorStrategy legacyLocatorStrategy = new LegacyLocatorStrategy( this); @@ -46,6 +51,8 @@ public class ComponentLocator { */ public ComponentLocator(ApplicationConnection client) { this.client = client; + locatorStrategies = Arrays.asList( + new VaadinFinderLocatorStrategy(this), legacyLocatorStrategy); } /** @@ -67,6 +74,7 @@ public class ComponentLocator { * String locator could not be created. */ public String getPathForElement(Element targetElement) { + // For now, only use the legacy locator to find paths return legacyLocatorStrategy .getPathForElement(getElement(targetElement)); } @@ -119,7 +127,40 @@ public class ComponentLocator { * could not be located. */ public Element getElementByPath(String path) { - return legacyLocatorStrategy.getElementByPath(path); + // As LegacyLocatorStrategy always is the last item in the list, it is + // always used as a last resort if no other strategies claim + // responsibility for the path syntax. + for (LocatorStrategy strategy : locatorStrategies) { + if (strategy.handlesPathSyntax(path)) { + return strategy.getElementByPath(path); + } + } + return null; + } + + /** + * Locates an element using a String locator (path) which identifies a DOM + * element. The path starts from the specified root element. + * + * @see #getElementByPath(String) + * + * @param path + * The path of the element to be found + * @param root + * The root element where the path is anchored + * @return The DOM element identified by {@code path} or null if the element + * could not be located. + */ + public Element getElementByPathStartingAt(String path, Element root) { + // As LegacyLocatorStrategy always is the last item in the list, it is + // always used as a last resort if no other strategies claim + // responsibility for the path syntax. + for (LocatorStrategy strategy : locatorStrategies) { + if (strategy.handlesPathSyntax(path)) { + return strategy.getElementByPathStartingAt(path, root); + } + } + return null; } /** diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index dd67ddbc43..34f5967092 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -205,6 +205,19 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return null; } + @Override + public Element getElementByPathStartingAt(String path, Element root) { + // Not supported by the legacy format + return null; + } + + @Override + public boolean handlesPathSyntax(String path) { + // The legacy strategy is always used if all else fails, so just return + // true here. + return true; + } + /** * Finds the first widget in the hierarchy (moving upwards) that implements * SubPartAware. Returns the SubPartAware implementor or null if none is diff --git a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java index 53cff10d4f..835b81bdae 100644 --- a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java @@ -28,7 +28,63 @@ import com.google.gwt.user.client.Element; * @author Vaadin Ltd */ public interface LocatorStrategy { + /** + * Generates a String locator which uniquely identifies the target element. + * The {@link #getElementByPath(String)} method can be used for the inverse + * operation, i.e. locating an element based on the return value from this + * method. + *

+ * Note that getElementByPath(getPathForElement(element)) == element is not + * always true as #getPathForElement(Element) can return a path to another + * element if the widget determines an action on the other element will give + * the same result as the action on the target element. + *

+ * + * @param targetElement + * The element to generate a path for. + * @return A String locator that identifies the target element or null if a + * String locator could not be created. + */ String getPathForElement(Element targetElement); + /** + * Locates an element using a String locator (path) which identifies a DOM + * element. The {@link #getPathForElement(Element)} method can be used for + * the inverse operation, i.e. generating a string expression for a DOM + * element. + * + * @param path + * The String locator which identifies the target element. + * @return The DOM element identified by {@code path} or null if the element + * could not be located. + */ Element getElementByPath(String path); + + /** + * Locates an element using a String locator (path) which identifies a DOM + * element. The path starts from the specified root element. + * + * @see #getElementByPath(String) + * + * @param path + * The String locator which identifies the target element. + * @param root + * The element that is at the root of the path. + * @return The DOM element identified by {@code path} or null if the element + * could not be located. + */ + Element getElementByPathStartingAt(String path, Element root); + + /** + * Allows the component locator orchestrator to determine whether this + * strategy should be used to locate an element using the provided path. + * Paths can have (slightly) different syntax, and each locator strategy + * should inspect the path string to see if it can be used to locate the + * element by the path in question. + * + * @param path + * The path whose syntax to check whether handled or not + * @return true if this strategy handles the path syntax in question + */ + boolean handlesPathSyntax(String path); } diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java new file mode 100644 index 0000000000..f597003b60 --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -0,0 +1,357 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gwt.regexp.shared.RegExp; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.Util; +import com.vaadin.client.metadata.NoDataException; +import com.vaadin.client.metadata.Property; +import com.vaadin.client.ui.AbstractConnector; +import com.vaadin.client.ui.AbstractHasComponentsConnector; +import com.vaadin.client.ui.VNotification; +import com.vaadin.shared.AbstractComponentState; + +/** + * The VaadinFinder locator strategy implements an XPath-like syntax for + * locating elements in Vaadin applications. This is used in the new + * VaadinFinder API in TestBench 4. + * + * Examples of the supported syntax: + *
    + *
  • Find the third text field in the DOM: {@code //VTextField[2]}
  • + *
  • Find the second button inside the first vertical layout: + * {@code //VVerticalLayout/VButton[1]}
  • + *
  • Find the first column on the third row of the "Accounts" table: + * {@code //VScrollTable[caption="Accounts"]#row[2]/col[0]}
  • + *
+ * + * @since 7.2 + * @author Vaadin Ltd + */ +public class VaadinFinderLocatorStrategy implements LocatorStrategy { + + private ComponentLocator componentLocator; + + public VaadinFinderLocatorStrategy(ComponentLocator componentLocator) { + this.componentLocator = componentLocator; + } + + /** + * {@inheritDoc} + */ + @Override + public String getPathForElement(Element targetElement) { + // Path generation functionality is not yet implemented as there is no + // current need for it. This might be implemented in the future if the + // need arises. Until then, all locator generation is handled by + // LegacyLocatorStrategy. + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public Element getElementByPath(String path) { + if (path.startsWith("//VNotification")) { + return findNotificationByPath(path); + } + return findElementByPath(path, componentLocator.getClient() + .getUIConnector()); + } + + /** + * Special case for finding notifications as they have no connectors and are + * directly attached to {@link RootPanel}. + * + * @param path + * The path of the notification, should be + * {@code "//VNotification"} optionally followed by an index in + * brackets. + * @return the notification element or null if not found. + */ + private Element findNotificationByPath(String path) { + ArrayList notifications = new ArrayList(); + for (Widget w : RootPanel.get()) { + if (w instanceof VNotification) { + notifications.add((VNotification) w); + } + } + String indexStr = extractPredicateString(path); + int index = indexStr == null ? 0 : Integer.parseInt(indexStr); + if (index >= 0 && index < notifications.size()) { + return notifications.get(index).getElement(); + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public Element getElementByPathStartingAt(String path, Element root) { + return findElementByPath(path, + Util.findPaintable(componentLocator.getClient(), root)); + } + + /** + * Recursively finds an element identified by the provided path by + * traversing the connector hierarchy starting from the {@code parent} + * connector. + * + * @param path + * The path identifying an element. + * @param parent + * The connector to start traversing from. + * @return The element identified by {@code path} or null if it no such + * element could be found. + */ + private Element findElementByPath(String path, ComponentConnector parent) { + boolean findRecursively = path.startsWith("//"); + // Strip away the one or two slashes from the beginning of the path + path = path.substring(findRecursively ? 2 : 1); + + String[] fragments = splitFirstFragmentFromTheRest(path); + List potentialMatches = collectPotentialMatches( + parent, fragments[0], findRecursively); + ComponentConnector connector = filterPotentialMatches(potentialMatches, + extractPredicateString(fragments[0])); + if (connector != null) { + if (fragments.length > 1) { + return findElementByPath(fragments[1], connector); + } else { + return connector.getWidget().getElement(); + } + } + return null; + } + + /** + * Returns the predicate string, i.e. the string between the brackets in a + * path fragment. Examples: + * VTextField[0] => 0 + * VTextField[caption='foo'] => caption='foo' + * + * + * @param pathFragment + * The path fragment from which to extract the predicate string. + * @return The predicate string for the path fragment or null if none. + */ + private String extractPredicateString(String pathFragment) { + int ixOpenBracket = pathFragment.indexOf('['); + if (ixOpenBracket >= 0) { + int ixCloseBracket = pathFragment.indexOf(']', ixOpenBracket); + return pathFragment.substring(ixOpenBracket + 1, ixCloseBracket); + } + return null; + } + + /** + * Returns the first ComponentConnector that matches the predicate string + * from a list of potential matches. If {@code predicateString} is null, the + * first element in the {@code potentialMatches} list is returned. + * + * @param potentialMatches + * A list of potential matches to check. + * @param predicateString + * The predicate that should match. Can be an index or a property + * name, value pair or null. + * @return A {@link ComponentConnector} from the {@code potentialMatches} + * list, which matches the {@code predicateString} or null if no + * matches are found. + */ + private ComponentConnector filterPotentialMatches( + List potentialMatches, String predicateString) { + if (potentialMatches.isEmpty()) { + return null; + } + + if (predicateString != null) { + String[] parts = predicateString.split("="); + if (parts.length == 1) { + int index = Integer.valueOf(predicateString); + return index < potentialMatches.size() ? potentialMatches + .get(index) : null; + } else { + String propertyName = parts[0].trim(); + String value = unquote(parts[1].trim()); + for (ComponentConnector connector : potentialMatches) { + Property property = AbstractConnector.getStateType( + connector).getProperty(propertyName); + if (valueEqualsPropertyValue(value, property, + connector.getState())) { + return connector; + } + } + } + } + return potentialMatches.get(0); + } + + /** + * Returns true if the value matches the value of the property in the state + * object. + * + * @param value + * The value to compare against. + * @param property + * The property, whose value to check. + * @param state + * The connector, whose state object contains the property. + * @return true if the values match. + */ + private boolean valueEqualsPropertyValue(String value, Property property, + AbstractComponentState state) { + try { + return value.equals(property.getValue(state)); + } catch (NoDataException e) { + // The property doesn't exist in the state object, so they aren't + // equal. + return false; + } + } + + /** + * Removes the surrounding quotes from a string if it is quoted. + * + * @param str + * the possibly quoted string + * @return an unquoted version of str + */ + private String unquote(String str) { + if ((str.startsWith("\"") && str.endsWith("\"")) + || (str.startsWith("'") && str.endsWith("'"))) { + return str.substring(1, str.length() - 1); + } + return str; + } + + /** + * Collects all connectors that match the widget class name of the path + * fragment. If the {@code collectRecursively} parameter is true, a + * depth-first search of the connector hierarchy is performed. + * + * Searching depth-first ensure that we can return the matches in correct + * order for selecting based on index predicates. + * + * @param parent + * The {@link ComponentConnector} to start the search from. + * @param pathFragment + * The path fragment identifying which type of widget to search + * for. + * @param collectRecursively + * If true, all matches from all levels below {@code parent} will + * be collected. If false only direct children will be collected. + * @return A list of {@link ComponentConnector}s matching the widget type + * specified in the {@code pathFragment}. + */ + private List collectPotentialMatches( + ComponentConnector parent, String pathFragment, + boolean collectRecursively) { + ArrayList potentialMatches = new ArrayList(); + if (parent instanceof AbstractHasComponentsConnector) { + List children = ((AbstractHasComponentsConnector) parent) + .getChildComponents(); + for (ComponentConnector child : children) { + String widgetName = getWidgetName(pathFragment); + if (connectorMatchesPathFragment(child, widgetName)) { + potentialMatches.add(child); + } + if (collectRecursively) { + potentialMatches.addAll(collectPotentialMatches(child, + pathFragment, collectRecursively)); + } + } + } + return potentialMatches; + } + + /** + * Determines whether a connector matches a path fragment. This is done by + * comparing the path fragment to the name of the widget type of the + * connector. + * + * @param connector + * The connector to compare. + * @param widgetName + * The name of the widget class. + * @return true if the widget type of the connector equals the widget type + * identified by the path fragment. + */ + private boolean connectorMatchesPathFragment(ComponentConnector connector, + String widgetName) { + return widgetName.equals(Util.getSimpleName(connector.getWidget())); + } + + /** + * Extracts the name of the widget class from a path fragment + * + * @param pathFragment + * the path fragment + * @return the name of the widget class. + */ + private String getWidgetName(String pathFragment) { + String widgetName = pathFragment; + int ixBracket = pathFragment.indexOf('['); + if (ixBracket >= 0) { + widgetName = pathFragment.substring(0, ixBracket); + } + return widgetName; + } + + /** + * Splits off the first path fragment from a path and returns an array of + * two elements, where the first element is the first path fragment and the + * second element is the rest of the path (all remaining path fragments + * untouched). + * + * @param path + * The path to split. + * @return An array of two elements: The first path fragment and the rest of + * the path. + */ + private String[] splitFirstFragmentFromTheRest(String path) { + int ixOfSlash = path.indexOf('/'); + if (ixOfSlash > 0) { + return new String[] { path.substring(0, ixOfSlash), + path.substring(ixOfSlash) }; + } + return new String[] { path }; + } + + /** + * Matches a string that contains either double slashes ({@code //}) or a + * complex predicate ({@code [caption = "foo"]}) + */ + private static RegExp syntaxMatcher = RegExp + .compile("^.*//.*$|^.*\\[\\w+.*=.*\\].*$"); + + /** + * {@inheritDoc} + */ + @Override + public boolean handlesPathSyntax(String path) { + // If the path contains a double-slash at any point, it's probably ours. + return syntaxMatcher.test(path); + } +} -- cgit v1.2.3 From dc14ea4ca1cec8a4fc1ac23c07151e11cd2ac72b Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Mon, 9 Sep 2013 15:52:23 +0300 Subject: Implemented SubPartAware in VScrollTable #12514 This allows for "//VScrollTable#row[n]/col[m]" -style locator strings. Change-Id: I65bea31ab0eaa59fcd5a566ea3d1a43465ef298f --- .../VaadinFinderLocatorStrategy.java | 55 ++++++++--- client/src/com/vaadin/client/ui/VScrollTable.java | 108 ++++++++++++++++++++- 2 files changed, 151 insertions(+), 12 deletions(-) diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index f597003b60..3516aa3e93 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -28,6 +28,7 @@ import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.AbstractHasComponentsConnector; +import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.VNotification; import com.vaadin.shared.AbstractComponentState; @@ -50,6 +51,7 @@ import com.vaadin.shared.AbstractComponentState; */ public class VaadinFinderLocatorStrategy implements LocatorStrategy { + private static final String SUBPART_SEPARATOR = "#"; private ComponentLocator componentLocator; public VaadinFinderLocatorStrategy(ComponentLocator componentLocator) { @@ -76,8 +78,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { if (path.startsWith("//VNotification")) { return findNotificationByPath(path); } - return findElementByPath(path, componentLocator.getClient() - .getUIConnector()); + return getElementByPathStartingAtConnector(path, componentLocator + .getClient().getUIConnector()); } /** @@ -110,23 +112,54 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ @Override public Element getElementByPathStartingAt(String path, Element root) { - return findElementByPath(path, + return getElementByPathStartingAtConnector(path, Util.findPaintable(componentLocator.getClient(), root)); } /** - * Recursively finds an element identified by the provided path by - * traversing the connector hierarchy starting from the {@code parent} - * connector. + * Finds an element by the specified path, starting traversal of the + * connector hierarchy from the specified root. + * + * @param path + * the locator path + * @param root + * the root connector + * @return the element identified by path or null if not found. + */ + private Element getElementByPathStartingAtConnector(String path, + ComponentConnector root) { + String[] pathComponents = path.split(SUBPART_SEPARATOR); + ComponentConnector connector = findConnectorByPath(pathComponents[0], + root); + if (connector != null) { + if (pathComponents.length > 1) { + // We have subparts + if (connector.getWidget() instanceof SubPartAware) { + return ((SubPartAware) connector.getWidget()) + .getSubPartElement(pathComponents[1]); + } else { + return null; + } + } + return connector.getWidget().getElement(); + } + return null; + } + + /** + * Recursively finds a connector for the element identified by the provided + * path by traversing the connector hierarchy starting from the + * {@code parent} connector. * * @param path * The path identifying an element. * @param parent * The connector to start traversing from. - * @return The element identified by {@code path} or null if it no such - * element could be found. + * @return The connector identified by {@code path} or null if it no such + * connector could be found. */ - private Element findElementByPath(String path, ComponentConnector parent) { + private ComponentConnector findConnectorByPath(String path, + ComponentConnector parent) { boolean findRecursively = path.startsWith("//"); // Strip away the one or two slashes from the beginning of the path path = path.substring(findRecursively ? 2 : 1); @@ -138,9 +171,9 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { extractPredicateString(fragments[0])); if (connector != null) { if (fragments.length > 1) { - return findElementByPath(fragments[1], connector); + return findConnectorByPath(fragments[1], connector); } else { - return connector.getWidget().getElement(); + return connector; } } return null; diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 3733ee204a..fe2e99a28f 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -61,6 +61,8 @@ import com.google.gwt.event.dom.client.ScrollHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; @@ -123,7 +125,7 @@ import com.vaadin.shared.ui.table.TableConstants; */ public class VScrollTable extends FlowPanel implements HasWidgets, ScrollHandler, VHasDropHandler, FocusHandler, BlurHandler, Focusable, - ActionOwner { + ActionOwner, SubPartAware { public static final String STYLENAME = "v-table"; @@ -5031,6 +5033,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } } + public int indexOf(Widget row) { + int relIx = -1; + for (int ix = 0; ix < renderedRows.size(); ix++) { + if (renderedRows.get(ix) == row) { + relIx = ix; + break; + } + } + if (relIx >= 0) { + return this.firstRendered + relIx; + } + return -1; + } + public class VScrollTableRow extends Panel implements ActionOwner { private static final int TOUCHSCROLL_TIMEOUT = 100; @@ -7728,4 +7744,94 @@ public class VScrollTable extends FlowPanel implements HasWidgets, return this; } + private static final String SUBPART_HEADER = "header"; + private static final String SUBPART_FOOTER = "footer"; + private static final String SUBPART_ROW = "row"; + private static final String SUBPART_COL = "col"; + /** Matches header[ix] - used for extracting the index of the targeted header cell */ + private static final RegExp SUBPART_HEADER_REGEXP = RegExp + .compile(SUBPART_HEADER + "\\[(\\d+)\\]"); + /** Matches footer[ix] - used for extracting the index of the targeted footer cell */ + private static final RegExp SUBPART_FOOTER_REGEXP = RegExp + .compile(SUBPART_FOOTER + "\\[(\\d+)\\]"); + /** Matches row[ix] - used for extracting the index of the targeted row */ + private static final RegExp SUBPART_ROW_REGEXP = RegExp.compile(SUBPART_ROW + + "\\[(\\d+)]"); + /** Matches col[ix] - used for extracting the index of the targeted column */ + private static final RegExp SUBPART_ROW_COL_REGEXP = RegExp + .compile(SUBPART_ROW + "\\[(\\d+)\\]/" + SUBPART_COL + "\\[(\\d+)\\]"); + + @Override + public Element getSubPartElement(String subPart) { + if (SUBPART_ROW_COL_REGEXP.test(subPart)) { + MatchResult result = SUBPART_ROW_COL_REGEXP.exec(subPart); + int rowIx = Integer.valueOf(result.getGroup(1)); + int colIx = Integer.valueOf(result.getGroup(2)); + VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx); + if (row != null) { + Element rowElement = row.getElement(); + if (colIx < rowElement.getChildCount()) { + return rowElement.getChild(colIx).getFirstChild().cast(); + } + } + + } else if (SUBPART_ROW_REGEXP.test(subPart)) { + MatchResult result = SUBPART_ROW_REGEXP.exec(subPart); + int rowIx = Integer.valueOf(result.getGroup(1)); + VScrollTableRow row = scrollBody.getRowByRowIndex(rowIx); + if (row != null) { + return row.getElement(); + } + + } else if (SUBPART_HEADER_REGEXP.test(subPart)) { + MatchResult result = SUBPART_HEADER_REGEXP.exec(subPart); + int headerIx = Integer.valueOf(result.getGroup(1)); + HeaderCell headerCell = tHead.getHeaderCell(headerIx); + if (headerCell != null) { + return headerCell.getElement(); + } + + } else if (SUBPART_FOOTER_REGEXP.test(subPart)) { + MatchResult result = SUBPART_FOOTER_REGEXP.exec(subPart); + int footerIx = Integer.valueOf(result.getGroup(1)); + FooterCell footerCell = tFoot.getFooterCell(footerIx); + if (footerCell != null) { + return footerCell.getElement(); + } + } + // Nothing found. + return null; + } + + @Override + public String getSubPartName(Element subElement) { + Widget widget = Util.findWidget(subElement, null); + if (widget instanceof HeaderCell) { + return SUBPART_HEADER + "[" + tHead.visibleCells.indexOf(widget) + + "]"; + } else if (widget instanceof FooterCell) { + return SUBPART_FOOTER + "[" + tFoot.visibleCells.indexOf(widget) + + "]"; + } else if (widget instanceof VScrollTableRow) { + // a cell in a row + VScrollTableRow row = (VScrollTableRow) widget; + int rowIx = scrollBody.indexOf(row); + if (rowIx >= 0) { + int colIx = -1; + for (int ix = 0; ix < row.getElement().getChildCount(); ix++) { + if (row.getElement().getChild(ix).isOrHasChild(subElement)) { + colIx = ix; + break; + } + } + if (colIx >= 0) { + return SUBPART_ROW + "[" + rowIx + "]/" + SUBPART_COL + "[" + + colIx + "]"; + } + return SUBPART_ROW + "[" + rowIx + "]"; + } + } + // Nothing found. + return null; + } } -- cgit v1.2.3 From a9f332fddb5ff70338527c1ddad3ca40dca70d6d Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Mon, 23 Sep 2013 08:52:22 +0300 Subject: Add simple calculator test application (#12444) Change-Id: Ie2880c9321f46a004e53ca0fa08aa43f840e6a5d --- .../vaadin/tests/application/calculator/Calc.java | 190 +++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/application/calculator/Calc.java diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java new file mode 100644 index 0000000000..7d080adfa6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/calculator/Calc.java @@ -0,0 +1,190 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.application.calculator; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class Calc extends AbstractTestUI { + + private class Log extends TextArea { + + public Log() { + super(); + setWidth("200px"); + } + + public void addRow(String row) { + setValue(getValue() + "\n" + row); + } + } + + // All variables are automatically stored in the session. + private Double current = 0.0; + private double stored = 0.0; + private char lastOperationRequested = 'C'; + private VerticalLayout topLayout = new VerticalLayout(); + + // User interface components + private final TextField display = new TextField("0.0"); + + private final Log log = new Log(); + + // Calculator "business logic" implemented here to keep the example + // minimal + private double calculate(char requestedOperation) { + if ('0' <= requestedOperation && requestedOperation <= '9') { + if (current == null) { + current = 0.0; + } + current = current * 10 + + Double.parseDouble("" + requestedOperation); + return current; + } + + if (current == null) { + current = stored; + } + switch (lastOperationRequested) { + case '+': + stored += current; + break; + case '-': + stored -= current; + break; + case '/': + stored /= current; + break; + case '*': + stored *= current; + break; + default: + stored = current; + break; + } + + switch (requestedOperation) { + case '+': + log.addRow(current + " +"); + break; + case '-': + log.addRow(current + " -"); + break; + case '/': + log.addRow(current + " /"); + break; + case '*': + log.addRow(current + " x"); + break; + case '=': + log.addRow(current + " ="); + log.addRow("------------"); + log.addRow("" + stored); + break; + } + + lastOperationRequested = requestedOperation; + current = null; + if (requestedOperation == 'C') { + log.addRow("0.0"); + stored = 0.0; + } + return stored; + } + + @Override + protected void setup(VaadinRequest request) { + setContent(topLayout); + + // Create the main layout for our application (4 columns, 5 rows) + final GridLayout layout = new GridLayout(4, 5); + + topLayout.setMargin(true); + topLayout.setSpacing(true); + Label title = new Label("Calculator"); + topLayout.addComponent(title); + topLayout.addComponent(log); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.setSpacing(true); + horizontalLayout.addComponent(layout); + horizontalLayout.addComponent(log); + topLayout.addComponent(horizontalLayout); + + // Create a result label that over all 4 columns in the first row + layout.addComponent(display, 0, 0, 3, 0); + layout.setComponentAlignment(display, Alignment.MIDDLE_RIGHT); + display.setSizeUndefined(); + display.setId("display"); + + // The operations for the calculator in the order they appear on the + // screen (left to right, top to bottom) + String[] operations = new String[] { "7", "8", "9", "/", "4", "5", "6", + "*", "1", "2", "3", "-", "0", "=", "C", "+" }; + + for (String caption : operations) { + + // Create a button and use this application for event handling + Button button = new Button(caption); + button.setHeight("30px"); + button.setWidth("40px"); + button.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // Get the button that was clicked + Button button = event.getButton(); + + // Get the requested operation from the button caption + char requestedOperation = button.getCaption().charAt(0); + + // Calculate the new value + double newValue = calculate(requestedOperation); + + // Update the result label with the new value + display.setValue("" + newValue); + } + }); + button.setId("button_" + caption); + + // Add the button to our main layout + layout.addComponent(button); + } + + } + + @Override + protected String getTestDescription() { + return "Provide test application for generic testing purposes"; + } + + @Override + protected Integer getTicketNumber() { + return 12444; + } + +} -- cgit v1.2.3 From 5cc968b378ccf99ed511deaadd8c47073c300365 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Tue, 1 Oct 2013 14:35:17 +0300 Subject: Support mixed legacy and VaadinFinder locators (#12641, #12642, #12643) ComponentLocator tries to use all available locator strategies until a match is found (#12641) and VaadinFinderLocatorStrategy also accepts simple indexed paths (#12642) with legacy locators as a backup. To enable mixed use of locators, LegacyLocatorStrategy now implements getElementByPathStartingAt() (#12643). Change-Id: I6b763565adef0e294b353ef6e2dfdf70ae0d77a9 --- .../client/componentlocator/ComponentLocator.java | 16 +++++--- .../componentlocator/LegacyLocatorStrategy.java | 43 ++++++++++++---------- .../client/componentlocator/LocatorStrategy.java | 13 ------- .../VaadinFinderLocatorStrategy.java | 19 +--------- 4 files changed, 36 insertions(+), 55 deletions(-) diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index c1f117d992..e319650d23 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -131,8 +131,9 @@ public class ComponentLocator { // always used as a last resort if no other strategies claim // responsibility for the path syntax. for (LocatorStrategy strategy : locatorStrategies) { - if (strategy.handlesPathSyntax(path)) { - return strategy.getElementByPath(path); + Element element = strategy.getElementByPath(path); + if (null != element) { + return element; } } return null; @@ -156,17 +157,22 @@ public class ComponentLocator { // always used as a last resort if no other strategies claim // responsibility for the path syntax. for (LocatorStrategy strategy : locatorStrategies) { - if (strategy.handlesPathSyntax(path)) { - return strategy.getElementByPathStartingAt(path, root); + Element element = strategy.getElementByPathStartingAt(path, root); + if (null != element) { + return element; } } return null; } /** + * Returns the {@link ApplicationConnection} used by this locator. + *

+ * This method is primarily for internal use by the framework. + * * @return the application connection */ - ApplicationConnection getClient() { + public ApplicationConnection getClient() { return client; } } diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 34f5967092..ed70486ff5 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -177,17 +177,30 @@ public class LegacyLocatorStrategy implements LocatorStrategy { @Override public Element getElementByPath(String path) { + return getElementByPathStartingAt(path, null); + } + + @Override + public Element getElementByPathStartingAt(String path, Element baseElement) { /* * Path is of type "targetWidgetPath#componentPart" or * "targetWidgetPath". */ String parts[] = path.split(LegacyLocatorStrategy.SUBPART_SEPARATOR, 2); String widgetPath = parts[0]; - Widget w = getWidgetFromPath(widgetPath); + + Widget baseWidget = null; + if (null != baseElement) { + // Note that this only works if baseElement can be mapped to a + // widget to which the path is relative. Otherwise, the current + // implementation simply interprets the path as if baseElement was + // null. + baseWidget = Util.findWidget(baseElement, null); + } + Widget w = getWidgetFromPath(widgetPath, baseWidget); if (w == null || !Util.isAttachedAndDisplayed(w)) { return null; } - if (parts.length == 1) { int pos = widgetPath.indexOf("domChild"); if (pos == -1) { @@ -196,7 +209,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { // Contains dom reference to a sub element of the widget String subPath = widgetPath.substring(pos); - return getElementByDOMPath(w.getElement(), subPath); + return getElementByDOMPath(baseElement, subPath); } else if (parts.length == 2) { if (w instanceof SubPartAware) { return ((SubPartAware) w).getSubPartElement(parts[1]); @@ -205,19 +218,6 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return null; } - @Override - public Element getElementByPathStartingAt(String path, Element root) { - // Not supported by the legacy format - return null; - } - - @Override - public boolean handlesPathSyntax(String path) { - // The legacy strategy is always used if all else fails, so just return - // true here. - return true; - } - /** * Finds the first widget in the hierarchy (moving upwards) that implements * SubPartAware. Returns the SubPartAware implementor or null if none is @@ -364,7 +364,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { /** * Creates a locator String for the given widget. The path can be used to - * locate the widget using {@link #getWidgetFromPath(String)}. + * locate the widget using {@link #getWidgetFromPath(String, Widget)}. *

* Returns null if no path can be determined for the widget or if the widget * is null. @@ -436,11 +436,14 @@ public class LegacyLocatorStrategy implements LocatorStrategy { * * @param path * The String locator that identifies the widget. + * @param baseWidget + * the widget to which the path is relative, null if relative to + * root * @return The Widget identified by the String locator or null if the widget * could not be identified. */ - private Widget getWidgetFromPath(String path) { - Widget w = null; + private Widget getWidgetFromPath(String path, Widget baseWidget) { + Widget w = baseWidget; String parts[] = path.split(PARENTCHILD_SEPARATOR); for (int i = 0; i < parts.length; i++) { @@ -517,7 +520,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { .next(); } /* - * The new grid and ordered layotus do not contain + * The new grid and ordered layouts do not contain * ChildComponentContainer widgets. This is instead simulated by * constructing a path step that would find the desired widget * from the layout and injecting it as the next search step diff --git a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java index 835b81bdae..56ed396609 100644 --- a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java @@ -74,17 +74,4 @@ public interface LocatorStrategy { * could not be located. */ Element getElementByPathStartingAt(String path, Element root); - - /** - * Allows the component locator orchestrator to determine whether this - * strategy should be used to locate an element using the provided path. - * Paths can have (slightly) different syntax, and each locator strategy - * should inspect the path string to see if it can be used to locate the - * element by the path in question. - * - * @param path - * The path whose syntax to check whether handled or not - * @return true if this strategy handles the path syntax in question - */ - boolean handlesPathSyntax(String path); } diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 3516aa3e93..a95b2013ed 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -18,7 +18,6 @@ package com.vaadin.client.componentlocator; import java.util.ArrayList; import java.util.List; -import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; @@ -51,7 +50,8 @@ import com.vaadin.shared.AbstractComponentState; */ public class VaadinFinderLocatorStrategy implements LocatorStrategy { - private static final String SUBPART_SEPARATOR = "#"; + public static final String SUBPART_SEPARATOR = "#"; + private ComponentLocator componentLocator; public VaadinFinderLocatorStrategy(ComponentLocator componentLocator) { @@ -372,19 +372,4 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return new String[] { path }; } - /** - * Matches a string that contains either double slashes ({@code //}) or a - * complex predicate ({@code [caption = "foo"]}) - */ - private static RegExp syntaxMatcher = RegExp - .compile("^.*//.*$|^.*\\[\\w+.*=.*\\].*$"); - - /** - * {@inheritDoc} - */ - @Override - public boolean handlesPathSyntax(String path) { - // If the path contains a double-slash at any point, it's probably ours. - return syntaxMatcher.test(path); - } } -- cgit v1.2.3 From c2b81b20ca3a981b775ac5f16506861724119df4 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Wed, 9 Oct 2013 16:19:00 +0300 Subject: Accept "=" in caption/id strings (#12737) Change-Id: I220fe86bcbfbf1c7188d7da78bb0ee446a5df7c2 --- .../VaadinFinderLocatorStrategy.java | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index a95b2013ed..264574788c 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -51,7 +51,6 @@ import com.vaadin.shared.AbstractComponentState; public class VaadinFinderLocatorStrategy implements LocatorStrategy { public static final String SUBPART_SEPARATOR = "#"; - private ComponentLocator componentLocator; public VaadinFinderLocatorStrategy(ComponentLocator componentLocator) { @@ -215,19 +214,22 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ private ComponentConnector filterPotentialMatches( List potentialMatches, String predicateString) { + if (potentialMatches.isEmpty()) { return null; } if (predicateString != null) { - String[] parts = predicateString.split("="); - if (parts.length == 1) { - int index = Integer.valueOf(predicateString); - return index < potentialMatches.size() ? potentialMatches - .get(index) : null; - } else { - String propertyName = parts[0].trim(); - String value = unquote(parts[1].trim()); + + int split_idx = predicateString.indexOf('='); + + if (split_idx != -1) { + + String propertyName = predicateString.substring(0, split_idx) + .trim(); + String value = unquote(predicateString.substring(split_idx + 1) + .trim()); + for (ComponentConnector connector : potentialMatches) { Property property = AbstractConnector.getStateType( connector).getProperty(propertyName); @@ -236,8 +238,14 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return connector; } } + + } else { + int index = Integer.valueOf(predicateString); + return index < potentialMatches.size() ? potentialMatches + .get(index) : null; } } + return potentialMatches.get(0); } -- cgit v1.2.3 From c141df78b37ccb36dfbf098c09b14df5535b99cb Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 2 Oct 2013 13:27:38 +0300 Subject: Generate correct selectors in debug window for TestBench 4 (#12694) Selectors use IDs, captions, indices of the widget type in parent and then as a fallback domChild/XPath paths to support sub-part selection and highlighting as well as other elements without subpart information. Change-Id: I1ce30a9eb4a96ef0387635ae7464db7e9bd6f542 --- .../vaadin/client/debug/internal/Highlight.java | 43 +- .../vaadin/client/debug/internal/SelectorPath.java | 813 +++++++++++++++++++++ .../client/debug/internal/TestBenchSection.java | 118 ++- 3 files changed, 910 insertions(+), 64 deletions(-) create mode 100644 client/src/com/vaadin/client/debug/internal/SelectorPath.java diff --git a/client/src/com/vaadin/client/debug/internal/Highlight.java b/client/src/com/vaadin/client/debug/internal/Highlight.java index f2695f58ca..5ee3a25e2c 100644 --- a/client/src/com/vaadin/client/debug/internal/Highlight.java +++ b/client/src/com/vaadin/client/debug/internal/Highlight.java @@ -144,20 +144,55 @@ public class Highlight { */ static Element show(Widget widget, String color) { if (widget != null) { + show(widget.getElement(), color); + } + return null; + } + + /** + * Highlights the given {@link Element}. + *

+ * Pass the returned {@link Element} to {@link #hide(Element)} to remove + * this particular highlight. + *

+ * + * @param element + * Element to highlight + * @return Highlight element + */ + static Element show(Element element) { + return show(element, DEFAULT_COLOR); + } + + /** + * Highlight the given {@link Element} using the given color. + *

+ * Pass the returned highlight {@link Element} to {@link #hide(Element)} to + * remove this particular highlight. + *

+ * + * @param element + * Element to highlight + * @param color + * Color of highlight + * @return Highlight element + */ + static Element show(Element element, String color) { + if (element != null) { if (highlights == null) { highlights = new HashSet(); } Element highlight = DOM.createDiv(); Style style = highlight.getStyle(); - style.setTop(widget.getAbsoluteTop(), Unit.PX); - style.setLeft(widget.getAbsoluteLeft(), Unit.PX); - int width = widget.getOffsetWidth(); + style.setTop(element.getAbsoluteTop(), Unit.PX); + style.setLeft(element.getAbsoluteLeft(), Unit.PX); + int width = element.getOffsetWidth(); if (width < MIN_WIDTH) { width = MIN_WIDTH; } style.setWidth(width, Unit.PX); - int height = widget.getOffsetHeight(); + int height = element.getOffsetHeight(); if (height < MIN_HEIGHT) { height = MIN_HEIGHT; } diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java new file mode 100644 index 0000000000..d4502daeda --- /dev/null +++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java @@ -0,0 +1,813 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.client.debug.internal; + +import com.google.gwt.regexp.shared.MatchResult; +import com.google.gwt.regexp.shared.RegExp; +import com.google.gwt.user.client.Element; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ComponentConnector; +import com.vaadin.client.ServerConnector; +import com.vaadin.client.Util; +import com.vaadin.client.componentlocator.ComponentLocator; +import com.vaadin.client.componentlocator.VaadinFinderLocatorStrategy; +import com.vaadin.client.metadata.NoDataException; +import com.vaadin.client.metadata.Property; +import com.vaadin.client.ui.AbstractConnector; +import com.vaadin.client.ui.SubPartAware; + +/** + * A single segment of a selector path with optional parent. + *

+ * The static method {@link #findTestBenchSelector(ServerConnector, Element)} + * permits looking up a selector chain for an element (a selector and its + * parents, each selector relative to its parent). + *

+ * The method {@link #findElement()} can be used to locate the element + * referenced by a {@link SelectorPath}. {@link #getJUnitSelector(String)} can + * be used to obtain the string to add to a JUnit test to refer to the element + * identified by the path. + *

+ * This class should be considered internal to the framework and may change at + * any time. + * + * @since 7.1.x + */ +public abstract class SelectorPath { + private final SelectorPath parent; + private final ComponentLocator locator; + + private static final String SUBPART_SEPARATOR = VaadinFinderLocatorStrategy.SUBPART_SEPARATOR; + + /** + * Creates a {@link SelectorPath} from the root of the UI (without a parent) + * to identify an element. + *

+ * The {@link ComponentLocator} is used to locate the corresponding + * {@link Element} in the context of a UI. If there are multiple UIs on a + * single page, the locator should correspond to the correct + * {@link ApplicationConnection}. + * + * @param locator + * {@link ComponentLocator} to use + */ + protected SelectorPath(ComponentLocator locator) { + this(null, locator); + } + + /** + * Creates a {@link SelectorPath} which is relative to another + * {@link SelectorPath}. to identify an element. + *

+ * The {@link ComponentLocator} is used to locate the corresponding + * {@link Element} in the context of a UI. If there are multiple UIs on a + * single page, the locator should correspond to the correct + * {@link ApplicationConnection}. + * + * @param parent + * parent {@link SelectorPath} or null for root paths + * @param locator + * {@link ComponentLocator} to use + */ + protected SelectorPath(SelectorPath parent, ComponentLocator locator) { + this.parent = parent; + this.locator = locator; + } + + /** + * Returns the parent {@link SelectorPath} to which this path is relative. + * + * @return parent path + */ + public SelectorPath getParent() { + return parent; + } + + @Override + public String toString() { + return "SelectorPath: " + getJUnitSelector("..."); + } + + /** + * Returns the JUnit test fragment which can be used to refer to the element + * in a test. + * + * @param context + * the context to use (usually "getDriver()" or a variable name) + * @return string to add in a JUnit test + */ + public abstract String getJUnitSelector(String context); + + /** + * Returns the {@link Element} that this {@link SelectorPath} points to in + * the context of the {@link ComponentLocator} of the {@link SelectorPath}. + * + * @return Element identified by the path in the current UI + */ + public abstract Element findElement(); + + /** + * Returns the path to an element/connector, including separate intermediate + * paths and the final path segment. + * + * @param connector + * the connector to find + * @param element + * sub-element inside connector or null to use connector root + * element + * @return Vaadin locator path + */ + public static SelectorPath findTestBenchSelector(ServerConnector connector, + Element element) { + // TODO there should be a better way to locate and refer to captions - + // now using domChild in layout + SelectorPath selectorPath = null; + ApplicationConnection connection = connector.getConnection(); + if (connection != null) { + if (null == element) { + element = findConnectorRootElement(connector); + } + if (null != element) { + ComponentLocator locator = new ComponentLocator(connection); + String path = locator.getPathForElement(element); + SelectorPath parent = null; + + if (!path.isEmpty()) { + selectorPath = extractIdSelectorPath(path, locator); + if (null == selectorPath) { + // parent paths first if not rooted on an ID + if (connector.getParent() != null) { + parent = findTestBenchSelector( + connector.getParent(), null); + } + + if (parent != null) { + // update path to be relative to parent + Element parentElement = parent.findElement(); + if (null != parentElement) { + String parentPath = locator + .getPathForElement(parentElement); + if (path.startsWith(parentPath)) { + // remove path of parent to look for the + // children + path = path.substring(parentPath.length()); + } + } + } + + selectorPath = extractVaadinSelectorPath(path, parent, + locator); + } + if (null == selectorPath) { + if (path.startsWith("/V")) { + // fall-back: Vaadin + // this branch is needed for /VTabsheetPanel etc. + selectorPath = SelectorPath.vaadinPath(path, + parent, locator); + } else { + // fall-back: XPath + selectorPath = SelectorPath.xpath(path, parent, + locator); + } + } + } + } + } + return selectorPath; + } + + private static SelectorPath extractIdSelectorPath(String path, + ComponentLocator locator) { + SelectorPath selectorPath = null; + if (path.startsWith("PID_S")) { + // remove internal prefix + path = path.substring(5); + + // no parent for an ID selector + String pid = path; + String rest = null; + // split at first slash that is not in the subpart (if any) + int slashPos = path.indexOf("/"); + int subPartPos = path.indexOf(SUBPART_SEPARATOR); + if (subPartPos >= 0 && slashPos > subPartPos) { + // ignore slashes in subpart + slashPos = -1; + } else if (slashPos >= 0 && subPartPos > slashPos) { + // ignore subpart after slashes - handled as a part of rest + subPartPos = -1; + } + // split the ID part and any relative path after it + if (slashPos > 0) { + pid = path.substring(0, slashPos); + rest = path.substring(slashPos); + } + + // if there is a subpart directly after the id, need to use a Vaadin + // selector + SelectorPath pidSelector = null; + if (subPartPos > 0) { + String id = pid.substring(0, subPartPos); + // include the subpart separator + String subPart = pid.substring(subPartPos); + Element element = locator.getElementByPath("PID_S" + pid); + ComponentConnector connector = Util.findPaintable( + locator.getClient(), element); + if (null != connector && null != connector.getWidget()) { + String type = connector.getWidget().getClass() + .getSimpleName(); + pidSelector = SelectorPath.vaadinPath("//" + type + + "[id=\\\"" + id + "\\\"]" + subPart, null, + locator); + } else { + // no valid connector for the subpart + return null; + } + } else { + pidSelector = SelectorPath.id(pid, locator); + } + if (null != rest && !rest.isEmpty()) { + selectorPath = extractVaadinSelectorPath(path, pidSelector, + locator); + if (selectorPath == null) { + selectorPath = SelectorPath.xpath(rest, pidSelector, + locator); + } + } else { + selectorPath = pidSelector; + } + } + return selectorPath; + } + + private static SelectorPath extractVaadinSelectorPath(String path, + SelectorPath parent, ComponentLocator locator) { + SelectorPath selectorPath = null; + + String xpathPart = null; + int xpathPos = Math.min(path.indexOf("/div"), path.indexOf("/span")); + if (xpathPos >= 0) { + xpathPart = path.substring(xpathPos); + path = path.substring(0, xpathPos); + } + + String subPartPart = null; + int subPartPos = path.indexOf("#"); + if (subPartPos >= 0) { + subPartPart = path.substring(subPartPos + 1); + path = path.substring(0, subPartPos); + } + + String domChildPart = null; + int domChildPos = path.indexOf("/domChild"); + if (domChildPos >= 0) { + // include the slash + domChildPart = path.substring(domChildPos); + path = path.substring(0, domChildPos); + } + + // is it something VaadinSelectorPath can handle? + String widgetClass = null; + // first cases in a layout slot + RegExp widgetInSlotMatcher = RegExp + .compile("^/(Slot\\[(\\d+)\\]/)([a-zA-Z]+)(\\[0\\])?$"); + MatchResult matchResult = widgetInSlotMatcher.exec(path); + if (null != matchResult) { + if (matchResult.getGroupCount() >= 3) { + widgetClass = matchResult.getGroup(3); + } + } + // handle cases without intervening slot + if (null == widgetClass) { + RegExp widgetDirectlyMatcher = RegExp + .compile("^//?([a-zA-Z]+)(\\[(\\d+)\\])?$"); + matchResult = widgetDirectlyMatcher.exec(path); + if (null != matchResult) { + if (matchResult.getGroupCount() >= 1) { + widgetClass = matchResult.getGroup(1); + } + } + } + if (null != widgetClass && !widgetClass.isEmpty()) { + selectorPath = findVaadinSelectorInParent(path, widgetClass, + parent, locator); + if (null != subPartPart + && selectorPath instanceof VaadinSelectorPath) { + ((VaadinSelectorPath) selectorPath).setSubPart(subPartPart); + } else if (null != xpathPart + && selectorPath instanceof VaadinSelectorPath) { + // try to find sub-part if supported + ComponentConnector connector = Util.findPaintable( + locator.getClient(), selectorPath.findElement()); + if (connector != null + && connector.getWidget() instanceof SubPartAware) { + // for SubPartAware, skip the XPath fall-back path + Element element = locator.getElementByPathStartingAt(path, + selectorPath.findElement()); + SubPartAware subPartAware = (SubPartAware) connector + .getWidget(); + String subPart = subPartAware.getSubPartName(element); + if (null != subPart) { + // type checked above + ((VaadinSelectorPath) selectorPath).setSubPart(subPart); + } + } else { + // fall-back to XPath for the last part of the path + selectorPath = SelectorPath.xpath(xpathPart, selectorPath, + locator); + } + } + + // the whole /domChild[i]/domChild[j]... part as a single selector + if (null != domChildPart + && selectorPath instanceof VaadinSelectorPath) { + selectorPath = SelectorPath.vaadinPath(domChildPart, + selectorPath, locator); + } + } else if (null != domChildPart) { + // cases with domChild path only (parent contains rest) + selectorPath = SelectorPath.vaadinPath(domChildPart, parent, + locator); + } + return selectorPath; + } + + /** + * Find the zero-based index of the widget of type widgetClass identified by + * path within its parent and returns the corresponding Vaadin path (if + * any). For instance, the second button in a layout has index 1 regardless + * of non-button components in the parent. + *

+ * The approach used internally is to try to find the caption of the element + * inside its parent and check whether it is sufficient to identify the + * element correctly. If not, possible indices are looped through to see if + * the component of the specified type within the specified parent + * identifies the correct element. This is inefficient but more reliable + * than some alternative approaches, and does not require special cases for + * various layouts etc. + * + * @param path + * relative path for the widget of interest + * @param widgetClass + * type of the widget of interest + * @param parent + * parent component to which the path is relative + * @param locator + * ComponentLocator used to map paths to elements + * @return selector path for the element, null if none found + */ + private static SelectorPath findVaadinSelectorInParent(String path, + String widgetClass, SelectorPath parent, ComponentLocator locator) { + if (null == parent) { + SelectorPath selectorPath = SelectorPath.vaadin(widgetClass, 0, + null, locator); + if (selectorPath.findElement() == locator.getElementByPath(path)) { + return selectorPath; + } else { + return null; + } + } + // This method uses an inefficient brute-force approach but its + // results should match what is used by the TestBench selectors. + Element parentElement = parent.findElement(); + String parentPathString = locator.getPathForElement(parentElement); + if (null == parentPathString) { + parentPathString = ""; + } + Element elementToFind = locator.getElementByPath(parentPathString + + path); + if (null == elementToFind) { + return null; + } + // if the connector has a caption, first try if the element can be + // located in parent with it; if that fails, use the index in parent + String caption = getCaptionForElement(elementToFind, locator); + if (null != caption) { + SelectorPath testPath = SelectorPath.vaadin(widgetClass, caption, + parent, locator); + Element testElement = testPath.findElement(); + // TODO in theory could also iterate upwards into parents, using + // "//" before the caption to find the shortest matching path that + // identifies the correct element + if (testElement == elementToFind) { + return testPath; + } + } + + // Assumes that the number of logical child elements is at most the + // number of direct children of the DOM element - e.g. layouts have a + // single component per slot. + for (int i = 0; i < parentElement.getChildCount(); ++i) { + SelectorPath testPath = SelectorPath.vaadin(widgetClass, i, parent, + locator); + Element testElement = testPath.findElement(); + if (testElement == elementToFind) { + return testPath; + } + } + return null; + } + + private static String getCaptionForElement(Element element, + ComponentLocator locator) { + String caption = null; + ComponentConnector connector = Util.findPaintable(locator.getClient(), + element); + if (null != connector) { + Property property = AbstractConnector.getStateType(connector) + .getProperty("caption"); + try { + Object value = property.getValue(connector.getState()); + if (null != value) { + caption = String.valueOf(value); + } + } catch (NoDataException e) { + // skip the caption based selection and use index below + } + } + return caption; + } + + private static Element findConnectorRootElement(ServerConnector connector) { + Element element = null; + // try to find the root element of the connector + if (connector instanceof ComponentConnector) { + Widget widget = ((ComponentConnector) connector).getWidget(); + if (widget != null) { + element = widget.getElement(); + } + } + return element; + } + + public ComponentLocator getLocator() { + return locator; + } + + @Override + public int hashCode() { + return getJUnitSelector("context").hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + SelectorPath other = (SelectorPath) obj; + if (parent == null) { + if (other.parent != null) { + return false; + } + } else if (!parent.equals(other.parent)) { + return false; + } + if (!other.getJUnitSelector("context").equals( + getJUnitSelector("context"))) { + return false; + } + return true; + } + + protected static SelectorPath xpath(String path, SelectorPath parent, + ComponentLocator locator) { + return new XPathSelectorPath(path, parent, locator); + } + + protected static SelectorPath id(String id, ComponentLocator locator) { + return new IdSelectorPath(id, locator); + } + + protected static SelectorPath vaadin(String widgetClass, + String widgetCaption, SelectorPath parent, ComponentLocator locator) { + return new VaadinSelectorPath(widgetClass, widgetCaption, 0, parent, + locator); + } + + protected static SelectorPath vaadin(String widgetClass, int widgetIndex, + SelectorPath parent, ComponentLocator locator) { + return new VaadinSelectorPath(widgetClass, null, widgetIndex, parent, + locator); + } + + protected static SelectorPath vaadinPath(String vaadinPath, + SelectorPath parent, ComponentLocator locator) { + return new ByVaadinSelectorPath(vaadinPath, parent, locator); + } + + /** + * Selector path for finding an {@link Element} based on an XPath (relative + * to the parent {@link SelectorPath}). + */ + private static class XPathSelectorPath extends SelectorPath { + // path segment relative to parent + private final String path; + + /** + * Creates a relative XPath based component selector path. + * + * @param path + * XPath + * @param parent + * {@link SelectorPath} to which the XPath is relative, null + * if from the root + * @param locator + * ComponentLocator to use to find the element + */ + public XPathSelectorPath(String path, SelectorPath parent, + ComponentLocator locator) { + super(parent, locator); + this.path = path; + } + + /** + * Returns the XPath relative to the parent element. + * + * @return relative path string + */ + public String getPath() { + return path; + } + + @Override + public String getJUnitSelector(String context) { + return context + ".findElement(By.xpath(\"" + getPath() + "\"))"; + } + + @Override + public Element findElement() { + if (null != getParent()) { + Element parentElement = getParent().findElement(); + if (null == parentElement) { + // broken path - possibly removed parent + return null; + } + Element element = getLocator().getElementByPathStartingAt( + getPath(), parentElement); + return element; + } else { + Element element = getLocator().getElementByPath(getPath()); + return element; + } + } + } + + /** + * Element identifier based locator path. + *

+ * Identifier paths never have a parent and the identifiers should be unique + * within the context of the {@link ComponentLocator}/page. + */ + private static class IdSelectorPath extends SelectorPath { + private final String id; + + /** + * Creates an identifier based {@link SelectorPath}. The identifier + * should not contain the old "PID_S" prefix. + * + * @param id + * @param locator + */ + public IdSelectorPath(String id, ComponentLocator locator) { + super(locator); + this.id = id; + } + + /** + * Returns the ID in the DOM used to identify the element. + * + * @return Vaadin debug ID or equivalent + */ + public String getId() { + return id; + } + + @Override + public String getJUnitSelector(String context) { + return context + ".findElement(By.id(\"" + getId() + "\"))"; + } + + @Override + public Element findElement() { + // this also works for IDs + return getLocator().getElementByPath("PID_S" + getId()); + } + } + + /** + * Common base class for Vaadin selector paths (By.vaadin(...)). + */ + private static abstract class AbstractVaadinSelectorPath extends + SelectorPath { + + protected AbstractVaadinSelectorPath(SelectorPath parent, + ComponentLocator locator) { + super(parent, locator); + } + + /** + * Returns the {@link ComponentLocator} path of the element relative to + * the parent path. + * + * @return path of the element for By.vaadin(...) + */ + protected abstract String getPath(); + + @Override + public String getJUnitSelector(String context) { + return context + ".findElement(By.vaadin(\"" + getPath() + "\"))"; + } + + @Override + public Element findElement() { + if (null != getParent()) { + Element parentElement = getParent().findElement(); + Element element = getLocator().getElementByPathStartingAt( + getPath(), parentElement); + return element; + } else { + return getLocator().getElementByPath(getPath()); + } + } + + } + + /** + * TestBench selector path for Vaadin widgets. These selectors are based on + * the widget class and either the index among the widgets of that type in + * the parent or the widget caption. + */ + private static class VaadinSelectorPath extends AbstractVaadinSelectorPath { + private final String widgetClass; + private final String widgetCaption; + // negative for no index + private final int widgetIndex; + private String subPart; + + /** + * Creates a Vaadin {@link SelectorPath}. The path identifies an element + * of a given type under its parent based on either its caption or its + * index (if both are given, only the caption is used). See also + * {@link ComponentLocator} for more details. + * + * @param widgetClass + * client-side widget class + * @param widgetCaption + * caption of the widget - null to use the index instead + * @param widgetIndex + * index of the widget of the type within its parent, used + * only if the caption is not given + * @param parent + * parent {@link SelectorPath} or null + * @param locator + * component locator to use to find the corresponding + * {@link Element} + */ + public VaadinSelectorPath(String widgetClass, String widgetCaption, + int widgetIndex, SelectorPath parent, ComponentLocator locator) { + super(parent, locator); + this.widgetClass = widgetClass; + this.widgetCaption = widgetCaption; + this.widgetIndex = widgetIndex; + } + + /** + * Returns the widget type used to identify the element. + * + * @return Vaadin widget class + */ + public String getWidgetClass() { + return widgetClass; + } + + /** + * Returns the widget caption to look for or null if index is used + * instead. + * + * @return widget caption to match + */ + public String getWidgetCaption() { + return widgetCaption; + } + + /** + * Returns the index of the widget of that type within its parent - only + * used if caption is null. + * + * @return widget index + */ + public int getWidgetIndex() { + return widgetIndex; + } + + /** + * Returns the sub-part string (e.g. row and column identifiers within a + * table) used to identify a part of a component. See + * {@link ComponentLocator} and especially Vaadin selectors for more + * information. + * + * @return sub-part string or null if none + */ + public String getSubPart() { + return subPart; + } + + /** + * Sets the sub-part string (e.g. row and column identifiers within a + * table) used to identify a part of a component. See + * {@link ComponentLocator} and especially Vaadin selectors for more + * information. + * + * @param subPart + * sub-part string to use or null for none + */ + public void setSubPart(String subPart) { + this.subPart = subPart; + } + + @Override + protected String getPath() { + return "/" + getWidgetClass() + getIndexString(false) + + getSubPartPostfix(); + } + + private String getIndexString(boolean escapeQuotes) { + if (null != getWidgetCaption()) { + if (escapeQuotes) { + return "[caption=\\\"" + widgetCaption + "\\\"]"; + } else { + return "[caption=\"" + widgetCaption + "\"]"; + } + } else if (widgetIndex >= 0) { + return "[" + getWidgetIndex() + "]"; + } else { + return ""; + } + } + + private String getSubPartPostfix() { + String subPartString = ""; + if (null != getSubPart()) { + subPartString = SUBPART_SEPARATOR + getSubPart(); + } + return subPartString; + } + } + + /** + * TestBench selector path for Vaadin widgets, always using a + * By.vaadin(path) rather than other convenience methods. + */ + private static class ByVaadinSelectorPath extends + AbstractVaadinSelectorPath { + private final String path; + + /** + * Vaadin selector path for an exact path (including any preceding + * slash). + * + * @param path + * path of the element (normally with a leading slash), not + * null + * @param parent + * parent selector path or null if none + * @param locator + * ComponentLocator to use to find the corresponding element + */ + public ByVaadinSelectorPath(String path, SelectorPath parent, + ComponentLocator locator) { + super(parent, locator); + this.path = path; + } + + /** + * Returns the By.vaadin(...) path relative to the parent element. + * + * @return relative path string + */ + @Override + public String getPath() { + return path; + } + } +} \ No newline at end of file diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java index a283b18912..efab5ac11f 100644 --- a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -15,6 +15,9 @@ */ package com.vaadin.client.debug.internal; +import java.util.HashMap; +import java.util.Map; + import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; @@ -38,12 +41,11 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.ValueMap; -import com.vaadin.client.componentlocator.ComponentLocator; /** * Provides functionality for picking selectors for Vaadin TestBench. * - * @since 7.1.4 + * @since 7.1.x * @author Vaadin Ltd */ public class TestBenchSection implements Section { @@ -51,47 +53,46 @@ public class TestBenchSection implements Section { /** * Selector widget showing a selector in a program-usable form. */ - private static class SelectorWidget extends HTML { - private static int selectorIndex = 1; - final private String path; + private static class SelectorWidget extends HTML implements + MouseOverHandler, MouseOutHandler { + private static int selectorCounter = 1; + + final private SelectorPath path; + final private SelectorWidget parent; + final private int selectorIndex = selectorCounter++; - public SelectorWidget(final String path) { + public SelectorWidget(final SelectorPath path, + final SelectorWidget parent) { this.path = path; + this.parent = parent; + + String parentString = (parent != null) ? ("element" + parent.selectorIndex) + : "getDriver()"; String html = "

" - + Util.escapeHTML("WebElement element" + (selectorIndex++) - + " = getDriver().findElement(By.vaadin(\"" + path - + "\"));") + "
"; + + Util.escapeHTML("WebElement element" + selectorIndex + + " = " + path.getJUnitSelector(parentString) + ";") + + ""; setHTML(html); - addMouseOverHandler(new MouseOverHandler() { - @Override - public void onMouseOver(MouseOverEvent event) { - for (ApplicationConnection a : ApplicationConfiguration - .getRunningApplications()) { - Element element = new ComponentLocator(a) - .getElementByPath(SelectorWidget.this.path); - ComponentConnector connector = Util - .getConnectorForElement(a, a.getUIConnector() - .getWidget(), element); - if (connector == null) { - connector = Util.getConnectorForElement(a, - RootPanel.get(), element); - } - if (connector != null) { - Highlight.showOnly(connector); - break; - } - } - } - }); - addMouseOutHandler(new MouseOutHandler() { - @Override - public void onMouseOut(MouseOutEvent event) { - Highlight.hideAll(); - } - }); + addMouseOverHandler(this); + addMouseOutHandler(this); + } + + @Override + public void onMouseOver(MouseOverEvent event) { + ApplicationConnection a = path.getLocator().getClient(); + Element element = path.findElement(); + if (null != element) { + Highlight.hideAll(); + Highlight.show(element); + } + } + + @Override + public void onMouseOut(MouseOutEvent event) { + Highlight.hideAll(); } } @@ -101,7 +102,10 @@ public class TestBenchSection implements Section { private final FlowPanel content = new FlowPanel(); private final HierarchyPanel hierarchyPanel = new HierarchyPanel(); + private final FlowPanel selectorPanel = new FlowPanel(); + // map from full path to SelectorWidget to enable reuse of old selectors + private Map selectorWidgets = new HashMap(); private final FlowPanel controls = new FlowPanel(); @@ -208,34 +212,28 @@ public class TestBenchSection implements Section { } private void pickSelector(ServerConnector connector, Element element) { - String path = findTestBenchSelector(connector, element); + SelectorPath path = SelectorPath.findTestBenchSelector(connector, + element); - if (null != path && !path.isEmpty()) { - selectorPanel.add(new SelectorWidget(path)); - } + addSelectorWidgets(path); } - private String findTestBenchSelector(ServerConnector connector, - Element element) { - String path = null; - ApplicationConnection connection = connector.getConnection(); - if (connection != null) { - if (null == element) { - // try to find the root element of the connector - if (connector instanceof ComponentConnector) { - Widget widget = ((ComponentConnector) connector) - .getWidget(); - if (widget != null) { - element = widget.getElement(); - } - } - } - if (null != element) { - path = new ComponentLocator(connection) - .getPathForElement(element); - } + private SelectorWidget addSelectorWidgets(SelectorPath path) { + // add selector widgets recursively from root towards children, reusing + // old ones + SelectorPath parent = path.getParent(); + SelectorWidget parentWidget = null; + if (null != parent) { + parentWidget = addSelectorWidgets(parent); + } + SelectorWidget widget = selectorWidgets.get(path); + if (null == widget) { + // the parent has already been added above + widget = new SelectorWidget(path, parentWidget); + selectorWidgets.put(path, widget); + selectorPanel.add(widget); } - return path; + return widget; } private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { -- cgit v1.2.3 From 90626d3583f04800c02e6c7856aac0921c6c2adb Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Fri, 11 Oct 2013 14:19:52 +0300 Subject: Improve Calculator test application (#12744) Change-Id: Ib65ade5ecc589717e68e34b7469b5bae3c58786d --- .../vaadin/tests/application/calculator/Calc.java | 90 ++++++++++++++++++++-- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/uitest/src/com/vaadin/tests/application/calculator/Calc.java b/uitest/src/com/vaadin/tests/application/calculator/Calc.java index 7d080adfa6..7911556f4e 100644 --- a/uitest/src/com/vaadin/tests/application/calculator/Calc.java +++ b/uitest/src/com/vaadin/tests/application/calculator/Calc.java @@ -25,23 +25,100 @@ import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.GridLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; -import com.vaadin.ui.TextArea; +import com.vaadin.ui.Table; +import com.vaadin.ui.Table.ColumnHeaderMode; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; @SuppressWarnings("serial") public class Calc extends AbstractTestUI { - private class Log extends TextArea { + private class Log extends VerticalLayout { + + private Table table; + private Button addCommentButton; + private int line = 0; public Log() { super(); + + table = new Table(); + table.setSizeFull(); + setWidth("200px"); + setHeight("100%"); + + table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); + table.addContainerProperty("Operation", String.class, ""); + + addComponent(table); + + addCommentButton = new Button("Add Comment"); + addCommentButton.setWidth("100%"); + + addCommentButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + + final Window w = new Window("Add comment"); + VerticalLayout vl = new VerticalLayout(); + vl.setMargin(true); + + final TextField tf = new TextField(); + tf.setSizeFull(); + vl.addComponent(tf); + + HorizontalLayout hl = new HorizontalLayout(); + + Button okButton = new Button("OK"); + okButton.setWidth("100%"); + okButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + addRow("[ " + tf.getValue() + " ]"); + tf.setValue(""); + w.close(); + removeWindow(w); + } + }); + + Button cancelButton = new Button("Cancel"); + cancelButton.setWidth("100%"); + cancelButton.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + tf.setValue(""); + w.close(); + removeWindow(w); + } + }); + + hl.addComponent(cancelButton); + hl.addComponent(okButton); + hl.setSpacing(true); + hl.setWidth("100%"); + + vl.addComponent(hl); + vl.setSpacing(true); + + w.setContent(vl); + addWindow(w); + } + }); + + addComponent(addCommentButton); + + setExpandRatio(table, 1); + setSpacing(true); } public void addRow(String row) { - setValue(getValue() + "\n" + row); + Integer id = ++line; + table.addItem(new Object[] { row }, id); + table.setCurrentPageFirstItemIndex(line + 1); } + } // All variables are automatically stored in the session. @@ -51,7 +128,7 @@ public class Calc extends AbstractTestUI { private VerticalLayout topLayout = new VerticalLayout(); // User interface components - private final TextField display = new TextField("0.0"); + private final TextField display = new TextField(); private final Log log = new Log(); @@ -137,10 +214,12 @@ public class Calc extends AbstractTestUI { topLayout.addComponent(horizontalLayout); // Create a result label that over all 4 columns in the first row + layout.setSpacing(true); layout.addComponent(display, 0, 0, 3, 0); layout.setComponentAlignment(display, Alignment.MIDDLE_RIGHT); - display.setSizeUndefined(); + display.setSizeFull(); display.setId("display"); + display.setValue("0.0"); // The operations for the calculator in the order they appear on the // screen (left to right, top to bottom) @@ -151,7 +230,6 @@ public class Calc extends AbstractTestUI { // Create a button and use this application for event handling Button button = new Button(caption); - button.setHeight("30px"); button.setWidth("40px"); button.addClickListener(new ClickListener() { @Override -- cgit v1.2.3 From 29ec642eb1321f58bbcfbde79c1f1362cf1e3f9b Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 31 Oct 2013 11:56:04 +0200 Subject: Produce TB4 style selectors in debug window (#12694) Change-Id: Ie2e5cc48c493d065221a30fa6d2058f7a61f0274 --- .../vaadin/client/debug/internal/SelectorPath.java | 69 +++++++++++++++++++--- .../client/debug/internal/TestBenchSection.java | 6 +- .../com/vaadin/client/metadata/TypeDataStore.java | 16 +++++ 3 files changed, 81 insertions(+), 10 deletions(-) diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java index d4502daeda..2ad77a246b 100644 --- a/client/src/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java @@ -16,18 +16,21 @@ package com.vaadin.client.debug.internal; +import com.google.gwt.core.client.JsArrayString; import com.google.gwt.regexp.shared.MatchResult; import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; +import com.vaadin.client.FastStringSet; import com.vaadin.client.ServerConnector; import com.vaadin.client.Util; import com.vaadin.client.componentlocator.ComponentLocator; import com.vaadin.client.componentlocator.VaadinFinderLocatorStrategy; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; +import com.vaadin.client.metadata.TypeDataStore; import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.SubPartAware; @@ -108,7 +111,8 @@ public abstract class SelectorPath { * in a test. * * @param context - * the context to use (usually "getDriver()" or a variable name) + * the context to use (usually a variable name) or null for + * default * @return string to add in a JUnit test */ public abstract String getJUnitSelector(String context); @@ -551,7 +555,10 @@ public abstract class SelectorPath { @Override public String getJUnitSelector(String context) { - return context + ".findElement(By.xpath(\"" + getPath() + "\"))"; + // use driver by default + String contextString = null != context ? context : "getDriver()"; + return contextString + ".findElement(By.xpath(\"" + getPath() + + "\"))"; } @Override @@ -604,7 +611,8 @@ public abstract class SelectorPath { @Override public String getJUnitSelector(String context) { - return context + ".findElement(By.id(\"" + getId() + "\"))"; + String contextPart = null != context ? ", " + context : ""; + return "getElementById(\"" + getId() + "\"" + contextPart + ")"; } @Override @@ -633,11 +641,6 @@ public abstract class SelectorPath { */ protected abstract String getPath(); - @Override - public String getJUnitSelector(String context) { - return context + ".findElement(By.vaadin(\"" + getPath() + "\"))"; - } - @Override public Element findElement() { if (null != getParent()) { @@ -745,6 +748,50 @@ public abstract class SelectorPath { this.subPart = subPart; } + @Override + public String getJUnitSelector(String context) { + String componentClass = getComponentClass(); + String contextPart = null != context ? ", " + context : ""; + // TODO update after subpart API finished + if (null != getSubPart() || null == componentClass) { + return "getElementByPath(\"" + getPath() + "\"" + contextPart + + ")"; + } else if (null != getWidgetCaption()) { + return "getElementByCaption(" + componentClass + ".class, \"" + + getWidgetCaption() + "\"" + contextPart + ")"; + } else if (getWidgetIndex() >= 0) { + return "getElementByIndex(" + componentClass + ".class, " + + getWidgetIndex() + contextPart + ")"; + } else { + return "getElement(" + componentClass + ".class" + contextPart + + ")"; + } + } + + /** + * Returns the Vaadin server side component class to use for a widget + * class. + * + * @return fully qualified server side class name, null if unable to + * determine it + */ + private String getComponentClass() { + ComponentConnector connector = Util.findPaintable(getLocator() + .getClient(), findElement()); + Class connectorClass = connector + .getClass(); + FastStringSet identifiers = TypeDataStore.get().findIdentifiersFor( + connectorClass); + JsArrayString ids = identifiers.dump(); + if (ids.length() == 1) { + return ids.get(0); + } else { + return null; + } + } + + // these are used only to locate components on the client side by path + @Override protected String getPath() { return "/" + getWidgetClass() + getIndexString(false) @@ -800,6 +847,12 @@ public abstract class SelectorPath { this.path = path; } + @Override + public String getJUnitSelector(String context) { + String contextPart = null != context ? ", " + context : ""; + return "getElementByPath(\"" + getPath() + "\"" + contextPart + ")"; + } + /** * Returns the By.vaadin(...) path relative to the parent element. * diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java index efab5ac11f..462309768f 100644 --- a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -67,7 +67,7 @@ public class TestBenchSection implements Section { this.parent = parent; String parentString = (parent != null) ? ("element" + parent.selectorIndex) - : "getDriver()"; + : null; String html = "
" @@ -215,7 +215,9 @@ public class TestBenchSection implements Section { SelectorPath path = SelectorPath.findTestBenchSelector(connector, element); - addSelectorWidgets(path); + if (null != path) { + addSelectorWidgets(path); + } } private SelectorWidget addSelectorWidgets(SelectorPath path) { diff --git a/client/src/com/vaadin/client/metadata/TypeDataStore.java b/client/src/com/vaadin/client/metadata/TypeDataStore.java index aa37d75dc8..649f018f95 100644 --- a/client/src/com/vaadin/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/client/metadata/TypeDataStore.java @@ -69,6 +69,22 @@ public class TypeDataStore { return class1; } + // this is a very inefficient implementation for getting all the identifiers + // for a class + public FastStringSet findIdentifiersFor(Class type) { + FastStringSet result = FastStringSet.create(); + + JsArrayString keys = identifiers.getKeys(); + for (int i = 0; i < keys.length(); i++) { + String key = keys.get(i); + if (identifiers.get(key) == type) { + result.add(key); + } + } + + return result; + } + public static Type getType(Class clazz) { return new Type(clazz); } -- cgit v1.2.3 From 5b8b824942019ab6fc9d70263c22de3644f1f785 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Tue, 5 Nov 2013 15:58:28 +0200 Subject: Fix TB3 style selectors (#12902, #12904) Change-Id: Ia1ad464b6890248e700ed2dbea03746671210eee --- client/src/com/vaadin/client/Util.java | 1 + .../client/componentlocator/ComponentLocator.java | 58 +++--------------- .../componentlocator/LegacyLocatorStrategy.java | 69 +++++++++++++--------- .../VaadinFinderLocatorStrategy.java | 14 +++-- 4 files changed, 59 insertions(+), 83 deletions(-) diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 8972670232..c0e5f621af 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -855,6 +855,7 @@ public class Util { * @param class1 * the Widget type to seek for */ + @SuppressWarnings("unchecked") public static T findWidget(Element element, Class class1) { if (element != null) { diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index e319650d23..6f6e52c0e1 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -20,7 +20,6 @@ import java.util.List; import com.google.gwt.user.client.Element; import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.BrowserInfo; /** * ComponentLocator provides methods for generating a String locator for a given @@ -34,14 +33,12 @@ import com.vaadin.client.BrowserInfo; public class ComponentLocator { private final List locatorStrategies; - private final LegacyLocatorStrategy legacyLocatorStrategy = new LegacyLocatorStrategy( - this); /** * Reference to ApplicationConnection instance. */ - private ApplicationConnection client; + private final ApplicationConnection client; /** * Construct a ComponentLocator for the given ApplicationConnection. @@ -51,8 +48,8 @@ public class ComponentLocator { */ public ComponentLocator(ApplicationConnection client) { this.client = client; - locatorStrategies = Arrays.asList( - new VaadinFinderLocatorStrategy(this), legacyLocatorStrategy); + locatorStrategies = Arrays.asList(new VaadinFinderLocatorStrategy( + client), new LegacyLocatorStrategy(client)); } /** @@ -74,44 +71,13 @@ public class ComponentLocator { * String locator could not be created. */ public String getPathForElement(Element targetElement) { - // For now, only use the legacy locator to find paths - return legacyLocatorStrategy - .getPathForElement(getElement(targetElement)); - } - - /** - * Returns the element passed to the method. Or in case of Firefox 15, - * returns the real element that is in the DOM instead of the element passed - * to the method (which is the same element but not ==). - * - * @param targetElement - * the element to return - * @return the element passed to the method - */ - private Element getElement(Element targetElement) { - if (targetElement == null) { - return null; - } - - if (!BrowserInfo.get().isFirefox()) { - return targetElement; - } - - if (BrowserInfo.get().getBrowserMajorVersion() != 15) { - return targetElement; - } - - // Firefox 15, you make me sad - if (targetElement.getNextSibling() != null) { - return (Element) targetElement.getNextSibling() - .getPreviousSibling(); - } - if (targetElement.getPreviousSibling() != null) { - return (Element) targetElement.getPreviousSibling() - .getNextSibling(); + for (LocatorStrategy strategy : locatorStrategies) { + String path = strategy.getPathForElement(targetElement); + if (null != path) { + return path; + } } - // No siblings so this is the only child - return (Element) targetElement.getParentNode().getChild(0); + return null; } /** @@ -127,9 +93,6 @@ public class ComponentLocator { * could not be located. */ public Element getElementByPath(String path) { - // As LegacyLocatorStrategy always is the last item in the list, it is - // always used as a last resort if no other strategies claim - // responsibility for the path syntax. for (LocatorStrategy strategy : locatorStrategies) { Element element = strategy.getElementByPath(path); if (null != element) { @@ -153,9 +116,6 @@ public class ComponentLocator { * could not be located. */ public Element getElementByPathStartingAt(String path, Element root) { - // As LegacyLocatorStrategy always is the last item in the list, it is - // always used as a last resort if no other strategies claim - // responsibility for the path syntax. for (LocatorStrategy strategy : locatorStrategies) { Element element = strategy.getElementByPathStartingAt(path, root); if (null != element) { diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index ed70486ff5..5f5e0279ce 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -25,6 +25,7 @@ import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorMap; import com.vaadin.client.ServerConnector; @@ -53,7 +54,7 @@ import com.vaadin.shared.communication.SharedState; * @author Vaadin Ltd */ public class LegacyLocatorStrategy implements LocatorStrategy { - private final ComponentLocator componentLocator; + /** * Separator used in the String locator between a parent and a child widget. */ @@ -70,14 +71,16 @@ public class LegacyLocatorStrategy implements LocatorStrategy { */ static final String ROOT_ID = "Root"; - public LegacyLocatorStrategy(ComponentLocator componentLocator) { - this.componentLocator = componentLocator; + private final ApplicationConnection client; + + public LegacyLocatorStrategy(ApplicationConnection clientConnection) { + client = clientConnection; } @Override public String getPathForElement(Element targetElement) { - ComponentConnector connector = Util.findPaintable( - componentLocator.getClient(), targetElement); + ComponentConnector connector = Util + .findPaintable(client, targetElement); Widget w = null; if (connector != null) { @@ -189,14 +192,12 @@ public class LegacyLocatorStrategy implements LocatorStrategy { String parts[] = path.split(LegacyLocatorStrategy.SUBPART_SEPARATOR, 2); String widgetPath = parts[0]; - Widget baseWidget = null; - if (null != baseElement) { - // Note that this only works if baseElement can be mapped to a - // widget to which the path is relative. Otherwise, the current - // implementation simply interprets the path as if baseElement was - // null. - baseWidget = Util.findWidget(baseElement, null); - } + // Note that this only works if baseElement can be mapped to a + // widget to which the path is relative. Otherwise, the current + // implementation simply interprets the path as if baseElement was + // null. + Widget baseWidget = Util.findWidget(baseElement, null); + Widget w = getWidgetFromPath(widgetPath, baseWidget); if (w == null || !Util.isAttachedAndDisplayed(w)) { return null; @@ -209,7 +210,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { // Contains dom reference to a sub element of the widget String subPath = widgetPath.substring(pos); - return getElementByDOMPath(baseElement, subPath); + return getElementByDOMPath(w.getElement(), subPath); } else if (parts.length == 2) { if (w instanceof SubPartAware) { return ((SubPartAware) w).getSubPartElement(parts[1]); @@ -283,7 +284,8 @@ public class LegacyLocatorStrategy implements LocatorStrategy { String parts[] = path.split(PARENTCHILD_SEPARATOR); Element element = baseElement; - for (String part : parts) { + for (int i = 0, l = parts.length; i < l; ++i) { + String part = parts[i]; if (part.startsWith("domChild[")) { String childIndexString = part.substring("domChild[".length(), part.length() - 1); @@ -311,6 +313,14 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return null; } + } else { + + path = parts[i]; + for (int j = i + 1; j < l; ++j) { + path += PARENTCHILD_SEPARATOR + parts[j]; + } + + return getElementByPathStartingAt(path, element); } } @@ -386,10 +396,10 @@ public class LegacyLocatorStrategy implements LocatorStrategy { } else if (w instanceof VUI) { return ""; } else if (w instanceof VWindow) { - Connector windowConnector = ConnectorMap.get( - componentLocator.getClient()).getConnector(w); - List subWindowList = componentLocator.getClient() - .getUIConnector().getSubWindows(); + Connector windowConnector = ConnectorMap.get(client) + .getConnector(w); + List subWindowList = client.getUIConnector() + .getSubWindows(); int indexOfSubWindow = subWindowList.indexOf(windowConnector); return PARENTCHILD_SEPARATOR + "VWindow[" + indexOfSubWindow + "]"; } else if (w instanceof RootPanel) { @@ -442,6 +452,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { * @return The Widget identified by the String locator or null if the widget * could not be identified. */ + @SuppressWarnings("unchecked") private Widget getWidgetFromPath(String path, Widget baseWidget) { Widget w = baseWidget; String parts[] = path.split(PARENTCHILD_SEPARATOR); @@ -452,17 +463,19 @@ public class LegacyLocatorStrategy implements LocatorStrategy { if (part.equals(ROOT_ID)) { w = RootPanel.get(); } else if (part.equals("")) { - w = componentLocator.getClient().getUIConnector().getWidget(); + if (w == null) { + w = client.getUIConnector().getWidget(); + } } else if (w == null) { String id = part; // Must be old static pid (PID_S*) - ServerConnector connector = ConnectorMap.get( - componentLocator.getClient()).getConnector(id); + ServerConnector connector = ConnectorMap.get(client) + .getConnector(id); if (connector == null) { // Lookup by component id // TODO Optimize this - connector = findConnectorById(componentLocator.getClient() - .getUIConnector(), id.substring(5)); + connector = findConnectorById(client.getUIConnector(), + id.substring(5)); } if (connector instanceof ComponentConnector) { @@ -516,7 +529,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { if (w instanceof VOverlay && "VCalendarPanel".equals(widgetClassName)) { // Vaadin 7.1 adds a wrapper for datefield popups - parent = (Iterable) ((Iterable) parent).iterator() + parent = (Iterable) ((Iterable) parent).iterator() .next(); } /* @@ -576,8 +589,8 @@ public class LegacyLocatorStrategy implements LocatorStrategy { * compatibility */ if (widgetClassName.equals("VWindow")) { - List windows = componentLocator - .getClient().getUIConnector().getSubWindows(); + List windows = client.getUIConnector() + .getSubWindows(); List windowWidgets = new ArrayList( windows.size()); for (WindowConnector wc : windows) { @@ -585,7 +598,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { } iterator = windowWidgets.iterator(); } else if (widgetClassName.equals("VContextMenu")) { - return componentLocator.getClient().getContextMenu(); + return client.getContextMenu(); } else { iterator = (Iterator) parent.iterator(); } diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 264574788c..3390de86a4 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -21,6 +21,7 @@ import java.util.List; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; import com.vaadin.client.Util; import com.vaadin.client.metadata.NoDataException; @@ -51,10 +52,11 @@ import com.vaadin.shared.AbstractComponentState; public class VaadinFinderLocatorStrategy implements LocatorStrategy { public static final String SUBPART_SEPARATOR = "#"; - private ComponentLocator componentLocator; - public VaadinFinderLocatorStrategy(ComponentLocator componentLocator) { - this.componentLocator = componentLocator; + private final ApplicationConnection client; + + public VaadinFinderLocatorStrategy(ApplicationConnection clientConnection) { + client = clientConnection; } /** @@ -77,8 +79,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { if (path.startsWith("//VNotification")) { return findNotificationByPath(path); } - return getElementByPathStartingAtConnector(path, componentLocator - .getClient().getUIConnector()); + return getElementByPathStartingAtConnector(path, + client.getUIConnector()); } /** @@ -112,7 +114,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { @Override public Element getElementByPathStartingAt(String path, Element root) { return getElementByPathStartingAtConnector(path, - Util.findPaintable(componentLocator.getClient(), root)); + Util.findPaintable(client, root)); } /** -- cgit v1.2.3 From d70d6a2cac7271b2f49805611d77cd3f7eb431f1 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Wed, 6 Nov 2013 16:15:52 +0200 Subject: Make component predicate matches exact (#12913) Change-Id: Ia9a938977437a2188a6f5b207789058abce62965 --- .../vaadin/client/componentlocator/LegacyLocatorStrategy.java | 11 ++++++++++- .../client/componentlocator/VaadinFinderLocatorStrategy.java | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 5f5e0279ce..5123a57e5d 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -499,7 +499,16 @@ public class LegacyLocatorStrategy implements LocatorStrategy { String widgetClassName = split[0]; String indexString = split[1].substring(0, split[1].length() - 1); - int widgetPosition = Integer.parseInt(indexString); + + int widgetPosition; + try { + widgetPosition = Integer.parseInt(indexString); + } catch (NumberFormatException e) { + // We've probably been fed a new-style Vaadin locator with a + // string-form predicate, that doesn't match anything in the + // search space. + return null; + } // AbsolutePanel in GridLayout has been removed -> skip it if (w instanceof VGridLayout diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 3390de86a4..96374e898a 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -241,6 +241,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { } } + return null; + } else { int index = Integer.valueOf(predicateString); return index < potentialMatches.size() ? potentialMatches -- cgit v1.2.3 From d2e7b366ef40bd5a27ba4693eba8d80ae8fc4f77 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 7 Nov 2013 11:32:28 +0200 Subject: Support special characters in quotes in locators (#12738). Change-Id: I5674bfdab3a5ff3ff9799178bbf9e187fa7ea544 --- .../VaadinFinderLocatorStrategy.java | 34 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 96374e898a..95b2745bf8 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -192,9 +192,10 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * @return The predicate string for the path fragment or null if none. */ private String extractPredicateString(String pathFragment) { - int ixOpenBracket = pathFragment.indexOf('['); + int ixOpenBracket = indexOfIgnoringQuotes(pathFragment, '['); if (ixOpenBracket >= 0) { - int ixCloseBracket = pathFragment.indexOf(']', ixOpenBracket); + int ixCloseBracket = indexOfIgnoringQuotes(pathFragment, ']', + ixOpenBracket); return pathFragment.substring(ixOpenBracket + 1, ixCloseBracket); } return null; @@ -376,7 +377,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * the path. */ private String[] splitFirstFragmentFromTheRest(String path) { - int ixOfSlash = path.indexOf('/'); + int ixOfSlash = indexOfIgnoringQuotes(path, '/'); if (ixOfSlash > 0) { return new String[] { path.substring(0, ixOfSlash), path.substring(ixOfSlash) }; @@ -384,4 +385,31 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return new String[] { path }; } + private int indexOfIgnoringQuotes(String str, char find) { + return indexOfIgnoringQuotes(str, find, 0); + } + + private int indexOfIgnoringQuotes(String str, char find, int startingAt) { + boolean quote = false; + String quoteChars = "'\""; + char currentQuote = '"'; + for (int i = startingAt; i < str.length(); ++i) { + char cur = str.charAt(i); + if (quote) { + if (cur == currentQuote) { + quote = !quote; + } + continue; + } else if (cur == find) { + return i; + } else { + if (quoteChars.indexOf(cur) >= 0) { + currentQuote = cur; + quote = !quote; + } + } + } + return -1; + } + } -- cgit v1.2.3 From 23e5683e14489c23708c067fe62e4009914f1a11 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Mon, 18 Nov 2013 18:11:40 +0200 Subject: Fixed TabSheet keyboard navigation (#12971) Change-Id: Ibb155946811eb43829c6c200fa83c5eaa1d7cdfa --- client/src/com/vaadin/client/ui/VTabsheet.java | 6 +-- .../components/tabsheet/TabsheetScrollingTest.java | 60 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index c64216d49f..68a685965b 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -421,10 +421,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } int index = getWidgetIndex(caption.getParent()); - // IE needs explicit focus() - if (BrowserInfo.get().isIE()) { - getTabsheet().focus(); - } getTabsheet().onTabSelected(index); } @@ -619,6 +615,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable, client.updateVariable(id, "selected", tabKeys.get(tabIndex) .toString(), true); waitingForResponse = true; + + tb.getTab(tabIndex).focus(); // move keyboard focus to active tab } // Note that we return true when tabIndex == activeTabIndex; the active // tab could be selected, it's just a no-op. diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java new file mode 100644 index 0000000000..1670963b9b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabsheetScrollingTest.java @@ -0,0 +1,60 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tabsheet; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabsheetScrollingTest extends MultiBrowserTest { + + @Test + public void keyboardScrolling() { + openTestURL(); + getTab(1).click(); + for (int i = 0; i < 10; i++) { + sendKey(Keys.ARROW_RIGHT); + } + Assert.assertEquals("Hide this tab (21)", getHideButtonText()); + } + + private WebElement getTab(int index) { + return getDriver().findElement( + By.vaadin("/VVerticalLayout[0]/Slot[1]" + + "/VVerticalLayout[0]/Slot[0]/VTabsheet[0]" + + "/domChild[0]/domChild[0]/domChild[0]" + + "/domChild[0]/domChild[" + index + "]")); + + } + + private String getHideButtonText() { + WebElement buttonCaption = getDriver().findElement( + By.vaadin("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]" + + "/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]" + + "/VButton[0]/domChild[0]/domChild[0]")); + return buttonCaption.getText(); + } + + private void sendKey(Keys key) { + new Actions(getDriver()).sendKeys(key).perform(); + } + +} -- cgit v1.2.3 From b7e184e30f8e5f1456344f3360c7e8e326c5ad2b Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Wed, 20 Nov 2013 17:08:16 +0200 Subject: Cleaned up the implementation of VTabsheet.selectPreviousTab() Change-Id: I8e7fef3005173d7647b4dfda31f60978cbf5972a --- client/src/com/vaadin/client/ui/VTabsheet.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 68a685965b..85c28218f7 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -1164,12 +1164,9 @@ public class VTabsheet extends VTabsheetBase implements Focusable, activeTabIndex = newTabIndex; if (isScrolledTabs()) { // Scroll until the new active tab is visible - int newScrollerIndex = scrollerIndex; - while (tb.getTab(activeTabIndex).getAbsoluteLeft() < getAbsoluteLeft() - && newScrollerIndex != -1) { - newScrollerIndex = tb.scrollLeft(newScrollerIndex); + while (!tb.getTab(activeTabIndex).isVisible()) { + scrollerIndex = tb.scrollLeft(scrollerIndex); } - scrollerIndex = newScrollerIndex; updateTabScroller(); } } -- cgit v1.2.3 From 9ab700417ee5fe54329beee3130e6303f9420389 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Thu, 31 Oct 2013 15:38:51 +0200 Subject: Fixed TabSheet tab keyboard focus issues (#12343) Change-Id: Ifacf4208e5124665115d13928463d87922282461 --- client/src/com/vaadin/client/ui/VTabsheet.java | 58 +++++++++++++++----------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 85c28218f7..1275308ed7 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -118,7 +118,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, setStyleName(td, TD_CLASSNAME); div = DOM.createDiv(); - focusImpl.setTabIndex(td, -1); + setTabulatorIndex(-1); setStyleName(div, DIV_CLASSNAME); DOM.appendChild(td, div); @@ -182,7 +182,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } public void setTabulatorIndex(int tabIndex) { - focusImpl.setTabIndex(td, tabIndex); + getElement().setTabIndex(tabIndex); } public boolean isClosable() { @@ -249,6 +249,17 @@ public class VTabsheet extends VTabsheetBase implements Focusable, public void blur() { focusImpl.blur(td); } + + public boolean isSelectable() { + VTabsheet ts = getTabsheet(); + if (ts.client == null || ts.disabled || ts.waitingForResponse) { + return false; + } + if (!isEnabledOnServer() || isHiddenOnServer()) { + return false; + } + return true; + } } public static class TabCaption extends VCaption { @@ -585,24 +596,14 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private String currentStyle; - /** - * @return Whether the tab could be selected or not. - */ - private boolean onTabSelected(final int tabIndex) { - Tab tab = tb.getTab(tabIndex); - if (client == null || disabled || waitingForResponse) { - return false; - } - if (!tab.isEnabledOnServer() || tab.isHiddenOnServer()) { - return false; - } + private void onTabSelected(final int tabIndex) { if (activeTabIndex != tabIndex) { tb.selectTab(tabIndex); // If this TabSheet already has focus, set the new selected tab // as focused. if (focusedTab != null) { - focusedTab = tab; + focusedTab = tb.getTab(tabIndex); } addStyleDependentName("loading"); @@ -618,9 +619,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, tb.getTab(tabIndex).focus(); // move keyboard focus to active tab } - // Note that we return true when tabIndex == activeTabIndex; the active - // tab could be selected, it's just a no-op. - return true; } public ApplicationConnection getApplicationConnection() { @@ -979,6 +977,13 @@ public class VTabsheet extends VTabsheetBase implements Focusable, SCROLLER_CLASSNAME + (scrolled ? "Prev" : "Prev-disabled")); DOM.setElementProperty(scrollerNext, "className", SCROLLER_CLASSNAME + (clipped ? "Next" : "Next-disabled")); + + // the active tab should be focusable if and only if it is visible + boolean isActiveTabVisible = scrollerIndex <= activeTabIndex + && !isClipped(tb.selected); + tb.selected.setTabulatorIndex(isActiveTabVisible ? tabulatorIndex + : -1); + } else { DOM.setStyleAttribute(scroller, "display", "none"); } @@ -1155,42 +1160,47 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private void selectPreviousTab() { int newTabIndex = activeTabIndex; + Tab newTab; // Find the previous visible and enabled tab if any. do { newTabIndex--; - } while (newTabIndex >= 0 && !onTabSelected(newTabIndex)); + newTab = tb.getTab(newTabIndex); + } while (newTabIndex >= 0 && !newTab.isSelectable()); if (newTabIndex >= 0) { - activeTabIndex = newTabIndex; if (isScrolledTabs()) { // Scroll until the new active tab is visible - while (!tb.getTab(activeTabIndex).isVisible()) { + while (!newTab.isVisible()) { scrollerIndex = tb.scrollLeft(scrollerIndex); } updateTabScroller(); } + onTabSelected(newTabIndex); + activeTabIndex = newTabIndex; } } private void selectNextTab() { int newTabIndex = activeTabIndex; + Tab newTab; // Find the next visible and enabled tab if any. do { newTabIndex++; - } while (newTabIndex < getTabCount() && !onTabSelected(newTabIndex)); + newTab = tb.getTab(newTabIndex); + } while (newTabIndex < getTabCount() && !newTab.isSelectable()); if (newTabIndex < getTabCount()) { - activeTabIndex = newTabIndex; if (isClippedTabs()) { // Scroll until the new active tab is completely visible int newScrollerIndex = scrollerIndex; - while (isClipped(tb.getTab(activeTabIndex)) - && newScrollerIndex != -1) { + while (isClipped(newTab) && newScrollerIndex != -1) { newScrollerIndex = tb.scrollRight(newScrollerIndex); } scrollerIndex = newScrollerIndex; updateTabScroller(); } + onTabSelected(newTabIndex); + activeTabIndex = newTabIndex; } } } -- cgit v1.2.3 From f4fa4e8ec53b0943635edf3f147680c9b9214db8 Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Tue, 26 Nov 2013 14:14:06 +0200 Subject: Normalize line endings Change-Id: I328a1d3505471c65681dccdaa1a342dbb9c9ab37 --- .../src/com/vaadin/sass/internal/parser/Parser.jj | 106 +++++++++++++++------ 1 file changed, 76 insertions(+), 30 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index d6861a8652..1c45d815a5 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -1669,13 +1669,20 @@ ArrayList arglist() : } JAVACODE -boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { +boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) +{ boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; - if(currentArgHasArguments) { - if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + + if(currentArgHasArguments) + { + if(hasNonOptionalArguments) + { + throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); } return hasNonOptionalArguments; - }else { return true; + }else + { + return true; } } @@ -1690,9 +1697,13 @@ VariableNode mixinArg() : { name=variableName() (< COLON > (< S >)* - ( first = nonVariableTerm(null) { - prev = first; } - (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) + ( + first = nonVariableTerm(null) + { + prev = first; + } + (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* + ) | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, prev, variable.image);} @@ -1879,39 +1890,66 @@ String listModifyDirectiveArgs(int nest) { t = getToken(1); String s = t.image; - if(t.kind == VARIABLE||t.kind == IDENT) { + if(t.kind == VARIABLE||t.kind == IDENT) + { list += s; - }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) + { int i = 2; Token temp = getToken(i); boolean isLast = true; while(temp.kind != SEMICOLON) - { if(temp.kind != RPARAN || temp.kind != S) - { isLast = false; } + { + if(temp.kind != RPARAN || temp.kind != S) + { + isLast = false; + } i++; temp = getToken(i); } - if(isLast) { return list; + if(isLast) + { + return list; } - } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); + } + else if(t.kind == STRING) + { + list += s.substring(1,s.length()).substring(0,s.length()-2); - }else if(t.kind == LPARAN) { nesting++; - if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + }else if(t.kind == LPARAN) + { + nesting++; + if(nesting > nest+1) + { + throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); } - }else if(t.kind == RPARAN) { nesting--; - if(nesting == 0) { + }else if(t.kind == RPARAN) + { + nesting--; + if(nesting == 0) + { return list; } - } else if(t.kind == COMMA) { - if(nesting == nest) { - return list; }else { - list += ","; } + } else if(t.kind == COMMA) + { + if(nesting == nest) + { + return list; + }else + { + list += ","; + } - }else if(t.kind == S) { - list += " "; } else if(t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", getLocator()); } - getNextToken(); + }else if(t.kind == S) + { + list += " "; + } else if(t.kind == LBRACE) + { + throw new CSSParseException("Invalid token,'{' found", getLocator()); + } + + getNextToken(); } } @@ -2303,14 +2341,20 @@ LexicalUnitImpl term(LexicalUnitImpl prev) : } } -LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { +LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : +{ LexicalUnitImpl result = null; - String varName = ""; } { + String varName = ""; +} +{ varName = variableName() {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, varName); return result;} } + prev, varName); return result;} +} -LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; +LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : +{ +LexicalUnitImpl result = null; Token n = null; char op = ' '; String varName; @@ -2433,7 +2477,9 @@ LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result | result=unicode(prev) ) ) ( )* { - return result; } } + return result; + } +} /** * Handle all CSS2 functions. -- cgit v1.2.3 From a705f8cc3fd5804e828b6647510795dbbb99eaa3 Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Mon, 25 Nov 2013 16:31:55 +0200 Subject: Mixins now accept an empty argument list in parentheses (#12992). Change-Id: If2484e2f289aa7039984df0d9a73ba595117462c --- .../vaadin/sass/internal/parser/CharStream.java | 2 +- .../com/vaadin/sass/internal/parser/Parser.java | 742 +++++++++++---------- .../src/com/vaadin/sass/internal/parser/Parser.jj | 17 +- .../src/com/vaadin/sass/internal/parser/Token.java | 2 +- .../vaadin/sass/internal/parser/TokenMgrError.java | 2 +- .../automatic/css/mixin-empty-paramlist.css | 15 + .../automatic/scss/mixin-empty-paramlist.scss | 28 + 7 files changed, 450 insertions(+), 358 deletions(-) create mode 100644 theme-compiler/tests/resources/automatic/css/mixin-empty-paramlist.css create mode 100644 theme-compiler/tests/resources/automatic/scss/mixin-empty-paramlist.scss diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java index c22f19451b..e43320453c 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java @@ -127,4 +127,4 @@ interface CharStream { void Done(); } -/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ +/* JavaCC - OriginalChecksum=18aae0a549695f0fec96a11297b442bb (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 679e696aa3..86d028a7d4 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -3545,34 +3545,41 @@ boolean isPseudoElement = false; ArrayList args = new ArrayList(); VariableNode arg; boolean hasNonOptionalArgument = false; - arg = mixinArg(); - label_97: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[145] = jj_gen; - break label_97; - } - jj_consume_token(COMMA); - label_98: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VARIABLE: + arg = mixinArg(); + label_97: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: + case COMMA: ; break; default: - jj_la1[146] = jj_gen; - break label_98; + jj_la1[145] = jj_gen; + break label_97; } - jj_consume_token(S); + jj_consume_token(COMMA); + label_98: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[146] = jj_gen; + break label_98; + } + jj_consume_token(S); + } + hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + arg = mixinArg(); } - hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); - arg = mixinArg(); - } hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + break; + default: + jj_la1[147] = jj_gen; + ; + } {if (true) return args;} throw new Error("Missing return statement in function"); } @@ -3613,7 +3620,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[147] = jj_gen; + jj_la1[148] = jj_gen; break label_99; } jj_consume_token(S); @@ -3637,14 +3644,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[148] = jj_gen; + jj_la1[149] = jj_gen; break label_101; } jj_consume_token(S); } break; default: - jj_la1[149] = jj_gen; + jj_la1[150] = jj_gen; ; } prev = nonVariableTerm(prev); @@ -3656,13 +3663,13 @@ boolean isPseudoElement = false; prev, variable.image); break; default: - jj_la1[150] = jj_gen; + jj_la1[151] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[151] = jj_gen; + jj_la1[152] = jj_gen; ; } VariableNode arg = new VariableNode(name, first, false); @@ -3675,100 +3682,43 @@ boolean isPseudoElement = false; LexicalUnitImpl first = null; LexicalUnitImpl next = null; LexicalUnitImpl prev = null; - first = term(null); - args.add(first); prev = first; - label_102: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case COLON: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - ; - break; - default: - jj_la1[152] = jj_gen; - break label_102; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_103: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[153] = jj_gen; - break label_103; - } - jj_consume_token(S); - } - break; - default: - jj_la1[154] = jj_gen; - ; - } - next = term(prev); - prev.setNextLexicalUnit(next); prev = next; - } - label_104: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[155] = jj_gen; - break label_104; - } - jj_consume_token(COMMA); - label_105: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[156] = jj_gen; - break label_105; - } - jj_consume_token(S); - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: first = term(null); - args.add(first); prev = first; - label_106: + args.add(first); prev = first; + label_102: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: @@ -3808,32 +3758,128 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[157] = jj_gen; - break label_106; + jj_la1[153] = jj_gen; + break label_102; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COLON: jj_consume_token(COLON); - label_107: + label_103: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[158] = jj_gen; - break label_107; + jj_la1[154] = jj_gen; + break label_103; } jj_consume_token(S); } break; default: - jj_la1[159] = jj_gen; + jj_la1[155] = jj_gen; ; } next = term(prev); - prev.setNextLexicalUnit(next); prev = next; + prev.setNextLexicalUnit(next); prev = next; + } + label_104: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[156] = jj_gen; + break label_104; + } + jj_consume_token(COMMA); + label_105: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[157] = jj_gen; + break label_105; + } + jj_consume_token(S); + } + first = term(null); + args.add(first); prev = first; + label_106: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case COLON: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[158] = jj_gen; + break label_106; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_107: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[159] = jj_gen; + break label_107; + } + jj_consume_token(S); + } + break; + default: + jj_la1[160] = jj_gen; + ; + } + next = term(prev); + prev.setNextLexicalUnit(next); prev = next; + } } + break; + default: + jj_la1[161] = jj_gen; + ; } {if (true) return args;} throw new Error("Missing return statement in function"); @@ -3850,7 +3896,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[160] = jj_gen; + jj_la1[162] = jj_gen; break label_108; } jj_consume_token(S); @@ -3875,14 +3921,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[161] = jj_gen; + jj_la1[163] = jj_gen; break label_109; } jj_consume_token(S); } break; default: - jj_la1[162] = jj_gen; + jj_la1[164] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3898,7 +3944,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[163] = jj_gen; + jj_la1[165] = jj_gen; break label_111; } jj_consume_token(S); @@ -3908,7 +3954,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[164] = jj_gen; + jj_la1[166] = jj_gen; break label_110; } } @@ -3923,7 +3969,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[165] = jj_gen; + jj_la1[167] = jj_gen; break label_112; } jj_consume_token(S); @@ -3951,7 +3997,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[166] = jj_gen; + jj_la1[168] = jj_gen; break label_113; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -3976,7 +4022,7 @@ boolean isPseudoElement = false; keyframeSelector(); break; default: - jj_la1[167] = jj_gen; + jj_la1[169] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -3989,7 +4035,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[168] = jj_gen; + jj_la1[170] = jj_gen; break label_114; } jj_consume_token(S); @@ -3997,7 +4043,7 @@ boolean isPseudoElement = false; documentHandler.endIncludeContentBlock(); break; default: - jj_la1[169] = jj_gen; + jj_la1[171] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4027,7 +4073,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[170] = jj_gen; + jj_la1[172] = jj_gen; break label_115; } jj_consume_token(S); @@ -4040,7 +4086,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[171] = jj_gen; + jj_la1[173] = jj_gen; break label_116; } jj_consume_token(S); @@ -4056,7 +4102,7 @@ boolean isPseudoElement = false; type = jj_consume_token(CONTAINS); break; default: - jj_la1[172] = jj_gen; + jj_la1[174] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4067,7 +4113,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[173] = jj_gen; + jj_la1[175] = jj_gen; break label_117; } jj_consume_token(S); @@ -4078,7 +4124,7 @@ boolean isPseudoElement = false; jj_consume_token(RPARAN); break; default: - jj_la1[174] = jj_gen; + jj_la1[176] = jj_gen; ; } jj_consume_token(COMMA); @@ -4089,7 +4135,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[175] = jj_gen; + jj_la1[177] = jj_gen; break label_118; } jj_consume_token(S); @@ -4105,7 +4151,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[176] = jj_gen; + jj_la1[178] = jj_gen; break label_119; } jj_consume_token(S); @@ -4119,14 +4165,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[177] = jj_gen; + jj_la1[179] = jj_gen; break label_120; } jj_consume_token(S); } break; default: - jj_la1[178] = jj_gen; + jj_la1[180] = jj_gen; ; } jj_consume_token(RPARAN); @@ -4153,7 +4199,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[179] = jj_gen; + jj_la1[181] = jj_gen; break label_121; } jj_consume_token(S); @@ -4166,7 +4212,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[180] = jj_gen; + jj_la1[182] = jj_gen; break label_122; } jj_consume_token(S); @@ -4191,7 +4237,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[181] = jj_gen; + jj_la1[183] = jj_gen; break label_123; } jj_consume_token(S); @@ -4204,7 +4250,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[182] = jj_gen; + jj_la1[184] = jj_gen; break label_124; } jj_consume_token(S); @@ -4217,7 +4263,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[183] = jj_gen; + jj_la1[185] = jj_gen; break label_125; } jj_consume_token(S); @@ -4228,7 +4274,7 @@ boolean isPseudoElement = false; jj_consume_token(RPARAN); break; default: - jj_la1[184] = jj_gen; + jj_la1[186] = jj_gen; ; } jj_consume_token(COMMA); @@ -4239,7 +4285,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[185] = jj_gen; + jj_la1[187] = jj_gen; break label_126; } jj_consume_token(S); @@ -4255,7 +4301,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[186] = jj_gen; + jj_la1[188] = jj_gen; break label_127; } jj_consume_token(S); @@ -4269,14 +4315,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[187] = jj_gen; + jj_la1[189] = jj_gen; break label_128; } jj_consume_token(S); } break; default: - jj_la1[188] = jj_gen; + jj_la1[190] = jj_gen; ; } jj_consume_token(RPARAN); @@ -4301,7 +4347,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[189] = jj_gen; + jj_la1[191] = jj_gen; break label_129; } jj_consume_token(S); @@ -4314,7 +4360,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[190] = jj_gen; + jj_la1[192] = jj_gen; break label_130; } jj_consume_token(S); @@ -4327,7 +4373,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[191] = jj_gen; + jj_la1[193] = jj_gen; break label_131; } jj_consume_token(S); @@ -4338,7 +4384,7 @@ boolean isPseudoElement = false; jj_consume_token(RPARAN); break; default: - jj_la1[192] = jj_gen; + jj_la1[194] = jj_gen; ; } jj_consume_token(COMMA); @@ -4349,7 +4395,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[193] = jj_gen; + jj_la1[195] = jj_gen; break label_132; } jj_consume_token(S); @@ -4365,7 +4411,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[194] = jj_gen; + jj_la1[196] = jj_gen; break label_133; } jj_consume_token(S); @@ -4379,14 +4425,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[195] = jj_gen; + jj_la1[197] = jj_gen; break label_134; } jj_consume_token(S); } break; default: - jj_la1[196] = jj_gen; + jj_la1[198] = jj_gen; ; } jj_consume_token(RPARAN); @@ -4413,7 +4459,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[197] = jj_gen; + jj_la1[199] = jj_gen; break label_135; } jj_consume_token(S); @@ -4426,14 +4472,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[198] = jj_gen; + jj_la1[200] = jj_gen; break label_136; } jj_consume_token(S); } break; default: - jj_la1[199] = jj_gen; + jj_la1[201] = jj_gen; ; } jj_consume_token(CONTAINS); @@ -4444,7 +4490,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[200] = jj_gen; + jj_la1[202] = jj_gen; break label_137; } jj_consume_token(S); @@ -4455,7 +4501,7 @@ boolean isPseudoElement = false; jj_consume_token(RPARAN); break; default: - jj_la1[201] = jj_gen; + jj_la1[203] = jj_gen; ; } jj_consume_token(COMMA); @@ -4466,7 +4512,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[202] = jj_gen; + jj_la1[204] = jj_gen; break label_138; } jj_consume_token(S); @@ -4482,7 +4528,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[203] = jj_gen; + jj_la1[205] = jj_gen; break label_139; } jj_consume_token(S); @@ -4496,14 +4542,14 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[204] = jj_gen; + jj_la1[206] = jj_gen; break label_140; } jj_consume_token(S); } break; default: - jj_la1[205] = jj_gen; + jj_la1[207] = jj_gen; ; } jj_consume_token(RPARAN); @@ -4608,7 +4654,7 @@ boolean isPseudoElement = false; warnDirective(); break; default: - jj_la1[206] = jj_gen; + jj_la1[208] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4626,7 +4672,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[207] = jj_gen; + jj_la1[209] = jj_gen; break label_141; } jj_consume_token(S); @@ -4645,7 +4691,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[208] = jj_gen; + jj_la1[210] = jj_gen; break label_142; } jj_consume_token(S); @@ -4672,7 +4718,7 @@ boolean isPseudoElement = false; exclusive = false; break; default: - jj_la1[209] = jj_gen; + jj_la1[211] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4684,7 +4730,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[210] = jj_gen; + jj_la1[212] = jj_gen; break label_143; } jj_consume_token(S); @@ -4713,7 +4759,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[211] = jj_gen; + jj_la1[213] = jj_gen; break label_144; } jj_consume_token(S); @@ -4729,7 +4775,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[212] = jj_gen; + jj_la1[214] = jj_gen; break label_146; } jj_consume_token(S); @@ -4739,7 +4785,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[213] = jj_gen; + jj_la1[215] = jj_gen; break label_145; } } @@ -4755,7 +4801,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[214] = jj_gen; + jj_la1[216] = jj_gen; break label_147; } jj_consume_token(S); @@ -4770,7 +4816,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[215] = jj_gen; + jj_la1[217] = jj_gen; break label_149; } jj_consume_token(S); @@ -4780,7 +4826,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[216] = jj_gen; + jj_la1[218] = jj_gen; break label_148; } } @@ -4815,7 +4861,7 @@ LexicalUnit exp; ; break; default: - jj_la1[217] = jj_gen; + jj_la1[219] = jj_gen; break label_150; } jj_consume_token(S); @@ -4828,7 +4874,7 @@ LexicalUnit exp; ; break; default: - jj_la1[218] = jj_gen; + jj_la1[220] = jj_gen; break label_151; } jj_consume_token(S); @@ -4840,7 +4886,7 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[219] = jj_gen; + jj_la1[221] = jj_gen; ; } label_152: @@ -4850,7 +4896,7 @@ LexicalUnit exp; ; break; default: - jj_la1[220] = jj_gen; + jj_la1[222] = jj_gen; break label_152; } jj_consume_token(SEMICOLON); @@ -4861,7 +4907,7 @@ LexicalUnit exp; ; break; default: - jj_la1[221] = jj_gen; + jj_la1[223] = jj_gen; break label_153; } jj_consume_token(S); @@ -4872,7 +4918,7 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[222] = jj_gen; + jj_la1[224] = jj_gen; ; } } @@ -4885,7 +4931,7 @@ LexicalUnit exp; ; break; default: - jj_la1[223] = jj_gen; + jj_la1[225] = jj_gen; break label_154; } jj_consume_token(S); @@ -4903,7 +4949,7 @@ LexicalUnit exp; debuggingDirective(); break; default: - jj_la1[224] = jj_gen; + jj_la1[226] = jj_gen; if (jj_2_6(2147483647)) { styleRule(); } else if (jj_2_7(3)) { @@ -4924,7 +4970,7 @@ LexicalUnit exp; styleRule(); break; default: - jj_la1[225] = jj_gen; + jj_la1[227] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -4976,7 +5022,7 @@ LexicalUnit exp; ; break; default: - jj_la1[226] = jj_gen; + jj_la1[228] = jj_gen; break label_155; } jj_consume_token(S); @@ -5021,7 +5067,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[227] = jj_gen; + jj_la1[229] = jj_gen; ; } Token next = getToken(1); @@ -5047,7 +5093,7 @@ LexicalUnit exp; ; break; default: - jj_la1[228] = jj_gen; + jj_la1[230] = jj_gen; break label_156; } jj_consume_token(S); @@ -5059,7 +5105,7 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[229] = jj_gen; + jj_la1[231] = jj_gen; ; } label_157: @@ -5069,7 +5115,7 @@ LexicalUnit exp; ; break; default: - jj_la1[230] = jj_gen; + jj_la1[232] = jj_gen; break label_157; } jj_consume_token(SEMICOLON); @@ -5080,7 +5126,7 @@ LexicalUnit exp; ; break; default: - jj_la1[231] = jj_gen; + jj_la1[233] = jj_gen; break label_158; } jj_consume_token(S); @@ -5091,7 +5137,7 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[232] = jj_gen; + jj_la1[234] = jj_gen; ; } } @@ -5103,7 +5149,7 @@ LexicalUnit exp; ; break; default: - jj_la1[233] = jj_gen; + jj_la1[235] = jj_gen; break label_159; } jj_consume_token(S); @@ -5111,7 +5157,7 @@ LexicalUnit exp; documentHandler.endNestedProperties(name); break; default: - jj_la1[234] = jj_gen; + jj_la1[236] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5168,7 +5214,7 @@ LexicalUnit exp; ; break; default: - jj_la1[235] = jj_gen; + jj_la1[237] = jj_gen; break label_160; } jj_consume_token(S); @@ -5179,7 +5225,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[236] = jj_gen; + jj_la1[238] = jj_gen; ; } documentHandler.property(name, exp, important); @@ -5229,7 +5275,7 @@ LexicalUnit exp; ; break; default: - jj_la1[237] = jj_gen; + jj_la1[239] = jj_gen; break label_161; } jj_consume_token(S); @@ -5247,7 +5293,7 @@ LexicalUnit exp; ; break; default: - jj_la1[238] = jj_gen; + jj_la1[240] = jj_gen; break label_162; } jj_consume_token(S); @@ -5280,7 +5326,7 @@ LexicalUnit exp; ; break; default: - jj_la1[239] = jj_gen; + jj_la1[241] = jj_gen; break label_163; } jj_consume_token(S); @@ -5298,7 +5344,7 @@ LexicalUnit exp; ; break; default: - jj_la1[240] = jj_gen; + jj_la1[242] = jj_gen; break label_164; } jj_consume_token(S); @@ -5316,7 +5362,7 @@ LexicalUnit exp; ; break; default: - jj_la1[241] = jj_gen; + jj_la1[243] = jj_gen; break label_165; } jj_consume_token(S); @@ -5334,7 +5380,7 @@ LexicalUnit exp; ; break; default: - jj_la1[242] = jj_gen; + jj_la1[244] = jj_gen; break label_166; } jj_consume_token(S); @@ -5353,7 +5399,7 @@ LexicalUnit exp; ; break; default: - jj_la1[243] = jj_gen; + jj_la1[245] = jj_gen; break label_167; } } @@ -5371,7 +5417,7 @@ LexicalUnit exp; ; break; default: - jj_la1[244] = jj_gen; + jj_la1[246] = jj_gen; break label_168; } } @@ -5380,7 +5426,7 @@ LexicalUnit exp; prev);} break; default: - jj_la1[245] = jj_gen; + jj_la1[247] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5427,7 +5473,7 @@ LexicalUnit exp; {if (true) return '+';} break; default: - jj_la1[246] = jj_gen; + jj_la1[248] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5480,7 +5526,7 @@ LexicalUnit exp; result = variableTerm(prev); break; default: - jj_la1[247] = jj_gen; + jj_la1[249] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5533,7 +5579,7 @@ LexicalUnitImpl result = null; op = unaryOperator(); break; default: - jj_la1[248] = jj_gen; + jj_la1[250] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5649,7 +5695,7 @@ LexicalUnitImpl result = null; result = function(op, prev); break; default: - jj_la1[249] = jj_gen; + jj_la1[251] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5682,7 +5728,7 @@ LexicalUnitImpl result = null; s+="."; break; default: - jj_la1[250] = jj_gen; + jj_la1[252] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5699,7 +5745,7 @@ LexicalUnitImpl result = null; n = jj_consume_token(FROM); break; default: - jj_la1[251] = jj_gen; + jj_la1[253] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5746,13 +5792,13 @@ LexicalUnitImpl result = null; result = unicode(prev); break; default: - jj_la1[252] = jj_gen; + jj_la1[254] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[253] = jj_gen; + jj_la1[255] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5763,7 +5809,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[254] = jj_gen; + jj_la1[256] = jj_gen; break label_170; } jj_consume_token(S); @@ -5787,7 +5833,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[255] = jj_gen; + jj_la1[257] = jj_gen; break label_171; } jj_consume_token(S); @@ -5839,7 +5885,7 @@ LexicalUnitImpl result = null; params = expr(); break; default: - jj_la1[256] = jj_gen; + jj_la1[258] = jj_gen; ; } jj_consume_token(RPARAN); @@ -6303,7 +6349,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[257] = jj_gen; + jj_la1[259] = jj_gen; break label_172; } jj_consume_token(S); @@ -6339,7 +6385,7 @@ LexicalUnitImpl result = null; fontFace(); break; default: - jj_la1[258] = jj_gen; + jj_la1[260] = jj_gen; ret = skipStatement(); if ((ret == null) || (ret.length() == 0)) { {if (true) return;} @@ -6361,7 +6407,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[259] = jj_gen; + jj_la1[261] = jj_gen; break label_173; } jj_consume_token(S); @@ -6377,7 +6423,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[260] = jj_gen; + jj_la1[262] = jj_gen; break label_174; } jj_consume_token(S); @@ -6393,7 +6439,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[261] = jj_gen; + jj_la1[263] = jj_gen; break label_175; } jj_consume_token(S); @@ -6404,7 +6450,7 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[262] = jj_gen; + jj_la1[264] = jj_gen; ; } label_176: @@ -6414,7 +6460,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[263] = jj_gen; + jj_la1[265] = jj_gen; break label_176; } jj_consume_token(SEMICOLON); @@ -6425,7 +6471,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[264] = jj_gen; + jj_la1[266] = jj_gen; break label_177; } jj_consume_token(S); @@ -6436,7 +6482,7 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[265] = jj_gen; + jj_la1[267] = jj_gen; ; } } @@ -6452,7 +6498,7 @@ LexicalUnitImpl result = null; ; break; default: - jj_la1[266] = jj_gen; + jj_la1[268] = jj_gen; break label_178; } jj_consume_token(S); @@ -6590,11 +6636,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_218() { - if (jj_3R_217()) return true; - return false; - } - private boolean jj_3R_216() { if (jj_scan_token(GUARDED_SYM)) return true; Token xsp; @@ -6605,6 +6646,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_218() { + if (jj_3R_217()) return true; + return false; + } + private boolean jj_3R_217() { Token xsp; xsp = jj_scanpos; @@ -6776,6 +6822,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_206() { + if (jj_3R_190()) return true; + return false; + } + private boolean jj_3R_271() { if (jj_scan_token(INTERPOLATION)) return true; return false; @@ -6786,11 +6837,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_206() { - if (jj_3R_190()) return true; - return false; - } - private boolean jj_3R_296() { Token xsp; xsp = jj_scanpos; @@ -6832,6 +6878,22 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_186() { + if (jj_3R_205()) return true; + if (jj_scan_token(COLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_206()) { + jj_scanpos = xsp; + if (jj_3R_207()) return true; + } + return false; + } + private boolean jj_3R_223() { if (jj_scan_token(LBRACKET)) return true; Token xsp; @@ -6850,19 +6912,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_186() { - if (jj_3R_205()) return true; - if (jj_scan_token(COLON)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - xsp = jj_scanpos; - if (jj_3R_206()) { - jj_scanpos = xsp; - if (jj_3R_207()) return true; - } + private boolean jj_3R_269() { + if (jj_3R_190()) return true; return false; } @@ -6871,11 +6922,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_269() { - if (jj_3R_190()) return true; - return false; - } - private boolean jj_3R_257() { if (jj_scan_token(PARENT)) return true; return false; @@ -6952,6 +6998,16 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_249() { + if (jj_3R_262()) return true; + return false; + } + + private boolean jj_3R_248() { + if (jj_3R_261()) return true; + return false; + } + private boolean jj_3R_301() { if (jj_scan_token(IDENT)) return true; return false; @@ -6967,21 +7023,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_249() { - if (jj_3R_262()) return true; - return false; - } - - private boolean jj_3R_248() { - if (jj_3R_261()) return true; - return false; - } - - private boolean jj_3R_300() { - if (jj_3R_222()) return true; - return false; - } - private boolean jj_3_5() { Token xsp; xsp = jj_scanpos; @@ -6990,6 +7031,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_300() { + if (jj_3R_222()) return true; + return false; + } + private boolean jj_3R_221() { if (jj_scan_token(DOT)) return true; Token xsp; @@ -7175,16 +7221,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_199() { - if (jj_3R_223()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_276()) { jj_scanpos = xsp; break; } - } - return false; - } - private boolean jj_3R_202() { Token xsp; xsp = jj_scanpos; @@ -7204,6 +7240,16 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_199() { + if (jj_3R_223()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_276()) { jj_scanpos = xsp; break; } + } + return false; + } + private boolean jj_3R_198() { if (jj_3R_222()) return true; Token xsp; @@ -7260,6 +7306,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_244() { + if (jj_scan_token(DIMEN)) return true; + return false; + } + private boolean jj_3R_195() { if (jj_3R_219()) return true; Token xsp; @@ -7270,8 +7321,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_244() { - if (jj_scan_token(DIMEN)) return true; + private boolean jj_3R_243() { + if (jj_scan_token(KHZ)) return true; return false; } @@ -7294,8 +7345,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_243() { - if (jj_scan_token(KHZ)) return true; + private boolean jj_3R_242() { + if (jj_scan_token(HZ)) return true; return false; } @@ -7305,11 +7356,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_242() { - if (jj_scan_token(HZ)) return true; - return false; - } - private boolean jj_3R_241() { if (jj_scan_token(MS)) return true; return false; @@ -7355,19 +7401,24 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_232() { + if (jj_scan_token(PX)) return true; + return false; + } + private boolean jj_3_2() { if (jj_3R_180()) return true; if (jj_3R_181()) return true; return false; } - private boolean jj_3R_232() { - if (jj_scan_token(PX)) return true; + private boolean jj_3R_231() { + if (jj_scan_token(IN)) return true; return false; } - private boolean jj_3R_231() { - if (jj_scan_token(IN)) return true; + private boolean jj_3R_230() { + if (jj_scan_token(PC)) return true; return false; } @@ -7387,13 +7438,13 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_230() { - if (jj_scan_token(PC)) return true; + private boolean jj_3R_229() { + if (jj_scan_token(MM)) return true; return false; } - private boolean jj_3R_229() { - if (jj_scan_token(MM)) return true; + private boolean jj_3R_228() { + if (jj_scan_token(CM)) return true; return false; } @@ -7415,11 +7466,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_228() { - if (jj_scan_token(CM)) return true; - return false; - } - private boolean jj_3R_227() { if (jj_scan_token(PT)) return true; return false; @@ -7514,21 +7560,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_1() { - if (jj_3R_179()) return true; - return false; - } - - private boolean jj_3R_185() { - if (jj_3R_203()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_204()) { jj_scanpos = xsp; break; } - } - return false; - } - private boolean jj_3R_184() { Token xsp; xsp = jj_scanpos; @@ -7548,6 +7579,21 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3_1() { + if (jj_3R_179()) return true; + return false; + } + + private boolean jj_3R_185() { + if (jj_3R_203()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_204()) { jj_scanpos = xsp; break; } + } + return false; + } + private boolean jj_3_4() { if (jj_3R_182()) return true; return false; @@ -7588,11 +7634,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_3() { - if (jj_3R_179()) return true; - return false; - } - private boolean jj_3R_268() { if (jj_scan_token(PLUS)) return true; return false; @@ -7613,6 +7654,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3_3() { + if (jj_3R_179()) return true; + return false; + } + private boolean jj_3R_263() { if (jj_scan_token(UNICODERANGE)) return true; return false; @@ -7626,22 +7672,22 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_192() { - if (jj_scan_token(SEMICOLON)) return true; + private boolean jj_3R_190() { + if (jj_3R_187()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + if (jj_3_8()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_190() { - if (jj_3R_187()) return true; + private boolean jj_3R_192() { + if (jj_scan_token(SEMICOLON)) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3_8()) { jj_scanpos = xsp; break; } + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } return false; } @@ -7696,11 +7742,6 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_191() { - if (jj_3R_216()) return true; - return false; - } - private boolean jj_3R_214() { if (jj_scan_token(PLUS)) return true; Token xsp; @@ -7712,6 +7753,11 @@ LexicalUnitImpl result = null; return false; } + private boolean jj_3R_191() { + if (jj_3R_216()) return true; + return false; + } + /** Generated Token Manager. */ public ParserTokenManager token_source; /** Current token. */ @@ -7722,7 +7768,7 @@ LexicalUnitImpl result = null; private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[267]; + final private int[] jj_la1 = new int[269]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; @@ -7734,16 +7780,16 @@ LexicalUnitImpl result = null; jj_la1_init_3(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x2,0x2,0x0,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x200400,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x2,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; + jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x0,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x800c0000,0x2,0x2,0x0,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x200400,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x2,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x0,0x0,0x80,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x160000,0x0,0x0,0x80,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; } private static void jj_la1_init_2() { - jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x1100,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; + jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0xfffffb80,0x0,0x0,0x1100,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; } private static void jj_la1_init_3() { - jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x440001,0x0,0x0,0x400000,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[9]; private boolean jj_rescan = false; @@ -7755,7 +7801,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 267; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7765,7 +7811,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 267; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7775,7 +7821,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 267; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7785,7 +7831,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 267; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7902,7 +7948,7 @@ LexicalUnitImpl result = null; la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 267; i++) { + for (int i = 0; i < 269; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< arglist() : boolean hasNonOptionalArgument = false; } { - arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } - arg=mixinArg() )* - { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + (arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } + arg=mixinArg() )* + { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } + )? + { return args; } } @@ -1723,10 +1725,11 @@ ArrayList argValuelist() : LexicalUnitImpl prev = null; } { - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - ( ()* - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - )* + (first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + ( ()* + first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + )* + )? {return args;} } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java index 26d1121f96..ba29df7d33 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java @@ -143,4 +143,4 @@ public class Token implements java.io.Serializable { } } -/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ +/* JavaCC - OriginalChecksum=8b653fc6be4ca9bd10137ee3ad4c32c4 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java index f093357e96..1757cf6705 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java @@ -159,4 +159,4 @@ public class TokenMgrError extends Error this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ +/* JavaCC - OriginalChecksum=525946b34c715198d7c29f668b049f5d (do not edit this line) */ diff --git a/theme-compiler/tests/resources/automatic/css/mixin-empty-paramlist.css b/theme-compiler/tests/resources/automatic/css/mixin-empty-paramlist.css new file mode 100644 index 0000000000..59ef68680d --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/mixin-empty-paramlist.css @@ -0,0 +1,15 @@ +body { + color: blue; +} + +h1 { + text-align: center; +} + +p { + font-style: italic; +} + +table { + width: 100%; +} \ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/mixin-empty-paramlist.scss b/theme-compiler/tests/resources/automatic/scss/mixin-empty-paramlist.scss new file mode 100644 index 0000000000..27033ba850 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/mixin-empty-paramlist.scss @@ -0,0 +1,28 @@ +@mixin emptyarglist1(){ + body{ + color: blue; + } +} + +@mixin emptyarglist2(){ + h1{ + text-align:center; + } +} + +@mixin emptyarglist3{ + p{ + font-style:italic; + } +} + +@mixin emptyarglist4{ + table{ + width: 100%; + } +} + +@include emptyarglist1(); +@include emptyarglist2; +@include emptyarglist3(); +@include emptyarglist4; \ No newline at end of file -- cgit v1.2.3 From 5b2ddc15bd2c30d9f9033a0c4cf50e32827ef0c6 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 13 Nov 2013 14:56:06 +0200 Subject: Make test work reliably by activating @Push Additional test now ensures that access() works both when called before init() is done and after init() is done Change-Id: Id56bd09f1aaa7a6a99eed8d097f12910cdc11596 --- uitest/src/com/vaadin/tests/push/PushFromInit.java | 53 +++++++++++++++++----- .../com/vaadin/tests/push/PushFromInitTest.java | 28 ++++-------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/uitest/src/com/vaadin/tests/push/PushFromInit.java b/uitest/src/com/vaadin/tests/push/PushFromInit.java index cb084f1232..0afaa866f7 100644 --- a/uitest/src/com/vaadin/tests/push/PushFromInit.java +++ b/uitest/src/com/vaadin/tests/push/PushFromInit.java @@ -15,29 +15,60 @@ */ package com.vaadin.tests.push; +import com.vaadin.annotations.Push; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; +@Push public class PushFromInit extends AbstractTestUIWithLog { + public static final String LOG_DURING_INIT = "Logged from access run before init ends"; + public static final String LOG_AFTER_INIT = "Logged from background thread run after init has finished"; + @Override protected void setup(VaadinRequest request) { - new Thread() { - @Override - public void run() { - access(new Runnable() { - @Override - public void run() { - log("Logged from background thread started in init"); - } - }); - } - }.start(); log("Logged in init"); + Thread t = new Thread(new RunBeforeInitEnds()); + t.start(); + try { + t.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + new Thread(new RunAfterInit()).start(); addComponent(new Button("Sync")); } + class RunBeforeInitEnds implements Runnable { + @Override + public void run() { + access(new Runnable() { + @Override + public void run() { + log(LOG_DURING_INIT); + } + }); + } + } + + class RunAfterInit implements Runnable { + @Override + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + access(new Runnable() { + @Override + public void run() { + log(LOG_AFTER_INIT); + } + }); + } + } + @Override protected String getTestDescription() { return "Pusing something to a newly created UI should not cause race conditions"; diff --git a/uitest/src/com/vaadin/tests/push/PushFromInitTest.java b/uitest/src/com/vaadin/tests/push/PushFromInitTest.java index 3c1bc1b610..4101de29cf 100644 --- a/uitest/src/com/vaadin/tests/push/PushFromInitTest.java +++ b/uitest/src/com/vaadin/tests/push/PushFromInitTest.java @@ -15,8 +15,9 @@ */ package com.vaadin.tests.push; -import org.junit.Assert; import org.junit.Test; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedCondition; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -25,26 +26,13 @@ public class PushFromInitTest extends MultiBrowserTest { public void testPushFromInit() { openTestURL(); - for (int second = 0;; second++) { - if (second >= 30) { - Assert.fail("timeout"); + waitUntil(new ExpectedCondition() { + @Override + public Boolean apply(WebDriver input) { + return ("3. " + PushFromInit.LOG_AFTER_INIT) + .equals(getLogRow(0)); } - try { - if ("1. Logged in init".equals(vaadinElementById( - "Log_row_1").getText())) { - break; - } - } catch (Exception e) { - } - try { - Thread.sleep(200); - } catch (InterruptedException e) { - } - } - - Assert.assertEquals( - "2. Logged from background thread started in init", - vaadinElementById("Log_row_0").getText()); + }); } } \ No newline at end of file -- cgit v1.2.3 From 10ca7ed57149eb20d8be936e9e060311b72298bb Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Wed, 27 Nov 2013 15:30:36 +0200 Subject: Catch and log exceptions in session lifecycle listeners (#12915) Change-Id: Ie8638f010d74c569c5ff56e91c95e23a5cb92c9b --- server/src/com/vaadin/event/EventRouter.java | 39 +++++++- server/src/com/vaadin/server/VaadinService.java | 15 ++- .../com/vaadin/tests/event/EventRouterTest.java | 111 +++++++++++++++++++++ 3 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 server/tests/src/com/vaadin/tests/event/EventRouterTest.java diff --git a/server/src/com/vaadin/event/EventRouter.java b/server/src/com/vaadin/event/EventRouter.java index 73bfa33881..fdc543143b 100644 --- a/server/src/com/vaadin/event/EventRouter.java +++ b/server/src/com/vaadin/event/EventRouter.java @@ -23,6 +23,10 @@ import java.util.EventObject; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.logging.Logger; + +import com.vaadin.server.ErrorEvent; +import com.vaadin.server.ErrorHandler; /** * EventRouter class implementing the inheritable event listening @@ -154,6 +158,25 @@ public class EventRouter implements MethodEventSource { * the Event to be sent to all listeners. */ public void fireEvent(EventObject event) { + fireEvent(event, null); + } + + /** + * Sends an event to all registered listeners. The listeners will decide if + * the activation method should be called or not. + *

+ * If an error handler is set, the processing of other listeners will + * continue after the error handler method call unless the error handler + * itself throws an exception. + * + * @param event + * the Event to be sent to all listeners. + * @param errorHandler + * error handler to use to handle any exceptions thrown by + * listeners or null to let the exception propagate to the + * caller, preventing further listener calls + */ + public void fireEvent(EventObject event, ErrorHandler errorHandler) { // It is not necessary to send any events if there are no listeners if (listenerList != null) { @@ -164,7 +187,16 @@ public class EventRouter implements MethodEventSource { // will filter out unwanted events. final Object[] listeners = listenerList.toArray(); for (int i = 0; i < listeners.length; i++) { - ((ListenerMethod) listeners[i]).receiveEvent(event); + ListenerMethod listenerMethod = (ListenerMethod) listeners[i]; + if (null != errorHandler) { + try { + listenerMethod.receiveEvent(event); + } catch (Exception e) { + errorHandler.error(new ErrorEvent(e)); + } + } else { + listenerMethod.receiveEvent(event); + } } } @@ -208,4 +240,9 @@ public class EventRouter implements MethodEventSource { } return listeners; } + + private Logger getLogger() { + return Logger.getLogger(EventRouter.class.getName()); + } + } diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 44ceaaaf87..216adce3c8 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -414,6 +414,9 @@ public abstract class VaadinService implements Serializable { /** * Adds a listener that gets notified when a Vaadin service session that has * been initialized for this service is destroyed. + *

+ * The session being destroyed is locked and its UIs have been removed when + * the listeners are called. * * @see #addSessionInitListener(SessionInitListener) * @@ -455,8 +458,11 @@ public abstract class VaadinService implements Serializable { } }); } + // for now, use the session error handler; in the future, could + // have an API for using some other handler for session init and + // destroy listeners eventRouter.fireEvent(new SessionDestroyEvent( - VaadinService.this, session)); + VaadinService.this, session), session.getErrorHandler()); } }); } @@ -770,7 +776,12 @@ public abstract class VaadinService implements Serializable { private void onVaadinSessionStarted(VaadinRequest request, VaadinSession session) throws ServiceException { - eventRouter.fireEvent(new SessionInitEvent(this, session, request)); + // for now, use the session error handler; in the future, could have an + // API for using some other handler for session init and destroy + // listeners + + eventRouter.fireEvent(new SessionInitEvent(this, session, request), + session.getErrorHandler()); ServletPortletHelper.checkUiProviders(session, this); } diff --git a/server/tests/src/com/vaadin/tests/event/EventRouterTest.java b/server/tests/src/com/vaadin/tests/event/EventRouterTest.java new file mode 100644 index 0000000000..dbbeaf778e --- /dev/null +++ b/server/tests/src/com/vaadin/tests/event/EventRouterTest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.event; + +import java.lang.reflect.Method; + +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import com.vaadin.event.EventRouter; +import com.vaadin.server.ErrorEvent; +import com.vaadin.server.ErrorHandler; +import com.vaadin.ui.Component; +import com.vaadin.ui.Component.Listener; +import com.vaadin.util.ReflectTools; + +/** + * Test EventRouter and related error handling. + */ +public class EventRouterTest { + + private static final Method COMPONENT_EVENT_METHOD = ReflectTools + .findMethod(Component.Listener.class, "componentEvent", + Component.Event.class); + + private EventRouter router; + private Component component; + private ErrorHandler errorHandler; + private Listener listener; + + @Before + public void createMocks() { + router = new EventRouter(); + component = EasyMock.createNiceMock(Component.class); + errorHandler = EasyMock.createMock(ErrorHandler.class); + listener = EasyMock.createMock(Component.Listener.class); + router.addListener(Component.Event.class, listener, + COMPONENT_EVENT_METHOD); + } + + @Test + public void fireEvent_noException_eventReceived() { + listener.componentEvent(EasyMock. anyObject()); + + EasyMock.replay(component, listener, errorHandler); + router.fireEvent(new Component.Event(component), errorHandler); + EasyMock.verify(listener, errorHandler); + } + + @Test + public void fireEvent_exceptionFromListenerAndNoHandler_exceptionPropagated() { + listener.componentEvent(EasyMock. anyObject()); + EasyMock.expectLastCall().andThrow( + new RuntimeException("listener failed")); + + EasyMock.replay(component, listener); + try { + router.fireEvent(new Component.Event(component)); + Assert.fail("Did not receive expected exception from listener"); + } catch (RuntimeException e) { + // e is a ListenerMethod@MethodException + Assert.assertEquals("listener failed", e.getCause().getMessage()); + } + EasyMock.verify(listener); + } + + @Test + public void fireEvent_exceptionFromListener_errorHandlerCalled() { + listener.componentEvent(EasyMock. anyObject()); + EasyMock.expectLastCall().andThrow( + new RuntimeException("listener failed")); + errorHandler.error(EasyMock. anyObject()); + + EasyMock.replay(component, listener, errorHandler); + router.fireEvent(new Component.Event(component), errorHandler); + EasyMock.verify(listener, errorHandler); + } + + @Test + public void fireEvent_multipleListenersAndException_errorHandlerCalled() { + Listener listener2 = EasyMock.createMock(Component.Listener.class); + router.addListener(Component.Event.class, listener2, + COMPONENT_EVENT_METHOD); + + listener.componentEvent(EasyMock. anyObject()); + EasyMock.expectLastCall().andThrow( + new RuntimeException("listener failed")); + errorHandler.error(EasyMock. anyObject()); + // second listener should be called despite an error in the first + listener2.componentEvent(EasyMock. anyObject()); + + EasyMock.replay(component, listener, listener2, errorHandler); + router.fireEvent(new Component.Event(component), errorHandler); + EasyMock.verify(listener, listener2, errorHandler); + } +} -- cgit v1.2.3 From 8abf43431ea67f7c3d7cc4faad816e2cddd4ac1d Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Wed, 27 Nov 2013 09:26:07 +0200 Subject: Move working sass tests from sasslangbroken to sasslang. Change-Id: Ic503021884fd52b650f29df221cef3e69e8ef570 --- theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css | 3 +++ .../sasslang/css/390-test_parent_selector_with_parent_and_subject.css | 3 +++ .../tests/resources/sasslang/scss/350-test_interpolation.scss | 2 ++ .../scss/390-test_parent_selector_with_parent_and_subject.scss | 3 +++ .../tests/resources/sasslangbroken/css/350-test_interpolation.css | 3 --- .../css/390-test_parent_selector_with_parent_and_subject.css | 3 --- .../tests/resources/sasslangbroken/scss/350-test_interpolation.scss | 2 -- .../scss/390-test_parent_selector_with_parent_and_subject.scss | 3 --- 8 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css create mode 100644 theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.css create mode 100644 theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss diff --git a/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css b/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css new file mode 100644 index 0000000000..8b44646800 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css @@ -0,0 +1,3 @@ +ul li#foo a span.label { + foo: bar; +} diff --git a/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.css b/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.css new file mode 100644 index 0000000000..234fea7aa5 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.css @@ -0,0 +1,3 @@ +bar foo.baz! .bip { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss b/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss new file mode 100644 index 0000000000..bb9c9a2c8f --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss @@ -0,0 +1,2 @@ +$bar : "#foo"; +ul li#{$bar} a span.label { foo: bar; } diff --git a/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.scss b/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.scss new file mode 100644 index 0000000000..646238f379 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.scss @@ -0,0 +1,3 @@ +$subject: "!"; +foo { + bar &.baz#{$subject} .bip {c: d}} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css b/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css deleted file mode 100644 index 8b44646800..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css +++ /dev/null @@ -1,3 +0,0 @@ -ul li#foo a span.label { - foo: bar; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css b/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css deleted file mode 100644 index 234fea7aa5..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css +++ /dev/null @@ -1,3 +0,0 @@ -bar foo.baz! .bip { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss b/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss deleted file mode 100644 index bb9c9a2c8f..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss +++ /dev/null @@ -1,2 +0,0 @@ -$bar : "#foo"; -ul li#{$bar} a span.label { foo: bar; } diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss b/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss deleted file mode 100644 index 646238f379..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss +++ /dev/null @@ -1,3 +0,0 @@ -$subject: "!"; -foo { - bar &.baz#{$subject} .bip {c: d}} -- cgit v1.2.3 From 1ac492e46b70de9314083492bd8e136e1c8398e3 Mon Sep 17 00:00:00 2001 From: Mika Murtojarvi Date: Wed, 27 Nov 2013 13:29:51 +0200 Subject: Move a sass test that no longer fails. Change-Id: Ic83330cbea688be1c30aa89cad9524016617be8d --- .../tests/resources/sasslang/css/369-test_mixins_with_empty_args.css | 3 +++ .../tests/resources/sasslang/scss/369-test_mixins_with_empty_args.scss | 3 +++ .../resources/sasslangbroken/css/369-test_mixins_with_empty_args.css | 3 --- .../resources/sasslangbroken/scss/369-test_mixins_with_empty_args.scss | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 theme-compiler/tests/resources/sasslang/css/369-test_mixins_with_empty_args.css create mode 100644 theme-compiler/tests/resources/sasslang/scss/369-test_mixins_with_empty_args.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/369-test_mixins_with_empty_args.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/369-test_mixins_with_empty_args.scss diff --git a/theme-compiler/tests/resources/sasslang/css/369-test_mixins_with_empty_args.css b/theme-compiler/tests/resources/sasslang/css/369-test_mixins_with_empty_args.css new file mode 100644 index 0000000000..234d524066 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/369-test_mixins_with_empty_args.css @@ -0,0 +1,3 @@ +.foo { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/scss/369-test_mixins_with_empty_args.scss b/theme-compiler/tests/resources/sasslang/scss/369-test_mixins_with_empty_args.scss new file mode 100644 index 0000000000..f608979293 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/369-test_mixins_with_empty_args.scss @@ -0,0 +1,3 @@ +@mixin foo() {a: b} + +.foo {@include foo();} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/369-test_mixins_with_empty_args.css b/theme-compiler/tests/resources/sasslangbroken/css/369-test_mixins_with_empty_args.css deleted file mode 100644 index 234d524066..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/369-test_mixins_with_empty_args.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/369-test_mixins_with_empty_args.scss b/theme-compiler/tests/resources/sasslangbroken/scss/369-test_mixins_with_empty_args.scss deleted file mode 100644 index f608979293..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/369-test_mixins_with_empty_args.scss +++ /dev/null @@ -1,3 +0,0 @@ -@mixin foo() {a: b} - -.foo {@include foo();} -- cgit v1.2.3 From 37919d14b7509b1c8d8495a3e334d50a913bfe6f Mon Sep 17 00:00:00 2001 From: joheriks Date: Wed, 27 Nov 2013 17:34:30 +0200 Subject: For @-directives, infer missing semicolon before closing brace (#12792) Parser now accepts the following (note missing semicolon after last @extend-directive): xyzzy { @extend foo ; @extend bar } As a consequence, moved 31 sasslang-cases from broken to fixed. Moved two tests from fixed to broken (34, 95, previously passed accidentally) Change-Id: I8968074abd79dec71be762ed926cc6f37fbcaa99 --- .../sass/internal/handler/SCSSDocumentHandler.java | 6 +- .../internal/handler/SCSSDocumentHandlerImpl.java | 10 +- .../vaadin/sass/internal/parser/CharStream.java | 2 +- .../com/vaadin/sass/internal/parser/Parser.java | 1620 ++++++++++---------- .../src/com/vaadin/sass/internal/parser/Parser.jj | 75 +- .../src/com/vaadin/sass/internal/parser/Token.java | 2 +- .../vaadin/sass/internal/parser/TokenMgrError.java | 2 +- ...test_pseudoclass_remains_at_end_of_selector.css | 3 + ...107-test_pseudoelement_goes_lefter_than_not.css | 3 + ..._pseudoelement_goes_lefter_than_pseudoclass.css | 3 + ...st_pseudoelement_remains_at_end_of_selector.css | 3 + .../110-test_redundant_selector_elimination.css | 3 + .../sasslang/css/112-test_target_with_child.css | 3 + .../tests/resources/sasslang/css/2-test_basic.css | 3 + ...rn_when_one_extension_fails_but_others_dont.css | 7 + ..._elimination_never_eliminates_base_selector.css | 3 + .../sasslang/css/333-test_empty_content.css | 3 + ...mination_when_it_would_preserve_specificity.css | 3 - ...limination_when_it_would_reduce_specificity.css | 3 + .../sasslang/css/368-test_mixins_with_args.css | 3 + .../sasslang/css/420-test_warn_directive.css | 3 + .../sasslang/css/55-test_long_extendee.css | 3 + .../sasslang/css/63-test_multiple_extendees.css | 7 + ...s_with_multiple_extenders_and_single_target.css | 3 + ...ends_with_single_extender_and_single_target.css | 3 + .../sasslang/css/67-test_multiple_targets.css | 7 + ...7-test_combinator_unification_angle_sibling.css | 3 + .../sasslang/css/70-test_nested_extender.css | 3 + ...t_nested_extender_merges_with_same_selector.css | 3 + .../81-test_nested_extender_runs_unification.css | 3 + ...85-test_nested_extender_with_child_selector.css | 3 + ...th_child_selector_merges_with_same_selector.css | 3 + ...th_early_child_selectors_doesnt_subseq_them.css | 3 + ...-test_nested_extender_with_sibling_selector.css | 3 + ..._selector_with_child_selector_hack_extendee.css | 3 + ...hack_extender_and_sibling_selector_extendee.css | 3 - .../sasslang/css/96-test_nested_target.css | 3 + .../css/98-test_not_remains_at_end_of_selector.css | 3 + ...est_pseudoclass_remains_at_end_of_selector.scss | 2 + ...07-test_pseudoelement_goes_lefter_than_not.scss | 2 + ...pseudoelement_goes_lefter_than_pseudoclass.scss | 2 + ...t_pseudoelement_remains_at_end_of_selector.scss | 2 + .../110-test_redundant_selector_elimination.scss | 3 + .../sasslang/scss/112-test_target_with_child.scss | 2 + .../resources/sasslang/scss/2-test_basic.scss | 2 + ...n_when_one_extension_fails_but_others_dont.scss | 3 + ...elimination_never_eliminates_base_selector.scss | 2 + .../sasslang/scss/333-test_empty_content.scss | 2 + ...ination_when_it_would_preserve_specificity.scss | 2 - ...imination_when_it_would_reduce_specificity.scss | 2 + .../sasslang/scss/368-test_mixins_with_args.scss | 3 + .../sasslang/scss/420-test_warn_directive.scss | 3 + .../sasslang/scss/55-test_long_extendee.scss | 2 + .../sasslang/scss/63-test_multiple_extendees.scss | 3 + ..._with_multiple_extenders_and_single_target.scss | 3 + ...nds_with_single_extender_and_single_target.scss | 2 + .../sasslang/scss/67-test_multiple_targets.scss | 3 + ...-test_combinator_unification_angle_sibling.scss | 2 + .../sasslang/scss/70-test_nested_extender.scss | 2 + ..._nested_extender_merges_with_same_selector.scss | 3 + .../81-test_nested_extender_runs_unification.scss | 2 + ...5-test_nested_extender_with_child_selector.scss | 2 + ...h_child_selector_merges_with_same_selector.scss | 2 + ...h_early_child_selectors_doesnt_subseq_them.scss | 4 + ...test_nested_extender_with_sibling_selector.scss | 2 + ...selector_with_child_selector_hack_extendee.scss | 2 + ...ack_extender_and_sibling_selector_extendee.scss | 2 - .../sasslang/scss/96-test_nested_target.scss | 2 + .../98-test_not_remains_at_end_of_selector.scss | 2 + ...test_pseudoclass_remains_at_end_of_selector.css | 3 - ...107-test_pseudoelement_goes_lefter_than_not.css | 3 - ..._pseudoelement_goes_lefter_than_pseudoclass.css | 3 - ...st_pseudoelement_remains_at_end_of_selector.css | 3 - .../110-test_redundant_selector_elimination.css | 3 - .../css/112-test_target_with_child.css | 3 - .../resources/sasslangbroken/css/2-test_basic.css | 3 - ...rn_when_one_extension_fails_but_others_dont.css | 7 - ..._elimination_never_eliminates_base_selector.css | 3 - .../sasslangbroken/css/333-test_empty_content.css | 3 - ...mination_when_it_would_preserve_specificity.css | 3 + ...limination_when_it_would_reduce_specificity.css | 3 - .../css/368-test_mixins_with_args.css | 3 - .../sasslangbroken/css/420-test_warn_directive.css | 3 - .../sasslangbroken/css/55-test_long_extendee.css | 3 - .../css/63-test_multiple_extendees.css | 7 - ...s_with_multiple_extenders_and_single_target.css | 3 - ...ends_with_single_extender_and_single_target.css | 3 - .../css/67-test_multiple_targets.css | 7 - ...7-test_combinator_unification_angle_sibling.css | 3 - .../sasslangbroken/css/70-test_nested_extender.css | 3 - ...t_nested_extender_merges_with_same_selector.css | 3 - .../81-test_nested_extender_runs_unification.css | 3 - ...85-test_nested_extender_with_child_selector.css | 3 - ...th_child_selector_merges_with_same_selector.css | 3 - ...th_early_child_selectors_doesnt_subseq_them.css | 3 - ...-test_nested_extender_with_sibling_selector.css | 3 - ..._selector_with_child_selector_hack_extendee.css | 3 - ...hack_extender_and_sibling_selector_extendee.css | 3 + .../sasslangbroken/css/96-test_nested_target.css | 3 - .../css/98-test_not_remains_at_end_of_selector.css | 3 - ...est_pseudoclass_remains_at_end_of_selector.scss | 2 - ...07-test_pseudoelement_goes_lefter_than_not.scss | 2 - ...pseudoelement_goes_lefter_than_pseudoclass.scss | 2 - ...t_pseudoelement_remains_at_end_of_selector.scss | 2 - .../110-test_redundant_selector_elimination.scss | 3 - .../scss/112-test_target_with_child.scss | 2 - .../sasslangbroken/scss/2-test_basic.scss | 2 - ...n_when_one_extension_fails_but_others_dont.scss | 3 - ...elimination_never_eliminates_base_selector.scss | 2 - .../scss/333-test_empty_content.scss | 2 - ...ination_when_it_would_preserve_specificity.scss | 2 + ...imination_when_it_would_reduce_specificity.scss | 2 - .../scss/368-test_mixins_with_args.scss | 3 - .../scss/420-test_warn_directive.scss | 3 - .../sasslangbroken/scss/55-test_long_extendee.scss | 2 - .../scss/63-test_multiple_extendees.scss | 3 - ..._with_multiple_extenders_and_single_target.scss | 3 - ...nds_with_single_extender_and_single_target.scss | 2 - .../scss/67-test_multiple_targets.scss | 3 - ...-test_combinator_unification_angle_sibling.scss | 2 - .../scss/70-test_nested_extender.scss | 2 - ..._nested_extender_merges_with_same_selector.scss | 3 - .../81-test_nested_extender_runs_unification.scss | 2 - ...5-test_nested_extender_with_child_selector.scss | 2 - ...h_child_selector_merges_with_same_selector.scss | 2 - ...h_early_child_selectors_doesnt_subseq_them.scss | 4 - ...test_nested_extender_with_sibling_selector.scss | 2 - ...selector_with_child_selector_hack_extendee.scss | 2 - ...ack_extender_and_sibling_selector_extendee.scss | 2 + .../sasslangbroken/scss/96-test_nested_target.scss | 2 - .../98-test_not_remains_at_end_of_selector.scss | 2 - 131 files changed, 1083 insertions(+), 988 deletions(-) create mode 100644 theme-compiler/tests/resources/sasslang/css/106-test_pseudoclass_remains_at_end_of_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/107-test_pseudoelement_goes_lefter_than_not.css create mode 100644 theme-compiler/tests/resources/sasslang/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css create mode 100644 theme-compiler/tests/resources/sasslang/css/109-test_pseudoelement_remains_at_end_of_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/110-test_redundant_selector_elimination.css create mode 100644 theme-compiler/tests/resources/sasslang/css/112-test_target_with_child.css create mode 100644 theme-compiler/tests/resources/sasslang/css/2-test_basic.css create mode 100644 theme-compiler/tests/resources/sasslang/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css create mode 100644 theme-compiler/tests/resources/sasslang/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/333-test_empty_content.css delete mode 100644 theme-compiler/tests/resources/sasslang/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css create mode 100644 theme-compiler/tests/resources/sasslang/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css create mode 100644 theme-compiler/tests/resources/sasslang/css/368-test_mixins_with_args.css create mode 100644 theme-compiler/tests/resources/sasslang/css/420-test_warn_directive.css create mode 100644 theme-compiler/tests/resources/sasslang/css/55-test_long_extendee.css create mode 100644 theme-compiler/tests/resources/sasslang/css/63-test_multiple_extendees.css create mode 100644 theme-compiler/tests/resources/sasslang/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css create mode 100644 theme-compiler/tests/resources/sasslang/css/66-test_multiple_extends_with_single_extender_and_single_target.css create mode 100644 theme-compiler/tests/resources/sasslang/css/67-test_multiple_targets.css create mode 100644 theme-compiler/tests/resources/sasslang/css/7-test_combinator_unification_angle_sibling.css create mode 100644 theme-compiler/tests/resources/sasslang/css/70-test_nested_extender.css create mode 100644 theme-compiler/tests/resources/sasslang/css/80-test_nested_extender_merges_with_same_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/81-test_nested_extender_runs_unification.css create mode 100644 theme-compiler/tests/resources/sasslang/css/85-test_nested_extender_with_child_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css create mode 100644 theme-compiler/tests/resources/sasslang/css/90-test_nested_extender_with_sibling_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/css/91-test_nested_selector_with_child_selector_hack_extendee.css delete mode 100644 theme-compiler/tests/resources/sasslang/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css create mode 100644 theme-compiler/tests/resources/sasslang/css/96-test_nested_target.css create mode 100644 theme-compiler/tests/resources/sasslang/css/98-test_not_remains_at_end_of_selector.css create mode 100644 theme-compiler/tests/resources/sasslang/scss/106-test_pseudoclass_remains_at_end_of_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/107-test_pseudoelement_goes_lefter_than_not.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/109-test_pseudoelement_remains_at_end_of_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/110-test_redundant_selector_elimination.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/112-test_target_with_child.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/2-test_basic.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/333-test_empty_content.scss delete mode 100644 theme-compiler/tests/resources/sasslang/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/368-test_mixins_with_args.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/420-test_warn_directive.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/55-test_long_extendee.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/63-test_multiple_extendees.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/67-test_multiple_targets.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/7-test_combinator_unification_angle_sibling.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/70-test_nested_extender.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/80-test_nested_extender_merges_with_same_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/81-test_nested_extender_runs_unification.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/85-test_nested_extender_with_child_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/90-test_nested_extender_with_sibling_selector.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss delete mode 100644 theme-compiler/tests/resources/sasslang/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/96-test_nested_target.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/98-test_not_remains_at_end_of_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/106-test_pseudoclass_remains_at_end_of_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/107-test_pseudoelement_goes_lefter_than_not.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/109-test_pseudoelement_remains_at_end_of_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/110-test_redundant_selector_elimination.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/112-test_target_with_child.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/2-test_basic.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/333-test_empty_content.css create mode 100644 theme-compiler/tests/resources/sasslangbroken/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/368-test_mixins_with_args.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/420-test_warn_directive.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/55-test_long_extendee.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/63-test_multiple_extendees.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/66-test_multiple_extends_with_single_extender_and_single_target.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/67-test_multiple_targets.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/7-test_combinator_unification_angle_sibling.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/70-test_nested_extender.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/80-test_nested_extender_merges_with_same_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/81-test_nested_extender_runs_unification.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/85-test_nested_extender_with_child_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/90-test_nested_extender_with_sibling_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/91-test_nested_selector_with_child_selector_hack_extendee.css create mode 100644 theme-compiler/tests/resources/sasslangbroken/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/96-test_nested_target.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/98-test_not_remains_at_end_of_selector.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/106-test_pseudoclass_remains_at_end_of_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/107-test_pseudoelement_goes_lefter_than_not.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/109-test_pseudoelement_remains_at_end_of_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/110-test_redundant_selector_elimination.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/112-test_target_with_child.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/2-test_basic.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/333-test_empty_content.scss create mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/368-test_mixins_with_args.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/420-test_warn_directive.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/55-test_long_extendee.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/63-test_multiple_extendees.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/67-test_multiple_targets.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/7-test_combinator_unification_angle_sibling.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/70-test_nested_extender.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/80-test_nested_extender_merges_with_same_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/81-test_nested_extender_runs_unification.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/85-test_nested_extender_with_child_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/90-test_nested_extender_with_sibling_selector.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss create mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/96-test_nested_target.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/98-test_not_remains_at_end_of_selector.scss diff --git a/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandler.java b/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandler.java index e6916e5070..3bf6c056c4 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandler.java +++ b/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandler.java @@ -51,8 +51,6 @@ public interface SCSSDocumentHandler extends DocumentHandler { void endNestedProperties(String name); - void includeDirective(String name, List args); - void importStyle(String uri, SACMediaList media, boolean isURL); void property(String name, LexicalUnitImpl value, boolean important, @@ -99,8 +97,8 @@ public interface SCSSDocumentHandler extends DocumentHandler { void contentDirective(); - void startIncludeContentBlock(String name, List args); + void startInclude(String name, List args); - void endIncludeContentBlock(); + void endInclude(); } diff --git a/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandlerImpl.java b/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandlerImpl.java index 99f00e3889..633ab98b9c 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandlerImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/handler/SCSSDocumentHandlerImpl.java @@ -244,12 +244,6 @@ public class SCSSDocumentHandlerImpl implements SCSSDocumentHandler { nodeStack.pop(); } - @Override - public void includeDirective(String name, List args) { - MixinNode node = new MixinNode(name, args); - nodeStack.peek().appendChild(node); - } - @Override public void importStyle(String uri, SACMediaList media, boolean isURL) { ImportNode node = new ImportNode(uri, media, isURL); @@ -375,7 +369,7 @@ public class SCSSDocumentHandlerImpl implements SCSSDocumentHandler { } @Override - public void startIncludeContentBlock(String name, List args) { + public void startInclude(String name, List args) { MixinNode node = new MixinNode(name, args); nodeStack.peek().appendChild(node); nodeStack.push(node); @@ -383,7 +377,7 @@ public class SCSSDocumentHandlerImpl implements SCSSDocumentHandler { } @Override - public void endIncludeContentBlock() { + public void endInclude() { nodeStack.pop(); } } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java index e43320453c..c22f19451b 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java @@ -127,4 +127,4 @@ interface CharStream { void Done(); } -/* JavaCC - OriginalChecksum=18aae0a549695f0fec96a11297b442bb (do not edit this line) */ +/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 86d028a7d4..eee53608b5 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -3908,7 +3908,7 @@ boolean isPseudoElement = false; break; case VARIABLE: name = variableName(); - name = "$"+name; + name = "$"+name; break; case FUNCTION: name = functionName(); @@ -3932,8 +3932,24 @@ boolean isPseudoElement = false; jj_consume_token(-1); throw new ParseException(); } + documentHandler.startInclude(name, args); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACE: + includeDirectiveBlockContents(); + break; case SEMICOLON: + includeDirectiveTerminator(); + break; + default: + jj_la1[165] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + documentHandler.endInclude(); + } + + final public void includeDirectiveTerminator() throws ParseException { + try { label_110: while (true) { jj_consume_token(SEMICOLON); @@ -3944,7 +3960,7 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[165] = jj_gen; + jj_la1[166] = jj_gen; break label_111; } jj_consume_token(S); @@ -3954,98 +3970,93 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[166] = jj_gen; + jj_la1[167] = jj_gen; break label_110; } } - documentHandler.includeDirective(name, args); - break; - case LBRACE: - jj_consume_token(LBRACE); - label_112: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[167] = jj_gen; - break label_112; - } - jj_consume_token(S); + } catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } + } + + final public void includeDirectiveBlockContents() throws ParseException { + jj_consume_token(LBRACE); + label_112: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[168] = jj_gen; + break label_112; } - documentHandler.startIncludeContentBlock(name, args); - label_113: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case TO: - case FROM: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case PERCENTAGE: - case HASH: - ; - break; - default: - jj_la1[168] = jj_gen; - break label_113; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case HASH: - styleRuleOrDeclarationOrNestedProperties(); - break; - case TO: - case FROM: - case PERCENTAGE: - keyframeSelector(); - break; - default: - jj_la1[169] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } + jj_consume_token(S); + } + label_113: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case TO: + case FROM: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case PERCENTAGE: + case HASH: + ; + break; + default: + jj_la1[169] = jj_gen; + break label_113; } - jj_consume_token(RBRACE); - label_114: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[170] = jj_gen; - break label_114; - } - jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case HASH: + styleRuleOrDeclarationOrNestedProperties(); + break; + case TO: + case FROM: + case PERCENTAGE: + keyframeSelector(); + break; + default: + jj_la1[170] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - documentHandler.endIncludeContentBlock(); - break; - default: - jj_la1[171] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); + } + jj_consume_token(RBRACE); + label_114: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[171] = jj_gen; + break label_114; + } + jj_consume_token(S); } } @@ -4662,39 +4673,71 @@ boolean isPseudoElement = false; final public void debugDirective() throws ParseException { jj_consume_token(DEBUG_SYM); - String content = skipStatementUntilSemiColon(); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. System.out.println(content); - label_141: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[209] = jj_gen; - break label_141; + try { + label_141: + while (true) { + jj_consume_token(SEMICOLON); + label_142: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[209] = jj_gen; + break label_142; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[210] = jj_gen; + break label_141; + } } - jj_consume_token(S); + } catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); } } final public void warnDirective() throws ParseException { jj_consume_token(WARN_SYM); - String content = skipStatementUntilSemiColon(); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. System.err.println(content); - label_142: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[210] = jj_gen; - break label_142; + try { + label_143: + while (true) { + jj_consume_token(SEMICOLON); + label_144: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[211] = jj_gen; + break label_144; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[212] = jj_gen; + break label_143; + } } - jj_consume_token(S); + } catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); } } @@ -4718,20 +4761,20 @@ boolean isPseudoElement = false; exclusive = false; break; default: - jj_la1[211] = jj_gen; + jj_la1[213] = jj_gen; jj_consume_token(-1); throw new ParseException(); } to = skipStatementUntilLeftBrace(); - label_143: + label_145: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[212] = jj_gen; - break label_143; + jj_la1[214] = jj_gen; + break label_145; } jj_consume_token(S); } @@ -4752,83 +4795,91 @@ boolean isPseudoElement = false; final public void extendDirective() throws ParseException { ArrayList list; jj_consume_token(EXTEND_SYM); - label_144: + label_146: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[213] = jj_gen; - break label_144; + jj_la1[215] = jj_gen; + break label_146; } jj_consume_token(S); } list = selectorList(); - label_145: - while (true) { - jj_consume_token(SEMICOLON); - label_146: + documentHandler.extendDirective(list); + try { + label_147: while (true) { + jj_consume_token(SEMICOLON); + label_148: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[216] = jj_gen; + break label_148; + } + jj_consume_token(S); + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: + case SEMICOLON: ; break; default: - jj_la1[214] = jj_gen; - break label_146; + jj_la1[217] = jj_gen; + break label_147; } - jj_consume_token(S); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[215] = jj_gen; - break label_145; } + } catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); } - documentHandler.extendDirective(list); } final public void contentDirective() throws ParseException { jj_consume_token(CONTENT_SYM); - label_147: + label_149: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[216] = jj_gen; - break label_147; + jj_la1[218] = jj_gen; + break label_149; } jj_consume_token(S); } - label_148: - while (true) { - jj_consume_token(SEMICOLON); - label_149: + try { + label_150: while (true) { + jj_consume_token(SEMICOLON); + label_151: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[219] = jj_gen; + break label_151; + } + jj_consume_token(S); + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: + case SEMICOLON: ; break; default: - jj_la1[217] = jj_gen; - break label_149; + jj_la1[220] = jj_gen; + break label_150; } - jj_consume_token(S); - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[218] = jj_gen; - break label_148; } + } catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); } documentHandler.contentDirective(); } @@ -4854,28 +4905,28 @@ boolean isPseudoElement = false; LexicalUnit exp; name = property(); jj_consume_token(COLON); - label_150: + label_152: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[219] = jj_gen; - break label_150; + jj_la1[221] = jj_gen; + break label_152; } jj_consume_token(S); } jj_consume_token(LBRACE); - label_151: + label_153: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[220] = jj_gen; - break label_151; + jj_la1[222] = jj_gen; + break label_153; } jj_consume_token(S); } @@ -4886,29 +4937,29 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[221] = jj_gen; + jj_la1[223] = jj_gen; ; } - label_152: + label_154: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[222] = jj_gen; - break label_152; + jj_la1[224] = jj_gen; + break label_154; } jj_consume_token(SEMICOLON); - label_153: + label_155: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[223] = jj_gen; - break label_153; + jj_la1[225] = jj_gen; + break label_155; } jj_consume_token(S); } @@ -4918,21 +4969,21 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[224] = jj_gen; + jj_la1[226] = jj_gen; ; } } jj_consume_token(RBRACE); documentHandler.endNestedProperties(name); - label_154: + label_156: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[225] = jj_gen; - break label_154; + jj_la1[227] = jj_gen; + break label_156; } jj_consume_token(S); } @@ -4949,7 +5000,7 @@ LexicalUnit exp; debuggingDirective(); break; default: - jj_la1[226] = jj_gen; + jj_la1[228] = jj_gen; if (jj_2_6(2147483647)) { styleRule(); } else if (jj_2_7(3)) { @@ -4970,7 +5021,7 @@ LexicalUnit exp; styleRule(); break; default: - jj_la1[227] = jj_gen; + jj_la1[229] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5015,15 +5066,15 @@ LexicalUnit exp; name = property(); save = token; jj_consume_token(COLON); - label_155: + label_157: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[228] = jj_gen; - break label_155; + jj_la1[230] = jj_gen; + break label_157; } jj_consume_token(S); } @@ -5067,7 +5118,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[229] = jj_gen; + jj_la1[231] = jj_gen; ; } Token next = getToken(1); @@ -5086,15 +5137,15 @@ LexicalUnit exp; break; case LBRACE: jj_consume_token(LBRACE); - label_156: + label_158: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[230] = jj_gen; - break label_156; + jj_la1[232] = jj_gen; + break label_158; } jj_consume_token(S); } @@ -5105,29 +5156,29 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[231] = jj_gen; + jj_la1[233] = jj_gen; ; } - label_157: + label_159: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[232] = jj_gen; - break label_157; + jj_la1[234] = jj_gen; + break label_159; } jj_consume_token(SEMICOLON); - label_158: + label_160: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[233] = jj_gen; - break label_158; + jj_la1[235] = jj_gen; + break label_160; } jj_consume_token(S); } @@ -5137,27 +5188,27 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[234] = jj_gen; + jj_la1[236] = jj_gen; ; } } jj_consume_token(RBRACE); - label_159: + label_161: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[235] = jj_gen; - break label_159; + jj_la1[237] = jj_gen; + break label_161; } jj_consume_token(S); } documentHandler.endNestedProperties(name); break; default: - jj_la1[236] = jj_gen; + jj_la1[238] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5207,15 +5258,15 @@ LexicalUnit exp; name = property(); save = token; jj_consume_token(COLON); - label_160: + label_162: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[237] = jj_gen; - break label_160; + jj_la1[239] = jj_gen; + break label_162; } jj_consume_token(S); } @@ -5225,7 +5276,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[238] = jj_gen; + jj_la1[240] = jj_gen; ; } documentHandler.property(name, exp, important); @@ -5268,15 +5319,15 @@ LexicalUnit exp; */ final public boolean prio() throws ParseException { jj_consume_token(IMPORTANT_SYM); - label_161: + label_163: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[239] = jj_gen; - break label_161; + jj_la1[241] = jj_gen; + break label_163; } jj_consume_token(S); } @@ -5286,15 +5337,15 @@ LexicalUnit exp; final public boolean guarded() throws ParseException { jj_consume_token(GUARDED_SYM); - label_162: + label_164: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[240] = jj_gen; - break label_162; + jj_la1[242] = jj_gen; + break label_164; } jj_consume_token(S); } @@ -5319,15 +5370,15 @@ LexicalUnit exp; * 3. parenthesis is not supported now. */ n = jj_consume_token(COMMA); - label_163: + label_165: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[241] = jj_gen; - break label_163; + jj_la1[243] = jj_gen; + break label_165; } jj_consume_token(S); } @@ -5337,15 +5388,15 @@ LexicalUnit exp; break; case DIV: n = jj_consume_token(DIV); - label_164: + label_166: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[242] = jj_gen; - break label_164; + jj_la1[244] = jj_gen; + break label_166; } jj_consume_token(S); } @@ -5355,15 +5406,15 @@ LexicalUnit exp; break; case ANY: n = jj_consume_token(ANY); - label_165: + label_167: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[243] = jj_gen; - break label_165; + jj_la1[245] = jj_gen; + break label_167; } jj_consume_token(S); } @@ -5373,15 +5424,15 @@ LexicalUnit exp; break; case MOD: n = jj_consume_token(MOD); - label_166: + label_168: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[244] = jj_gen; - break label_166; + jj_la1[246] = jj_gen; + break label_168; } jj_consume_token(S); } @@ -5391,7 +5442,7 @@ LexicalUnit exp; break; case PLUS: n = jj_consume_token(PLUS); - label_167: + label_169: while (true) { jj_consume_token(S); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5399,8 +5450,8 @@ LexicalUnit exp; ; break; default: - jj_la1[245] = jj_gen; - break label_167; + jj_la1[247] = jj_gen; + break label_169; } } {if (true) return LexicalUnitImpl.createAdd(n.beginLine, @@ -5409,7 +5460,7 @@ LexicalUnit exp; break; case MINUS: n = jj_consume_token(MINUS); - label_168: + label_170: while (true) { jj_consume_token(S); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5417,8 +5468,8 @@ LexicalUnit exp; ; break; default: - jj_la1[246] = jj_gen; - break label_168; + jj_la1[248] = jj_gen; + break label_170; } } {if (true) return LexicalUnitImpl.createMinus(n.beginLine, @@ -5426,7 +5477,7 @@ LexicalUnit exp; prev);} break; default: - jj_la1[247] = jj_gen; + jj_la1[249] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5441,12 +5492,12 @@ LexicalUnit exp; char op; first = term(null); res = first; - label_169: + label_171: while (true) { if (jj_2_8(2)) { ; } else { - break label_169; + break label_171; } if (jj_2_9(2)) { res = operator(res); @@ -5473,7 +5524,7 @@ LexicalUnit exp; {if (true) return '+';} break; default: - jj_la1[248] = jj_gen; + jj_la1[250] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5526,7 +5577,7 @@ LexicalUnit exp; result = variableTerm(prev); break; default: - jj_la1[249] = jj_gen; + jj_la1[251] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5579,7 +5630,7 @@ LexicalUnitImpl result = null; op = unaryOperator(); break; default: - jj_la1[250] = jj_gen; + jj_la1[252] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5695,7 +5746,7 @@ LexicalUnitImpl result = null; result = function(op, prev); break; default: - jj_la1[251] = jj_gen; + jj_la1[253] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5728,7 +5779,7 @@ LexicalUnitImpl result = null; s+="."; break; default: - jj_la1[252] = jj_gen; + jj_la1[254] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5745,7 +5796,7 @@ LexicalUnitImpl result = null; n = jj_consume_token(FROM); break; default: - jj_la1[253] = jj_gen; + jj_la1[255] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5792,25 +5843,25 @@ LexicalUnitImpl result = null; result = unicode(prev); break; default: - jj_la1[254] = jj_gen; + jj_la1[256] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[255] = jj_gen; + jj_la1[257] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - label_170: + label_172: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[256] = jj_gen; - break label_170; + jj_la1[258] = jj_gen; + break label_172; } jj_consume_token(S); } @@ -5826,15 +5877,15 @@ LexicalUnitImpl result = null; Token n; LexicalUnit params = null; n = jj_consume_token(FUNCTION); - label_171: + label_173: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[257] = jj_gen; - break label_171; + jj_la1[259] = jj_gen; + break label_173; } jj_consume_token(S); } @@ -5885,7 +5936,7 @@ LexicalUnitImpl result = null; params = expr(); break; default: - jj_la1[258] = jj_gen; + jj_la1[260] = jj_gen; ; } jj_consume_token(RPARAN); @@ -6342,15 +6393,15 @@ LexicalUnitImpl result = null; // TODO required by original parser but not used by Vaadin? final public void _parseRule() throws ParseException { String ret = null; - label_172: + label_174: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[259] = jj_gen; - break label_172; + jj_la1[261] = jj_gen; + break label_174; } jj_consume_token(S); } @@ -6385,7 +6436,7 @@ LexicalUnitImpl result = null; fontFace(); break; default: - jj_la1[260] = jj_gen; + jj_la1[262] = jj_gen; ret = skipStatement(); if ((ret == null) || (ret.length() == 0)) { {if (true) return;} @@ -6400,15 +6451,15 @@ LexicalUnitImpl result = null; } final public void _parseImportRule() throws ParseException { - label_173: + label_175: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[261] = jj_gen; - break label_173; + jj_la1[263] = jj_gen; + break label_175; } jj_consume_token(S); } @@ -6416,15 +6467,15 @@ LexicalUnitImpl result = null; } final public void _parseMediaRule() throws ParseException { - label_174: + label_176: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[262] = jj_gen; - break label_174; + jj_la1[264] = jj_gen; + break label_176; } jj_consume_token(S); } @@ -6432,15 +6483,15 @@ LexicalUnitImpl result = null; } final public void _parseDeclarationBlock() throws ParseException { - label_175: + label_177: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[263] = jj_gen; - break label_175; + jj_la1[265] = jj_gen; + break label_177; } jj_consume_token(S); } @@ -6450,29 +6501,29 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[264] = jj_gen; + jj_la1[266] = jj_gen; ; } - label_176: + label_178: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[265] = jj_gen; - break label_176; + jj_la1[267] = jj_gen; + break label_178; } jj_consume_token(SEMICOLON); - label_177: + label_179: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[266] = jj_gen; - break label_177; + jj_la1[268] = jj_gen; + break label_179; } jj_consume_token(S); } @@ -6482,7 +6533,7 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[267] = jj_gen; + jj_la1[269] = jj_gen; ; } } @@ -6491,15 +6542,15 @@ LexicalUnitImpl result = null; final public ArrayList _parseSelectors() throws ParseException { ArrayList p = null; try { - label_178: + label_180: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[268] = jj_gen; - break label_178; + jj_la1[270] = jj_gen; + break label_180; } jj_consume_token(S); } @@ -6511,6 +6562,13 @@ LexicalUnitImpl result = null; throw new Error("Missing return statement in function"); } + void acceptMissingSemicolonBeforeRbrace(ParseException parseException) throws ParseException { + Token next = getToken(1); + if (next.kind != RBRACE) { + throw parseException; + } + } + private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } @@ -6574,29 +6632,14 @@ LexicalUnitImpl result = null; finally { jj_save(8, xla); } } - private boolean jj_3R_213() { - if (jj_scan_token(MOD)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - return false; - } - - private boolean jj_3R_212() { - if (jj_scan_token(ANY)) return true; + private boolean jj_3R_202() { + if (jj_scan_token(VARIABLE)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } - return false; - } - - private boolean jj_3R_211() { - if (jj_scan_token(DIV)) return true; - Token xsp; + if (jj_scan_token(COLON)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -6604,54 +6647,25 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_210() { - if (jj_scan_token(COMMA)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_220() { + if (jj_3R_219()) return true; return false; } - private boolean jj_3R_188() { + private boolean jj_3R_184() { Token xsp; xsp = jj_scanpos; - if (jj_3R_210()) { - jj_scanpos = xsp; - if (jj_3R_211()) { - jj_scanpos = xsp; - if (jj_3R_212()) { - jj_scanpos = xsp; - if (jj_3R_213()) { - jj_scanpos = xsp; - if (jj_3R_214()) { - jj_scanpos = xsp; - if (jj_3R_215()) return true; - } - } - } - } - } - return false; - } - - private boolean jj_3R_216() { - if (jj_scan_token(GUARDED_SYM)) return true; - Token xsp; + if (jj_3R_202()) jj_scanpos = xsp; + if (jj_scan_token(CONTAINS)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } + if (true) { jj_la = 0; jj_scanpos = jj_lastpos; return false;} return false; } - private boolean jj_3R_218() { - if (jj_3R_217()) return true; - return false; - } - - private boolean jj_3R_217() { + private boolean jj_3R_219() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(18)) { @@ -6668,87 +6682,59 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_179() { - if (jj_3R_189()) return true; + private boolean jj_3R_181() { + if (jj_3R_191()) return true; if (jj_scan_token(COLON)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } - if (jj_3R_190()) return true; - xsp = jj_scanpos; - if (jj_3R_191()) jj_scanpos = xsp; if (jj_3R_192()) return true; + xsp = jj_scanpos; + if (jj_3R_193()) jj_scanpos = xsp; + if (jj_3R_194()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_192()) { jj_scanpos = xsp; break; } + if (jj_3R_194()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_194() { + private boolean jj_3R_196() { if (jj_scan_token(S)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_218()) jj_scanpos = xsp; - return false; - } - - private boolean jj_3R_193() { - if (jj_3R_217()) return true; - return false; - } - - private boolean jj_3R_180() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_193()) { - jj_scanpos = xsp; - if (jj_3R_194()) return true; - } + if (jj_3R_220()) jj_scanpos = xsp; return false; } - private boolean jj_3R_200() { - if (jj_scan_token(VARIABLE)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - if (jj_scan_token(COLON)) return true; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_195() { + if (jj_3R_219()) return true; return false; } private boolean jj_3R_182() { Token xsp; xsp = jj_scanpos; - if (jj_3R_200()) jj_scanpos = xsp; - if (jj_scan_token(CONTAINS)) return true; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + if (jj_3R_195()) { + jj_scanpos = xsp; + if (jj_3R_196()) return true; } - if (true) { jj_la = 0; jj_scanpos = jj_lastpos; return false;} return false; } - private boolean jj_3R_220() { + private boolean jj_3R_222() { if (jj_scan_token(HASH)) return true; return false; } - private boolean jj_3R_290() { + private boolean jj_3R_292() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_291() { + private boolean jj_3R_293() { if (jj_scan_token(FUNCTION)) return true; Token xsp; while (true) { @@ -6759,98 +6745,138 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_289() { + private boolean jj_3_7() { + if (jj_3R_188()) return true; + return false; + } + + private boolean jj_3R_291() { if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3R_222() { + private boolean jj_3R_209() { + if (jj_scan_token(LBRACE)) return true; + return false; + } + + private boolean jj_3R_224() { if (jj_scan_token(COLON)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_289()) jj_scanpos = xsp; + if (jj_3R_291()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_290()) { + if (jj_3R_292()) { jj_scanpos = xsp; - if (jj_3R_291()) return true; + if (jj_3R_293()) return true; } return false; } - private boolean jj_3_7() { - if (jj_3R_186()) return true; + private boolean jj_3R_208() { + if (jj_3R_192()) return true; return false; } - private boolean jj_3R_207() { + private boolean jj_3_6() { + if (jj_3R_187()) return true; if (jj_scan_token(LBRACE)) return true; return false; } - private boolean jj_3R_310() { - if (jj_scan_token(STRING)) return true; + private boolean jj_3R_188() { + if (jj_3R_207()) return true; + if (jj_scan_token(COLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_208()) { + jj_scanpos = xsp; + if (jj_3R_209()) return true; + } return false; } - private boolean jj_3R_308() { - if (jj_scan_token(STARMATCH)) return true; + private boolean jj_3R_271() { + if (jj_3R_192()) return true; return false; } - private boolean jj_3R_309() { - if (jj_scan_token(IDENT)) return true; + private boolean jj_3R_312() { + if (jj_scan_token(STRING)) return true; return false; } - private boolean jj_3R_307() { + private boolean jj_3R_261() { + if (jj_scan_token(FUNCTION)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_271()) jj_scanpos = xsp; + if (jj_scan_token(RPARAN)) return true; + return false; + } + + private boolean jj_3R_310() { + if (jj_scan_token(STARMATCH)) return true; + return false; + } + + private boolean jj_3R_311() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_309() { if (jj_scan_token(DOLLARMATCH)) return true; return false; } - private boolean jj_3R_306() { + private boolean jj_3R_308() { if (jj_scan_token(CARETMATCH)) return true; return false; } - private boolean jj_3R_305() { + private boolean jj_3R_307() { if (jj_scan_token(DASHMATCH)) return true; return false; } - private boolean jj_3R_304() { + private boolean jj_3R_306() { if (jj_scan_token(INCLUDES)) return true; return false; } - private boolean jj_3R_206() { - if (jj_3R_190()) return true; - return false; - } - - private boolean jj_3R_271() { + private boolean jj_3R_273() { if (jj_scan_token(INTERPOLATION)) return true; return false; } - private boolean jj_3R_303() { + private boolean jj_3R_305() { if (jj_scan_token(EQ)) return true; return false; } - private boolean jj_3R_296() { + private boolean jj_3R_298() { Token xsp; xsp = jj_scanpos; - if (jj_3R_303()) { - jj_scanpos = xsp; - if (jj_3R_304()) { - jj_scanpos = xsp; if (jj_3R_305()) { jj_scanpos = xsp; if (jj_3R_306()) { jj_scanpos = xsp; if (jj_3R_307()) { jj_scanpos = xsp; - if (jj_3R_308()) return true; + if (jj_3R_308()) { + jj_scanpos = xsp; + if (jj_3R_309()) { + jj_scanpos = xsp; + if (jj_3R_310()) return true; } } } @@ -6861,9 +6887,9 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_309()) { + if (jj_3R_311()) { jj_scanpos = xsp; - if (jj_3R_310()) return true; + if (jj_3R_312()) return true; } while (true) { xsp = jj_scanpos; @@ -6872,29 +6898,22 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3_6() { - if (jj_3R_185()) return true; - if (jj_scan_token(LBRACE)) return true; + private boolean jj_3R_252() { + if (jj_3R_265()) return true; return false; } - private boolean jj_3R_186() { - if (jj_3R_205()) return true; - if (jj_scan_token(COLON)) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } - xsp = jj_scanpos; - if (jj_3R_206()) { - jj_scanpos = xsp; - if (jj_3R_207()) return true; - } + private boolean jj_3R_251() { + if (jj_3R_264()) return true; return false; } - private boolean jj_3R_223() { + private boolean jj_3R_250() { + if (jj_3R_263()) return true; + return false; + } + + private boolean jj_3R_225() { if (jj_scan_token(LBRACKET)) return true; Token xsp; while (true) { @@ -6907,83 +6926,65 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_296()) jj_scanpos = xsp; + if (jj_3R_298()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } - private boolean jj_3R_269() { - if (jj_3R_190()) return true; - return false; - } - - private boolean jj_3R_302() { + private boolean jj_3R_304() { if (jj_scan_token(INTERPOLATION)) return true; return false; } - private boolean jj_3R_257() { + private boolean jj_3R_259() { if (jj_scan_token(PARENT)) return true; return false; } - private boolean jj_3R_256() { + private boolean jj_3R_258() { if (jj_scan_token(ANY)) return true; return false; } - private boolean jj_3R_266() { + private boolean jj_3R_268() { Token xsp; xsp = jj_scanpos; - if (jj_3R_270()) { + if (jj_3R_272()) { jj_scanpos = xsp; - if (jj_3R_271()) return true; + if (jj_3R_273()) return true; } return false; } - private boolean jj_3R_270() { + private boolean jj_3R_272() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_219() { + private boolean jj_3R_221() { Token xsp; xsp = jj_scanpos; - if (jj_3R_255()) { + if (jj_3R_257()) { jj_scanpos = xsp; - if (jj_3R_256()) { + if (jj_3R_258()) { jj_scanpos = xsp; - if (jj_3R_257()) return true; - } + if (jj_3R_259()) return true; } - return false; - } - - private boolean jj_3R_255() { - Token xsp; - if (jj_3R_266()) return true; - while (true) { - xsp = jj_scanpos; - if (jj_3R_266()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_259() { - if (jj_scan_token(FUNCTION)) return true; + private boolean jj_3R_257() { Token xsp; + if (jj_3R_268()) return true; while (true) { xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + if (jj_3R_268()) { jj_scanpos = xsp; break; } } - xsp = jj_scanpos; - if (jj_3R_269()) jj_scanpos = xsp; - if (jj_scan_token(RPARAN)) return true; return false; } - private boolean jj_3R_183() { + private boolean jj_3R_185() { if (jj_scan_token(COMMA)) return true; Token xsp; while (true) { @@ -6993,32 +6994,40 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_250() { - if (jj_3R_263()) return true; - return false; - } - - private boolean jj_3R_249() { - if (jj_3R_262()) return true; + private boolean jj_3R_303() { + if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_248() { - if (jj_3R_261()) return true; + private boolean jj_3R_286() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_303()) { + jj_scanpos = xsp; + if (jj_3R_304()) return true; + } return false; } - private boolean jj_3R_301() { - if (jj_scan_token(IDENT)) return true; + private boolean jj_3R_262() { + if (jj_scan_token(DOT)) return true; return false; } - private boolean jj_3R_284() { + private boolean jj_3R_249() { Token xsp; xsp = jj_scanpos; - if (jj_3R_301()) { + if (jj_3R_262()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(72)) { jj_scanpos = xsp; - if (jj_3R_302()) return true; + if (jj_scan_token(49)) { + jj_scanpos = xsp; + if (jj_scan_token(50)) { + jj_scanpos = xsp; + if (jj_scan_token(52)) return true; + } + } } return false; } @@ -7026,480 +7035,413 @@ LexicalUnitImpl result = null; private boolean jj_3_5() { Token xsp; xsp = jj_scanpos; - if (jj_3R_183()) jj_scanpos = xsp; - if (jj_3R_184()) return true; + if (jj_3R_185()) jj_scanpos = xsp; + if (jj_3R_186()) return true; return false; } - private boolean jj_3R_300() { - if (jj_3R_222()) return true; + private boolean jj_3R_302() { + if (jj_3R_224()) return true; return false; } - private boolean jj_3R_221() { + private boolean jj_3R_248() { + if (jj_scan_token(STRING)) return true; + return false; + } + + private boolean jj_3R_223() { if (jj_scan_token(DOT)) return true; Token xsp; - if (jj_3R_284()) return true; + if (jj_3R_286()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_284()) { jj_scanpos = xsp; break; } + if (jj_3R_286()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_298() { - if (jj_3R_221()) return true; + private boolean jj_3R_247() { + if (jj_3R_261()) return true; return false; } - private boolean jj_3R_293() { - if (jj_3R_221()) return true; + private boolean jj_3R_204() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_248()) { + jj_scanpos = xsp; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) { + jj_scanpos = xsp; + if (jj_3R_251()) { + jj_scanpos = xsp; + if (jj_3R_252()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_300() { + if (jj_3R_223()) return true; return false; } private boolean jj_3R_295() { - if (jj_3R_222()) return true; + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_283() { - if (jj_3R_222()) return true; + private boolean jj_3R_297() { + if (jj_3R_224()) return true; return false; } - private boolean jj_3R_286() { - if (jj_3R_221()) return true; + private boolean jj_3R_285() { + if (jj_3R_224()) return true; return false; } private boolean jj_3R_288() { - if (jj_3R_222()) return true; + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_299() { - if (jj_3R_223()) return true; + private boolean jj_3R_290() { + if (jj_3R_224()) return true; return false; } - private boolean jj_3R_276() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_297()) { - jj_scanpos = xsp; - if (jj_3R_298()) { - jj_scanpos = xsp; - if (jj_3R_299()) { - jj_scanpos = xsp; - if (jj_3R_300()) return true; - } - } - } + private boolean jj_3R_246() { + if (jj_scan_token(DIMEN)) return true; return false; } - private boolean jj_3R_297() { - if (jj_3R_220()) return true; + private boolean jj_3R_245() { + if (jj_scan_token(KHZ)) return true; return false; } - private boolean jj_3R_275() { + private boolean jj_3R_301() { + if (jj_3R_225()) return true; + return false; + } + + private boolean jj_3R_244() { + if (jj_scan_token(HZ)) return true; + return false; + } + + private boolean jj_3R_278() { Token xsp; xsp = jj_scanpos; - if (jj_3R_292()) { + if (jj_3R_299()) { jj_scanpos = xsp; - if (jj_3R_293()) { + if (jj_3R_300()) { jj_scanpos = xsp; - if (jj_3R_294()) { + if (jj_3R_301()) { jj_scanpos = xsp; - if (jj_3R_295()) return true; + if (jj_3R_302()) return true; } } } return false; } - private boolean jj_3R_292() { - if (jj_3R_220()) return true; - return false; - } - - private boolean jj_3R_280() { + private boolean jj_3R_299() { if (jj_3R_222()) return true; return false; } - private boolean jj_3R_274() { + private boolean jj_3R_277() { Token xsp; xsp = jj_scanpos; - if (jj_3R_285()) { + if (jj_3R_294()) { jj_scanpos = xsp; - if (jj_3R_286()) { + if (jj_3R_295()) { jj_scanpos = xsp; - if (jj_3R_287()) { + if (jj_3R_296()) { jj_scanpos = xsp; - if (jj_3R_288()) return true; + if (jj_3R_297()) return true; } } } return false; } - private boolean jj_3R_285() { - if (jj_3R_220()) return true; - return false; - } - private boolean jj_3R_294() { - if (jj_3R_223()) return true; + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_282() { - if (jj_3R_223()) return true; + private boolean jj_3R_243() { + if (jj_scan_token(MS)) return true; return false; } - private boolean jj_3R_287() { - if (jj_3R_223()) return true; + private boolean jj_3R_282() { + if (jj_3R_224()) return true; return false; } - private boolean jj_3R_273() { + private boolean jj_3R_276() { Token xsp; xsp = jj_scanpos; - if (jj_3R_281()) { + if (jj_3R_287()) { jj_scanpos = xsp; - if (jj_3R_282()) { + if (jj_3R_288()) { jj_scanpos = xsp; - if (jj_3R_283()) return true; + if (jj_3R_289()) { + jj_scanpos = xsp; + if (jj_3R_290()) return true; + } } } return false; } - private boolean jj_3R_278() { - if (jj_3R_221()) return true; + private boolean jj_3R_287() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_281() { - if (jj_3R_221()) return true; + private boolean jj_3R_296() { + if (jj_3R_225()) return true; return false; } - private boolean jj_3R_260() { - if (jj_scan_token(DOT)) return true; + private boolean jj_3R_284() { + if (jj_3R_225()) return true; return false; } - private boolean jj_3R_247() { + private boolean jj_3R_242() { + if (jj_scan_token(SECOND)) return true; + return false; + } + + private boolean jj_3R_289() { + if (jj_3R_225()) return true; + return false; + } + + private boolean jj_3R_275() { Token xsp; xsp = jj_scanpos; - if (jj_3R_260()) jj_scanpos = xsp; - xsp = jj_scanpos; - if (jj_scan_token(72)) { + if (jj_3R_283()) { jj_scanpos = xsp; - if (jj_scan_token(49)) { - jj_scanpos = xsp; - if (jj_scan_token(50)) { + if (jj_3R_284()) { jj_scanpos = xsp; - if (jj_scan_token(52)) return true; - } + if (jj_3R_285()) return true; } } return false; } - private boolean jj_3R_246() { - if (jj_scan_token(STRING)) return true; + private boolean jj_3R_280() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_245() { - if (jj_3R_259()) return true; + private boolean jj_3R_283() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_202() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_246()) { - jj_scanpos = xsp; - if (jj_3R_247()) { - jj_scanpos = xsp; - if (jj_3R_248()) { - jj_scanpos = xsp; - if (jj_3R_249()) { - jj_scanpos = xsp; - if (jj_3R_250()) return true; - } - } - } - } + private boolean jj_3R_241() { + if (jj_scan_token(GRAD)) return true; return false; } - private boolean jj_3R_199() { - if (jj_3R_223()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_276()) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_240() { + if (jj_scan_token(RAD)) return true; return false; } - private boolean jj_3R_198() { - if (jj_3R_222()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_275()) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_239() { + if (jj_scan_token(DEG)) return true; return false; } - private boolean jj_3R_279() { - if (jj_3R_223()) return true; + private boolean jj_3R_238() { + if (jj_scan_token(EXS)) return true; return false; } - private boolean jj_3R_197() { - if (jj_3R_221()) return true; + private boolean jj_3R_201() { + if (jj_3R_225()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_274()) { jj_scanpos = xsp; break; } + if (jj_3R_278()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_196() { - if (jj_3R_220()) return true; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_273()) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_237() { + if (jj_scan_token(REM)) return true; return false; } - private boolean jj_3R_272() { + private boolean jj_3R_200() { + if (jj_3R_224()) return true; Token xsp; - xsp = jj_scanpos; - if (jj_3R_277()) { - jj_scanpos = xsp; - if (jj_3R_278()) { - jj_scanpos = xsp; - if (jj_3R_279()) { - jj_scanpos = xsp; - if (jj_3R_280()) return true; - } - } + while (true) { + xsp = jj_scanpos; + if (jj_3R_277()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_277() { - if (jj_3R_220()) return true; + private boolean jj_3R_281() { + if (jj_3R_225()) return true; return false; } - private boolean jj_3R_244() { - if (jj_scan_token(DIMEN)) return true; + private boolean jj_3R_236() { + if (jj_scan_token(LEM)) return true; return false; } - private boolean jj_3R_195() { - if (jj_3R_219()) return true; + private boolean jj_3R_199() { + if (jj_3R_223()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_272()) { jj_scanpos = xsp; break; } + if (jj_3R_276()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_243() { - if (jj_scan_token(KHZ)) return true; + private boolean jj_3R_198() { + if (jj_3R_222()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_275()) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3R_181() { + private boolean jj_3R_274() { Token xsp; xsp = jj_scanpos; - if (jj_3R_195()) { - jj_scanpos = xsp; - if (jj_3R_196()) { + if (jj_3R_279()) { jj_scanpos = xsp; - if (jj_3R_197()) { + if (jj_3R_280()) { jj_scanpos = xsp; - if (jj_3R_198()) { + if (jj_3R_281()) { jj_scanpos = xsp; - if (jj_3R_199()) return true; - } + if (jj_3R_282()) return true; } } } return false; } - private boolean jj_3R_242() { - if (jj_scan_token(HZ)) return true; - return false; - } - - private boolean jj_3R_252() { - if (jj_3R_217()) return true; - if (jj_3R_181()) return true; - return false; - } - - private boolean jj_3R_241() { - if (jj_scan_token(MS)) return true; - return false; - } - - private boolean jj_3R_240() { - if (jj_scan_token(SECOND)) return true; - return false; - } - - private boolean jj_3R_239() { - if (jj_scan_token(GRAD)) return true; - return false; - } - - private boolean jj_3R_238() { - if (jj_scan_token(RAD)) return true; - return false; - } - - private boolean jj_3R_237() { - if (jj_scan_token(DEG)) return true; - return false; - } - - private boolean jj_3R_236() { - if (jj_scan_token(EXS)) return true; + private boolean jj_3R_279() { + if (jj_3R_222()) return true; return false; } private boolean jj_3R_235() { - if (jj_scan_token(REM)) return true; - return false; - } - - private boolean jj_3R_234() { - if (jj_scan_token(LEM)) return true; - return false; - } - - private boolean jj_3R_233() { if (jj_scan_token(EMS)) return true; return false; } - private boolean jj_3R_232() { + private boolean jj_3R_234() { if (jj_scan_token(PX)) return true; return false; } - private boolean jj_3_2() { - if (jj_3R_180()) return true; - if (jj_3R_181()) return true; + private boolean jj_3R_197() { + if (jj_3R_221()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_274()) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3R_231() { + private boolean jj_3R_233() { if (jj_scan_token(IN)) return true; return false; } - private boolean jj_3R_230() { - if (jj_scan_token(PC)) return true; - return false; - } - - private boolean jj_3R_204() { - if (jj_scan_token(COMMA)) return true; + private boolean jj_3R_183() { Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + xsp = jj_scanpos; + if (jj_3R_197()) { + jj_scanpos = xsp; + if (jj_3R_198()) { + jj_scanpos = xsp; + if (jj_3R_199()) { + jj_scanpos = xsp; + if (jj_3R_200()) { + jj_scanpos = xsp; + if (jj_3R_201()) return true; + } + } + } } - if (jj_3R_203()) return true; return false; } - private boolean jj_3R_251() { - if (jj_3R_181()) return true; + private boolean jj_3R_232() { + if (jj_scan_token(PC)) return true; return false; } - private boolean jj_3R_229() { - if (jj_scan_token(MM)) return true; + private boolean jj_3R_254() { + if (jj_3R_219()) return true; + if (jj_3R_183()) return true; return false; } - private boolean jj_3R_228() { - if (jj_scan_token(CM)) return true; + private boolean jj_3R_231() { + if (jj_scan_token(MM)) return true; return false; } - private boolean jj_3R_203() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_251()) { - jj_scanpos = xsp; - if (jj_3R_252()) return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { jj_scanpos = xsp; break; } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { jj_scanpos = xsp; break; } - } + private boolean jj_3R_230() { + if (jj_scan_token(CM)) return true; return false; } - private boolean jj_3R_227() { + private boolean jj_3R_229() { if (jj_scan_token(PT)) return true; return false; } - private boolean jj_3R_226() { + private boolean jj_3R_228() { if (jj_scan_token(PERCENTAGE)) return true; return false; } - private boolean jj_3R_209() { - if (jj_3R_254()) return true; + private boolean jj_3R_211() { + if (jj_3R_256()) return true; return false; } - private boolean jj_3R_225() { + private boolean jj_3R_227() { if (jj_scan_token(NUMBER)) return true; return false; } - private boolean jj_3R_224() { - if (jj_3R_258()) return true; + private boolean jj_3R_226() { + if (jj_3R_260()) return true; return false; } - private boolean jj_3R_201() { + private boolean jj_3R_203() { Token xsp; xsp = jj_scanpos; - if (jj_3R_224()) jj_scanpos = xsp; + if (jj_3R_226()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_225()) { - jj_scanpos = xsp; - if (jj_3R_226()) { - jj_scanpos = xsp; if (jj_3R_227()) { jj_scanpos = xsp; if (jj_3R_228()) { @@ -7536,7 +7478,11 @@ LexicalUnitImpl result = null; jj_scanpos = xsp; if (jj_3R_244()) { jj_scanpos = xsp; - if (jj_3R_245()) return true; + if (jj_3R_245()) { + jj_scanpos = xsp; + if (jj_3R_246()) { + jj_scanpos = xsp; + if (jj_3R_247()) return true; } } } @@ -7560,12 +7506,12 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_184() { + private boolean jj_3R_186() { Token xsp; xsp = jj_scanpos; - if (jj_3R_201()) { + if (jj_3R_203()) { jj_scanpos = xsp; - if (jj_3R_202()) return true; + if (jj_3R_204()) return true; } while (true) { xsp = jj_scanpos; @@ -7574,92 +7520,117 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_261() { + private boolean jj_3R_263() { if (jj_scan_token(HASH)) return true; return false; } - private boolean jj_3_1() { - if (jj_3R_179()) return true; + private boolean jj_3_2() { + if (jj_3R_182()) return true; + if (jj_3R_183()) return true; return false; } - private boolean jj_3R_185() { - if (jj_3R_203()) return true; + private boolean jj_3R_256() { + if (jj_3R_191()) return true; + return false; + } + + private boolean jj_3R_264() { + if (jj_scan_token(URL)) return true; + return false; + } + + private boolean jj_3R_206() { + if (jj_scan_token(COMMA)) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_204()) { jj_scanpos = xsp; break; } + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } + if (jj_3R_205()) return true; return false; } - private boolean jj_3_4() { - if (jj_3R_182()) return true; - return false; - } - - private boolean jj_3R_254() { - if (jj_3R_189()) return true; + private boolean jj_3R_253() { + if (jj_3R_183()) return true; return false; } - private boolean jj_3R_262() { - if (jj_scan_token(URL)) return true; + private boolean jj_3R_205() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_253()) { + jj_scanpos = xsp; + if (jj_3R_254()) return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3R_208() { - if (jj_3R_184()) return true; + private boolean jj_3R_210() { + if (jj_3R_186()) return true; return false; } - private boolean jj_3R_187() { + private boolean jj_3R_189() { Token xsp; xsp = jj_scanpos; - if (jj_3R_208()) { + if (jj_3R_210()) { jj_scanpos = xsp; - if (jj_3R_209()) return true; + if (jj_3R_211()) return true; } return false; } private boolean jj_3_9() { - if (jj_3R_188()) return true; - return false; - } - - private boolean jj_3R_265() { - if (jj_scan_token(INTERPOLATION)) return true; + if (jj_3R_190()) return true; return false; } - private boolean jj_3R_268() { + private boolean jj_3R_270() { if (jj_scan_token(PLUS)) return true; return false; } - private boolean jj_3R_258() { + private boolean jj_3R_260() { Token xsp; xsp = jj_scanpos; - if (jj_3R_267()) { + if (jj_3R_269()) { jj_scanpos = xsp; - if (jj_3R_268()) return true; + if (jj_3R_270()) return true; } return false; } - private boolean jj_3R_267() { + private boolean jj_3R_269() { if (jj_scan_token(MINUS)) return true; return false; } - private boolean jj_3_3() { - if (jj_3R_179()) return true; + private boolean jj_3_1() { + if (jj_3R_181()) return true; return false; } - private boolean jj_3R_263() { + private boolean jj_3R_187() { + if (jj_3R_205()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_206()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_265() { if (jj_scan_token(UNICODERANGE)) return true; return false; } @@ -7668,12 +7639,17 @@ LexicalUnitImpl result = null; Token xsp; xsp = jj_scanpos; if (jj_3_9()) jj_scanpos = xsp; - if (jj_3R_187()) return true; + if (jj_3R_189()) return true; return false; } - private boolean jj_3R_190() { - if (jj_3R_187()) return true; + private boolean jj_3_4() { + if (jj_3R_184()) return true; + return false; + } + + private boolean jj_3R_192() { + if (jj_3R_189()) return true; Token xsp; while (true) { xsp = jj_scanpos; @@ -7682,9 +7658,10 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_192() { - if (jj_scan_token(SEMICOLON)) return true; + private boolean jj_3R_217() { + if (jj_scan_token(MINUS)) return true; Token xsp; + if (jj_scan_token(1)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -7692,9 +7669,10 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_189() { - if (jj_scan_token(VARIABLE)) return true; + private boolean jj_3R_216() { + if (jj_scan_token(PLUS)) return true; Token xsp; + if (jj_scan_token(1)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -7702,28 +7680,49 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_253() { + private boolean jj_3R_267() { + if (jj_scan_token(INTERPOLATION)) return true; + return false; + } + + private boolean jj_3_3() { + if (jj_3R_181()) return true; + return false; + } + + private boolean jj_3R_215() { + if (jj_scan_token(MOD)) return true; Token xsp; - xsp = jj_scanpos; - if (jj_3R_264()) { - jj_scanpos = xsp; - if (jj_3R_265()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_264() { - if (jj_scan_token(IDENT)) return true; + private boolean jj_3R_214() { + if (jj_scan_token(ANY)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } return false; } - private boolean jj_3R_205() { + private boolean jj_3R_213() { + if (jj_scan_token(DIV)) return true; Token xsp; - if (jj_3R_253()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_253()) { jj_scanpos = xsp; break; } + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } + return false; + } + + private boolean jj_3R_194() { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -7731,10 +7730,9 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_215() { - if (jj_scan_token(MINUS)) return true; + private boolean jj_3R_212() { + if (jj_scan_token(COMMA)) return true; Token xsp; - if (jj_scan_token(1)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -7742,10 +7740,31 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_214() { - if (jj_scan_token(PLUS)) return true; + private boolean jj_3R_190() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_212()) { + jj_scanpos = xsp; + if (jj_3R_213()) { + jj_scanpos = xsp; + if (jj_3R_214()) { + jj_scanpos = xsp; + if (jj_3R_215()) { + jj_scanpos = xsp; + if (jj_3R_216()) { + jj_scanpos = xsp; + if (jj_3R_217()) return true; + } + } + } + } + } + return false; + } + + private boolean jj_3R_191() { + if (jj_scan_token(VARIABLE)) return true; Token xsp; - if (jj_scan_token(1)) return true; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } @@ -7753,8 +7772,47 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_191() { - if (jj_3R_216()) return true; + private boolean jj_3R_255() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_266()) { + jj_scanpos = xsp; + if (jj_3R_267()) return true; + } + return false; + } + + private boolean jj_3R_266() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_207() { + Token xsp; + if (jj_3R_255()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_255()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_218() { + if (jj_scan_token(GUARDED_SYM)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_193() { + if (jj_3R_218()) return true; return false; } @@ -7768,7 +7826,7 @@ LexicalUnitImpl result = null; private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[269]; + final private int[] jj_la1 = new int[271]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; @@ -7780,16 +7838,16 @@ LexicalUnitImpl result = null; jj_la1_init_3(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x0,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x800c0000,0x2,0x2,0x0,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x200400,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x2,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; + jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x0,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x800c0000,0x2,0x2,0x0,0x200400,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x200000,0x2,0x200000,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x160000,0x0,0x0,0x80,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x160000,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; } private static void jj_la1_init_2() { - jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0xfffffb80,0x0,0x0,0x1100,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; + jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0xfffffb80,0x0,0x0,0x1100,0x0,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; } private static void jj_la1_init_3() { - jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x440001,0x0,0x0,0x400000,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x440001,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[9]; private boolean jj_rescan = false; @@ -7801,7 +7859,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 269; i++) jj_la1[i] = -1; + for (int i = 0; i < 271; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7811,7 +7869,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 269; i++) jj_la1[i] = -1; + for (int i = 0; i < 271; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7821,7 +7879,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 269; i++) jj_la1[i] = -1; + for (int i = 0; i < 271; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7831,7 +7889,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 269; i++) jj_la1[i] = -1; + for (int i = 0; i < 271; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7948,7 +8006,7 @@ LexicalUnitImpl result = null; la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 269; i++) { + for (int i = 0; i < 271; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< ()* - (name = property()|name = variableName(){ name = "$"+name;} - |(name = functionName() - args = argValuelist()) ()*) - ((";"()*)+ - {documentHandler.includeDirective(name, args);} - | ()* {documentHandler.startIncludeContentBlock(name, args);} - (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* - ()* {documentHandler.endIncludeContentBlock();} - ) + (name = property() | name = variableName(){ name = "$"+name;} + | (name = functionName() args = argValuelist()) ()*) + {documentHandler.startInclude(name, args);} + (includeDirectiveBlockContents() | includeDirectiveTerminator()) + {documentHandler.endInclude();} } +void includeDirectiveTerminator(): +{} +{ + try { + (";"()*)+ + } + catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } +} + +void includeDirectiveBlockContents(): +{} +{ + ()* + (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* + ()* +} + + String interpolation() : { Token n; @@ -1976,11 +1992,16 @@ void debugDirective() : { { - String content = skipStatementUntilSemiColon(); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. System.out.println(content); } - ()* + try { + (";"()*)+ + } + catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } } void warnDirective() : @@ -1988,11 +2009,16 @@ void warnDirective() : { { - String content = skipStatementUntilSemiColon(); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. System.err.println(content); } - ()* + try { + (";"()*)+ + } + catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } } Node forDirective() : @@ -2035,8 +2061,13 @@ void extendDirective() : ()* list = selectorList() - (";"()*)+ {documentHandler.extendDirective(list);} + try { + (";"()*)+ + } + catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } } void contentDirective() : @@ -2044,7 +2075,12 @@ void contentDirective() : { ()* - (";"()*)+ + try { + (";"()*)+ + } + catch (ParseException e) { + acceptMissingSemicolonBeforeRbrace(e); + } {documentHandler.contentDirective();} } @@ -3050,6 +3086,15 @@ ArrayList _parseSelectors() : } } +JAVACODE +void acceptMissingSemicolonBeforeRbrace( ParseException parseException ) { + Token next = getToken(1); + if (next.kind != RBRACE) { + throw parseException; + } +} + + /* * Local Variables: * compile-command: javacc Parser.jj & javac Parser.java diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java index ba29df7d33..26d1121f96 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java @@ -143,4 +143,4 @@ public class Token implements java.io.Serializable { } } -/* JavaCC - OriginalChecksum=8b653fc6be4ca9bd10137ee3ad4c32c4 (do not edit this line) */ +/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java index 1757cf6705..f093357e96 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java @@ -159,4 +159,4 @@ public class TokenMgrError extends Error this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=525946b34c715198d7c29f668b049f5d (do not edit this line) */ +/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ diff --git a/theme-compiler/tests/resources/sasslang/css/106-test_pseudoclass_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslang/css/106-test_pseudoclass_remains_at_end_of_selector.css new file mode 100644 index 0000000000..2118fad2a2 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/106-test_pseudoclass_remains_at_end_of_selector.css @@ -0,0 +1,3 @@ +.foo:bar, .baz:bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/107-test_pseudoelement_goes_lefter_than_not.css b/theme-compiler/tests/resources/sasslang/css/107-test_pseudoelement_goes_lefter_than_not.css new file mode 100644 index 0000000000..7a53dec628 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/107-test_pseudoelement_goes_lefter_than_not.css @@ -0,0 +1,3 @@ +.foo::bar, .baz:not(.bang)::bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css b/theme-compiler/tests/resources/sasslang/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css new file mode 100644 index 0000000000..a5ae5ac363 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css @@ -0,0 +1,3 @@ +.foo::bar, .baz:bang::bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/109-test_pseudoelement_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslang/css/109-test_pseudoelement_remains_at_end_of_selector.css new file mode 100644 index 0000000000..aa379e70b3 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/109-test_pseudoelement_remains_at_end_of_selector.css @@ -0,0 +1,3 @@ +.foo::bar, .baz::bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/110-test_redundant_selector_elimination.css b/theme-compiler/tests/resources/sasslang/css/110-test_redundant_selector_elimination.css new file mode 100644 index 0000000000..7be91d143a --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/110-test_redundant_selector_elimination.css @@ -0,0 +1,3 @@ +.foo.bar, .x, .y { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/112-test_target_with_child.css b/theme-compiler/tests/resources/sasslang/css/112-test_target_with_child.css new file mode 100644 index 0000000000..cee3a34a5a --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/112-test_target_with_child.css @@ -0,0 +1,3 @@ +.foo .bar, .baz .bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/2-test_basic.css b/theme-compiler/tests/resources/sasslang/css/2-test_basic.css new file mode 100644 index 0000000000..4504b8d829 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/2-test_basic.css @@ -0,0 +1,3 @@ +.foo, .bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css b/theme-compiler/tests/resources/sasslang/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css new file mode 100644 index 0000000000..47d93c5dc1 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css @@ -0,0 +1,7 @@ +a.bar { + a: b; +} + +.bar, b.foo { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslang/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css b/theme-compiler/tests/resources/sasslang/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css new file mode 100644 index 0000000000..4a4aa6d222 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css @@ -0,0 +1,3 @@ +a.foo, .foo { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/333-test_empty_content.css b/theme-compiler/tests/resources/sasslang/css/333-test_empty_content.css new file mode 100644 index 0000000000..f1c0f6c996 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/333-test_empty_content.css @@ -0,0 +1,3 @@ +a { + b: c; +} diff --git a/theme-compiler/tests/resources/sasslang/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css b/theme-compiler/tests/resources/sasslang/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css deleted file mode 100644 index 77b7586abb..0000000000 --- a/theme-compiler/tests/resources/sasslang/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css +++ /dev/null @@ -1,3 +0,0 @@ -.bar a { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslang/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css b/theme-compiler/tests/resources/sasslang/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css new file mode 100644 index 0000000000..eb28eca8fa --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css @@ -0,0 +1,3 @@ +a, a.foo { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/368-test_mixins_with_args.css b/theme-compiler/tests/resources/sasslang/css/368-test_mixins_with_args.css new file mode 100644 index 0000000000..318a3f6ffb --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/368-test_mixins_with_args.css @@ -0,0 +1,3 @@ +.foo { + a: bar; +} diff --git a/theme-compiler/tests/resources/sasslang/css/420-test_warn_directive.css b/theme-compiler/tests/resources/sasslang/css/420-test_warn_directive.css new file mode 100644 index 0000000000..6d661f2404 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/420-test_warn_directive.css @@ -0,0 +1,3 @@ +bar { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslang/css/55-test_long_extendee.css b/theme-compiler/tests/resources/sasslang/css/55-test_long_extendee.css new file mode 100644 index 0000000000..0d6bd2ec98 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/55-test_long_extendee.css @@ -0,0 +1,3 @@ +.foo.bar, .baz { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/63-test_multiple_extendees.css b/theme-compiler/tests/resources/sasslang/css/63-test_multiple_extendees.css new file mode 100644 index 0000000000..d3fae7600f --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/63-test_multiple_extendees.css @@ -0,0 +1,7 @@ +.foo, .baz { + a: b; +} + +.bar, .baz { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslang/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css b/theme-compiler/tests/resources/sasslang/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css new file mode 100644 index 0000000000..44196e6602 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css @@ -0,0 +1,3 @@ +.foo .bar, .baz .bar, .foo .bang, .baz .bang { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/66-test_multiple_extends_with_single_extender_and_single_target.css b/theme-compiler/tests/resources/sasslang/css/66-test_multiple_extends_with_single_extender_and_single_target.css new file mode 100644 index 0000000000..9b5770d7c5 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/66-test_multiple_extends_with_single_extender_and_single_target.css @@ -0,0 +1,3 @@ +.foo .bar, .baz .bar, .foo .baz, .baz .baz { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/67-test_multiple_targets.css b/theme-compiler/tests/resources/sasslang/css/67-test_multiple_targets.css new file mode 100644 index 0000000000..779bd00f75 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/67-test_multiple_targets.css @@ -0,0 +1,7 @@ +.foo, .bar { + a: b; +} + +.blip .foo, .blip .bar { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslang/css/7-test_combinator_unification_angle_sibling.css b/theme-compiler/tests/resources/sasslang/css/7-test_combinator_unification_angle_sibling.css new file mode 100644 index 0000000000..657d1ec2f6 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/7-test_combinator_unification_angle_sibling.css @@ -0,0 +1,3 @@ +.a > x, .a > .b ~ y { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/70-test_nested_extender.css b/theme-compiler/tests/resources/sasslang/css/70-test_nested_extender.css new file mode 100644 index 0000000000..1c4e604b71 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/70-test_nested_extender.css @@ -0,0 +1,3 @@ +.foo, foo bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/80-test_nested_extender_merges_with_same_selector.css b/theme-compiler/tests/resources/sasslang/css/80-test_nested_extender_merges_with_same_selector.css new file mode 100644 index 0000000000..d1a50d50e3 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/80-test_nested_extender_merges_with_same_selector.css @@ -0,0 +1,3 @@ +.foo .bar, .foo .baz { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/81-test_nested_extender_runs_unification.css b/theme-compiler/tests/resources/sasslang/css/81-test_nested_extender_runs_unification.css new file mode 100644 index 0000000000..9aa8d14958 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/81-test_nested_extender_runs_unification.css @@ -0,0 +1,3 @@ +.foo.bar, foo bar.bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/85-test_nested_extender_with_child_selector.css b/theme-compiler/tests/resources/sasslang/css/85-test_nested_extender_with_child_selector.css new file mode 100644 index 0000000000..f7bd620245 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/85-test_nested_extender_with_child_selector.css @@ -0,0 +1,3 @@ +.baz .foo, .baz foo > bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css b/theme-compiler/tests/resources/sasslang/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css new file mode 100644 index 0000000000..75561708b3 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css @@ -0,0 +1,3 @@ +.foo > .bar .baz, .foo > .bar .bang { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css b/theme-compiler/tests/resources/sasslang/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css new file mode 100644 index 0000000000..4285daf8dd --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css @@ -0,0 +1,3 @@ +.foo .bar, .foo .bip > .baz { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/90-test_nested_extender_with_sibling_selector.css b/theme-compiler/tests/resources/sasslang/css/90-test_nested_extender_with_sibling_selector.css new file mode 100644 index 0000000000..e9fe832391 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/90-test_nested_extender_with_sibling_selector.css @@ -0,0 +1,3 @@ +.baz .foo, .baz foo + bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/91-test_nested_selector_with_child_selector_hack_extendee.css b/theme-compiler/tests/resources/sasslang/css/91-test_nested_selector_with_child_selector_hack_extendee.css new file mode 100644 index 0000000000..5556837892 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/91-test_nested_selector_with_child_selector_hack_extendee.css @@ -0,0 +1,3 @@ +> .foo, > foo bar { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css b/theme-compiler/tests/resources/sasslang/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css deleted file mode 100644 index 09b4ccac27..0000000000 --- a/theme-compiler/tests/resources/sasslang/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css +++ /dev/null @@ -1,3 +0,0 @@ -~ .foo { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslang/css/96-test_nested_target.css b/theme-compiler/tests/resources/sasslang/css/96-test_nested_target.css new file mode 100644 index 0000000000..d1a50d50e3 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/96-test_nested_target.css @@ -0,0 +1,3 @@ +.foo .bar, .foo .baz { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/css/98-test_not_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslang/css/98-test_not_remains_at_end_of_selector.css new file mode 100644 index 0000000000..540e6f8bf4 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/98-test_not_remains_at_end_of_selector.css @@ -0,0 +1,3 @@ +.foo:not(.bar), .baz:not(.bar) { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslang/scss/106-test_pseudoclass_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslang/scss/106-test_pseudoclass_remains_at_end_of_selector.scss new file mode 100644 index 0000000000..619bbb51cd --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/106-test_pseudoclass_remains_at_end_of_selector.scss @@ -0,0 +1,2 @@ +.foo:bar {a: b} +.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/107-test_pseudoelement_goes_lefter_than_not.scss b/theme-compiler/tests/resources/sasslang/scss/107-test_pseudoelement_goes_lefter_than_not.scss new file mode 100644 index 0000000000..f50ad04b12 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/107-test_pseudoelement_goes_lefter_than_not.scss @@ -0,0 +1,2 @@ +.foo::bar {a: b} +.baz:not(.bang) {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss b/theme-compiler/tests/resources/sasslang/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss new file mode 100644 index 0000000000..230f925a10 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss @@ -0,0 +1,2 @@ +.foo::bar {a: b} +.baz:bang {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/109-test_pseudoelement_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslang/scss/109-test_pseudoelement_remains_at_end_of_selector.scss new file mode 100644 index 0000000000..cd588ed24a --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/109-test_pseudoelement_remains_at_end_of_selector.scss @@ -0,0 +1,2 @@ +.foo::bar {a: b} +.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/110-test_redundant_selector_elimination.scss b/theme-compiler/tests/resources/sasslang/scss/110-test_redundant_selector_elimination.scss new file mode 100644 index 0000000000..ab8ba4845f --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/110-test_redundant_selector_elimination.scss @@ -0,0 +1,3 @@ +.foo.bar {a: b} +.x {@extend .foo, .bar} +.y {@extend .foo, .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/112-test_target_with_child.scss b/theme-compiler/tests/resources/sasslang/scss/112-test_target_with_child.scss new file mode 100644 index 0000000000..3748f64233 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/112-test_target_with_child.scss @@ -0,0 +1,2 @@ +.foo .bar {a: b} +.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/2-test_basic.scss b/theme-compiler/tests/resources/sasslang/scss/2-test_basic.scss new file mode 100644 index 0000000000..9f3cde0011 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/2-test_basic.scss @@ -0,0 +1,2 @@ +.foo {a: b} +.bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss b/theme-compiler/tests/resources/sasslang/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss new file mode 100644 index 0000000000..a5a0dff1d0 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss @@ -0,0 +1,3 @@ +a.bar {a: b} +.bar {c: d} +b.foo {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss b/theme-compiler/tests/resources/sasslang/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss new file mode 100644 index 0000000000..ac6ad58994 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss @@ -0,0 +1,2 @@ +a.foo {a: b} +.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslang/scss/333-test_empty_content.scss b/theme-compiler/tests/resources/sasslang/scss/333-test_empty_content.scss new file mode 100644 index 0000000000..ad8df41f25 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/333-test_empty_content.scss @@ -0,0 +1,2 @@ +@mixin foo { @content } +a { b: c; @include foo {} } diff --git a/theme-compiler/tests/resources/sasslang/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss b/theme-compiler/tests/resources/sasslang/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss deleted file mode 100644 index 713644b221..0000000000 --- a/theme-compiler/tests/resources/sasslang/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss +++ /dev/null @@ -1,2 +0,0 @@ -.bar a {a: b} -a.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslang/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss b/theme-compiler/tests/resources/sasslang/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss new file mode 100644 index 0000000000..30a9d092cb --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss @@ -0,0 +1,2 @@ +a {a: b} +a.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslang/scss/368-test_mixins_with_args.scss b/theme-compiler/tests/resources/sasslang/scss/368-test_mixins_with_args.scss new file mode 100644 index 0000000000..3ba39ecac2 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/368-test_mixins_with_args.scss @@ -0,0 +1,3 @@ +@mixin foo($a) {a: $a} + +.foo {@include foo(bar)} diff --git a/theme-compiler/tests/resources/sasslang/scss/420-test_warn_directive.scss b/theme-compiler/tests/resources/sasslang/scss/420-test_warn_directive.scss new file mode 100644 index 0000000000..53546355cc --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/420-test_warn_directive.scss @@ -0,0 +1,3 @@ +@mixin foo { @warn "this is a mixin";} +@warn "this is a warning"; +bar {c: d; @include foo;} diff --git a/theme-compiler/tests/resources/sasslang/scss/55-test_long_extendee.scss b/theme-compiler/tests/resources/sasslang/scss/55-test_long_extendee.scss new file mode 100644 index 0000000000..26ab65d344 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/55-test_long_extendee.scss @@ -0,0 +1,2 @@ +.foo.bar {a: b} +.baz {@extend .foo.bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/63-test_multiple_extendees.scss b/theme-compiler/tests/resources/sasslang/scss/63-test_multiple_extendees.scss new file mode 100644 index 0000000000..2c0f5aa72a --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/63-test_multiple_extendees.scss @@ -0,0 +1,3 @@ +.foo {a: b} +.bar {c: d} +.baz {@extend .foo; @extend .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss b/theme-compiler/tests/resources/sasslang/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss new file mode 100644 index 0000000000..4c2a4c59f8 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss @@ -0,0 +1,3 @@ +.foo .bar {a: b} +.baz {@extend .foo} +.bang {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss b/theme-compiler/tests/resources/sasslang/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss new file mode 100644 index 0000000000..48d9c5b733 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss @@ -0,0 +1,2 @@ +.foo .bar {a: b} +.baz {@extend .foo; @extend .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/67-test_multiple_targets.scss b/theme-compiler/tests/resources/sasslang/scss/67-test_multiple_targets.scss new file mode 100644 index 0000000000..fdcba65999 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/67-test_multiple_targets.scss @@ -0,0 +1,3 @@ +.foo {a: b} +.bar {@extend .foo} +.blip .foo {c: d} diff --git a/theme-compiler/tests/resources/sasslang/scss/7-test_combinator_unification_angle_sibling.scss b/theme-compiler/tests/resources/sasslang/scss/7-test_combinator_unification_angle_sibling.scss new file mode 100644 index 0000000000..b0120ac34e --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/7-test_combinator_unification_angle_sibling.scss @@ -0,0 +1,2 @@ +.a > x {a: b} +.b ~ y {@extend x} diff --git a/theme-compiler/tests/resources/sasslang/scss/70-test_nested_extender.scss b/theme-compiler/tests/resources/sasslang/scss/70-test_nested_extender.scss new file mode 100644 index 0000000000..6245cdfda7 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/70-test_nested_extender.scss @@ -0,0 +1,2 @@ +.foo {a: b} +foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/80-test_nested_extender_merges_with_same_selector.scss b/theme-compiler/tests/resources/sasslang/scss/80-test_nested_extender_merges_with_same_selector.scss new file mode 100644 index 0000000000..d959cce374 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/80-test_nested_extender_merges_with_same_selector.scss @@ -0,0 +1,3 @@ +.foo { + .bar {a: b} + .baz {@extend .bar} } diff --git a/theme-compiler/tests/resources/sasslang/scss/81-test_nested_extender_runs_unification.scss b/theme-compiler/tests/resources/sasslang/scss/81-test_nested_extender_runs_unification.scss new file mode 100644 index 0000000000..32c2c0cc62 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/81-test_nested_extender_runs_unification.scss @@ -0,0 +1,2 @@ +.foo.bar {a: b} +foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/85-test_nested_extender_with_child_selector.scss b/theme-compiler/tests/resources/sasslang/scss/85-test_nested_extender_with_child_selector.scss new file mode 100644 index 0000000000..da249ad564 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/85-test_nested_extender_with_child_selector.scss @@ -0,0 +1,2 @@ +.baz .foo {a: b} +foo > bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss b/theme-compiler/tests/resources/sasslang/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss new file mode 100644 index 0000000000..224945cd71 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss @@ -0,0 +1,2 @@ +.foo > .bar .baz {a: b} +.foo > .bar .bang {@extend .baz} diff --git a/theme-compiler/tests/resources/sasslang/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss b/theme-compiler/tests/resources/sasslang/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss new file mode 100644 index 0000000000..f2b8c6c07b --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss @@ -0,0 +1,4 @@ +.foo { + .bar {a: b} + .bip > .baz {@extend .bar} +} diff --git a/theme-compiler/tests/resources/sasslang/scss/90-test_nested_extender_with_sibling_selector.scss b/theme-compiler/tests/resources/sasslang/scss/90-test_nested_extender_with_sibling_selector.scss new file mode 100644 index 0000000000..b9d495ce76 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/90-test_nested_extender_with_sibling_selector.scss @@ -0,0 +1,2 @@ +.baz .foo {a: b} +foo + bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss b/theme-compiler/tests/resources/sasslang/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss new file mode 100644 index 0000000000..928bc64f93 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss @@ -0,0 +1,2 @@ +> .foo {a: b} +foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss b/theme-compiler/tests/resources/sasslang/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss deleted file mode 100644 index 73f6254f21..0000000000 --- a/theme-compiler/tests/resources/sasslang/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss +++ /dev/null @@ -1,2 +0,0 @@ -~ .foo {a: b} -> foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslang/scss/96-test_nested_target.scss b/theme-compiler/tests/resources/sasslang/scss/96-test_nested_target.scss new file mode 100644 index 0000000000..6662dea791 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/96-test_nested_target.scss @@ -0,0 +1,2 @@ +.foo .bar {a: b} +.baz {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslang/scss/98-test_not_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslang/scss/98-test_not_remains_at_end_of_selector.scss new file mode 100644 index 0000000000..c1af8b1b2a --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/98-test_not_remains_at_end_of_selector.scss @@ -0,0 +1,2 @@ +.foo:not(.bar) {a: b} +.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/106-test_pseudoclass_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/106-test_pseudoclass_remains_at_end_of_selector.css deleted file mode 100644 index 2118fad2a2..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/106-test_pseudoclass_remains_at_end_of_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo:bar, .baz:bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/107-test_pseudoelement_goes_lefter_than_not.css b/theme-compiler/tests/resources/sasslangbroken/css/107-test_pseudoelement_goes_lefter_than_not.css deleted file mode 100644 index 7a53dec628..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/107-test_pseudoelement_goes_lefter_than_not.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo::bar, .baz:not(.bang)::bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css b/theme-compiler/tests/resources/sasslangbroken/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css deleted file mode 100644 index a5ae5ac363..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/108-test_pseudoelement_goes_lefter_than_pseudoclass.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo::bar, .baz:bang::bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/109-test_pseudoelement_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/109-test_pseudoelement_remains_at_end_of_selector.css deleted file mode 100644 index aa379e70b3..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/109-test_pseudoelement_remains_at_end_of_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo::bar, .baz::bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/110-test_redundant_selector_elimination.css b/theme-compiler/tests/resources/sasslangbroken/css/110-test_redundant_selector_elimination.css deleted file mode 100644 index 7be91d143a..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/110-test_redundant_selector_elimination.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo.bar, .x, .y { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/112-test_target_with_child.css b/theme-compiler/tests/resources/sasslangbroken/css/112-test_target_with_child.css deleted file mode 100644 index cee3a34a5a..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/112-test_target_with_child.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .baz .bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/2-test_basic.css b/theme-compiler/tests/resources/sasslangbroken/css/2-test_basic.css deleted file mode 100644 index 4504b8d829..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/2-test_basic.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo, .bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css b/theme-compiler/tests/resources/sasslangbroken/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css deleted file mode 100644 index 47d93c5dc1..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.css +++ /dev/null @@ -1,7 +0,0 @@ -a.bar { - a: b; -} - -.bar, b.foo { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css deleted file mode 100644 index 4a4aa6d222..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/33-test_extend_redundancy_elimination_never_eliminates_base_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -a.foo, .foo { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/333-test_empty_content.css b/theme-compiler/tests/resources/sasslangbroken/css/333-test_empty_content.css deleted file mode 100644 index f1c0f6c996..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/333-test_empty_content.css +++ /dev/null @@ -1,3 +0,0 @@ -a { - b: c; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css b/theme-compiler/tests/resources/sasslangbroken/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css new file mode 100644 index 0000000000..77b7586abb --- /dev/null +++ b/theme-compiler/tests/resources/sasslangbroken/css/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.css @@ -0,0 +1,3 @@ +.bar a { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css b/theme-compiler/tests/resources/sasslangbroken/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css deleted file mode 100644 index eb28eca8fa..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.css +++ /dev/null @@ -1,3 +0,0 @@ -a, a.foo { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/368-test_mixins_with_args.css b/theme-compiler/tests/resources/sasslangbroken/css/368-test_mixins_with_args.css deleted file mode 100644 index 318a3f6ffb..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/368-test_mixins_with_args.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo { - a: bar; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/420-test_warn_directive.css b/theme-compiler/tests/resources/sasslangbroken/css/420-test_warn_directive.css deleted file mode 100644 index 6d661f2404..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/420-test_warn_directive.css +++ /dev/null @@ -1,3 +0,0 @@ -bar { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/55-test_long_extendee.css b/theme-compiler/tests/resources/sasslangbroken/css/55-test_long_extendee.css deleted file mode 100644 index 0d6bd2ec98..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/55-test_long_extendee.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo.bar, .baz { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/63-test_multiple_extendees.css b/theme-compiler/tests/resources/sasslangbroken/css/63-test_multiple_extendees.css deleted file mode 100644 index d3fae7600f..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/63-test_multiple_extendees.css +++ /dev/null @@ -1,7 +0,0 @@ -.foo, .baz { - a: b; -} - -.bar, .baz { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css b/theme-compiler/tests/resources/sasslangbroken/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css deleted file mode 100644 index 44196e6602..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/65-test_multiple_extends_with_multiple_extenders_and_single_target.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .baz .bar, .foo .bang, .baz .bang { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/66-test_multiple_extends_with_single_extender_and_single_target.css b/theme-compiler/tests/resources/sasslangbroken/css/66-test_multiple_extends_with_single_extender_and_single_target.css deleted file mode 100644 index 9b5770d7c5..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/66-test_multiple_extends_with_single_extender_and_single_target.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .baz .bar, .foo .baz, .baz .baz { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/67-test_multiple_targets.css b/theme-compiler/tests/resources/sasslangbroken/css/67-test_multiple_targets.css deleted file mode 100644 index 779bd00f75..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/67-test_multiple_targets.css +++ /dev/null @@ -1,7 +0,0 @@ -.foo, .bar { - a: b; -} - -.blip .foo, .blip .bar { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/7-test_combinator_unification_angle_sibling.css b/theme-compiler/tests/resources/sasslangbroken/css/7-test_combinator_unification_angle_sibling.css deleted file mode 100644 index 657d1ec2f6..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/7-test_combinator_unification_angle_sibling.css +++ /dev/null @@ -1,3 +0,0 @@ -.a > x, .a > .b ~ y { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/70-test_nested_extender.css b/theme-compiler/tests/resources/sasslangbroken/css/70-test_nested_extender.css deleted file mode 100644 index 1c4e604b71..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/70-test_nested_extender.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo, foo bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/80-test_nested_extender_merges_with_same_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/80-test_nested_extender_merges_with_same_selector.css deleted file mode 100644 index d1a50d50e3..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/80-test_nested_extender_merges_with_same_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .foo .baz { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/81-test_nested_extender_runs_unification.css b/theme-compiler/tests/resources/sasslangbroken/css/81-test_nested_extender_runs_unification.css deleted file mode 100644 index 9aa8d14958..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/81-test_nested_extender_runs_unification.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo.bar, foo bar.bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/85-test_nested_extender_with_child_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/85-test_nested_extender_with_child_selector.css deleted file mode 100644 index f7bd620245..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/85-test_nested_extender_with_child_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.baz .foo, .baz foo > bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css deleted file mode 100644 index 75561708b3..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/86-test_nested_extender_with_child_selector_merges_with_same_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo > .bar .baz, .foo > .bar .bang { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css b/theme-compiler/tests/resources/sasslangbroken/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css deleted file mode 100644 index 4285daf8dd..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .foo .bip > .baz { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/90-test_nested_extender_with_sibling_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/90-test_nested_extender_with_sibling_selector.css deleted file mode 100644 index e9fe832391..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/90-test_nested_extender_with_sibling_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.baz .foo, .baz foo + bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/91-test_nested_selector_with_child_selector_hack_extendee.css b/theme-compiler/tests/resources/sasslangbroken/css/91-test_nested_selector_with_child_selector_hack_extendee.css deleted file mode 100644 index 5556837892..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/91-test_nested_selector_with_child_selector_hack_extendee.css +++ /dev/null @@ -1,3 +0,0 @@ -> .foo, > foo bar { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css b/theme-compiler/tests/resources/sasslangbroken/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css new file mode 100644 index 0000000000..09b4ccac27 --- /dev/null +++ b/theme-compiler/tests/resources/sasslangbroken/css/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.css @@ -0,0 +1,3 @@ +~ .foo { + a: b; +} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/96-test_nested_target.css b/theme-compiler/tests/resources/sasslangbroken/css/96-test_nested_target.css deleted file mode 100644 index d1a50d50e3..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/96-test_nested_target.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar, .foo .baz { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/98-test_not_remains_at_end_of_selector.css b/theme-compiler/tests/resources/sasslangbroken/css/98-test_not_remains_at_end_of_selector.css deleted file mode 100644 index 540e6f8bf4..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/98-test_not_remains_at_end_of_selector.css +++ /dev/null @@ -1,3 +0,0 @@ -.foo:not(.bar), .baz:not(.bar) { - a: b; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/106-test_pseudoclass_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/106-test_pseudoclass_remains_at_end_of_selector.scss deleted file mode 100644 index 619bbb51cd..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/106-test_pseudoclass_remains_at_end_of_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo:bar {a: b} -.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/107-test_pseudoelement_goes_lefter_than_not.scss b/theme-compiler/tests/resources/sasslangbroken/scss/107-test_pseudoelement_goes_lefter_than_not.scss deleted file mode 100644 index f50ad04b12..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/107-test_pseudoelement_goes_lefter_than_not.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo::bar {a: b} -.baz:not(.bang) {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss b/theme-compiler/tests/resources/sasslangbroken/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss deleted file mode 100644 index 230f925a10..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/108-test_pseudoelement_goes_lefter_than_pseudoclass.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo::bar {a: b} -.baz:bang {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/109-test_pseudoelement_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/109-test_pseudoelement_remains_at_end_of_selector.scss deleted file mode 100644 index cd588ed24a..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/109-test_pseudoelement_remains_at_end_of_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo::bar {a: b} -.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/110-test_redundant_selector_elimination.scss b/theme-compiler/tests/resources/sasslangbroken/scss/110-test_redundant_selector_elimination.scss deleted file mode 100644 index ab8ba4845f..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/110-test_redundant_selector_elimination.scss +++ /dev/null @@ -1,3 +0,0 @@ -.foo.bar {a: b} -.x {@extend .foo, .bar} -.y {@extend .foo, .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/112-test_target_with_child.scss b/theme-compiler/tests/resources/sasslangbroken/scss/112-test_target_with_child.scss deleted file mode 100644 index 3748f64233..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/112-test_target_with_child.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo .bar {a: b} -.baz {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/2-test_basic.scss b/theme-compiler/tests/resources/sasslangbroken/scss/2-test_basic.scss deleted file mode 100644 index 9f3cde0011..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/2-test_basic.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo {a: b} -.bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss b/theme-compiler/tests/resources/sasslangbroken/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss deleted file mode 100644 index a5a0dff1d0..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/29-test_extend_does_not_warn_when_one_extension_fails_but_others_dont.scss +++ /dev/null @@ -1,3 +0,0 @@ -a.bar {a: b} -.bar {c: d} -b.foo {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss deleted file mode 100644 index ac6ad58994..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/33-test_extend_redundancy_elimination_never_eliminates_base_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -a.foo {a: b} -.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/333-test_empty_content.scss b/theme-compiler/tests/resources/sasslangbroken/scss/333-test_empty_content.scss deleted file mode 100644 index ad8df41f25..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/333-test_empty_content.scss +++ /dev/null @@ -1,2 +0,0 @@ -@mixin foo { @content } -a { b: c; @include foo {} } diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss b/theme-compiler/tests/resources/sasslangbroken/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss new file mode 100644 index 0000000000..713644b221 --- /dev/null +++ b/theme-compiler/tests/resources/sasslangbroken/scss/34-test_extend_redundancy_elimination_when_it_would_preserve_specificity.scss @@ -0,0 +1,2 @@ +.bar a {a: b} +a.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss b/theme-compiler/tests/resources/sasslangbroken/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss deleted file mode 100644 index 30a9d092cb..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/35-test_extend_redundancy_elimination_when_it_would_reduce_specificity.scss +++ /dev/null @@ -1,2 +0,0 @@ -a {a: b} -a.foo {@extend a} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/368-test_mixins_with_args.scss b/theme-compiler/tests/resources/sasslangbroken/scss/368-test_mixins_with_args.scss deleted file mode 100644 index 3ba39ecac2..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/368-test_mixins_with_args.scss +++ /dev/null @@ -1,3 +0,0 @@ -@mixin foo($a) {a: $a} - -.foo {@include foo(bar)} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/420-test_warn_directive.scss b/theme-compiler/tests/resources/sasslangbroken/scss/420-test_warn_directive.scss deleted file mode 100644 index 53546355cc..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/420-test_warn_directive.scss +++ /dev/null @@ -1,3 +0,0 @@ -@mixin foo { @warn "this is a mixin";} -@warn "this is a warning"; -bar {c: d; @include foo;} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/55-test_long_extendee.scss b/theme-compiler/tests/resources/sasslangbroken/scss/55-test_long_extendee.scss deleted file mode 100644 index 26ab65d344..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/55-test_long_extendee.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo.bar {a: b} -.baz {@extend .foo.bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/63-test_multiple_extendees.scss b/theme-compiler/tests/resources/sasslangbroken/scss/63-test_multiple_extendees.scss deleted file mode 100644 index 2c0f5aa72a..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/63-test_multiple_extendees.scss +++ /dev/null @@ -1,3 +0,0 @@ -.foo {a: b} -.bar {c: d} -.baz {@extend .foo; @extend .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss b/theme-compiler/tests/resources/sasslangbroken/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss deleted file mode 100644 index 4c2a4c59f8..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/65-test_multiple_extends_with_multiple_extenders_and_single_target.scss +++ /dev/null @@ -1,3 +0,0 @@ -.foo .bar {a: b} -.baz {@extend .foo} -.bang {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss b/theme-compiler/tests/resources/sasslangbroken/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss deleted file mode 100644 index 48d9c5b733..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/66-test_multiple_extends_with_single_extender_and_single_target.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo .bar {a: b} -.baz {@extend .foo; @extend .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/67-test_multiple_targets.scss b/theme-compiler/tests/resources/sasslangbroken/scss/67-test_multiple_targets.scss deleted file mode 100644 index fdcba65999..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/67-test_multiple_targets.scss +++ /dev/null @@ -1,3 +0,0 @@ -.foo {a: b} -.bar {@extend .foo} -.blip .foo {c: d} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/7-test_combinator_unification_angle_sibling.scss b/theme-compiler/tests/resources/sasslangbroken/scss/7-test_combinator_unification_angle_sibling.scss deleted file mode 100644 index b0120ac34e..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/7-test_combinator_unification_angle_sibling.scss +++ /dev/null @@ -1,2 +0,0 @@ -.a > x {a: b} -.b ~ y {@extend x} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/70-test_nested_extender.scss b/theme-compiler/tests/resources/sasslangbroken/scss/70-test_nested_extender.scss deleted file mode 100644 index 6245cdfda7..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/70-test_nested_extender.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo {a: b} -foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/80-test_nested_extender_merges_with_same_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/80-test_nested_extender_merges_with_same_selector.scss deleted file mode 100644 index d959cce374..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/80-test_nested_extender_merges_with_same_selector.scss +++ /dev/null @@ -1,3 +0,0 @@ -.foo { - .bar {a: b} - .baz {@extend .bar} } diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/81-test_nested_extender_runs_unification.scss b/theme-compiler/tests/resources/sasslangbroken/scss/81-test_nested_extender_runs_unification.scss deleted file mode 100644 index 32c2c0cc62..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/81-test_nested_extender_runs_unification.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo.bar {a: b} -foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/85-test_nested_extender_with_child_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/85-test_nested_extender_with_child_selector.scss deleted file mode 100644 index da249ad564..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/85-test_nested_extender_with_child_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.baz .foo {a: b} -foo > bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss deleted file mode 100644 index 224945cd71..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/86-test_nested_extender_with_child_selector_merges_with_same_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo > .bar .baz {a: b} -.foo > .bar .bang {@extend .baz} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss b/theme-compiler/tests/resources/sasslangbroken/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss deleted file mode 100644 index f2b8c6c07b..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/88-test_nested_extender_with_early_child_selectors_doesnt_subseq_them.scss +++ /dev/null @@ -1,4 +0,0 @@ -.foo { - .bar {a: b} - .bip > .baz {@extend .bar} -} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/90-test_nested_extender_with_sibling_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/90-test_nested_extender_with_sibling_selector.scss deleted file mode 100644 index b9d495ce76..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/90-test_nested_extender_with_sibling_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.baz .foo {a: b} -foo + bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss b/theme-compiler/tests/resources/sasslangbroken/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss deleted file mode 100644 index 928bc64f93..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/91-test_nested_selector_with_child_selector_hack_extendee.scss +++ /dev/null @@ -1,2 +0,0 @@ -> .foo {a: b} -foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss b/theme-compiler/tests/resources/sasslangbroken/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss new file mode 100644 index 0000000000..73f6254f21 --- /dev/null +++ b/theme-compiler/tests/resources/sasslangbroken/scss/95-test_nested_selector_with_child_selector_hack_extender_and_sibling_selector_extendee.scss @@ -0,0 +1,2 @@ +~ .foo {a: b} +> foo bar {@extend .foo} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/96-test_nested_target.scss b/theme-compiler/tests/resources/sasslangbroken/scss/96-test_nested_target.scss deleted file mode 100644 index 6662dea791..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/96-test_nested_target.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo .bar {a: b} -.baz {@extend .bar} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/98-test_not_remains_at_end_of_selector.scss b/theme-compiler/tests/resources/sasslangbroken/scss/98-test_not_remains_at_end_of_selector.scss deleted file mode 100644 index c1af8b1b2a..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/98-test_not_remains_at_end_of_selector.scss +++ /dev/null @@ -1,2 +0,0 @@ -.foo:not(.bar) {a: b} -.baz {@extend .foo} -- cgit v1.2.3 From 74dcb6f2478f611ce828a9fee7c7be52812af964 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 16:53:05 +0200 Subject: Correct assertion message which changed due to #12915 Converted to TB3 to allow running on only one browser Change-Id: I8a0d20cfb5af798d8b89f3fca86ef7d9d7a37527 --- .../vaadin/launcher/ApplicationRunnerServlet.java | 2 +- .../applicationservlet/NoApplicationClass.html | 26 ------------ .../applicationservlet/NoApplicationClass.java | 49 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html create mode 100644 uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index a2f3c59f07..47d3a19fde 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -280,7 +280,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } - throw new ClassNotFoundException(); + throw new ClassNotFoundException(baseName); } private Logger getLogger() { diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html deleted file mode 100644 index 6ed410fdb6..0000000000 --- a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - -
New Test
open/run/ClassThatIsNotPresent?restartApplication
assertText//pre[2]*java.lang.InstantiationException: Failed to load application class: ClassThatIsNotPresent*
- - diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java new file mode 100644 index 0000000000..c2222c4608 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.applicationservlet; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class NoApplicationClass extends MultiBrowserTest { + + @Test + public void testInvalidApplicationClass() { + openTestURL(); + String exceptionMessage = getDriver().findElement(By.xpath("//pre[2]")) + .getText(); + Assert.assertTrue(exceptionMessage + .contains("ServletException: ClassThatIsNotPresent")); + } + + @Override + public List getBrowsersToTest() { + return Collections.singletonList(Browser.CHROME + .getDesiredCapabilities()); + } + + @Override + protected String getDeploymentPath() { + return "/run/ClassThatIsNotPresent"; + } +} -- cgit v1.2.3 From 12b6a8b42f3327e315e617e015304c4cc9dd4fa8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 6 Nov 2013 17:17:42 +0200 Subject: Test for broken Webkit feature which causes extra scrollbars (#12736, #12727) This is the original cause for the Vaadin issues Live test at http://artur.virtuallypreinstalled.com/webkit-scrollbars.html Change-Id: Iaf9a46b635fabcb7cd795547c782c596aa57ce12 --- .../WebkitPositionAbsoluteScrollbars.html | 69 ++++++++++++++++++++++ .../WebkitPositionAbsoluteScrollbarsTest.java | 39 ++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 WebContent/statictestfiles/browserfeatures/WebkitPositionAbsoluteScrollbars.html create mode 100644 uitest/src/com/vaadin/tests/browserfeatures/WebkitPositionAbsoluteScrollbarsTest.java diff --git a/WebContent/statictestfiles/browserfeatures/WebkitPositionAbsoluteScrollbars.html b/WebContent/statictestfiles/browserfeatures/WebkitPositionAbsoluteScrollbars.html new file mode 100644 index 0000000000..7547816006 --- /dev/null +++ b/WebContent/statictestfiles/browserfeatures/WebkitPositionAbsoluteScrollbars.html @@ -0,0 +1,69 @@ + + + + + +

+ Starting point: No horizontal scrollbar
+ Expected: Get back to starting point after clicking through steps (do 1, do 2, cancel 1, cancel 2)
+ Actual: Scrollbars after doing the steps

+
+ + + + +
+
+
+
+
+
+
+
+ + + + + + diff --git a/uitest/src/com/vaadin/tests/browserfeatures/WebkitPositionAbsoluteScrollbarsTest.java b/uitest/src/com/vaadin/tests/browserfeatures/WebkitPositionAbsoluteScrollbarsTest.java new file mode 100644 index 0000000000..54fb7212ca --- /dev/null +++ b/uitest/src/com/vaadin/tests/browserfeatures/WebkitPositionAbsoluteScrollbarsTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.browserfeatures; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class WebkitPositionAbsoluteScrollbarsTest extends MultiBrowserTest { + + @Override + protected String getDeploymentPath() { + return "/statictestfiles/browserfeatures/WebkitPositionAbsoluteScrollbars.html"; + } + + @Test + public void testWebkitScrollbarProblem() throws Exception { + openTestURL(); + getDriver().findElement(By.id("step1")).click(); + getDriver().findElement(By.id("step2")).click(); + getDriver().findElement(By.id("step3")).click(); + getDriver().findElement(By.id("step4")).click(); + compareScreen("no-scrollbars"); + } +} -- cgit v1.2.3 From ea46029ea154cc018525219f06095817339607e8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 18:40:35 +0200 Subject: Allow excluding test from the standard test suite Mostly useful for very long running tests Change-Id: I9027f981da0a1e6ba464196449f2a9c27e965d2f --- .../src/com/vaadin/tests/tb3/ExcludeFromSuite.java | 28 ++++++++++++++++++++++ uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java | 18 ++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/tb3/ExcludeFromSuite.java diff --git a/uitest/src/com/vaadin/tests/tb3/ExcludeFromSuite.java b/uitest/src/com/vaadin/tests/tb3/ExcludeFromSuite.java new file mode 100644 index 0000000000..722b643f78 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tb3/ExcludeFromSuite.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.tb3; + +/** + * Marker interface for a TB3+ test class which will exclude the test from any + * test suite which automatically scans for test classes. Mostly useful for long + * tests which should not be run in every build. + * + * @since 7.1.10 + * @author Vaadin Ltd + */ +public @interface ExcludeFromSuite { + +} diff --git a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java index e1c8edfd60..f1576a9393 100644 --- a/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java +++ b/uitest/src/com/vaadin/tests/tb3/TB3TestSuite.java @@ -223,6 +223,10 @@ public class TB3TestSuite extends Suite { if (!baseClass.isAssignableFrom(c)) { return; } + if (!includeInSuite(c)) { + return; + } + if (!Modifier.isAbstract(c.getModifiers()) && !c.isAnonymousClass()) { result.add((Class) c); } @@ -235,4 +239,18 @@ public class TB3TestSuite extends Suite { } + /** + * @return true if the class should be included in the suite, false if not + */ + private static boolean includeInSuite(Class c) { + if (c.getAnnotation(ExcludeFromSuite.class) != null) { + return false; + } + if (c == Object.class) { + return true; + } + + return includeInSuite(c.getSuperclass()); + } + } \ No newline at end of file -- cgit v1.2.3 From c171850a2c6fab38a81b2d0ab92d3433b2cf558c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 18:18:04 +0200 Subject: Disable client timeout so websockets are not disconnected when idle (#13015) Updated sleep method to ensure that long sleeps can be performed without losing the connection to the browser Change-Id: I4f29d946e7a9a400e303e3a574876e1bc2d56773 --- .../communication/AtmospherePushConnection.java | 12 +++++++ .../window/SubWindowsTextSelectionTest.java | 3 +- .../src/com/vaadin/tests/push/BasicPushTest.java | 2 +- .../tests/push/IdlePushChannelStreamingTest.java | 23 ++++++++++++++ .../com/vaadin/tests/push/IdlePushChannelTest.java | 37 ++++++++++++++++++++++ .../tests/push/IdlePushChannelWebsocketTest.java | 35 ++++++++++++++++++++ .../tests/push/PushLargeDataStreamingTest.java | 4 +-- .../tests/push/PushLargeDataWebsocketTest.java | 4 +-- .../src/com/vaadin/tests/push/TogglePushTest.java | 4 +-- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 23 ++++++++++---- 10 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/push/IdlePushChannelStreamingTest.java create mode 100644 uitest/src/com/vaadin/tests/push/IdlePushChannelTest.java create mode 100644 uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index 320ba9ebe7..95584412cd 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -348,6 +348,14 @@ public class AtmospherePushConnection implements PushConnection { state = State.CONNECT_PENDING; } + protected void onClientTimeout(AtmosphereResponse response) { + state = State.DISCONNECTED; + errorHandler + .onError( + "Client unexpectedly disconnected. Ensure client timeout is disabled.", + -1); + } + protected void onReconnect(JavaScriptObject request, final AtmosphereResponse response) { if (state == State.CONNECTED) { @@ -442,6 +450,7 @@ public class AtmospherePushConnection implements PushConnection { fallbackTransport: 'streaming', contentType: 'application/json; charset=UTF-8', reconnectInterval: 5000, + timeout: -1, maxReconnectOnClose: 10000000, trackMessageLength: true, enableProtocol: false, @@ -476,6 +485,9 @@ public class AtmospherePushConnection implements PushConnection { config.onReconnect = $entry(function(request, response) { self.@com.vaadin.client.communication.AtmospherePushConnection::onReconnect(*)(request, response); }); + config.onClientTimeout = $entry(function(request) { + self.@com.vaadin.client.communication.AtmospherePushConnection::onClientTimeout(*)(request); + }); return $wnd.jQueryVaadin.atmosphere.subscribe(config); }-*/; diff --git a/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java b/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java index 1df036af58..2e0873956c 100644 --- a/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java +++ b/uitest/src/com/vaadin/tests/components/window/SubWindowsTextSelectionTest.java @@ -15,7 +15,6 @@ */ package com.vaadin.tests.components.window; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; @@ -64,7 +63,7 @@ public class SubWindowsTextSelectionTest extends MultiBrowserTest { } @Test - public void verifyNoTextSelectionOnMove() throws MalformedURLException { + public void verifyNoTextSelectionOnMove() throws Exception { openTestURL(); diff --git a/uitest/src/com/vaadin/tests/push/BasicPushTest.java b/uitest/src/com/vaadin/tests/push/BasicPushTest.java index ef40ae09dc..e03262ca7e 100644 --- a/uitest/src/com/vaadin/tests/push/BasicPushTest.java +++ b/uitest/src/com/vaadin/tests/push/BasicPushTest.java @@ -25,7 +25,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public abstract class BasicPushTest extends MultiBrowserTest { @Test - public void testPush() { + public void testPush() throws InterruptedException { openTestURL(); // Test client initiated push diff --git a/uitest/src/com/vaadin/tests/push/IdlePushChannelStreamingTest.java b/uitest/src/com/vaadin/tests/push/IdlePushChannelStreamingTest.java new file mode 100644 index 0000000000..f9a0a722e5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/IdlePushChannelStreamingTest.java @@ -0,0 +1,23 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +public class IdlePushChannelStreamingTest extends IdlePushChannelTest { + @Override + protected Class getUIClass() { + return BasicPushStreaming.class; + } +} diff --git a/uitest/src/com/vaadin/tests/push/IdlePushChannelTest.java b/uitest/src/com/vaadin/tests/push/IdlePushChannelTest.java new file mode 100644 index 0000000000..4dcc8a680d --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/IdlePushChannelTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public abstract class IdlePushChannelTest extends MultiBrowserTest { + + private static final int SEVEN_MINUTES_IN_MS = 7 * 60 * 1000; + + @Test + public void longWaitBetweenActions() throws Exception { + openTestURL(); + BasicPushTest.getIncrementButton(this).click(); + Assert.assertEquals(1, BasicPushTest.getClientCounter(this)); + sleep(SEVEN_MINUTES_IN_MS); + BasicPushTest.getIncrementButton(this).click(); + Assert.assertEquals(2, BasicPushTest.getClientCounter(this)); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java b/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java new file mode 100644 index 0000000000..3fd9c616fb --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/IdlePushChannelWebsocketTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import java.util.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class IdlePushChannelWebsocketTest extends IdlePushChannelTest { + + @Override + protected Class getUIClass() { + return BasicPushWebsocket.class; + } + + @Override + public List getBrowsersToTest() { + return WebsocketTest.getWebsocketBrowsers(); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java index 8f10f0fbba..0d71c21118 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataStreamingTest.java @@ -24,7 +24,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class PushLargeDataStreamingTest extends MultiBrowserTest { @Test - public void testStreamingLargeData() { + public void testStreamingLargeData() throws InterruptedException { openTestURL(); // Without this there is a large chance that we will wait for all pushes @@ -38,7 +38,7 @@ public class PushLargeDataStreamingTest extends MultiBrowserTest { } - private void push() { + private void push() throws InterruptedException { // Wait for startButton to be present waitForElementToBePresent(vaadinLocatorById("startButton")); diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java index 70a94f743e..cc8668a729 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataWebsocketTest.java @@ -24,7 +24,7 @@ import com.vaadin.tests.tb3.WebsocketTest; public class PushLargeDataWebsocketTest extends WebsocketTest { @Test - public void testWebsocketLargeData() { + public void testWebsocketLargeData() throws Exception { openTestURL(); // Without this timing will be completly off as pushing "start" can @@ -38,7 +38,7 @@ public class PushLargeDataWebsocketTest extends WebsocketTest { } - private void push() { + private void push() throws Exception { // Wait for startButton to be present waitForElementToBePresent(vaadinLocatorById("startButton")); diff --git a/uitest/src/com/vaadin/tests/push/TogglePushTest.java b/uitest/src/com/vaadin/tests/push/TogglePushTest.java index 68d6f52b9f..1867f4a63a 100644 --- a/uitest/src/com/vaadin/tests/push/TogglePushTest.java +++ b/uitest/src/com/vaadin/tests/push/TogglePushTest.java @@ -24,7 +24,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class TogglePushTest extends MultiBrowserTest { @Test - public void togglePushInInit() { + public void togglePushInInit() throws Exception { setPush(true); String url = getTestUrl(); @@ -58,7 +58,7 @@ public class TogglePushTest extends MultiBrowserTest { } @Test - public void togglePush() { + public void togglePush() throws InterruptedException { setPush(true); openTestURL(); getDelayedCounterUpdateButton().click(); diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index d7b7cd050f..f6fce18fae 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -74,6 +74,11 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ private static final int SCREENSHOT_WIDTH = 1500; + /** + * Timeout used by the TB grid + */ + private static final int BROWSER_TIMEOUT_IN_MS = 30 * 1000; + private DesiredCapabilities desiredCapabilities; private boolean debug = false; @@ -641,17 +646,21 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } /** - * Helper method for sleeping X ms in a test. Catches and ignores - * InterruptedExceptions + * Sleeps for the given number of ms but ensures that the browser connection + * does not time out. * * @param timeoutMillis * Number of ms to wait + * @throws InterruptedException */ - protected void sleep(int timeoutMillis) { - try { - Thread.sleep(timeoutMillis); - } catch (InterruptedException e) { - throw new RuntimeException(e); + protected void sleep(int timeoutMillis) throws InterruptedException { + while (timeoutMillis > 0) { + int d = Math.min(BROWSER_TIMEOUT_IN_MS, timeoutMillis); + Thread.sleep(d); + timeoutMillis -= d; + + // Do something to keep the connection alive + getDriver().getTitle(); } } -- cgit v1.2.3 From 36fce654841a5bf82a6be765930db07892e374fb Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 29 Nov 2013 19:10:19 +0200 Subject: Test for pushing for an extended period of time (24h) Change-Id: I8e47ba926f41fdc103cfa72ba85ca2f9edbc57d0 --- .../vaadin/tests/push/ExtremelyLongPushTime.java | 50 ++++++++++++++++ .../tests/push/ExtremelyLongPushTimeStreaming.java | 33 +++++++++++ .../push/ExtremelyLongPushTimeStreamingTest.java | 21 +++++++ .../tests/push/ExtremelyLongPushTimeTest.java | 67 ++++++++++++++++++++++ .../tests/push/ExtremelyLongPushTimeWebsocket.java | 34 +++++++++++ .../push/ExtremelyLongPushTimeWebsocketTest.java | 31 ++++++++++ .../src/com/vaadin/tests/push/PushLargeData.java | 12 +++- 7 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java create mode 100644 uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java new file mode 100644 index 0000000000..d90394d3b5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import com.vaadin.server.VaadinRequest; + +public abstract class ExtremelyLongPushTime extends PushLargeData { + + private static final int DURATION_MS = 48 * 60 * 60 * 1000; // 48 H + private static int INTERVAL_MS = 60 * 1000; // 1 minute + private static int PAYLOAD_SIZE = 100 * 1024; // 100 KB + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + duration.setConvertedValue(DURATION_MS); + interval.setConvertedValue(INTERVAL_MS); + dataSize.setConvertedValue(PAYLOAD_SIZE); + } + + @Override + protected String getTestDescription() { + return "Test which pushes data every minute for 48 hours"; + } + + @Override + protected Integer getTicketNumber() { + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java new file mode 100644 index 0000000000..3e9582740d --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.STREAMING) +public class ExtremelyLongPushTimeStreaming extends ExtremelyLongPushTime { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect failures + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java new file mode 100644 index 0000000000..17837cb2d3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java @@ -0,0 +1,21 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +public class ExtremelyLongPushTimeStreamingTest extends + ExtremelyLongPushTimeTest { + +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java new file mode 100644 index 0000000000..56eb8b6929 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.tests.tb3.ExcludeFromSuite; +import com.vaadin.tests.tb3.MultiBrowserTest; + +@ExcludeFromSuite +public abstract class ExtremelyLongPushTimeTest extends MultiBrowserTest { + + private static final int ONE_HOUR_IN_MS = 20 * 1000; + + @Test + public void test24HourPush() { + openTestURL(); + + // Without this there is a large chance that we will wait for all pushes + // to complete before moving on + testBench(driver).disableWaitForVaadin(); + + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + + String logRow0Id = "Log_row_0"; + By logRow0 = vaadinLocatorById(logRow0Id); + + // Start the test + vaadinElementById("startButton").click(); + + // Wait for push to start. Should take 60s + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package "), 120); + + // Check every hour that push is still going on + for (int i = 0; i < 24; i++) { + sleep(ONE_HOUR_IN_MS); + ensureStillPushing(logRow0); + } + + } + + private void ensureStillPushing(By logRow0) { + String logValue = getDriver().findElement(logRow0).getText(); + // Wait for the log value to change. Should take max 60s + waitUntilNot( + ExpectedConditions.textToBePresentInElement(logRow0, logValue), + 120); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java new file mode 100644 index 0000000000..8346d49234 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.WEBSOCKET) +public class ExtremelyLongPushTimeWebsocket extends ExtremelyLongPushTime { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect if websocket fails + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java new file mode 100644 index 0000000000..23d773c7da --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import java.util.List; + +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.WebsocketTest; + +public class ExtremelyLongPushTimeWebsocketTest extends + ExtremelyLongPushTimeTest { + + @Override + public List getBrowsersToTest() { + return WebsocketTest.getWebsocketBrowsers(); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeData.java b/uitest/src/com/vaadin/tests/push/PushLargeData.java index 3b72424b32..83f573ed2c 100644 --- a/uitest/src/com/vaadin/tests/push/PushLargeData.java +++ b/uitest/src/com/vaadin/tests/push/PushLargeData.java @@ -51,14 +51,20 @@ public abstract class PushLargeData extends AbstractTestUIWithLog { private final ExecutorService executor = Executors .newSingleThreadExecutor(); + protected TextField dataSize; + + protected TextField interval; + + protected TextField duration; + @Override protected void setup(VaadinRequest request) { dataLabel.setSizeUndefined(); - final TextField dataSize = new TextField("Data size"); + dataSize = new TextField("Data size"); dataSize.setConverter(Integer.class); - final TextField interval = new TextField("Interval (ms)"); + interval = new TextField("Interval (ms)"); interval.setConverter(Integer.class); - final TextField duration = new TextField("Duration (ms)"); + duration = new TextField("Duration (ms)"); duration.setConverter(Integer.class); dataSize.setValue(DEFAULT_SIZE_BYTES + ""); -- cgit v1.2.3 From 54a5667b2cebf6df7825d92c287112f6be64fe7d Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 2 Dec 2013 15:24:38 +0200 Subject: Fix compilation error Change-Id: Ib2ca104b8ab92a23a525c617004c6efe7f7edc14 --- uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java index 56eb8b6929..a1ce4b9d8f 100644 --- a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java +++ b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java @@ -28,7 +28,7 @@ public abstract class ExtremelyLongPushTimeTest extends MultiBrowserTest { private static final int ONE_HOUR_IN_MS = 20 * 1000; @Test - public void test24HourPush() { + public void test24HourPush() throws Exception { openTestURL(); // Without this there is a large chance that we will wait for all pushes -- cgit v1.2.3 From 25fc48c52067237faa208cea849a775a7aa1668c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 15 Nov 2013 18:40:57 +0200 Subject: Do not throw NPE if conversion messages is null (#12962) Change-Id: Ie2b95ed4da89e2c5ab8b462300a6f4bd28dc7570 --- server/src/com/vaadin/ui/AbstractField.java | 17 +++++++++-------- .../abstractfield/AbsFieldValueConversionError.java | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 6a52d6b849..b96e331889 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -783,15 +783,16 @@ public abstract class AbstractField extends AbstractComponent implements ConversionException e) { String conversionError = getConversionError(); - if (dataSourceType != null) { - conversionError = conversionError.replace("{0}", - dataSourceType.getSimpleName()); - } - if (e != null) { - conversionError = conversionError.replace("{1}", - e.getLocalizedMessage()); + if (conversionError != null) { + if (dataSourceType != null) { + conversionError = conversionError.replace("{0}", + dataSourceType.getSimpleName()); + } + if (e != null) { + conversionError = conversionError.replace("{1}", + e.getLocalizedMessage()); + } } - return conversionError; } diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java index ad762f8931..887f1b8ff3 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionError.java @@ -54,6 +54,21 @@ public class AbsFieldValueConversionError extends TestCase { } + public void testNullConversionMessages() { + TextField tf = new TextField(); + tf.setConverter(new StringToIntegerConverter()); + tf.setPropertyDataSource(new MethodProperty(paulaBean, "age")); + tf.setConversionError(null); + tf.setValue("abc"); + try { + tf.validate(); + fail(); + } catch (InvalidValueException e) { + Assert.assertEquals(null, e.getMessage()); + } + + } + public void testDefaultConversionErrorMessage() { TextField tf = new TextField(); tf.setConverter(new StringToIntegerConverter()); -- cgit v1.2.3 From 26b5b672df0aa3bdefdced81ed4619c11f3e945a Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Tue, 26 Nov 2013 14:49:12 +0200 Subject: Timeout redirect timer is reset on server activity (#12446) Change-Id: Iec2e3de627bc1cf5c7d39bf98715b1bf343e7519 --- WebContent/WEB-INF/web.xml | 15 ++++ .../com/vaadin/client/ApplicationConnection.java | 4 +- .../ui/TimeoutRedirectResetsOnActivity.java | 74 +++++++++++++++++++ .../ui/TimeoutRedirectResetsOnActivityTest.java | 85 ++++++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index 8a917966a1..f98b7c78d1 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -76,6 +76,16 @@ true + + + VaadinApplicationRunnerWithTimeoutRedirect + com.vaadin.launcher.ApplicationRunnerServlet + + VaadinApplicationRunnerWithPush com.vaadin.launcher.ApplicationRunnerServlet @@ -116,6 +126,11 @@ /run/* + + VaadinApplicationRunnerWithTimeoutRedirect + /12446/* + + VaadinApplicationRunnerWithPush /run-push/* diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index f95cec4fbc..a87fa3e342 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -64,7 +64,6 @@ import com.google.gwt.user.client.Window.ClosingHandler; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration.ErrorMessage; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.communication.HasJavaScriptConnectorHelper; @@ -1417,6 +1416,9 @@ public class ApplicationConnection { if (meta.containsKey("timedRedirect")) { final ValueMap timedRedirect = meta .getValueMap("timedRedirect"); + if (redirectTimer != null) { + redirectTimer.cancel(); + } redirectTimer = new Timer() { @Override public void run() { diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java new file mode 100644 index 0000000000..2c649c9ca8 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivity.java @@ -0,0 +1,74 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import com.vaadin.server.CustomizedSystemMessages; +import com.vaadin.server.SystemMessages; +import com.vaadin.server.SystemMessagesInfo; +import com.vaadin.server.SystemMessagesProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; + +public class TimeoutRedirectResetsOnActivity extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + setupTimout(request); + + addComponent(new Button("clicky", new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // NOOP + } + })); + } + + private void setupTimout(VaadinRequest request) { + request.getService().setSystemMessagesProvider( + new SystemMessagesProvider() { + @Override + public SystemMessages getSystemMessages( + SystemMessagesInfo systemMessagesInfo) { + CustomizedSystemMessages msgs = new CustomizedSystemMessages(); + msgs.setSessionExpiredMessage(null); + msgs.setSessionExpiredCaption(null); + msgs.setSessionExpiredNotificationEnabled(true); + msgs.setSessionExpiredURL("http://example.com/"); + return msgs; + } + }); + /* + * NOTE: in practice, this means a timeout after 25 seconds, because of + * implementation details in + * com.vaadin.server.communication.MetadataWriter + */ + getSession().getSession().setMaxInactiveInterval(10); + } + + @Override + protected String getTestDescription() { + return "The timeout redirect timer should reset if there's activity between the client and server."; + } + + @Override + @SuppressWarnings("boxing") + protected Integer getTicketNumber() { + return 12446; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java new file mode 100644 index 0000000000..272bacb8d5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/TimeoutRedirectResetsOnActivityTest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TimeoutRedirectResetsOnActivityTest extends MultiBrowserTest { + @Test + public void verifyRedirectWorks() throws Exception { + setDebug(true); + openTestURL(); + + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < 30000) { + clickTheButton(); + Thread.sleep(1000); + } + + assertTrue("button disappeared before timeout", buttonIsStillThere()); + + Thread.sleep(30000); + assertTrue("no redirection occurred within 30 seconds", + !buttonIsStillThere()); + } + + private boolean buttonIsStillThere() { + try { + return getButton() != null; + } catch (NoSuchElementException e) { + return false; + } + } + + private void clickTheButton() { + getButton().click(); + } + + private WebElement getButton() { + /* + * For some reason, the vaadinElement() method doesn't work when tests + * are run outside of "/run/" and "/run-push/" contexts. The given error + * message says that the generated Vaadin path doesn't match any + * elements, but when that selector is put into the recorder, the + * recorder finds it. + * + * XPath works fine. + */ + /*- + return vaadinElement("/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VButton[0]"); + */ + return getDriver().findElement( + By.xpath("//div[contains(@class,'v-button')]")); + } + + @Override + protected String getDeploymentPath() { + /* + * AbstractTB3Test assumes only /run/ and /run-push/ contexts, so this + * method needs some overriding. + */ + return "/12446/" + + TimeoutRedirectResetsOnActivity.class.getCanonicalName() + + "?restartApplication&debug"; + } +} -- cgit v1.2.3 From d45785d6763f269b4e00460ace07ab47c712b5ca Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Mon, 28 Oct 2013 11:50:18 +0200 Subject: Fixes right click selection focus issues in Tree. (#12618) Change-Id: I1057424fc8956b05e15a92c32e48a767e9fc8df9 --- .../com/vaadin/client/ui/tree/TreeConnector.java | 20 ++++++- .../components/tree/TreeScrollingOnRightClick.java | 53 +++++++++++++++++ .../tree/TreeScrollingOnRightClickTest.java | 69 ++++++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java create mode 100644 uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index ef016c31b7..7560a0f56b 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -18,6 +18,7 @@ package com.vaadin.client.ui.tree; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Set; import com.google.gwt.aria.client.Roles; import com.google.gwt.dom.client.Element; @@ -136,9 +137,24 @@ public class TreeConnector extends AbstractComponentConnector implements getWidget().lastSelection = getWidget().getNodeByKey( getWidget().lastSelection.key); } + if (getWidget().focusedNode != null) { - getWidget().setFocusedNode( - getWidget().getNodeByKey(getWidget().focusedNode.key)); + + Set selectedIds = getWidget().selectedIds; + + // If the focused node is not between the selected nodes, we need to + // refresh the focused node to prevent an undesired scroll. #12618. + if (!selectedIds.isEmpty() + && !selectedIds.contains(getWidget().focusedNode.key)) { + String keySelectedId = selectedIds.iterator().next(); + + TreeNode nodeToSelect = getWidget().getNodeByKey(keySelectedId); + + getWidget().setFocusedNode(nodeToSelect); + } else { + getWidget().setFocusedNode( + getWidget().getNodeByKey(getWidget().focusedNode.key)); + } } if (getWidget().lastSelection == null diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java new file mode 100644 index 0000000000..8a2b263006 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClick.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.tree; + +import com.vaadin.event.ItemClickEvent; +import com.vaadin.event.MouseEvents; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Tree; + +/** + * Test for #12618: Trying to select item with right click in Tree causes focus + * issues. + */ +@SuppressWarnings("serial") +public class TreeScrollingOnRightClick extends AbstractTestUI { + + public static final String TREE_ID = "my-tree"; + + @Override + protected void setup(VaadinRequest request) { + final Tree tree = new Tree(); + tree.setId(TREE_ID); + tree.setSizeUndefined(); + + // Add item click listener for right click selection + tree.addItemClickListener(new ItemClickEvent.ItemClickListener() { + @SuppressWarnings("deprecation") + @Override + public void itemClick(ItemClickEvent event) { + if (event.getButton() == MouseEvents.ClickEvent.BUTTON_RIGHT) { + tree.select(event.getItemId()); + } + } + }); + + // Add some items + for (int i = 0; i < 200; i++) { + tree.addItem(String.format("Node %s", i)); + } + + addComponent(tree); + } + + @Override + protected String getTestDescription() { + return "Right clicking on items should not scroll Tree."; + } + + @Override + protected Integer getTicketNumber() { + return 12618; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java new file mode 100644 index 0000000000..76ab1b3fdb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tree/TreeScrollingOnRightClickTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tree; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since 7.1.9 + * @author Vaadin Ltd + */ +public class TreeScrollingOnRightClickTest extends MultiBrowserTest { + + @Test + public void testScrollingOnRightClick() throws Throwable { + openTestURL(); + + // Focus tree + WebElement tree = getDriver().findElement( + By.id(TreeScrollingOnRightClick.TREE_ID)); + tree.click(); + + // Move selection down 50 items + for (int down = 0; down < 50; down++) { + tree.sendKeys(Keys.ARROW_DOWN); + } + + Thread.sleep(1000); + + // Get location of item 40 + Point item40Location = getTreeNode("Node 40").getLocation(); + + // Right click on item 45 + WebElement item45 = getTreeNode("Node 45"); + new Actions(getDriver()).moveToElement(item45).contextClick(item45) + .perform(); + + // Ensure location of item 40 is still the same (no scrolling) + Point item40Location2 = getTreeNode("Node 40").getLocation(); + assertEquals(item40Location.getY(), item40Location2.getY()); + } + + private WebElement getTreeNode(String caption) { + return getDriver().findElement( + By.xpath("//span[text() = '" + caption + "']")); + } +} -- cgit v1.2.3 From 401fa5c940d9b55a4f0b3f96db5990d57271fe82 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Wed, 4 Dec 2013 15:13:48 +0200 Subject: Don't send TabSheet focus and blur events to the server when moving the focus from one tab to another (#12971) Change-Id: Ie496a403bdcfc833c4871efbae11453efa66c14e --- client/src/com/vaadin/client/ui/VTabsheet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 1275308ed7..a930ac5b58 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -1087,7 +1087,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, @Override public void onBlur(BlurEvent event) { - if (focusedTab != null && event.getSource() instanceof Tab) { + if (focusedTab != null && focusedTab == event.getSource()) { focusedTab = null; if (client.hasEventListeners(this, EventId.BLUR)) { client.updateVariable(id, EventId.BLUR, "", true); -- cgit v1.2.3 From 5b56eeb521fdb92df5434647a8db27f0a45f09b9 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Thu, 5 Dec 2013 07:28:37 +0200 Subject: Changed the rendering order of TabSheet tabs to prevent an NPE in isClipped (#12343) Change-Id: Ife96ff3fe0c3f9c8926cf96eab4f5dfca99e925e --- client/src/com/vaadin/client/ui/VTabsheet.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index a930ac5b58..379b6107f4 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -840,6 +840,10 @@ public class VTabsheet extends VTabsheetBase implements Focusable, if (tab == null) { tab = tb.addTab(); } + if (selected) { + renderContent(tabUidl.getChildUIDL(0)); + tb.selectTab(index); + } tab.updateFromUIDL(tabUidl); tab.setEnabledOnServer((!disabledTabKeys.contains(tabKeys.get(index)))); tab.setHiddenOnServer(hidden); @@ -856,11 +860,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, * and tabs won't be too narrow in certain browsers */ tab.recalculateCaptionWidth(); - - if (selected) { - renderContent(tabUidl.getChildUIDL(0)); - tb.selectTab(index); - } } /** -- cgit v1.2.3 From 9026cef9719e8607c289bb91515bb23b5b0b9fe5 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Mon, 9 Dec 2013 13:33:47 +0200 Subject: Make VTreeTableScrollBody extendable (#13054) Change-Id: I97fc69c96dd589cb0d5cde0686dca9e1742f2c86 --- client/src/com/vaadin/client/ui/VTreeTable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java index 097b9c7ab2..54c9c2d30c 100644 --- a/client/src/com/vaadin/client/ui/VTreeTable.java +++ b/client/src/com/vaadin/client/ui/VTreeTable.java @@ -131,7 +131,7 @@ public class VTreeTable extends VScrollTable { private int indentWidth = -1; private int maxIndent = 0; - VTreeTableScrollBody() { + protected VTreeTableScrollBody() { super(); } -- cgit v1.2.3 From b5a080cced33ad088ccd269da64ae495000baaa9 Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Wed, 4 Dec 2013 16:06:43 +0200 Subject: Provides error location for ArithmeticException. (#11877) Change-Id: Ieb63ad556c3dc01196f0b9898aed9670923c9138 --- .../expression/ArithmeticExpressionEvaluator.java | 7 ++++--- .../expression/exception/ArithmeticException.java | 20 ++++++++++++++++++-- .../ArithmeticExpressionEvaluatorTest.java | 12 ++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java b/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java index 7dbd8ae1a0..552b464941 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java +++ b/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java @@ -99,7 +99,8 @@ public class ArithmeticExpressionEvaluator { continue inputTermLoop; } } - throw new ArithmeticException(); + throw new ArithmeticException("Illegal arithmetic expression", + term); } if (current.getLexicalUnitType() == SCSSLexicalUnit.SCSS_OPERATOR_LEFT_PAREN) { operators.push(Parentheses.LEFT); @@ -115,7 +116,7 @@ public class ArithmeticExpressionEvaluator { while (!operators.isEmpty()) { Object operator = operators.pop(); if (operator == Parentheses.LEFT) { - throw new ArithmeticException("Unexpected \"(\" found"); + throw new ArithmeticException("Unexpected \"(\" found", term); } createNewOperand((BinaryOperator) operator, operands); } @@ -123,7 +124,7 @@ public class ArithmeticExpressionEvaluator { if (!operands.isEmpty()) { LexicalUnitImpl operand = (LexicalUnitImpl) operands.peek(); throw new ArithmeticException("Unexpected operand " - + operand.toString() + " found"); + + operand.toString() + " found", term); } return expression; } diff --git a/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java b/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java index 13b6f0e936..f9ab90fc32 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java @@ -15,12 +15,28 @@ */ package com.vaadin.sass.internal.expression.exception; +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + public class ArithmeticException extends RuntimeException { public ArithmeticException(String errorMsg) { super(errorMsg); } - public ArithmeticException() { - super("Illegal arithmetic expression"); + public ArithmeticException(String error, LexicalUnitImpl term) { + super(buildMessage(error, term)); + } + + private static String buildMessage(String message, LexicalUnitImpl term) { + StringBuilder builder = new StringBuilder(message); + + builder.append(": \""); + builder.append(term.toString()); + builder.append("\" ["); + builder.append(term.getLineNumber()); + builder.append(","); + builder.append(term.getColumnNumber()); + builder.append("]"); + + return builder.toString(); } } diff --git a/theme-compiler/tests/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluatorTest.java b/theme-compiler/tests/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluatorTest.java index 8978eb812e..c408255d0e 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluatorTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluatorTest.java @@ -19,6 +19,7 @@ import org.junit.Assert; import org.junit.Test; import org.w3c.css.sac.LexicalUnit; +import com.vaadin.sass.internal.expression.exception.ArithmeticException; import com.vaadin.sass.internal.expression.exception.IncompatibleUnitsException; import com.vaadin.sass.internal.parser.LexicalUnitImpl; @@ -122,4 +123,15 @@ public class ArithmeticExpressionEvaluatorTest { Assert.assertEquals(LexicalUnit.SAC_CENTIMETER, result.getLexicalUnitType()); } + + @Test(expected = ArithmeticException.class) + public void testNonExistingSignal() { + LexicalUnitImpl operand2Integer = LexicalUnitImpl.createInteger(2, 3, + null, 2); + LexicalUnitImpl operatorComma = LexicalUnitImpl.createComma(2, 3, + operand2Integer); + LexicalUnitImpl operand3Integer = LexicalUnitImpl.createInteger(2, 3, + operatorComma, 3); + LexicalUnitImpl result = evaluator.evaluate(operand2Integer); + } } -- cgit v1.2.3 From a494133164f4b3a725d1307da175f684c6a49dad Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Mon, 9 Dec 2013 12:33:22 +0200 Subject: Fixed TabSheet tab bar sizing by removing an obsolete Safari hack (#12343) Change-Id: I627dee377aa19aab2168152cf7cbe3cfd6f95e10 --- client/src/com/vaadin/client/ui/VTabsheet.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 379b6107f4..b65f058a46 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -988,11 +988,6 @@ public class VTabsheet extends VTabsheetBase implements Focusable, } if (BrowserInfo.get().isSafari()) { - // fix tab height for safari, bugs sometimes if tabs contain icons - String property = tabs.getStyle().getProperty("height"); - if (property == null || property.equals("")) { - tabs.getStyle().setPropertyPx("height", tb.getOffsetHeight()); - } /* * another hack for webkits. tabscroller sometimes drops without * "shaking it" reproducable in -- cgit v1.2.3 From 1dd2ed36b73404f17863765ec34a56f8fdb0b40f Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Mon, 2 Dec 2013 15:00:08 +0200 Subject: Changes padding for Textfields with Chameleon theme. (#12974) Change-Id: Iefccedce67cb04cf3ceb8128cb07c871fc940ab8 --- .../chameleon/components/textfield/textfield.scss | 2 +- ...extFieldTruncatesUnderscoresInModalDialogs.java | 65 ++++++++++++++++++++++ ...ieldTruncatesUnderscoresInModalDialogsTest.java | 16 ++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java create mode 100644 uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogsTest.java diff --git a/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss b/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss index 7c5c72c1df..3962ba9ccd 100644 --- a/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss +++ b/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss @@ -20,7 +20,7 @@ textarea.v-textarea, input.#{$primaryStyleName}[type="text"], textarea.v-textarea, .v-filterselect { - padding: .2em; + padding: .1em; } input.#{$primaryStyleName}[type="text"] { diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java b/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java new file mode 100644 index 0000000000..2a9df42ba1 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogs.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.components.textfield; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.FormLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Window; + +@SuppressWarnings("serial") +@Theme("chameleon") +public class TextFieldTruncatesUnderscoresInModalDialogs extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Window dialog = new Window(); + + FormLayout formLayout = new FormLayout(); + formLayout.setSpacing(true); + + formLayout.addComponent(new Button("Disappear", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + event.getButton().setVisible(false); + } + })); + + formLayout.addComponent(new TextField(null, "____pqjgy____")); + + dialog.setContent(formLayout); + + getUI().addWindow(dialog); + } + + @Override + protected String getTestDescription() { + return "Text field must not truncate underscores in modal dialogs."; + } + + @Override + protected Integer getTicketNumber() { + return 12974; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogsTest.java b/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogsTest.java new file mode 100644 index 0000000000..66b0df5ff4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/TextFieldTruncatesUnderscoresInModalDialogsTest.java @@ -0,0 +1,16 @@ +package com.vaadin.tests.components.textfield; + +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TextFieldTruncatesUnderscoresInModalDialogsTest extends + MultiBrowserTest { + + @Test + public void testWindowRepositioning() throws Exception { + openTestURL(); + + compareScreen("TextFieldTruncatesUnderscoresInModalDialogs"); + } +} -- cgit v1.2.3 From cbfffae957fad3f3c7656f6c641a9a08a67724e4 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Thu, 28 Nov 2013 21:22:22 +0200 Subject: Add VaadinLocator multielement queries (#13016, #13017, #13018, #13019) Change-Id: If6faa939953023761dccaf256001c6ece018d5e8 --- .../vaadin/client/ApplicationConfiguration.java | 25 +- .../com/vaadin/client/ApplicationConnection.java | 9 +- .../client/componentlocator/ComponentLocator.java | 78 +++- .../componentlocator/LegacyLocatorStrategy.java | 44 ++ .../client/componentlocator/LocatorStrategy.java | 45 ++ .../VaadinFinderLocatorStrategy.java | 499 ++++++++++++++++++--- 6 files changed, 628 insertions(+), 72 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java index a8ae47385a..1a5b0d836f 100644 --- a/client/src/com/vaadin/client/ApplicationConfiguration.java +++ b/client/src/com/vaadin/client/ApplicationConfiguration.java @@ -512,6 +512,30 @@ public class ApplicationConfiguration implements EntryPoint { } } + /** + * Returns all tags for given class. Tags are used in + * {@link ApplicationConfiguration} to keep track of different classes and + * their hierarchy + * + * @since 7.2 + * @param classname + * name of class which tags we want + * @return Integer array of tags pointing to this classname + */ + public Integer[] getTagsForServerSideClassName(String classname) { + List tags = new ArrayList(); + + for (Map.Entry entry : tagToServerSideClassName + .entrySet()) { + if (classname.equals(entry.getValue())) { + tags.add(entry.getKey()); + } + } + + Integer[] out = new Integer[tags.size()]; + return tags.toArray(out); + } + public Integer getParentTag(int tag) { return componentInheritanceMap.get(tag); } @@ -762,5 +786,4 @@ public class ApplicationConfiguration implements EntryPoint { private static final Logger getLogger() { return Logger.getLogger(ApplicationConfiguration.class.getName()); } - } diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 841e1df96d..68fb57b8c0 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -1,4 +1,4 @@ -/* +/* * Copyright 2000-2013 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not @@ -64,7 +64,6 @@ import com.google.gwt.user.client.Window.ClosingHandler; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration.ErrorMessage; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.communication.HasJavaScriptConnectorHelper; @@ -577,6 +576,12 @@ public class ApplicationConnection { client.getElementByPathStartingAt = $entry(function(id, element) { return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/user/client/Element;)(id, element); }); + client.getElementsByPath = $entry(function(id) { + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPath(Ljava/lang/String;)(id); + }); + client.getElementsByPathStartingAt = $entry(function(id, element) { + return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getElementsByPathStartingAt(Ljava/lang/String;Lcom/google/gwt/user/client/Element;)(id, element); + }); client.getPathForElement = $entry(function(element) { return componentLocator.@com.vaadin.client.componentlocator.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element); }); diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index 6f6e52c0e1..aa841ce5b0 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -18,6 +18,8 @@ package com.vaadin.client.componentlocator; import java.util.Arrays; import java.util.List; +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.JsArray; import com.google.gwt.user.client.Element; import com.vaadin.client.ApplicationConnection; @@ -94,14 +96,74 @@ public class ComponentLocator { */ public Element getElementByPath(String path) { for (LocatorStrategy strategy : locatorStrategies) { - Element element = strategy.getElementByPath(path); - if (null != element) { - return element; + if (strategy.validatePath(path)) { + Element element = strategy.getElementByPath(path); + if (null != element) { + return element; + } } } return null; } + /** + * Locates elements using a String locator (path) which identifies DOM + * elements. + * + * @since 7.2 + * @param path + * The String locator which identifies target elements. + * @return The JavaScriptArray of DOM elements identified by {@code path} or + * empty array if elements could not be located. + */ + public JsArray getElementsByPath(String path) { + JsArray jsElements = JavaScriptObject.createArray().cast(); + for (LocatorStrategy strategy : locatorStrategies) { + if (strategy.validatePath(path)) { + List elements = strategy.getElementsByPath(path); + if (elements.size() > 0) { + for (Element e : elements) { + jsElements.push(e); + } + return jsElements; + } + } + } + return jsElements; + } + + /** + * Locates elements using a String locator (path) which identifies DOM + * elements. The path starts from the specified root element. + * + * @see #getElementByPath(String) + * + * @since 7.2 + * @param path + * The path of elements to be found + * @param root + * The root element where the path is anchored + * @return The JavaScriptArray of DOM elements identified by {@code path} or + * empty array if elements could not be located. + */ + public JsArray getElementsByPathStartingAt(String path, + Element root) { + JsArray jsElements = JavaScriptObject.createArray().cast(); + for (LocatorStrategy strategy : locatorStrategies) { + if (strategy.validatePath(path)) { + List elements = strategy.getElementsByPathStartingAt( + path, root); + if (elements.size() > 0) { + for (Element e : elements) { + jsElements.push(e); + } + return jsElements; + } + } + } + return jsElements; + } + /** * Locates an element using a String locator (path) which identifies a DOM * element. The path starts from the specified root element. @@ -117,9 +179,12 @@ public class ComponentLocator { */ public Element getElementByPathStartingAt(String path, Element root) { for (LocatorStrategy strategy : locatorStrategies) { - Element element = strategy.getElementByPathStartingAt(path, root); - if (null != element) { - return element; + if (strategy.validatePath(path)) { + Element element = strategy.getElementByPathStartingAt(path, + root); + if (null != element) { + return element; + } } } return null; @@ -135,4 +200,5 @@ public class ComponentLocator { public ApplicationConnection getClient() { return client; } + } diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 5123a57e5d..4a1b100213 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -20,6 +20,7 @@ import java.util.Iterator; import java.util.List; import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.regexp.shared.RegExp; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.HasWidgets; @@ -73,10 +74,18 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; + private static final RegExp validSyntax = RegExp + .compile("^((\\w+::)?(PID_S\\w+)?)?(/[a-zA-Z0-9]+\\[\\d+\\])*$"); + public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; } + @Override + public boolean validatePath(String path) { + return validSyntax.test(path); + } + @Override public String getPathForElement(Element targetElement) { ComponentConnector connector = Util @@ -178,11 +187,17 @@ public class LegacyLocatorStrategy implements LocatorStrategy { } } + /** + * {@inheritDoc} + */ @Override public Element getElementByPath(String path) { return getElementByPathStartingAt(path, null); } + /** + * {@inheritDoc} + */ @Override public Element getElementByPathStartingAt(String path, Element baseElement) { /* @@ -219,6 +234,34 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return null; } + /** + * {@inheritDoc} + */ + @Override + public List getElementsByPath(String path) { + // This type of search is not supported in LegacyLocator + List array = new ArrayList(); + Element e = getElementByPath(path); + if (e != null) { + array.add(e); + } + return array; + } + + /** + * {@inheritDoc} + */ + @Override + public List getElementsByPathStartingAt(String path, Element root) { + // This type of search is not supported in LegacyLocator + List array = new ArrayList(); + Element e = getElementByPathStartingAt(path, root); + if (e != null) { + array.add(e); + } + return array; + } + /** * Finds the first widget in the hierarchy (moving upwards) that implements * SubPartAware. Returns the SubPartAware implementor or null if none is @@ -672,4 +715,5 @@ public class LegacyLocatorStrategy implements LocatorStrategy { return null; } + } diff --git a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java index 56ed396609..e892f43d76 100644 --- a/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LocatorStrategy.java @@ -15,6 +15,8 @@ */ package com.vaadin.client.componentlocator; +import java.util.List; + import com.google.gwt.user.client.Element; /** @@ -28,6 +30,18 @@ import com.google.gwt.user.client.Element; * @author Vaadin Ltd */ public interface LocatorStrategy { + + /** + * Test the given input path for formatting errors. If a given path can not + * be validated, the locator strategy will not be attempted. + * + * @param path + * a locator path expression + * @return true, if the implementing class can process the given path, + * otherwise false + */ + boolean validatePath(String path); + /** * Generates a String locator which uniquely identifies the target element. * The {@link #getElementByPath(String)} method can be used for the inverse @@ -74,4 +88,35 @@ public interface LocatorStrategy { * could not be located. */ Element getElementByPathStartingAt(String path, Element root); + + /** + * Locates all elements that match a String locator (path) which identifies + * DOM elements. + * + * This functionality is limited in {@link LegacyLocatorStrategy}. + * + * @param path + * The String locator which identifies target elements. + * @return List that contains all matched elements. Empty list if none + * found. + */ + List getElementsByPath(String path); + + /** + * Locates all elements that match a String locator (path) which identifies + * DOM elements. The path starts from the specified root element. + * + * This functionality is limited in {@link LegacyLocatorStrategy}. + * + * @see #getElementsByPath(String) + * + * @param path + * The String locator which identifies target elements. + * @param root + * The element that is at the root of the path. + * @return List that contains all matched elements. Empty list if none + * found. + */ + + List getElementsByPathStartingAt(String path, Element root); } diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 95b2745bf8..6337ca7e8c 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -16,18 +16,22 @@ package com.vaadin.client.componentlocator; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import com.google.gwt.core.client.JsArrayString; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; +import com.vaadin.client.FastStringSet; +import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.Util; import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; +import com.vaadin.client.metadata.TypeDataStore; import com.vaadin.client.ui.AbstractConnector; -import com.vaadin.client.ui.AbstractHasComponentsConnector; import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.VNotification; import com.vaadin.shared.AbstractComponentState; @@ -55,6 +59,18 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; + /** + * Internal container/descriptor for search predicates + * + * @author Vaadin Ltd + */ + private static final class Predicate { + private String name = ""; + private String value = ""; + private boolean wildcard = false; + private int index = -1; + } + public VaadinFinderLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; } @@ -71,18 +87,145 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return null; } + private boolean isNotificationExpression(String path) { + String[] starts = { "//", "/" }; + + String[] frags = { "com.vaadin.ui.Notification.class", + "com.vaadin.ui.Notification", "VNotification.class", + "VNotification", "Notification.class", "Notification" }; + + String[] ends = { "/", "[" }; + + for (String s : starts) { + for (String f : frags) { + if (path.equals(s + f)) { + return true; + } + + for (String e : ends) { + if (path.startsWith(s + f + e)) { + return true; + } + } + } + } + + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public List getElementsByPath(String path) { + + if (isNotificationExpression(path)) { + List elements = new ArrayList(); + + for (VNotification n : findNotificationsByPath(path)) { + elements.add(n.getElement()); + } + + return elements; + } + + List elems = eliminateDuplicates(getElementsByPathStartingAtConnector( + path, client.getUIConnector())); + + return elems; + } + /** * {@inheritDoc} */ @Override public Element getElementByPath(String path) { - if (path.startsWith("//VNotification")) { - return findNotificationByPath(path); + if (isNotificationExpression(path)) { + return findNotificationsByPath(path).get(0).getElement(); } return getElementByPathStartingAtConnector(path, client.getUIConnector()); } + /** + * Generate a list of predicates from a single predicate string + * + * @param str + * a comma separated string of predicates + * @return a List of Predicate objects + */ + private List extractPredicates(String path) { + List predicates = new ArrayList(); + + String str = extractPredicateString(path); + if (null == str || str.length() == 0) { + return predicates; + } + + // Extract input strings + List input = new ArrayList(); + { + int idx = indexOfIgnoringQuotes(str, ',', 0), p = 0; + if (idx == -1) { + input.add(str); + } else { + do { + input.add(str.substring(p, idx)); + p = idx + 1; + idx = indexOfIgnoringQuotes(str, ',', p); + } while (idx > -1); + input.add(str.substring(p)); + } + } + + // Process each predicate into proper predicate descriptor + for (String s : input) { + Predicate p = new Predicate(); + s = s.trim(); + + try { + // If we can parse out the predicate as a pure index argument, + // stop processing here. + p.index = Integer.parseInt(s); + predicates.add(p); + + continue; + } catch (Exception e) { + p.index = -1; + } + + int idx = indexOfIgnoringQuotes(s, '='); + if (idx < 0) { + continue; + } + p.name = s.substring(0, idx); + p.value = s.substring(idx + 1); + + if (p.value.equals("?")) { + p.wildcard = true; + p.value = null; + } else { + // Only unquote predicate value once we're sure it's a proper + // value... + + p.value = unquote(p.value); + } + + predicates.add(p); + } + + // Move any (and all) index predicates to last place in the list. + for (int i = 0, l = predicates.size(); i < l - 1; ++i) { + if (predicates.get(i).index > -1) { + predicates.add(predicates.remove(i)); + --i; + --l; + } + } + + return predicates; + } + /** * Special case for finding notifications as they have no connectors and are * directly attached to {@link RootPanel}. @@ -93,19 +236,29 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * brackets. * @return the notification element or null if not found. */ - private Element findNotificationByPath(String path) { - ArrayList notifications = new ArrayList(); + private List findNotificationsByPath(String path) { + + List notifications = new ArrayList(); for (Widget w : RootPanel.get()) { if (w instanceof VNotification) { notifications.add((VNotification) w); } } - String indexStr = extractPredicateString(path); - int index = indexStr == null ? 0 : Integer.parseInt(indexStr); - if (index >= 0 && index < notifications.size()) { - return notifications.get(index).getElement(); + + List predicates = extractPredicates(path); + for (Predicate p : predicates) { + + if (p.index > -1) { + VNotification n = notifications.get(p.index); + notifications.clear(); + if (n != null) { + notifications.add(n); + } + } + } - return null; + + return eliminateDuplicates(notifications); } /** @@ -117,6 +270,16 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { Util.findPaintable(client, root)); } + /** + * {@inheritDoc} + */ + @Override + public List getElementsByPathStartingAt(String path, Element root) { + List elements = getElementsByPathStartingAtConnector(path, + Util.findPaintable(client, root)); + return elements; + } + /** * Finds an element by the specified path, starting traversal of the * connector hierarchy from the specified root. @@ -130,8 +293,12 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { private Element getElementByPathStartingAtConnector(String path, ComponentConnector root) { String[] pathComponents = path.split(SUBPART_SEPARATOR); - ComponentConnector connector = findConnectorByPath(pathComponents[0], - root); + ComponentConnector connector; + if (pathComponents[0].length() > 0) { + connector = findConnectorByPath(pathComponents[0], root); + } else { + connector = root; + } if (connector != null) { if (pathComponents.length > 1) { // We have subparts @@ -147,6 +314,47 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return null; } + /** + * Finds a list of elements by the specified path, starting traversal of the + * connector hierarchy from the specified root. + * + * @param path + * the locator path + * @param root + * the root connector + * @return the list of elements identified by path or empty list if not + * found. + */ + private List getElementsByPathStartingAtConnector(String path, + ComponentConnector root) { + String[] pathComponents = path.split(SUBPART_SEPARATOR); + List connectors; + if (pathComponents[0].length() > 0) { + connectors = findConnectorsByPath(pathComponents[0], + Arrays.asList(root)); + } else { + connectors = Arrays.asList(root); + } + + List output = new ArrayList(); + if (null != connectors && !connectors.isEmpty()) { + if (pathComponents.length > 1) { + // We have subparts + for (ComponentConnector connector : connectors) { + if (connector.getWidget() instanceof SubPartAware) { + output.add(((SubPartAware) connector.getWidget()) + .getSubPartElement(pathComponents[1])); + } + } + } else { + for (ComponentConnector connector : connectors) { + output.add(connector.getWidget().getElement()); + } + } + } + return eliminateDuplicates(output); + } + /** * Recursively finds a connector for the element identified by the provided * path by traversing the connector hierarchy starting from the @@ -156,7 +364,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * The path identifying an element. * @param parent * The connector to start traversing from. - * @return The connector identified by {@code path} or null if it no such + * @return The connector identified by {@code path} or null if no such * connector could be found. */ private ComponentConnector findConnectorByPath(String path, @@ -168,18 +376,55 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { String[] fragments = splitFirstFragmentFromTheRest(path); List potentialMatches = collectPotentialMatches( parent, fragments[0], findRecursively); - ComponentConnector connector = filterPotentialMatches(potentialMatches, - extractPredicateString(fragments[0])); - if (connector != null) { + + List connectors = filterMatches(potentialMatches, + extractPredicates(fragments[0])); + + if (!connectors.isEmpty()) { if (fragments.length > 1) { - return findConnectorByPath(fragments[1], connector); + return findConnectorByPath(fragments[1], connectors.get(0)); } else { - return connector; + return connectors.get(0); } } return null; } + /** + * Recursively finds connectors for the elements identified by the provided + * path by traversing the connector hierarchy starting from {@code parents} + * connectors. + * + * @param path + * The path identifying elements. + * @param parents + * The list of connectors to start traversing from. + * @return The list of connectors identified by {@code path} or empty list + * if no such connectors could be found. + */ + private List findConnectorsByPath(String path, + List parents) { + boolean findRecursively = path.startsWith("//"); + // Strip away the one or two slashes from the beginning of the path + path = path.substring(findRecursively ? 2 : 1); + + String[] fragments = splitFirstFragmentFromTheRest(path); + + List potentialMatches = new ArrayList(); + for (ComponentConnector parent : parents) { + potentialMatches.addAll(collectPotentialMatches(parent, + fragments[0], findRecursively)); + } + + List connectors = filterMatches(potentialMatches, + extractPredicates(fragments[0])); + + if (!connectors.isEmpty() && fragments.length > 1) { + return (findConnectorsByPath(fragments[1], connectors)); + } + return eliminateDuplicates(connectors); + } + /** * Returns the predicate string, i.e. the string between the brackets in a * path fragment. Examples: @@ -189,7 +434,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * * @param pathFragment * The path fragment from which to extract the predicate string. - * @return The predicate string for the path fragment or null if none. + * @return The predicate string for the path fragment or empty string if not + * found. */ private String extractPredicateString(String pathFragment) { int ixOpenBracket = indexOfIgnoringQuotes(pathFragment, '['); @@ -198,60 +444,63 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { ixOpenBracket); return pathFragment.substring(ixOpenBracket + 1, ixCloseBracket); } - return null; + return ""; } /** - * Returns the first ComponentConnector that matches the predicate string - * from a list of potential matches. If {@code predicateString} is null, the - * first element in the {@code potentialMatches} list is returned. + * Go through a list of potentially matching components, modifying that list + * until all elements that remain in that list match the complete list of + * predicates. * * @param potentialMatches - * A list of potential matches to check. - * @param predicateString - * The predicate that should match. Can be an index or a property - * name, value pair or null. - * @return A {@link ComponentConnector} from the {@code potentialMatches} - * list, which matches the {@code predicateString} or null if no - * matches are found. + * a list of component connectors. Will be changed. + * @param predicates + * an immutable list of predicates + * @return filtered list of component connectors. */ - private ComponentConnector filterPotentialMatches( - List potentialMatches, String predicateString) { - - if (potentialMatches.isEmpty()) { - return null; - } - - if (predicateString != null) { + private List filterMatches( + List potentialMatches, + List predicates) { + + for (Predicate p : predicates) { + + if (p.index > -1) { + try { + ComponentConnector v = potentialMatches.get(p.index); + potentialMatches.clear(); + potentialMatches.add(v); + } catch (IndexOutOfBoundsException e) { + potentialMatches.clear(); + } - int split_idx = predicateString.indexOf('='); + continue; + } - if (split_idx != -1) { + for (int i = 0, l = potentialMatches.size(); i < l; ++i) { - String propertyName = predicateString.substring(0, split_idx) - .trim(); - String value = unquote(predicateString.substring(split_idx + 1) - .trim()); + ComponentConnector c = potentialMatches.get(i); + Property property = AbstractConnector.getStateType(c) + .getProperty(p.name); - for (ComponentConnector connector : potentialMatches) { - Property property = AbstractConnector.getStateType( - connector).getProperty(propertyName); - if (valueEqualsPropertyValue(value, property, - connector.getState())) { - return connector; - } + Object propData; + try { + propData = property.getValue(c.getState()); + } catch (NoDataException e) { + propData = null; } - return null; - - } else { - int index = Integer.valueOf(predicateString); - return index < potentialMatches.size() ? potentialMatches - .get(index) : null; + if ((p.wildcard && propData == null) + || (!p.wildcard && !valueEqualsPropertyValue(p.value, + property, c.getState()))) { + potentialMatches.remove(i); + --l; + --i; + } } + } - return potentialMatches.get(0); + return eliminateDuplicates(potentialMatches); } /** @@ -270,7 +519,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { AbstractComponentState state) { try { return value.equals(property.getValue(state)); - } catch (NoDataException e) { + } catch (Exception e) { // The property doesn't exist in the state object, so they aren't // equal. return false; @@ -315,8 +564,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { ComponentConnector parent, String pathFragment, boolean collectRecursively) { ArrayList potentialMatches = new ArrayList(); - if (parent instanceof AbstractHasComponentsConnector) { - List children = ((AbstractHasComponentsConnector) parent) + if (parent instanceof HasComponentsConnector) { + List children = ((HasComponentsConnector) parent) .getChildComponents(); for (ComponentConnector child : children) { String widgetName = getWidgetName(pathFragment); @@ -329,7 +578,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { } } } - return potentialMatches; + return eliminateDuplicates(potentialMatches); } /** @@ -346,7 +595,60 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ private boolean connectorMatchesPathFragment(ComponentConnector connector, String widgetName) { - return widgetName.equals(Util.getSimpleName(connector.getWidget())); + Class connectorClass = connector.getClass(); + List ids = new ArrayList(); + + FastStringSet identifiers = TypeDataStore.get().findIdentifiersFor( + connectorClass); + JsArrayString str = identifiers.dump(); + + for (int j = 0; j < str.length(); ++j) { + ids.add(str.get(j)); + } + + Integer[] widgetTags = client.getConfiguration() + .getTagsForServerSideClassName(getFullClassName(widgetName)); + if (widgetTags.length == 0) { + widgetTags = client.getConfiguration() + .getTagsForServerSideClassName( + getFullClassName("com.vaadin.ui." + widgetName)); + } + + for (int i = 0, l = ids.size(); i < l; ++i) { + + // Fuzz the connector name, so that the client can provide (for + // example: /Button, /Button.class, /com.vaadin.ui.Button, + // /com.vaadin.ui.Button.class, etc) + + String name = ids.get(i); + final String simpleName = getSimpleClassName(name); + final String fullName = getFullClassName(name); + + if (widgetTags.length > 0) { + Integer[] foundTags = client.getConfiguration() + .getTagsForServerSideClassName(fullName); + for (int tag : foundTags) { + if (tagsMatch(widgetTags, tag)) { + return true; + } + } + } + + // Fallback if something failed before. + if (widgetName.equals(fullName + ".class") + || widgetName.equals(fullName) + || widgetName.equals(simpleName + ".class") + || widgetName.equals(simpleName) || widgetName.equals(name)) { + return true; + } + } + + // If the server-side class name didn't match, fall back to testing for + // the explicit widget name + String widget = Util.getSimpleName(connector.getWidget()); + return widgetName.equals(widget) + || widgetName.equals(widget + ".class"); + } /** @@ -412,4 +714,75 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return -1; } + private String getSimpleClassName(String s) { + String[] parts = s.split("\\."); + if (s.endsWith(".class")) { + return parts[parts.length - 2]; + } + return parts.length > 0 ? parts[parts.length - 1] : s; + } + + private String getFullClassName(String s) { + if (s.endsWith(".class")) { + return s.substring(0, s.lastIndexOf(".class")); + } + return s; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.client.componentlocator.LocatorStrategy#validatePath(java. + * lang.String) + */ + @Override + public boolean validatePath(String path) { + // This syntax is so difficult to regexp properly, that we'll just try + // to find something with it regardless of the correctness of the + // syntax... + return true; + } + + /** + * Go through a list, removing all duplicate elements from it. This method + * is used to avoid accumulation of duplicate entries in result lists + * resulting from low-context recursion. + * + * Preserves first entry in list, removes others. Preserves list order. + * + * @return list passed as parameter, after modification + */ + private final List eliminateDuplicates(List list) { + + int l = list.size(); + for (int j = 0; j < l; ++j) { + T ref = list.get(j); + + for (int i = j + 1; i < l; ++i) { + if (list.get(i) == ref) { + list.remove(i); + --i; + --l; + } + } + } + + return list; + } + + private boolean tagsMatch(Integer[] targets, Integer tag) { + for (int i = 0; i < targets.length; ++i) { + if (targets[i].equals(tag)) { + return true; + } + } + + try { + return tagsMatch(targets, + client.getConfiguration().getParentTag(tag)); + } catch (Exception e) { + return false; + } + } } -- cgit v1.2.3 From e941ab13913082f6178c89f39ce54fac27f9c952 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 12 Dec 2013 10:08:12 +0200 Subject: Expand allowed character set for LegacyLocatorStrategy (#13017) Change-Id: Ib95fecb67e97d71fb68faee82aa9ebf458c735f3 --- .../src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 4a1b100213..42551db043 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -75,7 +75,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; private static final RegExp validSyntax = RegExp - .compile("^((\\w+::)?(PID_S\\w+)?)?(/[a-zA-Z0-9]+\\[\\d+\\])*$"); + .compile("^((\\w+::)?(PID_S\\w+)?)?(/[$_a-zA-Z0-9]+\\[\\d+\\])*/?$"); public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; -- cgit v1.2.3 From bf77c65bd4a7c880dc852a16d2009e02e5d8941b Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 12 Dec 2013 10:59:32 +0200 Subject: Allow also subparts in LegacyLocatorStrategy (#13017) Change-Id: I7df7cbd03497168b772ee0636df05afb7bcc7995 --- .../src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 42551db043..dfd29058cd 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -75,7 +75,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; private static final RegExp validSyntax = RegExp - .compile("^((\\w+::)?(PID_S\\w+)?)?(/[$_a-zA-Z0-9]+\\[\\d+\\])*/?$"); + .compile("^((\\w+::)?(PID_S\\w+)?)?(/[$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; -- cgit v1.2.3 From caddd1e32396b328402db7e456346d202ea6fcd0 Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 12 Dec 2013 13:37:47 +0200 Subject: More flexible criteria for using LegacyLocatorStrategy (#13017) Change-Id: I88070e09010de77ac4656df47a308aae635a8328 --- .../src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index dfd29058cd..cf91d5d4ad 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -75,7 +75,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; private static final RegExp validSyntax = RegExp - .compile("^((\\w+::)?(PID_S\\w+)?)?(/[$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); + .compile("^((\\w+::)?((PID_S)?\\w[-$_a-zA-Z0-9]*)?)?(/[-$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; -- cgit v1.2.3 From a8947f7f6461c6382448e9b569f49fd37d5044bf Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Fri, 13 Dec 2013 09:34:35 +0200 Subject: Allow also dots and spaces in legacy locator PIDs (#13017) These characters are used in automated tests of Vaadin itself. Change-Id: I7cff655e36f39c48f539487609e58eac90ec8761 --- .../src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index cf91d5d4ad..56c86bab7b 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -75,7 +75,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; private static final RegExp validSyntax = RegExp - .compile("^((\\w+::)?((PID_S)?\\w[-$_a-zA-Z0-9]*)?)?(/[-$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); + .compile("^((\\w+::)?((PID_S)?\\w[-$_a-zA-Z0-9. ]*)?)?(/[-$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; -- cgit v1.2.3 From 681864fee3c95dd281493f881db276b7b7abe87d Mon Sep 17 00:00:00 2001 From: Jarno Rantala Date: Wed, 11 Dec 2013 15:31:30 +0200 Subject: Backported null value support for NestedMethodProperty to 7.1 (#12884) Support for null values in NestedMethodProperty was already implemented in master branch (#11435) This changeset includes changesets made for that. Change-Id: I10696467f792e234326075bbcdd5aad487905a7e Merge: no --- .../vaadin/data/util/AbstractBeanContainer.java | 10 +++--- server/src/com/vaadin/data/util/BeanItem.java | 9 ++--- .../com/vaadin/data/util/NestedMethodProperty.java | 10 ++++-- .../com/vaadin/data/util/BeanContainerTest.java | 13 +++++++ .../vaadin/data/util/BeanItemContainerTest.java | 12 +++++++ .../vaadin/data/util/NestedMethodPropertyTest.java | 40 ++++++++++++---------- .../vaadin/data/util/PropertyDescriptorTest.java | 18 +++++++++- 7 files changed, 82 insertions(+), 30 deletions(-) diff --git a/server/src/com/vaadin/data/util/AbstractBeanContainer.java b/server/src/com/vaadin/data/util/AbstractBeanContainer.java index 35403d6419..b19cdd980c 100644 --- a/server/src/com/vaadin/data/util/AbstractBeanContainer.java +++ b/server/src/com/vaadin/data/util/AbstractBeanContainer.java @@ -836,8 +836,9 @@ public abstract class AbstractBeanContainer extends * Adds a nested container property for the container, e.g. * "manager.address.street". * - * All intermediate getters must exist and must return non-null values when - * the property value is accessed. + * All intermediate getters must exist and should return non-null values + * when the property value is accessed. If an intermediate getter returns + * null, a null value will be returned. * * @see NestedMethodProperty * @@ -854,8 +855,9 @@ public abstract class AbstractBeanContainer extends * property to the container. The named property itself is removed from the * model as its subproperties are added. * - * All intermediate getters must exist and must return non-null values when - * the property value is accessed. + * All intermediate getters must exist and should return non-null values + * when the property value is accessed. If an intermediate getter returns + * null, a null value will be returned. * * @see NestedMethodProperty * @see #addNestedContainerProperty(String) diff --git a/server/src/com/vaadin/data/util/BeanItem.java b/server/src/com/vaadin/data/util/BeanItem.java index fc51be8f36..49f5f95898 100644 --- a/server/src/com/vaadin/data/util/BeanItem.java +++ b/server/src/com/vaadin/data/util/BeanItem.java @@ -255,12 +255,13 @@ public class BeanItem extends PropertysetItem { } /** - * Adds a nested property to the item. + * Adds a nested property to the item. The property must not exist in the + * item already and must of form "field1.field2" where field2 is a field in + * the object referenced to by field1. If an intermediate property returns + * null, the property will return a null value * * @param nestedPropertyId - * property id to add. This property must not exist in the item - * already and must of of form "field1.field2" where field2 is a - * field in the object referenced to by field1 + * property id to add. */ public void addNestedProperty(String nestedPropertyId) { addItemProperty(nestedPropertyId, new NestedMethodProperty( diff --git a/server/src/com/vaadin/data/util/NestedMethodProperty.java b/server/src/com/vaadin/data/util/NestedMethodProperty.java index b62ecfbfc3..8fe3b9d4c5 100644 --- a/server/src/com/vaadin/data/util/NestedMethodProperty.java +++ b/server/src/com/vaadin/data/util/NestedMethodProperty.java @@ -31,8 +31,9 @@ import com.vaadin.data.util.MethodProperty.MethodException; * The property is specified in the dotted notation, e.g. "address.street", and * can contain multiple levels of nesting. * - * When accessing the property value, all intermediate getters must return - * non-null values. + * When accessing the property value, all intermediate getters must exist and + * should return non-null values when the property value is accessed. If an + * intermediate getter returns null, a null value will be returned. * * @see MethodProperty * @@ -76,6 +77,8 @@ public class NestedMethodProperty extends AbstractProperty { * Constructs a nested method property for a given object instance. The * property name is a dot separated string pointing to a nested property, * e.g. "manager.address.street". + *

+ * Calling getValue will return null if any intermediate getter returns null * * @param instance * top-level bean to which the property applies @@ -199,6 +202,9 @@ public class NestedMethodProperty extends AbstractProperty { Object object = instance; for (Method m : getMethods) { object = m.invoke(object); + if (object == null) { + return null; + } } return (T) object; } catch (final Throwable e) { diff --git a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java index 9037e303a8..684ab5d6bc 100644 --- a/server/tests/src/com/vaadin/data/util/BeanContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanContainerTest.java @@ -457,4 +457,17 @@ public class BeanContainerTest extends AbstractBeanContainerTest { .getValue()); } + public void testNestedContainerPropertyWithNullBean() { + BeanContainer container = new BeanContainer( + NestedMethodPropertyTest.Person.class); + container.setBeanIdProperty("name"); + + container.addBean(new NestedMethodPropertyTest.Person("John", null)); + assertTrue(container + .addNestedContainerProperty("address.postalCodeObject")); + assertTrue(container.addNestedContainerProperty("address.street")); + assertNull(container.getContainerProperty("John", "address.street") + .getValue()); + } + } diff --git a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java index 6b88eb336d..767a9e2e4d 100644 --- a/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java +++ b/server/tests/src/com/vaadin/data/util/BeanItemContainerTest.java @@ -714,4 +714,16 @@ public class BeanItemContainerTest extends AbstractBeanContainerTest { .getValue()); } + public void testNestedContainerPropertyWithNullBean() { + BeanItemContainer container = new BeanItemContainer( + NestedMethodPropertyTest.Person.class); + NestedMethodPropertyTest.Person john = new NestedMethodPropertyTest.Person( + "John", null); + assertNotNull(container.addBean(john)); + assertTrue(container + .addNestedContainerProperty("address.postalCodeObject")); + assertTrue(container.addNestedContainerProperty("address.street")); + assertNull(container.getContainerProperty(john, "address.street") + .getValue()); + } } diff --git a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java index 640ede8743..1133626df9 100644 --- a/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java +++ b/server/tests/src/com/vaadin/data/util/NestedMethodPropertyTest.java @@ -7,9 +7,10 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import junit.framework.Assert; import junit.framework.TestCase; +import org.junit.Assert; + public class NestedMethodPropertyTest extends TestCase { public static class Address implements Serializable { @@ -248,29 +249,16 @@ public class NestedMethodPropertyTest extends TestCase { vaadin, "manager.address.street"); joonas.setAddress(null); - try { - streetProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } + assertNull(streetProperty.getValue()); vaadin.setManager(null); - try { - managerNameProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } - try { - streetProperty.getValue(); - fail(); - } catch (Exception e) { - // should get exception - } + assertNull(managerNameProperty.getValue()); + assertNull(streetProperty.getValue()); vaadin.setManager(joonas); Assert.assertEquals("Joonas", managerNameProperty.getValue()); + Assert.assertNull(streetProperty.getValue()); + } public void testMultiLevelNestedPropertySetValue() { @@ -314,6 +302,20 @@ public class NestedMethodPropertyTest extends TestCase { Assert.assertEquals("Ruukinkatu 2-4", property2.getValue()); } + public void testSerializationWithIntermediateNull() throws IOException, + ClassNotFoundException { + vaadin.setManager(null); + NestedMethodProperty streetProperty = new NestedMethodProperty( + vaadin, "manager.address.street"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + new ObjectOutputStream(baos).writeObject(streetProperty); + @SuppressWarnings("unchecked") + NestedMethodProperty property2 = (NestedMethodProperty) new ObjectInputStream( + new ByteArrayInputStream(baos.toByteArray())).readObject(); + + Assert.assertNull(property2.getValue()); + } + public void testIsReadOnly() { NestedMethodProperty streetProperty = new NestedMethodProperty( vaadin, "manager.address.street"); diff --git a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java index 14e70d76d4..12ded84fe2 100644 --- a/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java +++ b/server/tests/src/com/vaadin/data/util/PropertyDescriptorTest.java @@ -39,7 +39,8 @@ public class PropertyDescriptorTest extends TestCase { Assert.assertEquals("John", property.getValue()); } - public void testNestedPropertyDescriptorSerialization() throws Exception { + public void testSimpleNestedPropertyDescriptorSerialization() + throws Exception { NestedPropertyDescriptor pd = new NestedPropertyDescriptor( "name", Person.class); @@ -52,4 +53,19 @@ public class PropertyDescriptorTest extends TestCase { Property property = pd2.createProperty(new Person("John", null)); Assert.assertEquals("John", property.getValue()); } + + public void testNestedPropertyDescriptorSerialization() throws Exception { + NestedPropertyDescriptor pd = new NestedPropertyDescriptor( + "address.street", Person.class); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + new ObjectOutputStream(baos).writeObject(pd); + @SuppressWarnings("unchecked") + VaadinPropertyDescriptor pd2 = (VaadinPropertyDescriptor) new ObjectInputStream( + new ByteArrayInputStream(baos.toByteArray())).readObject(); + + Property property = pd2.createProperty(new Person("John", null)); + Assert.assertNull(property.getValue()); + } + } -- cgit v1.2.3 From 8245079252865d19a929c86bfd67cbe139259f18 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 16 Dec 2013 13:08:02 +0200 Subject: Decrease the websocket buffer size due to a Jetty 9.1 issue (#13087) Jetty 9.1 throws if InputBufferSize is set to greater than or equal to MaxTextMessageBufferSize. We cannot simply increase the value of the latter because Atmosphere sets the former first. Thus, its value must be set to less than 32768 (the default for MaxTextMessageBufferSize). This should not cause problems with regard to performance; the original figure of 65536 was more or less an arbitrary choice. Change-Id: If9596fc2bffdd14e8c1f31ff4b9b10d6685e01ed --- shared/src/com/vaadin/shared/communication/PushConstants.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/com/vaadin/shared/communication/PushConstants.java b/shared/src/com/vaadin/shared/communication/PushConstants.java index f16cbb7390..4b4f247e5f 100644 --- a/shared/src/com/vaadin/shared/communication/PushConstants.java +++ b/shared/src/com/vaadin/shared/communication/PushConstants.java @@ -27,8 +27,11 @@ public class PushConstants implements Serializable { /** * The size, in bytes, of the receiving buffer used by some servers. + *

+ * Should not be set to a value equal to or greater than 32768 due to a + * Jetty 9.1 issue (see #13087) */ - public static final int WEBSOCKET_BUFFER_SIZE = 65536; + public static final int WEBSOCKET_BUFFER_SIZE = 16384; /** * The maximum size, in characters, of a websocket message fragment. -- cgit v1.2.3 From 78a6232b6b0dd2e6c89039e9ca50c164f2d9ab6a Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Sat, 7 Dec 2013 15:10:30 +0200 Subject: removed invalid documentation Change-Id: I8562c1853e17d008738d759bd33f57b9b57c1c4c --- server/src/com/vaadin/ui/AbstractComponent.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 61bcf00ad8..a0a87b260d 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -360,23 +360,16 @@ public abstract class AbstractComponent extends AbstractClientConnector } } - /* - * Tests if the component is in the immediate mode. Don't add a JavaDoc - * comment here, we use the default documentation from implemented - * interface. - */ public boolean isImmediate() { return getState(false).immediate; } /** - * Sets the component's immediate mode to the specified status. This method - * will trigger a {@link RepaintRequestEvent}. + * Sets the component's immediate mode to the specified status. * * @param immediate * the boolean value specifying if the component should be in the * immediate mode after the call. - * @see Component#isImmediate() */ public void setImmediate(boolean immediate) { getState().immediate = immediate; -- cgit v1.2.3 From ea8f381d440b3d5d3d7785b7b235155263aaab2a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 16 Dec 2013 17:18:13 +0100 Subject: Show the widgetset name to more easily spot misconfigurations Change-Id: I69e2995489e9f573718a053c34fe8736988e3f90 --- client/src/com/vaadin/client/ui/UnknownComponentConnector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/ui/UnknownComponentConnector.java b/client/src/com/vaadin/client/ui/UnknownComponentConnector.java index ca461eb640..b9b0388d9a 100644 --- a/client/src/com/vaadin/client/ui/UnknownComponentConnector.java +++ b/client/src/com/vaadin/client/ui/UnknownComponentConnector.java @@ -16,6 +16,8 @@ package com.vaadin.client.ui; +import com.google.gwt.core.client.GWT; + public class UnknownComponentConnector extends AbstractComponentConnector { @Override @@ -31,7 +33,9 @@ public class UnknownComponentConnector extends AbstractComponentConnector { public void setServerSideClassName(String serverClassName) { getWidget() .setCaption( - "Widgetset does not contain implementation for " + "Widgetset '" + + GWT.getModuleName() + + "' does not contain implementation for " + serverClassName + ". Check its component connector's @Connect mapping, widgetsets " + "GWT module description file and re-compile your" -- cgit v1.2.3 From 797ebdff7c1cb5c0d58910f3ff6e86bbdb91ea0a Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 16 Dec 2013 13:56:19 +0200 Subject: Allow user to override Atmosphere init params set by Vaadin (#13088) Change-Id: Iea7c7978240f79cb7c9586b472e94da53d625ba7 --- .../vaadin/server/communication/PushRequestHandler.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/com/vaadin/server/communication/PushRequestHandler.java b/server/src/com/vaadin/server/communication/PushRequestHandler.java index 8d0da24896..aff07d96d7 100644 --- a/server/src/com/vaadin/server/communication/PushRequestHandler.java +++ b/server/src/com/vaadin/server/communication/PushRequestHandler.java @@ -18,6 +18,7 @@ package com.vaadin.server.communication; import java.io.IOException; +import javax.servlet.ServletConfig; import javax.servlet.ServletException; import org.atmosphere.client.TrackMessageSizeInterceptor; @@ -56,11 +57,22 @@ public class PushRequestHandler implements RequestHandler, public PushRequestHandler(VaadinServletService service) throws ServiceException { + final ServletConfig config = service.getServlet().getServletConfig(); + atmosphere = new AtmosphereFramework() { @Override protected void analytics() { // Overridden to disable version number check } + + @Override + public AtmosphereFramework addInitParameter(String name, + String value) { + if (config.getInitParameter(name) == null) { + super.addInitParameter(name, value); + } + return this; + } }; pushHandler = new PushHandler(service); @@ -84,7 +96,7 @@ public class PushRequestHandler implements RequestHandler, "false"); try { - atmosphere.init(service.getServlet().getServletConfig()); + atmosphere.init(config); // Ensure the client-side knows how to split the message stream // into individual messages when using certain transports -- cgit v1.2.3 From 0d303da73bca604474649a83817d1b7d5e09f2e2 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Sat, 7 Dec 2013 17:51:56 +0200 Subject: Added convenience method to add items as a varargs array (#13067) Change-Id: Iab49d0960946cec5e949f4f60bb2f79dce66dcc3 --- server/src/com/vaadin/ui/AbstractSelect.java | 31 ++++++++++++++++++++++ .../abstractselect/TestVarargsItemAddition.java | 26 ++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 server/tests/src/com/vaadin/tests/server/component/abstractselect/TestVarargsItemAddition.java diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 556b16943f..a32d40b11d 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -878,6 +878,37 @@ public abstract class AbstractSelect extends AbstractField implements return retval; } + /** + * Adds given items with given item ids to container. + * + * @since 7.2 + * @param itemId + * item identifiers to be added to underlying container + * @throws UnsupportedOperationException + * if the underlying container don't support adding items with + * identifiers + */ + public void addItems(Object... itemId) throws UnsupportedOperationException { + for (Object id : itemId) { + addItem(id); + } + } + + /** + * Adds given items with given item ids to container. + * + * @since 7.2 + * @param itemIds + * item identifiers to be added to underlying container + * @throws UnsupportedOperationException + * if the underlying container don't support adding items with + * identifiers + */ + public void addItems(Collection itemIds) + throws UnsupportedOperationException { + addItems(itemIds.toArray()); + } + /* * (non-Javadoc) * diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/TestVarargsItemAddition.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/TestVarargsItemAddition.java new file mode 100644 index 0000000000..5575b8fd3d --- /dev/null +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/TestVarargsItemAddition.java @@ -0,0 +1,26 @@ +package com.vaadin.tests.server.component.abstractselect; + +import java.util.Collection; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.vaadin.ui.OptionGroup; + +public class TestVarargsItemAddition extends TestCase { + + public void itemAddition() throws Exception { + + OptionGroup optionGroup = new OptionGroup(); + + optionGroup.addItems("foo", "bar", "car"); + + Collection itemIds = optionGroup.getItemIds(); + Assert.assertEquals(3, itemIds.size()); + Assert.assertTrue(itemIds.contains("foo")); + Assert.assertTrue(itemIds.contains("bar")); + Assert.assertTrue(itemIds.contains("car")); + + } +} -- cgit v1.2.3 From 8af8d2f8c25dc1f8ced34d7ba1de727bb6f2d0ac Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Sat, 7 Dec 2013 17:22:02 +0200 Subject: Make fields with value change listener immediate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes fields with value change listener immediate without explicit call. If immediate value has been explicitly set, it is honoured. In most cases immediate now works seamlessly and excess server round trips should be rare as a regression. “Fixes” #8029 in a more elegant manner Change-Id: Ic240c78c0a29447809a17de74196d3325a78ec1f --- server/src/com/vaadin/ui/AbstractComponent.java | 18 ++- server/src/com/vaadin/ui/AbstractField.java | 4 + .../components/textfield/AutomaticImmediate.java | 147 +++++++++++++++++++++ .../textfield/AutomaticImmediateTest.java | 109 +++++++++++++++ 4 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java create mode 100644 uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index a0a87b260d..85671922a5 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -38,6 +38,7 @@ import com.vaadin.server.VaadinSession; import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.ComponentConstants; import com.vaadin.shared.ui.ComponentStateUtil; +import com.vaadin.ui.Field.ValueChangeEvent; import com.vaadin.util.ReflectTools; /** @@ -97,6 +98,8 @@ public abstract class AbstractComponent extends AbstractClientConnector private HasComponents parent; + private Boolean explicitImmediateValue; + /* Constructor */ /** @@ -361,7 +364,17 @@ public abstract class AbstractComponent extends AbstractClientConnector } public boolean isImmediate() { - return getState(false).immediate; + if (explicitImmediateValue != null) { + return explicitImmediateValue; + } else if (hasListeners(ValueChangeEvent.class)) { + /* + * Automatic immediate for fields that developers are interested + * about. + */ + return true; + } else { + return false; + } } /** @@ -372,6 +385,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * immediate mode after the call. */ public void setImmediate(boolean immediate) { + explicitImmediateValue = immediate; getState().immediate = immediate; } @@ -668,6 +682,8 @@ public abstract class AbstractComponent extends AbstractClientConnector } else { getState().errorMessage = null; } + + getState().immediate = isImmediate(); } /* General event framework */ diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index 6a52d6b849..cecce59e97 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -1085,6 +1085,8 @@ public abstract class AbstractField extends AbstractComponent implements public void addValueChangeListener(Property.ValueChangeListener listener) { addListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); + // ensure "automatic immediate handling" works + markAsDirty(); } /** @@ -1106,6 +1108,8 @@ public abstract class AbstractField extends AbstractComponent implements public void removeValueChangeListener(Property.ValueChangeListener listener) { removeListener(AbstractField.ValueChangeEvent.class, listener, VALUE_CHANGE_METHOD); + // ensure "automatic immediate handling" works + markAsDirty(); } /** diff --git a/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java new file mode 100644 index 0000000000..26716846fc --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediate.java @@ -0,0 +1,147 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.textfield; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.TextField; + +/** + * Test to verify fields become implicitly "immediate" when adding value change + * listener to them. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class AutomaticImmediate extends AbstractTestUIWithLog { + + /** + * + */ + static final String BUTTON = "button"; + /** + * + */ + static final String EXPLICIT_FALSE = "explicit-false"; + /** + * + */ + static final String FIELD = "field"; + /** + * + */ + static final String LISTENER_TOGGLE = "listener-toggle"; + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + + final TextField textField = new TextField() { + + /* + * (non-Javadoc) + * + * @see com.vaadin.ui.AbstractField#fireValueChange(boolean) + */ + @Override + protected void fireValueChange(boolean repaintIsNotNeeded) { + log("fireValueChange"); + super.fireValueChange(repaintIsNotNeeded); + } + }; + textField.setId(FIELD); + + final ValueChangeListener listener = new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + log("Value changed: " + event.getProperty().getValue()); + } + }; + + final CheckBox checkBox = new CheckBox("Toggle listener"); + checkBox.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + if (checkBox.getValue()) { + textField.addValueChangeListener(listener); + } else { + textField.removeValueChangeListener(listener); + } + } + }); + checkBox.setId(LISTENER_TOGGLE); + + Button b = new Button( + "setImmediate(false), sets explicitly false and causes server roundtrip", + new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + textField.setImmediate(false); + } + }); + b.setId(EXPLICIT_FALSE); + + Button b2 = new Button("Hit server, causes server roundtrip", + new ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + } + }); + b2.setId(BUTTON); + + addComponent(textField); + addComponent(checkBox); + addComponent(b); + addComponent(b2); + + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Field should be immediate automatically if it has value change listener"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 8029; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java new file mode 100644 index 0000000000..4b522a1f37 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textfield/AutomaticImmediateTest.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.textfield; + +import org.apache.commons.lang.RandomStringUtils; +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class AutomaticImmediateTest extends MultiBrowserTest { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass() + */ + @Override + protected Class getUIClass() { + return AutomaticImmediate.class; + } + + @Test + public void test() { + openTestURL(); + + WebElement field = getDriver().findElement( + By.id(AutomaticImmediate.FIELD)); + + WebElement toggle = getDriver().findElement( + By.xpath("//input[@type = 'checkbox']")); + + WebElement explicitFalseButton = getDriver().findElement( + By.id(AutomaticImmediate.EXPLICIT_FALSE)); + + WebElement hitServerButton = getDriver().findElement( + By.id(AutomaticImmediate.BUTTON)); + + String string = getRandomString(); + field.sendKeys(string + Keys.ENTER); + + // Non immediate, just the initial server side valuechange + assertLastLog("1. fireValueChange"); + + hitServerButton.click(); + + // No value change, but value sent to server + assertLastLog("2. fireValueChange"); + + // listener on -> immediate on + toggle.click(); + + string = getRandomString(); + String delSequence = "" + Keys.BACK_SPACE + Keys.BACK_SPACE; + field.sendKeys(delSequence + string + Keys.ENTER); + assertLastLog("4. Value changed: " + string); + + // listener off -> immediate off + String lastvalue = string; + toggle.click(); + string = getRandomString(); + field.sendKeys(delSequence + string + Keys.ENTER); + // No new value change should happen... + assertLastLog("4. Value changed: " + lastvalue); + hitServerButton.click(); + // ... but server should receive value with roundtrip + assertLastLog("5. fireValueChange"); + + // explicitly non immediate, but with listener + explicitFalseButton.click(); + toggle.click(); + + string = getRandomString(); + field.sendKeys(delSequence + string + Keys.ENTER); + // non immediate, no change... + assertLastLog("5. fireValueChange"); + // ... until server round trip + hitServerButton.click(); + assertLastLog("7. Value changed: " + string); + + } + + private String getRandomString() { + String string = RandomStringUtils.randomAlphanumeric(2); + return string; + } + + private void assertLastLog(String string) { + String text = getDriver().findElement(By.id("Log_row_0")).getText(); + Assert.assertEquals(string, text); + } + +} -- cgit v1.2.3 From 90b8d277a2498cd3aa37f55731f5e1513723d580 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Wed, 18 Dec 2013 12:28:46 +0200 Subject: Fixes serialization-related errors Build-breaking error introduced in c14334f284c7e7c344b2983726b9242e3ef8562e Change-Id: Ie27ffba1f700b9373f446a61f78cac2c2d3e23bc --- server/src/com/vaadin/server/communication/ServerRpcHandler.java | 2 +- server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java index 432a9ea893..ff418a95e8 100644 --- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java +++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java @@ -68,7 +68,7 @@ public class ServerRpcHandler implements Serializable { * @since 7.2 * @author Vaadin Ltd */ - public static class RpcRequest { + public static class RpcRequest implements Serializable { private final String csrfToken; private final JSONArray invocations; diff --git a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java b/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java index e5420b8921..705bae3d98 100644 --- a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java +++ b/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java @@ -42,6 +42,7 @@ public class TestClassesSerializable extends TestCase { "com\\.vaadin\\.event\\.FieldEvents", // "com\\.vaadin\\.event\\.LayoutEvents", // "com\\.vaadin\\.event\\.MouseEvents", // + "com\\.vaadin\\.event\\.UIEvents", // "com\\.vaadin\\.server\\.VaadinPortlet", // "com\\.vaadin\\.server\\.MockServletConfig", // "com\\.vaadin\\.server\\.MockServletContext", // -- cgit v1.2.3 From 65c2f2bf06986d397169e58f819ba1592fa52bb7 Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Mon, 30 Dec 2013 21:47:18 +0200 Subject: Properly remove shadow event listeners to prevent IE8 memory leak (#13129) Change-Id: I98becf08f56ce35a3ee47650d0d4e204e7d18e73 --- client/src/com/vaadin/client/ui/VOverlay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java index 2f5df6d4f3..e2c9001fed 100644 --- a/client/src/com/vaadin/client/ui/VOverlay.java +++ b/client/src/com/vaadin/client/ui/VOverlay.java @@ -241,10 +241,10 @@ public class VOverlay extends PopupPanel implements CloseHandler { private void removeShadowIfPresent() { if (isShadowAttached()) { - shadow.removeFromParent(); - // Remove event listener from the shadow unsinkShadowEvents(); + + shadow.removeFromParent(); } } -- cgit v1.2.3 From e9a547ac4e153f85597e056f5c51ade60fe29c45 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 31 Dec 2013 15:24:55 +0200 Subject: Fixed spelling mistake in log message. Change-Id: Ib43cca840a8f66b13d14a84b629068a53e8f4c9d --- server/src/com/vaadin/server/communication/ServerRpcHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java index f14d703454..ea25777525 100644 --- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java +++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java @@ -366,7 +366,7 @@ public class ServerRpcHandler implements Serializable { "Ignoring RPC call to " + interfaceName + "." + methodName + " in connector " + connector.getClass().getName() + "(" + connectorId - + ") as no RPC implementation is regsitered"); + + ") as no RPC implementation is registered"); return null; } -- cgit v1.2.3 From 0b95f8d6f6e3f278b51c0242e8ce2dfc82ed829e Mon Sep 17 00:00:00 2001 From: Jarno Rantala Date: Wed, 11 Dec 2013 11:10:43 +0200 Subject: Moved selection of selected rows in TableConnector to occur after the new rows are created (#13008) The selection of selected rows happened before the new rows were created. This resulted in situation where the visible items on server side were different than the rows in scrollbody during the selection of selected rows. Therefore, the selected keys in uidl contained wrong information and some selected rows was marked as unselected even though they shouldn't. This again resulted in the original bug that all the rows was not selected because the 'selectionRangeStart' row was not selected anymore. Change-Id: I9f985cb45c97bacb6b71e36fa4bf077a1ac1311d --- .../com/vaadin/client/ui/table/TableConnector.java | 6 +- .../tests/components/table/SelectAllRows.java | 83 ++++++++++++++++ .../tests/components/table/SelectAllRowsTest.java | 105 +++++++++++++++++++++ 3 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/SelectAllRows.java create mode 100644 uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java diff --git a/client/src/com/vaadin/client/ui/table/TableConnector.java b/client/src/com/vaadin/client/ui/table/TableConnector.java index 07689a640f..80a84f0a19 100644 --- a/client/src/com/vaadin/client/ui/table/TableConnector.java +++ b/client/src/com/vaadin/client/ui/table/TableConnector.java @@ -142,9 +142,6 @@ public class TableConnector extends AbstractHasComponentsConnector implements getWidget().updateSortingProperties(uidl); - boolean keyboardSelectionOverRowFetchInProgress = getWidget() - .selectSelectedRows(uidl); - getWidget().updateActionMap(uidl); getWidget().updateColumnProperties(uidl); @@ -216,6 +213,9 @@ public class TableConnector extends AbstractHasComponentsConnector implements } } + boolean keyboardSelectionOverRowFetchInProgress = getWidget() + .selectSelectedRows(uidl); + // If a row had an open context menu before the update, and after the // update there's a row with the same key as that row, restore the // context menu. See #8526. diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java new file mode 100644 index 0000000000..6007ea2984 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRows.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.table; + +import java.util.Set; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +public class SelectAllRows extends AbstractTestUI { + + static final String TABLE = "table"; + static final String COUNT_SELECTED_BUTTON = "button"; + static final int TOTAL_NUMBER_OF_ROWS = 300; + static final String COUNT_OF_SELECTED_ROWS_LABEL = "label"; + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setMargin(true); + layout.setSpacing(true); + setContent(layout); + + final Table table = new Table(); + table.setId(TABLE); + table.setImmediate(true); + table.setMultiSelect(true); + table.setSelectable(true); + table.addContainerProperty("row", String.class, null); + layout.addComponent(table); + + Button button = new Button("Count"); + button.setId(COUNT_SELECTED_BUTTON); + layout.addComponent(button); + + final Label label = new Label(); + label.setId(COUNT_OF_SELECTED_ROWS_LABEL); + label.setCaption("Selected count:"); + layout.addComponent(label); + + button.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(Button.ClickEvent event) { + Set selected = (Set) table.getValue(); + label.setValue(String.valueOf(selected.size())); + } + }); + + for (int i = 0; i < TOTAL_NUMBER_OF_ROWS; i++) { + Object itemId = table.addItem(); + table.getContainerProperty(itemId, "row").setValue("row " + i); + } + } + + @Override + protected String getTestDescription() { + return "Selecting all rows does not work by selecting first row, press shift then select last row"; + } + + @Override + protected Integer getTicketNumber() { + return 13008; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java new file mode 100644 index 0000000000..664b36fa75 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/SelectAllRowsTest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.table; + +import static com.vaadin.tests.components.table.SelectAllRows.COUNT_OF_SELECTED_ROWS_LABEL; +import static com.vaadin.tests.components.table.SelectAllRows.COUNT_SELECTED_BUTTON; +import static com.vaadin.tests.components.table.SelectAllRows.TABLE; +import static com.vaadin.tests.components.table.SelectAllRows.TOTAL_NUMBER_OF_ROWS; +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SelectAllRowsTest extends MultiBrowserTest { + + private final static String TABLE_ROW = "v-table-row"; + + @Override + public List getBrowsersToTest() { + // Pressing Shift modifier key does not work with TestBench and IE + // (#8621) + return Arrays.asList(Browser.FIREFOX.getDesiredCapabilities(), + Browser.CHROME.getDesiredCapabilities()); + } + + @Test + public void testAllRowsAreSelected() { + openTestURL(); + + selectAllRowsInTable(); + int selectedRows = countSelectedItems(); + + assertEquals(TOTAL_NUMBER_OF_ROWS, selectedRows); + } + + private int countSelectedItems() { + WebElement countButton = vaadinElementById(COUNT_SELECTED_BUTTON); + countButton.click(); + WebElement countOfSelectedRows = vaadinElementById(COUNT_OF_SELECTED_ROWS_LABEL); + String count = countOfSelectedRows.getText(); + return Integer.parseInt(count); + } + + private void selectAllRowsInTable() { + clickFirstRow(); + scrollTableToBottom(); + new Actions(getDriver()).keyDown(Keys.SHIFT).perform(); + clickLastRow(); + new Actions(getDriver()).keyUp(Keys.SHIFT).perform(); + } + + private void clickLastRow() { + List rows = allVisibleTableRows(); + WebElement lastRow = rows.get(rows.size() - 1); + lastRow.click(); + } + + private void clickFirstRow() { + WebElement firstRow = allVisibleTableRows().get(0); + firstRow.click(); + } + + private void scrollTableToBottom() { + WebElement table = vaadinElementById(TABLE); + testBenchElement(table.findElement(By.className("v-scrollable"))) + .scroll(TOTAL_NUMBER_OF_ROWS * 30); + + // Wait for scrolling to complete. Otherwise, clicking last row will + // fail with Chrome + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private List allVisibleTableRows() { + WebElement table = vaadinElementById(TABLE); + List rows = table.findElements(By + .cssSelector(".v-table-table tr")); + return rows; + } +} -- cgit v1.2.3 From 0579fba63048ffa8daa22db5243a149e67f73594 Mon Sep 17 00:00:00 2001 From: Tomi Virtanen Date: Mon, 9 Dec 2013 13:44:27 +0200 Subject: Upload control with empty selection (#9602) Event is now sent on submit even if no file is selected. Removed forceSubmit UIDL attribute and replaced it with a UploadClientRpc call. Added TestBench3 test. Change-Id: Id32b82532ec34e61a9c0718413fd1755015d2c30 --- client/src/com/vaadin/client/ui/VUpload.java | 7 +- .../vaadin/client/ui/upload/UploadConnector.java | 14 ++-- server/src/com/vaadin/ui/Upload.java | 14 +--- .../vaadin/shared/ui/upload/UploadClientRpc.java | 26 +++++++ .../tests/components/upload/UploadNoSelection.java | 83 ++++++++++++++++++++++ .../components/upload/UploadNoSelectionTest.java | 56 +++++++++++++++ 6 files changed, 182 insertions(+), 18 deletions(-) create mode 100644 shared/src/com/vaadin/shared/ui/upload/UploadClientRpc.java create mode 100644 uitest/src/com/vaadin/tests/components/upload/UploadNoSelection.java create mode 100644 uitest/src/com/vaadin/tests/components/upload/UploadNoSelectionTest.java diff --git a/client/src/com/vaadin/client/ui/VUpload.java b/client/src/com/vaadin/client/ui/VUpload.java index c08d75e9b7..8e55387d39 100644 --- a/client/src/com/vaadin/client/ui/VUpload.java +++ b/client/src/com/vaadin/client/ui/VUpload.java @@ -295,10 +295,13 @@ public class VUpload extends SimplePanel { /** For internal use only. May be removed or replaced in the future. */ public void submit() { - if (fu.getFilename().length() == 0 || submitted || !enabled) { - VConsole.log("Submit cancelled (disabled, no file or already submitted)"); + if (submitted || !enabled) { + VConsole.log("Submit cancelled (disabled or already submitted)"); return; } + if (fu.getFilename().length() == 0) { + VConsole.log("Submitting empty selection (no file)"); + } // flush possibly pending variable changes, so they will be handled // before upload client.sendPendingVariableChanges(); diff --git a/client/src/com/vaadin/client/ui/upload/UploadConnector.java b/client/src/com/vaadin/client/ui/upload/UploadConnector.java index 937ff438ac..989a913adc 100644 --- a/client/src/com/vaadin/client/ui/upload/UploadConnector.java +++ b/client/src/com/vaadin/client/ui/upload/UploadConnector.java @@ -22,12 +22,22 @@ import com.vaadin.client.UIDL; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.VUpload; import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.upload.UploadClientRpc; import com.vaadin.ui.Upload; @Connect(Upload.class) public class UploadConnector extends AbstractComponentConnector implements Paintable { + public UploadConnector() { + registerRpc(UploadClientRpc.class, new UploadClientRpc() { + @Override + public void submitUpload() { + getWidget().submit(); + } + }); + } + @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { if (!isRealUpdate(uidl)) { @@ -37,10 +47,6 @@ public class UploadConnector extends AbstractComponentConnector implements getWidget().t.schedule(400); return; } - if (uidl.hasAttribute("forceSubmit")) { - getWidget().submit(); - return; - } getWidget().setImmediate(getState().immediate); getWidget().client = client; getWidget().paintableId = uidl.getId(); diff --git a/server/src/com/vaadin/ui/Upload.java b/server/src/com/vaadin/ui/Upload.java index 08cabf979a..98f5d2ded9 100644 --- a/server/src/com/vaadin/ui/Upload.java +++ b/server/src/com/vaadin/ui/Upload.java @@ -28,6 +28,7 @@ import com.vaadin.server.NoOutputStreamException; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.StreamVariable.StreamingProgressEvent; +import com.vaadin.shared.ui.upload.UploadClientRpc; /** * Component for uploading files from client to server. @@ -106,11 +107,6 @@ public class Upload extends AbstractComponent implements Component.Focusable, private int nextid; - /** - * Flag to indicate that submitting file has been requested. - */ - private boolean forceSubmit; - /** * Creates a new instance of Upload. * @@ -157,11 +153,6 @@ public class Upload extends AbstractComponent implements Component.Focusable, notStarted = false; return; } - if (forceSubmit) { - target.addAttribute("forceSubmit", true); - forceSubmit = true; - return; - } // The field should be focused if (focus) { target.addAttribute("focus", true); @@ -1011,12 +1002,11 @@ public class Upload extends AbstractComponent implements Component.Focusable, */ public void submitUpload() { markAsDirty(); - forceSubmit = true; + getRpcProxy(UploadClientRpc.class).submitUpload(); } @Override public void markAsDirty() { - forceSubmit = false; super.markAsDirty(); } diff --git a/shared/src/com/vaadin/shared/ui/upload/UploadClientRpc.java b/shared/src/com/vaadin/shared/ui/upload/UploadClientRpc.java new file mode 100644 index 0000000000..1757ddb001 --- /dev/null +++ b/shared/src/com/vaadin/shared/ui/upload/UploadClientRpc.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.upload; + +import com.vaadin.shared.communication.ClientRpc; + +public interface UploadClientRpc extends ClientRpc { + + /** + * Forces the upload the send selected file to the server. + */ + void submitUpload(); +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadNoSelection.java b/uitest/src/com/vaadin/tests/components/upload/UploadNoSelection.java new file mode 100644 index 0000000000..c304293170 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadNoSelection.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.upload; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Upload; +import com.vaadin.ui.Upload.FailedEvent; +import com.vaadin.ui.Upload.FinishedEvent; +import com.vaadin.ui.Upload.Receiver; + +public class UploadNoSelection extends AbstractTestUIWithLog implements + Receiver { + + static final String LOG_ID_PREFIX = "Log_row_"; + static final String UPLOAD_ID = "u"; + + static final String UPLOAD_FINISHED = "Upload Finished"; + static final String RECEIVING_UPLOAD = "Receiving upload"; + + static final String FILE_LENGTH_PREFIX = "File length:"; + static final String FILE_NAME_PREFIX = "File name:"; + + @Override + protected Integer getTicketNumber() { + return 9602; + } + + @Override + protected String getTestDescription() { + return "Uploading an empty selection (no file) will trigger FinishedEvent with 0-length file size and empty filename."; + } + + @Override + protected void setup(VaadinRequest request) { + Upload u = new Upload("Upload", this); + u.setId(UPLOAD_ID); + u.setSizeUndefined(); + + addComponent(u); + + u.addFinishedListener(new Upload.FinishedListener() { + @Override + public void uploadFinished(FinishedEvent event) { + log(UPLOAD_FINISHED); + log(FILE_LENGTH_PREFIX + " " + event.getLength()); + log(FILE_NAME_PREFIX + " " + event.getFilename()); + } + }); + u.addFailedListener(new Upload.FailedListener() { + + @Override + public void uploadFailed(FailedEvent event) { + log("Upload Failed"); + log(FILE_LENGTH_PREFIX + " " + event.getLength()); + log(FILE_NAME_PREFIX + " " + event.getFilename()); + } + }); + } + + @Override + public OutputStream receiveUpload(String filename, String MIMEType) { + log(RECEIVING_UPLOAD); + return new ByteArrayOutputStream(); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/upload/UploadNoSelectionTest.java b/uitest/src/com/vaadin/tests/components/upload/UploadNoSelectionTest.java new file mode 100644 index 0000000000..1b30c4080a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/upload/UploadNoSelectionTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.upload; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class UploadNoSelectionTest extends MultiBrowserTest { + + @Test + public void testUploadNoSelection() throws Exception { + openTestURL(); + + // empty content is populated by com.vaadin.tests.util.Log + Assert.assertEquals(" ", getLogRow(0)); + + getSubmitButton().click(); + + // expecting empty file name + assertLogRow(0, 4, UploadNoSelection.FILE_NAME_PREFIX); + // expecting 0-length file + assertLogRow(1, 3, UploadNoSelection.FILE_LENGTH_PREFIX + " " + 0); + assertLogRow(2, 2, UploadNoSelection.UPLOAD_FINISHED); + assertLogRow(3, 1, UploadNoSelection.RECEIVING_UPLOAD); + } + + private WebElement getSubmitButton() { + WebElement element = getDriver().findElement( + By.id(UploadNoSelection.UPLOAD_ID)); + WebElement submitButton = element.findElement(By.className("v-button")); + return submitButton; + } + + private void assertLogRow(int index, int expentedRowNo, + String expectedValueWithoutRowNo) { + Assert.assertEquals(expentedRowNo + ". " + expectedValueWithoutRowNo, + getLogRow(index)); + } +} -- cgit v1.2.3 From db4dba4b43f6dde1a17804409d34248bd8698a2e Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 31 Dec 2013 09:49:44 +0200 Subject: Ensure event listener is a widget before casting #13130 Change-Id: I7f106356116d73eebbfeeee52d61d8d7a7117b3e --- client/src/com/vaadin/client/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 8972670232..55d3d13c19 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -866,7 +866,7 @@ public class Util { element = (Element) element.getParentElement(); } } - if (eventListener != null) { + if (eventListener instanceof Widget) { /* * Then find the first widget of type class1 from widget * hierarchy -- cgit v1.2.3 From 5e8e866664f0301ab442c0013bdec0f27e9f550d Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Tue, 7 Jan 2014 14:38:53 +0200 Subject: Changes padding for Textfields with Chameleon theme. (#12974) Change-Id: I911ddd8ef1162412ae99ef252c3302e1f8b555ef --- .../VAADIN/themes/chameleon/components/textfield/textfield.scss | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss b/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss index 3962ba9ccd..4554672da4 100644 --- a/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss +++ b/WebContent/VAADIN/themes/chameleon/components/textfield/textfield.scss @@ -20,7 +20,10 @@ textarea.v-textarea, input.#{$primaryStyleName}[type="text"], textarea.v-textarea, .v-filterselect { - padding: .1em; + padding-bottom: .1em; + padding-top: .1em; + padding-left: .2em; + padding-right: .2em; } input.#{$primaryStyleName}[type="text"] { @@ -29,7 +32,7 @@ input.#{$primaryStyleName}[type="text"] { input.v-widget.#{$primaryStyleName}[type="text"], .v-filterselect { - height: 1.6em; + height: 1.7em; } &.v-app input.#{$primaryStyleName}, -- cgit v1.2.3 From 171e68da0d072cb7a7f256d2d27c8b2674759358 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 7 Jan 2014 13:13:58 +0200 Subject: Only use ClientRcp and ServerRpc types that are interfaces (#13056) Change-Id: I73b062628052ec545d5f53314a0cc479806ee89d --- .../widgetsetutils/metadata/ConnectorBundle.java | 8 +++- .../widgetset/client/ClientRpcClassConnector.java | 36 +++++++++++++++++ .../widgetset/client/ClientRpcClassWidget.java | 33 +++++++++++++++ .../tests/widgetset/server/ClientRpcClass.java | 47 ++++++++++++++++++++++ .../widgetset/server/ClientRpcClassComponent.java | 29 +++++++++++++ .../tests/widgetset/server/ClientRpcClassTest.java | 35 ++++++++++++++++ 6 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java create mode 100644 uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java create mode 100644 uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java create mode 100644 uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java create mode 100644 uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java index cbdd3e89aa..4d6a7ff6d7 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java @@ -430,11 +430,11 @@ public class ConnectorBundle { } private static boolean isClientRpc(JClassType type) { - return isType(type, ClientRpc.class); + return isInterfaceType(type, ClientRpc.class); } private static boolean isServerRpc(JClassType type) { - return isType(type, ServerRpc.class); + return isInterfaceType(type, ServerRpc.class); } public static boolean isConnectedConnector(JClassType type) { @@ -451,6 +451,10 @@ public class ConnectorBundle { return isConnected(type) && isType(type, ComponentConnector.class); } + private static boolean isInterfaceType(JClassType type, Class class1) { + return type.isInterface() != null && isType(type, class1); + } + private static boolean isType(JClassType type, Class class1) { try { return type.getOracle().getType(class1.getName()) diff --git a/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java new file mode 100644 index 0000000000..fb28e94bfa --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassConnector.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client; + +import com.vaadin.client.ui.label.LabelConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.MediaControl; +import com.vaadin.tests.widgetset.server.ClientRpcClassComponent; + +@Connect(ClientRpcClassComponent.class) +public class ClientRpcClassConnector extends LabelConnector { + + @Override + protected void init() { + super.init(); + registerRpc(MediaControl.class, getWidget()); + } + + @Override + public ClientRpcClassWidget getWidget() { + return (ClientRpcClassWidget) super.getWidget(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java new file mode 100644 index 0000000000..91b4f19d92 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/ClientRpcClassWidget.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client; + +import com.vaadin.client.ui.VLabel; +import com.vaadin.shared.ui.MediaControl; + +public class ClientRpcClassWidget extends VLabel implements MediaControl { + + @Override + public void play() { + setText("play"); + } + + @Override + public void pause() { + setText("pause"); + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java new file mode 100644 index 0000000000..cbc46b26f5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClass.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; + +@Widgetset(TestingWidgetSet.NAME) +public class ClientRpcClass extends AbstractTestUI { + + public static String TEST_COMPONENT_ID = "testComponent"; + + @Override + protected void setup(VaadinRequest request) { + ClientRpcClassComponent component = new ClientRpcClassComponent(); + component.setId(TEST_COMPONENT_ID); + addComponent(component); + + component.pause(); + } + + @Override + protected String getTestDescription() { + return "UI showing dummy component where the wiget type is implementing the RPC interface."; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(13056); + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java new file mode 100644 index 0000000000..135f112fe4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassComponent.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import com.vaadin.shared.ui.MediaControl; +import com.vaadin.ui.Label; + +public class ClientRpcClassComponent extends Label { + public void play() { + getRpcProxy(MediaControl.class).play(); + } + + public void pause() { + getRpcProxy(MediaControl.class).pause(); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java new file mode 100644 index 0000000000..16c5ba4b61 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/ClientRpcClassTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ClientRpcClassTest extends MultiBrowserTest { + + @Test + public void pauseDisplayed() { + openTestURL(); + + WebElement element = getDriver().findElement( + By.id(ClientRpcClass.TEST_COMPONENT_ID)); + Assert.assertEquals("pause", element.getText()); + } +} -- cgit v1.2.3 From e41a2cef9b50d3a63b6bffa0f7777c61f5093492 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 7 Jan 2014 15:01:20 +0200 Subject: Add helper for adding multiple components to AbstractTestUI Change-Id: I5153810f635831732ed17c5af215d17ff9a2c801 --- uitest/src/com/vaadin/tests/components/AbstractTestUI.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 8f92ff3118..6213993257 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -148,6 +148,10 @@ public abstract class AbstractTestUI extends UI { getLayout().addComponent(c); } + public void addComponents(Component... c) { + getLayout().addComponents(c); + } + public void removeComponent(Component c) { getLayout().removeComponent(c); } -- cgit v1.2.3 From 87652c5642d70c029d9a4e6e31123dbfbc9ac040 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 8 Jan 2014 16:00:55 +0200 Subject: Fix VaadinFinderLocatorStrategy result filtering (#13154) Change-Id: Ia59fbd4fc5d784423c2fc4da4ed19b81723d6de4 --- .../client/componentlocator/VaadinFinderLocatorStrategy.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 6337ca7e8c..2bb08a52c9 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -410,15 +410,13 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { String[] fragments = splitFirstFragmentFromTheRest(path); - List potentialMatches = new ArrayList(); + List connectors = new ArrayList(); for (ComponentConnector parent : parents) { - potentialMatches.addAll(collectPotentialMatches(parent, - fragments[0], findRecursively)); + connectors.addAll(filterMatches( + collectPotentialMatches(parent, fragments[0], + findRecursively), extractPredicates(fragments[0]))); } - List connectors = filterMatches(potentialMatches, - extractPredicates(fragments[0])); - if (!connectors.isEmpty() && fragments.length > 1) { return (findConnectorsByPath(fragments[1], connectors)); } -- cgit v1.2.3 From 407bdb39f7d87acaf15c399e46baf6d6a858fa6d Mon Sep 17 00:00:00 2001 From: Jarno Rantala Date: Fri, 3 Jan 2014 14:39:58 +0200 Subject: Ignores scroll events while update from server is in progress (#11454) When ItemSetChange event occurs, it will recreate the rows in client side. This will mess up the scroll position in scrollBodyPanel when its content is removed. This why the onScroll events should be ignored until the scroll position is reset by lazyScroller. Change-Id: Ib70e0dd7b730d4745a84742509145658e35d517e --- client/src/com/vaadin/client/ui/VScrollTable.java | 38 +- .../tests/components/table/ExpandingContainer.java | 429 +++++++++++++++++++++ .../ExpandingContainerVisibleRowRaceCondition.java | 67 ++++ ...andingContainerVisibleRowRaceConditionTest.java | 90 +++++ 4 files changed, 622 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java create mode 100644 uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceCondition.java create mode 100644 uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index c56a2a8772..bb431bf132 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -991,6 +991,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (scrollBody != null) { scrollBody.removeFromParent(); } + + // Without this call the scroll position is messed up in IE even after + // the lazy scroller has set the scroll position to the first visible + // item + scrollBodyPanel.getScrollPosition(); + scrollBody = createScrollBody(); scrollBody.renderInitialRows(rowData, uidl.getIntAttribute("firstrow"), @@ -1121,7 +1127,28 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } } + private boolean lazyScrollerIsActive; + + private void disableLazyScroller() { + lazyScrollerIsActive = false; + scrollBodyPanel.getElement().getStyle().clearOverflowX(); + scrollBodyPanel.getElement().getStyle().clearOverflowY(); + } + + private void enableLazyScroller() { + Scheduler.get().scheduleDeferred(lazyScroller); + lazyScrollerIsActive = true; + // prevent scrolling to jump in IE11 + scrollBodyPanel.getElement().getStyle().setOverflowX(Overflow.HIDDEN); + scrollBodyPanel.getElement().getStyle().setOverflowY(Overflow.HIDDEN); + } + + private boolean isLazyScrollerActive() { + return lazyScrollerIsActive; + } + private ScheduledCommand lazyScroller = new ScheduledCommand() { + @Override public void execute() { if (firstvisible > 0) { @@ -1134,6 +1161,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .setScrollPosition(measureRowHeightOffset(firstvisible)); } } + disableLazyScroller(); } }; @@ -1152,7 +1180,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // Only scroll if the first visible changes from the server side. // Else we might unintentionally scroll even when the scroll // position has not changed. - Scheduler.get().scheduleDeferred(lazyScroller); + enableLazyScroller(); } } @@ -2172,7 +2200,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, isNewBody = false; if (firstvisible > 0) { - Scheduler.get().scheduleDeferred(lazyScroller); + enableLazyScroller(); } if (enabled) { @@ -6871,6 +6899,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets, @Override public void onScroll(ScrollEvent event) { + // Do not handle scroll events while there is scroll initiated from + // server side which is not yet executed (#11454) + if (isLazyScrollerActive()) { + return; + } + scrollLeft = scrollBodyPanel.getElement().getScrollLeft(); scrollTop = scrollBodyPanel.getScrollPosition(); /* diff --git a/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java b/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java new file mode 100644 index 0000000000..829c29b95b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ExpandingContainer.java @@ -0,0 +1,429 @@ +package com.vaadin.tests.components.table; + +import java.util.AbstractList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.logging.Logger; + +import com.vaadin.data.Container; +import com.vaadin.data.Item; +import com.vaadin.data.Property; +import com.vaadin.data.util.AbstractContainer; +import com.vaadin.data.util.BeanItem; +import com.vaadin.server.VaadinSession; +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; + +@SuppressWarnings("serial") +public class ExpandingContainer extends AbstractContainer implements + Container.Ordered, Container.Indexed, Container.ItemSetChangeNotifier { + + public static final List PROPERTY_IDS = Arrays.asList("id", + "column1", "column2"); + + private final Label sizeLabel; + private final Logger log = Logger.getLogger(this.getClass().getName()); + + private int currentSize = 300; + + private boolean loggingEnabled; + + public ExpandingContainer(Label sizeLabel) { + this.sizeLabel = sizeLabel; + updateLabel(); + } + + private void log(String message) { + if (loggingEnabled) { + log.info(message); + } + } + + // Expand container if we scroll past 85% + public int checkExpand(int index) { + log("checkExpand(" + index + ")"); + if (index >= currentSize * 0.85) { + final int oldsize = currentSize; + currentSize = (int) (oldsize * 1.3333); + log("*** getSizeWithHint(" + index + "): went past 85% of size=" + + oldsize + ", new size=" + currentSize); + updateLabel(); + } + return currentSize; + }; + + @Override + public void fireItemSetChange() { + super.fireItemSetChange(); + } + + private void updateLabel() { + sizeLabel.setValue("Container size: " + currentSize); + } + + public void triggerItemSetChange() { + log("*** triggerItemSetChange(): scheduling item set change event"); + final VaadinSession session = VaadinSession.getCurrent(); + new Thread() { + @Override + public void run() { + ExpandingContainer.this.invoke(session, new Runnable() { + @Override + public void run() { + log("*** Firing item set change event"); + ExpandingContainer.this.fireItemSetChange(); + } + }); + } + }.start(); + } + + private void invoke(VaadinSession session, Runnable action) { + session.lock(); + VaadinSession previousSession = VaadinSession.getCurrent(); + VaadinSession.setCurrent(session); + try { + action.run(); + } finally { + session.unlock(); + VaadinSession.setCurrent(previousSession); + } + } + + // Container + + @Override + public BeanItem getItem(Object itemId) { + if (!(itemId instanceof Integer)) { + return null; + } + final int index = ((Integer) itemId).intValue(); + return new BeanItem(new MyBean(index)); + } + + @Override + public Collection getItemIds() { + return new IntList(size()); + } + + @Override + public List getContainerPropertyIds() { + return PROPERTY_IDS; + } + + @Override + @SuppressWarnings("rawtypes") + public Property/* */getContainerProperty(Object itemId, + Object propertyId) { + BeanItem item = getItem(itemId); + return item != null ? item.getItemProperty(propertyId) : null; + } + + @Override + public Class getType(Object propertyId) { + return Component.class; + } + + @Override + public int size() { + return currentSize; + } + + @Override + public boolean containsId(Object itemId) { + if (!(itemId instanceof Integer)) { + return false; + } + int index = ((Integer) itemId).intValue(); + checkExpand(index); + return index >= 0 && index < currentSize; + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Item addItem(Object itemId) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Item addItem() { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public boolean removeItem(Object itemId) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public boolean addContainerProperty(Object propertyId, Class type, + Object defaultValue) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public boolean removeContainerProperty(Object propertyId) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public boolean removeAllItems() { + throw new UnsupportedOperationException(); + } + + // Container.Indexed + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Object addItemAt(int index) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Item addItemAt(int index, Object newItemId) { + throw new UnsupportedOperationException(); + } + + @Override + public Integer getIdByIndex(int index) { + if (index < 0) { + throw new IndexOutOfBoundsException("index < " + index); + } + final int size = currentSize; + if (index >= size) { + throw new IndexOutOfBoundsException("index=" + index + " but size=" + + size); + } + checkExpand(index); + return index; + } + + @Override + public List getItemIds(int startIndex, int numberOfItems) { + if (numberOfItems < 0) { + throw new IllegalArgumentException("numberOfItems < 0"); + } + final int size = currentSize; + checkExpand(startIndex); + if (startIndex < 0 || startIndex > size) { + throw new IndexOutOfBoundsException("startIndex=" + startIndex + + " but size=" + size); + } + if (startIndex + numberOfItems > size) { + numberOfItems = size - startIndex; + } + return new IntList(startIndex, numberOfItems); + } + + @Override + public int indexOfId(Object itemId) { + if (!(itemId instanceof Integer)) { + return -1; + } + final int index = ((Integer) itemId).intValue(); + checkExpand(index); + if (index < 0 || index >= currentSize) { + return -1; + } + return index; + } + + // Container.Ordered + + @Override + public Integer nextItemId(Object itemId) { + if (!(itemId instanceof Integer)) { + return null; + } + int index = ((Integer) itemId).intValue(); + checkExpand(index); + if (index < 0 || index + 1 >= currentSize) { + return null; + } + return index + 1; + } + + @Override + public Integer prevItemId(Object itemId) { + if (!(itemId instanceof Integer)) { + return null; + } + int index = ((Integer) itemId).intValue(); + checkExpand(index); + if (index - 1 < 0 || index >= currentSize) { + return null; + } + return index - 1; + } + + @Override + public Integer firstItemId() { + return currentSize == 0 ? null : 0; + } + + @Override + public Integer lastItemId() { + final int size = currentSize; + return size == 0 ? null : size - 1; + } + + @Override + public boolean isFirstId(Object itemId) { + if (!(itemId instanceof Integer)) { + return false; + } + final int index = ((Integer) itemId).intValue(); + checkExpand(index); + final int size = currentSize; + return size > 0 && index == 0; + } + + @Override + public boolean isLastId(Object itemId) { + if (!(itemId instanceof Integer)) { + return false; + } + int index = ((Integer) itemId).intValue(); + checkExpand(index); + int size = currentSize; + return size > 0 && index == size - 1; + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Item addItemAfter(Object previousItemId) { + throw new UnsupportedOperationException(); + } + + /** + * @throws UnsupportedOperationException + * always + */ + @Override + public Item addItemAfter(Object previousItemId, Object newItemId) { + throw new UnsupportedOperationException(); + } + + // Container.ItemSetChangeNotifier + + @Override + @SuppressWarnings("deprecation") + public void addListener(Container.ItemSetChangeListener listener) { + super.addListener(listener); + } + + @Override + public void addItemSetChangeListener( + Container.ItemSetChangeListener listener) { + super.addItemSetChangeListener(listener); + } + + @Override + @SuppressWarnings("deprecation") + public void removeListener(Container.ItemSetChangeListener listener) { + super.removeListener(listener); + } + + @Override + public void removeItemSetChangeListener( + Container.ItemSetChangeListener listener) { + super.removeItemSetChangeListener(listener); + } + + // IntList + + private static class IntList extends AbstractList { + + private final int min; + private final int size; + + public IntList(int size) { + this(0, size); + } + + public IntList(int min, int size) { + if (size < 0) { + throw new IllegalArgumentException("size < 0"); + } + this.min = min; + this.size = size; + } + + @Override + public int size() { + return size; + } + + @Override + public Integer get(int index) { + if (index < 0 || index >= size) { + throw new IndexOutOfBoundsException(); + } + return min + index; + } + } + + // MyBean + public class MyBean { + + private final int index; + + public MyBean(int index) { + this.index = index; + } + + public String getId() { + return "ROW #" + index; + } + + public String getColumn1() { + return genText(); + } + + public String getColumn2() { + return genText(); + } + + private String genText() { + return "this is a line of text in row #" + index; + } + } + + public void logDetails(boolean enabled) { + loggingEnabled = enabled; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceCondition.java b/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceCondition.java new file mode 100644 index 0000000000..8ad2d7f9c7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceCondition.java @@ -0,0 +1,67 @@ +package com.vaadin.tests.components.table; + +import java.util.Map; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; + +@SuppressWarnings("serial") +public class ExpandingContainerVisibleRowRaceCondition extends UI { + + static final String TABLE = "table"; + + @Override + public void init(VaadinRequest request) { + final VerticalLayout rootLayout = new VerticalLayout(); + + rootLayout.setSpacing(true); + rootLayout.setSizeFull(); + rootLayout.setMargin(true); + + final Label sizeLabel = new Label(); + final ExpandingContainer container = new ExpandingContainer(sizeLabel); + container.logDetails(false); + + Table table = new Table(null, container) { + @Override + public void changeVariables(Object source, + Map variables) { + if (variables.containsKey("firstvisible")) { + int index = (Integer) variables.get("firstvisible"); + container.checkExpand(index); + } + if (variables.containsKey("reqfirstrow") + || variables.containsKey("reqrows")) { + try { + int index = ((Integer) variables + .get("lastToBeRendered")).intValue(); + container.checkExpand(index); + } catch (Exception e) { + // do nothing + } + } + super.changeVariables(source, variables); + } + }; + table.setId(TABLE); + table.setCacheRate(0); + table.setSizeFull(); + table.setVisibleColumns(ExpandingContainer.PROPERTY_IDS + .toArray(new String[ExpandingContainer.PROPERTY_IDS.size()])); + + table.setCurrentPageFirstItemIndex(120); + + rootLayout.addComponent(table); + rootLayout.setExpandRatio(table, 1); + + rootLayout.addComponent(sizeLabel); + + setContent(rootLayout); + + container.checkExpand(300); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java b/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java new file mode 100644 index 0000000000..73dd7b1f81 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ExpandingContainerVisibleRowRaceConditionTest.java @@ -0,0 +1,90 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.table; + +import static com.vaadin.tests.components.table.ExpandingContainerVisibleRowRaceCondition.TABLE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ExpandingContainerVisibleRowRaceConditionTest extends + MultiBrowserTest { + + private static final int ROW_HEIGHT = 20; + + @Test + public void testScrollingWorksWithoutJumpingWhenItemSetChangeOccurs() { + openTestURL(); + sleep(1000); + + WebElement table = vaadinElementById(TABLE); + assertFirstRowIdIs("ROW #120"); + + testBenchElement(table.findElement(By.className("v-scrollable"))) + .scroll(320 * ROW_HEIGHT); + sleep(1000); + + assertRowIdIsInThePage("ROW #330"); + assertScrollPositionIsNotVisible(); + } + + @Override + protected void sleep(int milliseconds) { + try { + super.sleep(milliseconds); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + private void assertFirstRowIdIs(String expected) { + List cellsOfFirstColumn = getCellsOfFirstColumn(); + WebElement first = cellsOfFirstColumn.get(0); + assertEquals(expected, first.getText()); + } + + private void assertRowIdIsInThePage(String expected) { + List cellsOfFirstColumn = getCellsOfFirstColumn(); + for (WebElement rowId : cellsOfFirstColumn) { + if (expected.equals(rowId.getText())) { + return; + } + } + fail("Expected row was not found"); + } + + private void assertScrollPositionIsNotVisible() { + WebElement table = vaadinElementById(TABLE); + WebElement scrollPosition = table.findElement(By + .className("v-table-scrollposition")); + assertFalse(scrollPosition.isDisplayed()); + } + + private List getCellsOfFirstColumn() { + WebElement table = vaadinElementById(TABLE); + List firstCellOfRows = table.findElements(By + .cssSelector(".v-table-table tr > td")); + return firstCellOfRows; + } +} -- cgit v1.2.3 From fbc48c6ab75479560919a463ba5693b44bb0e811 Mon Sep 17 00:00:00 2001 From: Felype Santiago Ferreira Date: Wed, 13 Nov 2013 13:58:06 +0200 Subject: Fix for scrolling with modal opened. (#12899) Change-Id: I9ba142a35ab887bb3a71c7311064ebab77bc01ba --- WebContent/VAADIN/themes/base/base.scss | 5 ++ client/src/com/vaadin/client/ui/VWindow.java | 7 +++ .../ScrollingBodyElementWithModalOpened.java | 58 ++++++++++++++++++++++ .../ScrollingBodyElementWithModalOpenedTest.java | 47 ++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpened.java create mode 100644 uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpenedTest.java diff --git a/WebContent/VAADIN/themes/base/base.scss b/WebContent/VAADIN/themes/base/base.scss index c6760e1907..aa1e778d6f 100644 --- a/WebContent/VAADIN/themes/base/base.scss +++ b/WebContent/VAADIN/themes/base/base.scss @@ -53,6 +53,11 @@ margin: 0; overflow: hidden; } + +.v-modal-window-open { + overflow: hidden; +} + $font-size: 16px; $line-height: normal; @mixin base { diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index e27ad383a9..ad9d0eac7e 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -22,6 +22,7 @@ import java.util.Comparator; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Position; import com.google.gwt.dom.client.Style.Unit; @@ -67,6 +68,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, public static final String CLASSNAME = "v-window"; + private static final String MODAL_WINDOW_OPEN_CLASSNAME = "v-modal-window-open"; + private static final int STACKING_OFFSET_PIXELS = 15; public static final int Z_INDEX = 10000; @@ -528,10 +531,14 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, getOverlayContainer().appendChild(getModalityCurtain()); } + Document.get().getBody().addClassName(MODAL_WINDOW_OPEN_CLASSNAME); } private void hideModalityCurtain() { + Document.get().getBody().removeClassName(MODAL_WINDOW_OPEN_CLASSNAME); + modalityCurtain.removeFromParent(); + if (BrowserInfo.get().isIE()) { // IE leaks memory in certain cases unless we release the reference // (#9197) diff --git a/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpened.java b/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpened.java new file mode 100644 index 0000000000..2f1c0ff685 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpened.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +/** + * + * @since 7.1.9 + * @author Vaadin Ltd + */ +public class ScrollingBodyElementWithModalOpened extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout verticalLayout = new VerticalLayout(); + verticalLayout.setHeight("10000px"); + + Window window = new Window("Caption"); + + VerticalLayout layout = new VerticalLayout(); + layout.setWidth("300px"); + layout.setHeight("300px"); + window.setContent(layout); + + addWindow(window); + + window.setModal(true); + + addComponent(verticalLayout); + } + + @Override + protected String getTestDescription() { + return "Screen must not scroll with modal opened."; + } + + @Override + protected Integer getTicketNumber() { + return 12899; + } +} diff --git a/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpenedTest.java b/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpenedTest.java new file mode 100644 index 0000000000..b6474519b0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/ScrollingBodyElementWithModalOpenedTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.window; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class ScrollingBodyElementWithModalOpenedTest extends MultiBrowserTest { + + @Test + public void testWindowScrollbars() throws Exception { + openTestURL(); + + WebElement bodyElement = driver.findElement(By + .className("v-modal-window-open")); + + TestBenchElementCommands scrollable = testBenchElement(bodyElement); + scrollable.scroll(1000); + + Thread.sleep(1000); + + compareScreen(getScreenshotBaseName()); + } + +} -- cgit v1.2.3 From c5515074b54f37c21d021ab910d2749a9a1bc24d Mon Sep 17 00:00:00 2001 From: Tomi Virtanen Date: Wed, 27 Nov 2013 15:10:41 +0200 Subject: Selected option is updated when item caption changes in Select (#9250) Fixed ComboBoxConnector to update input-element text to match the changed item caption. Added SelectItemCaptionRefresh test case and TestBench2 (html) test for it. Change-Id: I45b2168aab27f83203a59500715ac9aca5357412 --- .../client/ui/combobox/ComboBoxConnector.java | 35 +++++----- .../select/SelectItemCaptionRefresh.html | 47 ++++++++++++++ .../select/SelectItemCaptionRefresh.java | 75 ++++++++++++++++++++++ 3 files changed, 138 insertions(+), 19 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.html create mode 100644 uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index f91ff9e2b9..24597d1d8c 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -212,26 +212,23 @@ public class ComboBoxConnector extends AbstractFieldConnector implements // some item selected for (FilterSelectSuggestion suggestion : getWidget().currentSuggestions) { String suggestionKey = suggestion.getOptionKey(); - if (suggestionKey.equals(selectedKey)) { - if (!getWidget().waitingForFilteringResponse - || getWidget().popupOpenerClicked) { - if (!suggestionKey.equals(getWidget().selectedOptionKey) - || suggestion.getReplacementString().equals( - getWidget().tb.getText())) { - // Update text field if we've got a new - // selection - // Also update if we've got the same text to - // retain old text selection behavior - getWidget().setPromptingOff( - suggestion.getReplacementString()); - getWidget().selectedOptionKey = suggestionKey; - } - } - getWidget().currentSuggestion = suggestion; - getWidget().setSelectedItemIcon(suggestion.getIconUri()); - // only a single item can be selected - break; + if (!suggestionKey.equals(selectedKey)) { + continue; + } + if (!getWidget().waitingForFilteringResponse + || getWidget().popupOpenerClicked) { + // Update text field if we've got a new + // selection + // Also update if we've got the same text to + // retain old text selection behavior + // OR if selected item caption is changed. + getWidget().setPromptingOff(suggestion.getReplacementString()); + getWidget().selectedOptionKey = suggestionKey; } + getWidget().currentSuggestion = suggestion; + getWidget().setSelectedItemIcon(suggestion.getIconUri()); + // only a single item can be selected + break; } } diff --git a/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.html b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.html new file mode 100644 index 0000000000..2f8532de61 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.html @@ -0,0 +1,47 @@ + + + + + + +SelectItemCaptionRefresh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SelectItemCaptionRefresh
open/run/com.vaadin.tests.components.select.SelectItemCaptionRefresh?restartApplication
mouseClickvaadin=runcomvaadintestscomponentsselectSelectItemCaptionRefresh::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VFilterSelect[0]#button10,14
mouseClick//div[@id='VAADIN_COMBOBOX_OPTIONLIST']/div/div[2]/table/tbody/tr[2]/td/span16,11
verifyValuevaadin=runcomvaadintestscomponentsselectSelectItemCaptionRefresh::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VFilterSelect[0]#textboxstart
clickvaadin=runcomvaadintestscomponentsselectSelectItemCaptionRefresh::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]
verifyValuevaadin=runcomvaadintestscomponentsselectSelectItemCaptionRefresh::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VFilterSelect[0]#textbox0
+ + diff --git a/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java new file mode 100644 index 0000000000..1a1a8fa642 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.select; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Select; + +public class SelectItemCaptionRefresh extends AbstractTestUI { + + final Object itemId = new Object(); + Select select; + + Button.ClickListener clickListener = new Button.ClickListener() { + Integer i = Integer.valueOf(0); + + @Override + public void buttonClick(final ClickEvent event) { + select.setItemCaption(itemId, (i++).toString()); + } + }; + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + select = new Select("Foo"); + + select.addItem(itemId); + select.setItemCaption(itemId, "start"); + + addComponent(select); + addComponent(new Button("click", clickListener)); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Selected option not updated when item caption changes in Select"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 9250; + } + +} -- cgit v1.2.3 From 3595685b81779e7c10fc3f2d9fe9b1e35d4f39d2 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 9 Jan 2014 10:34:26 +0200 Subject: Converted TestUIWidgetset test to TB3 and fixed wrong text in assertion. Change-Id: Ie1d5374280381f9ff81415ce9d9d82773718800c --- .../ui/ComponentIncludedInCustomWidgetset.java | 28 +++++++++++++++ .../ui/ComponentIncludedInCustomWidgetsetTest.java | 41 +++++++++++++++++++++ .../ui/ComponentMissingFromDefaultWidgetset.java | 26 ++++++++++++++ .../ComponentMissingFromDefaultWidgetsetTest.java | 42 ++++++++++++++++++++++ .../tests/components/ui/TestUIWidgetset.html | 36 ------------------- .../tests/components/ui/TestUIWidgetset.java | 26 -------------- .../tests/components/ui/TestUIWidgetset2.java | 24 ------------- 7 files changed, 137 insertions(+), 86 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetset.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetsetTest.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetset.java create mode 100644 uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetsetTest.java delete mode 100644 uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.html delete mode 100644 uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.java delete mode 100644 uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset2.java diff --git a/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetset.java b/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetset.java new file mode 100644 index 0000000000..f674567a2d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetset.java @@ -0,0 +1,28 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; + +@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") +public class ComponentIncludedInCustomWidgetset extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + MissingFromDefaultWidgetsetComponent component = new MissingFromDefaultWidgetsetComponent(); + component.setId("missing-component"); + addComponent(component); + } + + @Override + public String getTestDescription() { + return "This contents if this UI should work as the component is present in TestingWidgetSet"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7885); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetsetTest.java b/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetsetTest.java new file mode 100644 index 0000000000..f27ef5d789 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ComponentIncludedInCustomWidgetsetTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests if a component is included in a custom widgetset + * (com.vaadin.tests.widgetset.TestingWidgetSet) + * + * @author Vaadin Ltd + */ +public class ComponentIncludedInCustomWidgetsetTest extends MultiBrowserTest { + + @Test + public void testComponentInTestingWidgetsetNotInDefaultWidgetset() { + openTestURL(); + WebElement component = vaadinElementById("missing-component"); + assertEquals( + "This component is available in TestingWidgetset, but not in DefaultWidgetset", + component.getText()); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetset.java b/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetset.java new file mode 100644 index 0000000000..554a461c37 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetset.java @@ -0,0 +1,26 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; + +public class ComponentMissingFromDefaultWidgetset extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + MissingFromDefaultWidgetsetComponent component = new MissingFromDefaultWidgetsetComponent(); + component.setId("missing-component"); + addComponent(component); + } + + @Override + public String getTestDescription() { + return "This contents if this UI should not work as the component is not present in DefaultWidgetSet"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7885); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetsetTest.java b/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetsetTest.java new file mode 100644 index 0000000000..ec8add75e0 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/ComponentMissingFromDefaultWidgetsetTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.ui; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for testing if a component is missing from a widgetset. + * + * @author Vaadin Ltd + */ +public class ComponentMissingFromDefaultWidgetsetTest extends MultiBrowserTest { + + @Test + public void testComponentInTestingWidgetset() { + openTestURL(); + WebElement component = vaadinElementById("missing-component"); + assertTrue(component + .getText() + .startsWith( + "Widgetset 'com.vaadin.DefaultWidgetSet' does not contain implementation for com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent.")); + + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.html b/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.html deleted file mode 100644 index 4c10dc4275..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - -Ticket4607 - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ticket4607
open/run/com.vaadin.tests.components.ui.TestUIWidgetset?restartApplication
assertTextvaadin=runcomvaadintestscomponentsuiTestUIWidgetset::/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]This component is available in TestingWidgetset, but not in DefaultWidgetset
open/run/com.vaadin.tests.components.ui.TestUIWidgetset2?restartApplication
assertTextvaadin=runcomvaadintestscomponentsuiTestUIWidgetset2::/VVerticalLayout[0]/VVerticalLayout[0]/VUnknownComponent[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Widgetset does not contain implementation for com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.
- - diff --git a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.java b/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.java deleted file mode 100644 index e837321b56..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.vaadin.tests.components.ui; - -import com.vaadin.annotations.Widgetset; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; - -@Widgetset("com.vaadin.tests.widgetset.TestingWidgetSet") -public class TestUIWidgetset extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - addComponent(new MissingFromDefaultWidgetsetComponent()); - } - - @Override - public String getTestDescription() { - return "This contents if this UI should work as the component is present in TestingWidgetSet"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7885); - } - -} diff --git a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset2.java b/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset2.java deleted file mode 100644 index a68cd91a5e..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TestUIWidgetset2.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.vaadin.tests.components.ui; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUI; -import com.vaadin.tests.widgetset.server.MissingFromDefaultWidgetsetComponent; - -public class TestUIWidgetset2 extends AbstractTestUI { - - @Override - protected void setup(VaadinRequest request) { - addComponent(new MissingFromDefaultWidgetsetComponent()); - } - - @Override - public String getTestDescription() { - return "This contents if this UI should not work as the component is not present in DefaultWidgetSet"; - } - - @Override - protected Integer getTicketNumber() { - return Integer.valueOf(7885); - } - -} -- cgit v1.2.3 From d4695494591bccb7b1dd4358133f8b5e854c3cbb Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 13 Jan 2014 13:49:43 +0200 Subject: Ensure DevelopmentLauncher uses servlet 3.0 API (#13053) Rendering of JSP pages does not work if servlet 2.5 API comes before servlet 3.0 API on the classpath Change-Id: I6f6bbdb22142848b424c991a15b058ea66ec4eac --- eclipse/Development Server (vaadin).launch | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eclipse/Development Server (vaadin).launch b/eclipse/Development Server (vaadin).launch index 8f57c441ec..87cee59f29 100644 --- a/eclipse/Development Server (vaadin).launch +++ b/eclipse/Development Server (vaadin).launch @@ -6,6 +6,13 @@ + + + + + + + -- cgit v1.2.3 From 0e7ac388039cf8140f37df9d83cf62b9efc95bb8 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 13 Jan 2014 13:50:34 +0200 Subject: Method for retrieving all VaadinSessions inside a HTTP session (#13053) Change-Id: I8e612ccd521d99f6b7ec6d10c72331b4d4373abe --- WebContent/statictestfiles/vaadinsessions.jsp | 54 +++++++++++ server/src/com/vaadin/server/VaadinSession.java | 29 ++++++ .../tests/integration/JSPIntegrationTest.java | 100 +++++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 WebContent/statictestfiles/vaadinsessions.jsp create mode 100644 uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java diff --git a/WebContent/statictestfiles/vaadinsessions.jsp b/WebContent/statictestfiles/vaadinsessions.jsp new file mode 100644 index 0000000000..b22787a203 --- /dev/null +++ b/WebContent/statictestfiles/vaadinsessions.jsp @@ -0,0 +1,54 @@ + +<%@page import="com.vaadin.ui.UI"%> +<%@page import="com.vaadin.server.VaadinSession"%> + + +JSP integration + + + + + + + + + + + + + + + <% + HttpSession httpSession = request.getSession(false); + for (VaadinSession vs : VaadinSession.getAllSessions(httpSession)) { + try { + vs.lock(); + for (UI ui : vs.getUIs()) { + out.append(""); + out.append(""); + out.append(""); + out.append(""); + out.append(""); + out.append(""); + out.append(""); + + } + } finally { + vs.unlock(); + } + + } + %> +
Available UIs:
Service NameCSRF tokenUI idUI typeMain content
" + vs.getService().getServiceName() + + "" + vs.getCsrfToken() + "" + ui.getUIId() + "" + ui.getClass().getName() + "" + ui.getContent().getClass().getName() + "
+ + \ No newline at end of file diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index f34721944a..265d18b859 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -22,12 +22,15 @@ import java.io.Serializable; import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Queue; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; @@ -422,6 +425,32 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { return vaadinSession; } + /** + * Retrieves all {@link VaadinSession}s which are stored in the given HTTP + * session + * + * @since 7.2 + * @param httpSession + * the HTTP session + * @return the found VaadinSessions + */ + public static Collection getAllSessions( + HttpSession httpSession) { + Set sessions = new HashSet(); + Enumeration attributeNames = httpSession.getAttributeNames(); + + while (attributeNames.hasMoreElements()) { + String attributeName = attributeNames.nextElement(); + if (attributeName.startsWith(VaadinSession.class.getName() + ".")) { + Object value = httpSession.getAttribute(attributeName); + if (value instanceof VaadinSession) { + sessions.add((VaadinSession) value); + } + } + } + return sessions; + } + /** * Removes this VaadinSession from the HTTP session. * diff --git a/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java b/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java new file mode 100644 index 0000000000..c5d6a65d87 --- /dev/null +++ b/uitest/src/com/vaadin/tests/integration/JSPIntegrationTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.integration; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +public class JSPIntegrationTest extends PrivateTB3Configuration { + + final String appRunnerTestUrl = getBaseURL() + "/run/Buttons"; + final String jspUrl = getBaseURL() + "/statictestfiles/vaadinsessions.jsp"; + final String integrationUrl = getBaseURL() + "/integration"; + + @Test + public void listVaadinSessions() { + + assertUICount(0); + + // Open a new UI + getDriver().get(integrationUrl); + assertUICount(1); + + // Open a new UI + getDriver().get(integrationUrl); + + // Should now have two UIs for the same service with different uiIds + List twoUIs = getUIs(); + assertEquals(2, twoUIs.size()); + assertNotEquals(twoUIs.get(0).uiId, twoUIs.get(1).uiId); + assertEquals(twoUIs.get(0).serviceName, twoUIs.get(1).serviceName); + + getDriver().get(appRunnerTestUrl); + // Should now have two services with 2 + 1 UIs + List threeUIs = getUIs(); + assertEquals(3, threeUIs.size()); + Set serviceNames = new HashSet(); + Set uiIds = new HashSet(); + for (UIData uiData : threeUIs) { + serviceNames.add(uiData.serviceName); + uiIds.add(uiData.uiId); + } + assertGreaterOrEqual( + "There should be at least two unique service names", + serviceNames.size(), 2); + assertGreaterOrEqual("There should be at least two unique ui ids", + uiIds.size(), 2); + } + + private static class UIData { + private String serviceName; + private int uiId; + } + + private List getUIs() { + List uis = new ArrayList(); + + getDriver().get(jspUrl); + List rows = getDriver().findElements( + By.xpath("//tr[@class='uirow']")); + for (WebElement row : rows) { + UIData data = new UIData(); + List tds = row.findElements(By.xpath("./td")); + + data.serviceName = tds.get(0).getText(); + data.uiId = Integer.parseInt(tds.get(2).getText()); + + uis.add(data); + } + + return uis; + } + + private void assertUICount(int i) { + assertEquals(i, getUIs().size()); + } +} -- cgit v1.2.3 From dd92ba5301f9db0b4139adcab6f667b26cd89b6d Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Fri, 10 Jan 2014 18:16:58 +0200 Subject: Upgrade to atmosphere-runtime 2.0.3.vaadin1 (#12601) Change-Id: Ic2e9543266b449e29fb8e52715559d3fbf249d93 --- push/build.xml | 2 +- push/ivy.xml | 2 +- server/src/com/vaadin/server/Constants.java | 2 +- .../server/communication/AtmospherePushConnection.java | 2 +- .../com/vaadin/server/communication/PushHandler.java | 18 ------------------ 5 files changed, 4 insertions(+), 22 deletions(-) diff --git a/push/build.xml b/push/build.xml index abeec2a8b0..0db99e815c 100644 --- a/push/build.xml +++ b/push/build.xml @@ -16,7 +16,7 @@ - + diff --git a/push/ivy.xml b/push/ivy.xml index 2be47512fe..fd9284b782 100644 --- a/push/ivy.xml +++ b/push/ivy.xml @@ -1,7 +1,7 @@ - + ]> diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java index b0841da314..a39c39fa72 100644 --- a/server/src/com/vaadin/server/Constants.java +++ b/server/src/com/vaadin/server/Constants.java @@ -67,7 +67,7 @@ public interface Constants { // Keep the version number in sync with push/build.xml and other locations // listed in that file - static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "1.0.18.vaadin1"; + static final String REQUIRED_ATMOSPHERE_RUNTIME_VERSION = "2.0.3.vaadin1"; static final String INVALID_ATMOSPHERE_VERSION_WARNING = "\n" + "=================================================================\n" diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index b9d4955b12..6a515abc29 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -94,7 +94,7 @@ public class AtmospherePushConnection implements PushConnection { private UI ui; private AtmosphereResource resource; - private Future outgoingMessage; + private Future outgoingMessage; private FragmentedMessage incomingMessage; public AtmospherePushConnection(UI ui, AtmosphereResource resource) { diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index 09428e47a9..eaa0de6027 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -19,7 +19,6 @@ package com.vaadin.server.communication; import java.io.IOException; import java.io.Reader; import java.io.Writer; -import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,7 +42,6 @@ import com.vaadin.server.VaadinService; import com.vaadin.server.VaadinServletRequest; import com.vaadin.server.VaadinServletService; import com.vaadin.server.VaadinSession; -import com.vaadin.server.WebBrowser; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.PushMode; import com.vaadin.ui.UI; @@ -84,14 +82,6 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter VaadinSession session = ui.getSession(); if (resource.transport() == TRANSPORT.STREAMING) { - // IE8 requires a longer padding to work properly if the - // initial message is small (#11573). Chrome does not work - // without the original padding... - WebBrowser browser = session.getBrowser(); - if (browser.isIE() && browser.getBrowserMajorVersion() == 8) { - resource.padding(LONG_PADDING); - } - // Must ensure that the streaming response contains // "Connection: close", otherwise iOS 6 will wait for the // response to this request before sending another request to @@ -214,14 +204,6 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter } }; - private static final String LONG_PADDING; - - static { - char[] array = new char[4096]; - Arrays.fill(array, '-'); - LONG_PADDING = String.copyValueOf(array); - - } private VaadinServletService service; public PushHandler(VaadinServletService service) { -- cgit v1.2.3 From 89d860c6b0c8ab02d5c8f3e3f5405a832a43cdb7 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 14 Jan 2014 09:39:34 +0200 Subject: Convinience methods for getting mouse and keyboard in test. Change-Id: Ic54887c252ba452bb841f7ae2da362235d4f924b --- .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index f6fce18fae..7a214bd60c 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -31,6 +31,9 @@ import org.openqa.selenium.By; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Keyboard; +import org.openqa.selenium.interactions.Mouse; import org.openqa.selenium.remote.BrowserType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; @@ -891,4 +894,22 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } + /** + * Returns the mouse object for doing mouse commands + * + * @return Returns the mouse + */ + public Mouse getMouse() { + return ((HasInputDevices) getDriver()).getMouse(); + } + + /** + * Returns the keyboard object for controlling keyboard events + * + * @return Return the keyboard + */ + public Keyboard getKeyboard() { + return ((HasInputDevices) getDriver()).getKeyboard(); + } + } -- cgit v1.2.3 From 034197d5a98cbf59153c824ed6f93d495c523854 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Mon, 13 Jan 2014 13:11:45 +0200 Subject: clone() method is removed from LexicalUnitImpl (#13182 ). Change-Id: I8e32c3ab8b79e31b7fae309a3f475f6fe520bfcc --- .../src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java index cfd428e094..e03cea8cfe 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java @@ -731,13 +731,6 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit, previous); } - @Override - public LexicalUnitImpl clone() { - LexicalUnitImpl cloned = new LexicalUnitImpl(type, line, column, prev); - cloned.replaceValue(this); - return cloned; - } - /** * Tries to return the value for this {@link LexicalUnitImpl} without * considering any related units. -- cgit v1.2.3 From d00397f548cc9f4ddbcb7ce68fcf74ddd28d3769 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 9 Jan 2014 11:04:59 +0200 Subject: Converted TB2 test to TB3 and fixed text assertion. Change-Id: I19bdbf1cf64853abc3bc7e72a86cd80599bfa652 --- .../components/UnknownComponentConnector.java | 47 ++++++++++++++++++++++ .../components/UnknownComponentConnectorTest.html | 27 ------------- .../components/UnknownComponentConnectorTest.java | 42 +++++++++---------- 3 files changed, 66 insertions(+), 50 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/UnknownComponentConnector.java delete mode 100644 uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.html diff --git a/uitest/src/com/vaadin/tests/components/UnknownComponentConnector.java b/uitest/src/com/vaadin/tests/components/UnknownComponentConnector.java new file mode 100644 index 0000000000..b6358b6c56 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/UnknownComponentConnector.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.tests.components; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractComponent; + +public class UnknownComponentConnector extends AbstractTestUI { + + public static class ComponentWithoutConnector extends AbstractComponent { + + } + + @Override + protected void setup(VaadinRequest request) { + ComponentWithoutConnector component = new ComponentWithoutConnector(); + component.setId("no-connector-component"); + addComponent(component); + } + + @Override + protected String getTestDescription() { + // TODO Auto-generated method stub + return null; + } + + @Override + protected Integer getTicketNumber() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.html b/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.html deleted file mode 100644 index 20f0e8e71e..0000000000 --- a/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.UnknownComponentConnectorTest?restartApplication
assertTextvaadin=runcomvaadintestscomponentsUnknownComponentConnectorTest::/VVerticalLayout[0]/VVerticalLayout[0]/VUnknownComponent[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]Widgetset does not contain implementation for com.vaadin.tests.components.UnknownComponentConnectorTest.ComponentWithoutConnector. Check its component connector's @Connect mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions.
- - diff --git a/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.java b/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.java index ff113d631e..49a3c29e2d 100644 --- a/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.java +++ b/uitest/src/com/vaadin/tests/components/UnknownComponentConnectorTest.java @@ -13,33 +13,29 @@ * License for the specific language governing permissions and limitations under * the License. */ - package com.vaadin.tests.components; -import com.vaadin.server.VaadinRequest; -import com.vaadin.ui.AbstractComponent; - -public class UnknownComponentConnectorTest extends AbstractTestUI { +import static org.junit.Assert.assertTrue; - public static class ComponentWithoutConnector extends AbstractComponent { +import org.junit.Test; +import org.openqa.selenium.WebElement; - } - - @Override - protected void setup(VaadinRequest request) { - addComponent(new ComponentWithoutConnector()); - } +import com.vaadin.tests.tb3.MultiBrowserTest; - @Override - protected String getTestDescription() { - // TODO Auto-generated method stub - return null; - } - - @Override - protected Integer getTicketNumber() { - // TODO Auto-generated method stub - return null; +/** + * Tests that a user is notified about a missing component from the widgetset + */ +public class UnknownComponentConnectorTest extends MultiBrowserTest { + + @Test + public void testConnectorNotFoundInWidgetset() throws Exception { + openTestURL(); + WebElement component = vaadinElementById("no-connector-component"); + assertTrue(component + .getText() + .startsWith( + "Widgetset 'com.vaadin.DefaultWidgetSet' does not contain " + + "implementation for com.vaadin.tests.components.UnknownComponentConnector." + + "ComponentWithoutConnector.")); } - } -- cgit v1.2.3 From 857de0f2f3964f4459b665d1928641c1689ccd37 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 14 Jan 2014 14:17:33 +0200 Subject: Renamed test according to conventions and fixed assertion text. Change-Id: I7ede421f7e0c5ae726167b4ee7b2d8651a70c77c --- .../applicationservlet/NoApplicationClass.java | 49 ---------------------- .../applicationservlet/NoApplicationClassTest.java | 49 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java create mode 100644 uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java deleted file mode 100644 index c2222c4608..0000000000 --- a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClass.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.applicationservlet; - -import java.util.Collections; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.remote.DesiredCapabilities; - -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class NoApplicationClass extends MultiBrowserTest { - - @Test - public void testInvalidApplicationClass() { - openTestURL(); - String exceptionMessage = getDriver().findElement(By.xpath("//pre[2]")) - .getText(); - Assert.assertTrue(exceptionMessage - .contains("ServletException: ClassThatIsNotPresent")); - } - - @Override - public List getBrowsersToTest() { - return Collections.singletonList(Browser.CHROME - .getDesiredCapabilities()); - } - - @Override - protected String getDeploymentPath() { - return "/run/ClassThatIsNotPresent"; - } -} diff --git a/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java new file mode 100644 index 0000000000..9d1b052182 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/NoApplicationClassTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.applicationservlet; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class NoApplicationClassTest extends MultiBrowserTest { + + @Test + public void testInvalidApplicationClass() { + openTestURL(); + String exceptionMessage = getDriver().findElement(By.xpath("//pre[2]")) + .getText(); + Assert.assertTrue(exceptionMessage + .contains("ServletException: java.lang.ClassNotFoundException: ClassThatIsNotPresent")); + } + + @Override + public List getBrowsersToTest() { + return Collections.singletonList(Browser.CHROME + .getDesiredCapabilities()); + } + + @Override + protected String getDeploymentPath() { + return "/run/ClassThatIsNotPresent"; + } +} -- cgit v1.2.3 From d2874fde4b8c6afa24f0f6535e0d6fcabc489f51 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Mon, 13 Jan 2014 09:44:52 +0200 Subject: Theme Parser is deleted, build procedure now generates it (#13161). Change-Id: I6e0f797b9eadf9fe796750e2764faf4434494e29 --- .gitignore | 10 + build/ide.xml | 13 +- theme-compiler/build.xml | 22 +- .../com/vaadin/sass/internal/ScssStylesheet.java | 2 +- .../vaadin/sass/internal/parser/CharStream.java | 130 - .../sass/internal/parser/Generic_CharStream.java | 370 - .../sass/internal/parser/Generic_CharStream.jj | 370 + .../vaadin/sass/internal/parser/LocatorImpl.java | 60 +- .../sass/internal/parser/ParseException.java | 174 +- .../vaadin/sass/internal/parser/ParseException.jj | 203 + .../com/vaadin/sass/internal/parser/Parser.java | 8605 +------------------- .../src/com/vaadin/sass/internal/parser/Parser.jj | 3028 ------- .../sass/internal/parser/ParserConstants.java | 392 - .../com/vaadin/sass/internal/parser/ParserImpl.jj | 3028 +++++++ .../sass/internal/parser/ParserTokenManager.java | 4997 ------------ .../src/com/vaadin/sass/internal/parser/Token.java | 146 - .../vaadin/sass/internal/parser/TokenMgrError.java | 162 - .../src/com/vaadin/sass/parser/ParserTest.java | 4 +- .../vaadin/sass/testcases/css/Interpolation.java | 2 +- .../com/vaadin/sass/testcases/scss/Comments.java | 2 +- .../vaadin/sass/testcases/scss/CompassImports.java | 2 +- .../sass/testcases/scss/ControlDirectives.java | 2 +- .../com/vaadin/sass/testcases/scss/Extends.java | 2 +- .../com/vaadin/sass/testcases/scss/Functions.java | 2 +- .../com/vaadin/sass/testcases/scss/Imports.java | 2 +- .../src/com/vaadin/sass/testcases/scss/Mixins.java | 2 +- .../sass/testcases/scss/NestedProperties.java | 2 +- .../com/vaadin/sass/testcases/scss/Nesting.java | 2 +- .../vaadin/sass/testcases/scss/ParentImports.java | 2 +- .../vaadin/sass/testcases/scss/ParentSelector.java | 2 +- .../sass/testcases/scss/VariableGuarded.java | 2 +- .../com/vaadin/sass/testcases/scss/Variables.java | 2 +- 32 files changed, 3679 insertions(+), 18065 deletions(-) delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Token.java delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java diff --git a/.gitignore b/.gitignore index 30c8597b16..9b120c7c3a 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,13 @@ WebContent/VAADIN/vaadinPush.debug.js # build result folders */result result + +# /theme-compiler +/theme-compiler/result +/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.java +/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImplConstants.java +/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImplTokenManager.java +/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java diff --git a/build/ide.xml b/build/ide.xml index 22e6818bea..51a9d82272 100755 --- a/build/ide.xml +++ b/build/ide.xml @@ -36,7 +36,6 @@ - @@ -68,9 +67,14 @@ - + + + + + + - + @@ -142,4 +146,7 @@ + + + diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml index 03d0531a68..623d2e4ec7 100644 --- a/theme-compiler/build.xml +++ b/theme-compiler/build.xml @@ -23,7 +23,7 @@ - + @@ -32,15 +32,29 @@ - - - + + + + + + + + + + + + + + + + + diff --git a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java index ed6b98f5ac..35400f7d40 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java +++ b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java @@ -171,7 +171,7 @@ public class ScssStylesheet extends Node { source.setEncoding(parentStylesheet.getCharset()); } - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); parser.setErrorHandler(errorHandler); parser.setDocumentHandler(documentHandler); diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java deleted file mode 100644 index c22f19451b..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package com.vaadin.sass.internal.parser; - -/** - * This interface describes a character stream that maintains line and - * column number positions of the characters. It also has the capability - * to backup the stream to some extent. An implementation of this - * interface is used in the TokenManager implementation generated by - * JavaCCParser. - * - * All the methods except backup can be implemented in any fashion. backup - * needs to be implemented correctly for the correct operation of the lexer. - * Rest of the methods are all used to get information like line number, - * column number and the String that constitutes a token and are not used - * by the lexer. Hence their implementation won't affect the generated lexer's - * operation. - */ - -public -interface CharStream { - - /** - * Returns the next character from the selected input. The method - * of selecting the input is the responsibility of the class - * implementing this interface. Can throw any java.io.IOException. - */ - char readChar() throws java.io.IOException; - - @Deprecated - /** - * Returns the column position of the character last read. - * @deprecated - * @see #getEndColumn - */ - int getColumn(); - - @Deprecated - /** - * Returns the line number of the character last read. - * @deprecated - * @see #getEndLine - */ - int getLine(); - - /** - * Returns the column number of the last character for current token (being - * matched after the last call to BeginTOken). - */ - int getEndColumn(); - - /** - * Returns the line number of the last character for current token (being - * matched after the last call to BeginTOken). - */ - int getEndLine(); - - /** - * Returns the column number of the first character for current token (being - * matched after the last call to BeginTOken). - */ - int getBeginColumn(); - - /** - * Returns the line number of the first character for current token (being - * matched after the last call to BeginTOken). - */ - int getBeginLine(); - - /** - * Backs up the input stream by amount steps. Lexer calls this method if it - * had already read some characters, but could not use them to match a - * (longer) token. So, they will be used again as the prefix of the next - * token and it is the implemetation's responsibility to do this right. - */ - void backup(int amount); - - /** - * Returns the next character that marks the beginning of the next token. - * All characters must remain in the buffer between two successive calls - * to this method to implement backup correctly. - */ - char BeginToken() throws java.io.IOException; - - /** - * Returns a string made up of characters from the marked token beginning - * to the current buffer position. Implementations have the choice of returning - * anything that they want to. For example, for efficiency, one might decide - * to just return null, which is a valid implementation. - */ - String GetImage(); - - /** - * Returns an array of characters that make up the suffix of length 'len' for - * the currently matched token. This is used to build up the matched string - * for use in actions in the case of MORE. A simple and inefficient - * implementation of this is as follows : - * - * { - * String t = GetImage(); - * return t.substring(t.length() - len, t.length()).toCharArray(); - * } - */ - char[] GetSuffix(int len); - - /** - * The lexer calls this function to indicate that it is done with the stream - * and hence implementations can free any resources held by this class. - * Again, the body of this function can be just empty and it will not - * affect the lexer's operation. - */ - void Done(); - -} -/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java deleted file mode 100644 index 7bc2973311..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. Generic_CharStream.java Version 0.7pre6 */ -package com.vaadin.sass.internal.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public final class Generic_CharStream implements CharStream -{ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; - public int bufpos = -1; - private int bufline[]; - private int bufcolumn[]; - - private int column = 0; - private int line = 1; - - private boolean prevCharIsCR = false; - private boolean prevCharIsLF = false; - - private java.io.Reader reader; - - private char[] buffer; - private int maxNextCharInd = 0; - private int inBuf = 0; - - private final void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - private final void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = reader.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) - { - reader.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - - public final char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - private final void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (8 - (column & 07)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public final char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]); - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = (char)((char)0xff & buffer[bufpos]); - - UpdateLineColumn(c); - return (c); - } - - /** - * @deprecated - * @see #getEndColumn - */ - - public final int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - - public final int getLine() { - return bufline[bufpos]; - } - - public final int getEndColumn() { - return bufcolumn[bufpos]; - } - - public final int getEndLine() { - return bufline[bufpos]; - } - - public final int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public final int getBeginLine() { - return bufline[tokenBegin]; - } - - public final void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public Generic_CharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - reader = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - public Generic_CharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - reader = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - public final String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public final char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - return ret; - } - - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token.
- */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj new file mode 100644 index 0000000000..7bc2973311 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj @@ -0,0 +1,370 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. Generic_CharStream.java Version 0.7pre6 */ +package com.vaadin.sass.internal.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public final class Generic_CharStream implements CharStream +{ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + private int bufline[]; + private int bufcolumn[]; + + private int column = 0; + private int line = 1; + + private boolean prevCharIsCR = false; + private boolean prevCharIsLF = false; + + private java.io.Reader reader; + + private char[] buffer; + private int maxNextCharInd = 0; + private int inBuf = 0; + + private final void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + private final void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = reader.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) + { + reader.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + + public final char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + private final void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (8 - (column & 07)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public final char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]); + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = (char)((char)0xff & buffer[bufpos]); + + UpdateLineColumn(c); + return (c); + } + + /** + * @deprecated + * @see #getEndColumn + */ + + public final int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @deprecated + * @see #getEndLine + */ + + public final int getLine() { + return bufline[bufpos]; + } + + public final int getEndColumn() { + return bufcolumn[bufpos]; + } + + public final int getEndLine() { + return bufline[bufpos]; + } + + public final int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public final int getBeginLine() { + return bufline[tokenBegin]; + } + + public final void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public Generic_CharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + reader = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + public Generic_CharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + reader = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + + public final String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public final char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + return ret; + } + + public void Done() + { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token.
+ */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java b/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java index ac244a9582..825b65fa24 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java @@ -51,82 +51,34 @@ public class LocatorImpl implements Locator { int line; int column; + @Override public String getURI() { return uri; } + @Override public int getLineNumber() { return line; } + @Override public int getColumnNumber() { return column; } /** - * Creates a new LocatorImpl - */ - public LocatorImpl(Parser p) { - if (W3CDebug) { - System.err.println("LocatorImpl::newLocator(" + p + ");"); - } - uri = p.source.getURI(); - line = p.token.beginLine; - column = p.token.beginColumn; - } - - /** - * Reinitializes a LocatorImpl - */ - public LocatorImpl(Parser p, Token tok) { - if (W3CDebug) { - System.err.println("LocatorImpl::newLocator(" + p + ", " + tok - + ");"); - } - uri = p.source.getURI(); - line = tok.beginLine; - column = tok.beginColumn; - } - - /** - * Reinitializes a LocatorImpl + * Creates a LocatorImpl */ public LocatorImpl(Parser p, int line, int column) { if (W3CDebug) { System.err.println("LocatorImpl::newLocator(" + p + ", " + line + ", " + column + ");"); } - uri = p.source.getURI(); + uri = p.getInputSource().getURI(); this.line = line; this.column = column; } - /** - * Reinitializes a LocatorImpl - */ - public LocatorImpl reInit(Parser p) { - if (W3CDebug) { - System.err.println("LocatorImpl::reInit(" + p + ");"); - } - uri = p.source.getURI(); - line = p.token.beginLine; - column = p.token.beginColumn; - return this; - } - - /** - * Reinitializes a LocatorImpl - */ - public LocatorImpl reInit(Parser p, Token tok) { - if (W3CDebug) { - System.err.println("LocatorImpl::reInit(" + p + ", " + tok + ");"); - } - uri = p.source.getURI(); - line = tok.beginLine; - column = tok.beginColumn; - return this; - } - /** * Reinitializes a LocatorImpl */ @@ -135,7 +87,7 @@ public class LocatorImpl implements Locator { System.err.println("LocatorImpl::reInit(" + p + ", " + line + ", " + column + ");"); } - uri = p.source.getURI(); + uri = p.getInputSource().getURI(); this.line = line; this.column = column; return this; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java index 392d71e767..d84decb771 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java @@ -19,185 +19,17 @@ package com.vaadin.sass.internal.parser; import org.w3c.css.sac.CSSException; /** - * This exception is thrown when parse errors are encountered. You can - * explicitly create objects of this exception type by calling the method - * generateParseException in the generated parser. - * - * You can modify this class to customize your error reporting mechanisms so - * long as you retain the public fields. + * Do not modify this file. It will be regenerated by the build procedure. Edit + * ParseException.jj file instead. The reason of this file presence here: avoid + * compilation errors if build procedure hasn't been yet executed. */ public class ParseException extends CSSException { - private static final long serialVersionUID = -8556588037264585977L; - - /** - * This constructor is used by the method "generateParseException" in the - * generated parser. Calling this constructor generates a new object of this - * type with the fields "currentToken", "expectedTokenSequences", and - * "tokenImage" set. The boolean flag "specialConstructor" is also set to - * true to indicate that this constructor was used to create this object. - * This constructor calls its super class with the empty string to force the - * "toString" method of parent class "Throwable" to print the error message - * in the form: ParseException: - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, String[] tokenImageVal) { - super(""); - specialConstructor = true; - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever purpose you - * can think of. Constructing the exception in this manner makes the - * exception behave in the normal way - i.e., as documented in the class - * "Throwable". The fields "errorToken", "expectedTokenSequences", and - * "tokenImage" do not contain relevant information. The JavaCC generated - * code does not use these constructors. - */ public ParseException() { super(); - specialConstructor = false; } public ParseException(String message) { super(message); - specialConstructor = false; - } - - /** - * This variable determines which constructor was used to create this object - * and thereby affects the semantics of the "getMessage" method (see below). - */ - protected boolean specialConstructor; - - /** - * This is the last token that has been consumed successfully. If this - * object has been created due to a parse error, the token followng this - * token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array of integers - * represents a sequence of tokens (by their ordinal values) that is - * expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated parser - * within which the parse error occurred. This array is defined in the - * generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * This method has the standard behavior when this object has been created - * using the standard constructors. Otherwise, it uses "currentToken" and - * "expectedTokenSequences" to generate a parse error message and returns - * it. If this object has been created due to a parse error, and you do not - * catch it (it gets thrown from the parser), then this method is called - * during the printing of the final stack trace, and hence the correct error - * message gets displayed. - */ - @Override - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - String expected = ""; - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected += tokenImage[expectedTokenSequences[i][j]] + " "; - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected += "..."; - } - expected += eol + " "; - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) { - retval += " "; - } - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += add_escapes(tok.image); - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " - + currentToken.next.beginColumn + "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected; - return retval; } - - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version when these raw - * version cannot be used as part of an ASCII string literal. - */ - protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" - + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj new file mode 100644 index 0000000000..392d71e767 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj @@ -0,0 +1,203 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */ +package com.vaadin.sass.internal.parser; + +import org.w3c.css.sac.CSSException; + +/** + * This exception is thrown when parse errors are encountered. You can + * explicitly create objects of this exception type by calling the method + * generateParseException in the generated parser. + * + * You can modify this class to customize your error reporting mechanisms so + * long as you retain the public fields. + */ +public class ParseException extends CSSException { + private static final long serialVersionUID = -8556588037264585977L; + + /** + * This constructor is used by the method "generateParseException" in the + * generated parser. Calling this constructor generates a new object of this + * type with the fields "currentToken", "expectedTokenSequences", and + * "tokenImage" set. The boolean flag "specialConstructor" is also set to + * true to indicate that this constructor was used to create this object. + * This constructor calls its super class with the empty string to force the + * "toString" method of parent class "Throwable" to print the error message + * in the form: ParseException: + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, String[] tokenImageVal) { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever purpose you + * can think of. Constructing the exception in this manner makes the + * exception behave in the normal way - i.e., as documented in the class + * "Throwable". The fields "errorToken", "expectedTokenSequences", and + * "tokenImage" do not contain relevant information. The JavaCC generated + * code does not use these constructors. + */ + + public ParseException() { + super(); + specialConstructor = false; + } + + public ParseException(String message) { + super(message); + specialConstructor = false; + } + + /** + * This variable determines which constructor was used to create this object + * and thereby affects the semantics of the "getMessage" method (see below). + */ + protected boolean specialConstructor; + + /** + * This is the last token that has been consumed successfully. If this + * object has been created due to a parse error, the token followng this + * token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array of integers + * represents a sequence of tokens (by their ordinal values) that is + * expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated parser + * within which the parse error occurred. This array is defined in the + * generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * This method has the standard behavior when this object has been created + * using the standard constructors. Otherwise, it uses "currentToken" and + * "expectedTokenSequences" to generate a parse error message and returns + * it. If this object has been created due to a parse error, and you do not + * catch it (it gets thrown from the parser), then this method is called + * during the printing of the final stack trace, and hence the correct error + * message gets displayed. + */ + @Override + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + String expected = ""; + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected += tokenImage[expectedTokenSequences[i][j]] + " "; + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected += "..."; + } + expected += eol + " "; + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) { + retval += " "; + } + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += add_escapes(tok.image); + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + + currentToken.next.beginColumn + "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected; + return retval; + } + + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version when these raw + * version cannot be used as part of an ASCII string literal. + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 53d1ee78ca..e66925ae2d 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -13,8611 +13,34 @@ * License for the specific language governing permissions and limitations under * the License. */ -/* Generated By:JavaCC: Do not edit this line. Parser.java */ package com.vaadin.sass.internal.parser; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.URL; -import java.util.ArrayList; -import java.util.Locale; -import java.util.UUID; - -import org.w3c.css.sac.CSSException; -import org.w3c.css.sac.CSSParseException; -import org.w3c.css.sac.ConditionFactory; -import org.w3c.css.sac.DocumentHandler; -import org.w3c.css.sac.ErrorHandler; import org.w3c.css.sac.InputSource; -import org.w3c.css.sac.LexicalUnit; -import org.w3c.css.sac.Locator; -import org.w3c.css.sac.SelectorFactory; -import org.w3c.css.sac.SelectorList; -import org.w3c.flute.parser.selectors.ConditionFactoryImpl; -import org.w3c.flute.parser.selectors.SelectorFactoryImpl; -import org.w3c.flute.util.Encoding; - -import com.vaadin.sass.internal.handler.SCSSDocumentHandlerImpl; -import com.vaadin.sass.internal.tree.Node; -import com.vaadin.sass.internal.tree.VariableNode; /** - * A CSS2 parser * - * @author Philippe Le H�garet - * @version $Revision: 1.15 $ + * @since + * @author Vaadin Ltd */ -public class Parser implements org.w3c.css.sac.Parser, ParserConstants { - - // replaces all \t, \n, etc with this StringBuffer. - static final StringBuilder SPACE = new StringBuilder(" "); - - // the document handler for the parser - protected SCSSDocumentHandlerImpl documentHandler; - // the error handler for the parser - protected ErrorHandler errorHandler; - // the input source for the parser - protected InputSource source; - - protected ConditionFactory conditionFactory; - protected SelectorFactory selectorFactory; - - // temporary place holder for pseudo-element ... - private String pseudoElt; - - /** - * Creates a new Parser - */ - public Parser() { - this((CharStream) null); - } - - /** - * @@TODO - * @exception CSSException - * Not yet implemented - */ - @Override - public void setLocale(Locale locale) throws CSSException { - throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); - } - - public InputSource getInputSource() { - return source; - } - - /** - * Set the document handler for this parser - */ - @Override - public void setDocumentHandler(DocumentHandler handler) { - documentHandler = (SCSSDocumentHandlerImpl) handler; - } - - @Override - public void setSelectorFactory(SelectorFactory selectorFactory) { - this.selectorFactory = selectorFactory; - } - - @Override - public void setConditionFactory(ConditionFactory conditionFactory) { - this.conditionFactory = conditionFactory; - } - - /** - * Set the error handler for this parser - */ - @Override - public void setErrorHandler(ErrorHandler error) { - errorHandler = error; - } - - /** - * Main parse methods - * - * @param source - * the source of the style sheet. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. - */ - @Override - public void parseStyleSheet(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - - parserUnit(); - } - - /** - * Convenient method for URIs. - * - * @param systemId - * the fully resolved URI of the style sheet. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. - */ - @Override - public void parseStyleSheet(String systemId) throws CSSException, - IOException { - parseStyleSheet(new InputSource(systemId)); - } - - /** - * This method parses only one rule (style rule or at-rule, except - * @charset). - * - * @param source - * the source of the rule. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. - */ - // TODO required by original parser but not used by Vaadin? - @Override - public void parseRule(InputSource source) throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseRule(); - } +public interface Parser extends org.w3c.css.sac.Parser { - /** - * This method parses a style declaration (including the surrounding curly - * braces). - * - * @param source - * the source of the style declaration. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. - */ - @Override - public void parseStyleDeclaration(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); + InputSource getInputSource(); - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseDeclarationBlock(); - } - - /** - * This methods returns "http://www.w3.org/TR/REC-CSS2". - * - * @return the string "http://www.w3.org/TR/REC-CSS2". - */ - @Override - public String getParserVersion() { - return "http://www.w3.org/TR/REC-CSS2"; - } - - /** - * Parse methods used by DOM Level 2 implementation. - */ - public void parseImportRule(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseImportRule(); - } - - public void parseMediaRule(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseMediaRule(); - } - - @Override - public SelectorList parseSelectors(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); + class ParserAccessor { - return null; - } - - @Override - public LexicalUnit parsePropertyValue(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return expr(); - } - - @Override - public boolean parsePriority(InputSource source) throws CSSException, - IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return prio(); - } - - /** - * Convert the source into a Reader. Used only by DOM Level 2 parser - * methods. - */ - private Reader getReader(InputSource source) throws IOException { - if (source.getCharacterStream() != null) { - return source.getCharacterStream(); - } else if (source.getByteStream() != null) { - // My DOM level 2 implementation doesn't use this case. - if (source.getEncoding() == null) { - // unknown encoding, use ASCII as default. - return new InputStreamReader(source.getByteStream(), "ASCII"); - } else { - return new InputStreamReader(source.getByteStream(), - source.getEncoding()); - } - } else { - // systemId - // @@TODO - throw new CSSException("not yet implemented"); - } - } - - /** - * Convert the source into a CharStream with encoding informations. The - * encoding can be found in the InputSource or in the CSS document. Since - * this method marks the reader and make a reset after looking for the - * charset declaration, you'll find the charset declaration into the stream. - */ - private CharStream getCharStreamWithLurk(InputSource source) - throws CSSException, IOException { - if (source.getCharacterStream() != null) { - // all encoding are supposed to be resolved by the user - // return the reader - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } else if (source.getByteStream() == null) { - // @@CONTINUE ME. see also getReader() with systemId + public static Parser getParser() { try { - source.setByteStream(new URL(source.getURI()).openStream()); + String implClassName = Parser.class.getPackage().getName() + + ".ParserImpl"; + Class clazz = Class.forName(implClassName); + return (Parser) clazz.newInstance(); } catch (Exception e) { - try { - source.setByteStream(new FileInputStream(source.getURI())); - } catch (IOException ex) { - throw new CSSException("invalid url ?"); - } - } - } - // use UTF-8 as the default encoding. - String encoding = source.getEncoding(); - InputStream input = source.getByteStream(); - if (!input.markSupported()) { - // If mark is not supported, wrap it in a stream which supports mark - input = new BufferedInputStream(input); - source.setByteStream(input); - } - // Mark either the original stream or the wrapped stream - input.mark(100); - if (encoding == null) { - encoding = "ASCII"; - - char c = ' '; - - c = (char) input.read(); - - if (c == '@') { - // hum, is it a charset ? - int size = 100; - byte[] buf = new byte[size]; - input.read(buf, 0, 7); - String keyword = new String(buf, 0, 7); - if (keyword.equals("charset")) { - // Yes, this is the charset declaration ! - - // here I don't use the right declaration : white space are - // ' '. - while ((c = (char) input.read()) == ' ') { - // find the first quote - } - char endChar = c; - int i = 0; - - if ((endChar != '"') && (endChar != '\u005c'')) { - // hum this is not a quote. - throw new CSSException("invalid charset declaration"); - } - - while ((c = (char) input.read()) != endChar) { - buf[i++] = (byte) c; - if (i == size) { - byte[] old = buf; - buf = new byte[size + 100]; - System.arraycopy(old, 0, buf, 0, size); - size += 100; - } - } - while ((c = (char) input.read()) == ' ') { - // find the next relevant character - } - if (c != ';') { - // no semi colon at the end ? - throw new CSSException("invalid charset declaration: " - + "missing semi colon"); - } - encoding = new String(buf, 0, i); - if (source.getEncoding() != null) { - // compare the two encoding informations. - // For example, I don't accept to have ASCII and after - // UTF-8. - // Is it really good ? That is the question. - if (!encoding.equals(source.getEncoding())) { - throw new CSSException( - "invalid encoding information."); - } - } - } // else no charset declaration available - } - } - // ok set the real encoding of this source. - source.setEncoding(encoding); - // set the real reader of this source. - source.setCharacterStream(new InputStreamReader(source.getByteStream(), - Encoding.getJavaEncoding(encoding))); - // reset the stream (leave the charset declaration in the stream). - input.reset(); - - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } - - private LocatorImpl currentLocator; - - private Locator getLocator() { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this); - return currentLocator; - } - return currentLocator.reInit(this); - } - - private LocatorImpl getLocator(Token save) { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this, save); - return currentLocator; - } - return currentLocator.reInit(this, save); - } - - private void reportError(Locator l, Exception e) { - if (errorHandler != null) { - if (e instanceof ParseException) { - // construct a clean error message. - ParseException pe = (ParseException) e; - if (pe.specialConstructor) { - StringBuffer errorM = new StringBuffer(); - if (pe.currentToken != null) { - errorM.append("encountered \u005c"").append( - pe.currentToken.next); - } - errorM.append('"'); - if (pe.expectedTokenSequences.length != 0) { - errorM.append(". Was expecting one of: "); - for (int i = 0; i < pe.expectedTokenSequences.length; i++) { - for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { - int kind = pe.expectedTokenSequences[i][j]; - if (kind != S) { - errorM.append(pe.tokenImage[kind]); - errorM.append(' '); - } - } - } - } - errorHandler.error(new CSSParseException(errorM.toString(), - l, e)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), l, - e)); - } - } else if (e == null) { - errorHandler.error(new CSSParseException("error", l, null)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), l, e)); - } - } - } - - private void reportWarningSkipText(Locator l, String text) { - if (errorHandler != null && text != null) { - errorHandler.warning(new CSSParseException("Skipping: " + text, l)); - } - } - - /* - * The grammar of CSS2 - */ - - /** - * The main entry for the parser. - * - * @exception ParseException - * exception during the parse - */ - final public void parserUnit() throws ParseException { - try { - documentHandler.startDocument(source); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CHARSET_SYM: - charset(); - break; - default: - jj_la1[0] = jj_gen; - ; - } - label_1: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[1] = jj_gen; - break label_1; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - jj_consume_token(S); - comments(); - break; - case CDO: - case CDC: - case ATKEYWORD: - ignoreStatement(); - break; - default: - jj_la1[2] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - label_2: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT_SYM: - ; - break; - default: - jj_la1[3] = jj_gen; - break label_2; - } - importDeclaration(); - label_3: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[4] = jj_gen; - break label_3; - } - ignoreStatement(); - label_4: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[5] = jj_gen; - break label_4; - } - jj_consume_token(S); - } - } - } - afterImportDeclaration(); - jj_consume_token(0); - } finally { - documentHandler.endDocument(source); - } - } - - final public void charset() throws ParseException { - Token n; - try { - jj_consume_token(CHARSET_SYM); - label_5: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[6] = jj_gen; - break label_5; - } - jj_consume_token(S); - } - n = jj_consume_token(STRING); - label_6: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[7] = jj_gen; - break label_6; - } - jj_consume_token(S); - } - jj_consume_token(SEMICOLON); - } catch (ParseException e) { - reportError(getLocator(e.currentToken.next), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (Exception e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } - } - - final public void afterImportDeclaration() throws ParseException { - String ret; - Locator l; - label_7: while (true) { - ; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case MIXIN_SYM: - mixinDirective(); - break; - case EACH_SYM: - case IF_SYM: - controlDirective(); - break; - case INCLUDE_SYM: - includeDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case MEDIA_SYM: - media(); - break; - case PAGE_SYM: - page(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - case KEY_FRAME_SYM: - keyframes(); - break; - default: - jj_la1[8] = jj_gen; - if (jj_2_1(2147483647)) { - variable(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - listModifyDirective(); - break; - default: - jj_la1[9] = jj_gen; - l = getLocator(); - ret = skipStatement(); - if ((ret == null) || (ret.length() == 0)) { - { - if (true) { - return; - } - } - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(l, ret); - } - } - } - } - label_8: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[10] = jj_gen; - break label_8; - } - ignoreStatement(); - label_9: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[11] = jj_gen; - break label_9; - } - jj_consume_token(S); - } - } - } - } - - final public void ignoreStatement() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - jj_consume_token(CDO); - break; - case CDC: - jj_consume_token(CDC); - break; - case ATKEYWORD: - atRuleDeclaration(); - break; - default: - jj_la1[12] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - /** - * The import statement - * - * @exception ParseException - * exception during the parse - */ - final public void importDeclaration() throws ParseException { - Token n; - String uri; - MediaListImpl ml = new MediaListImpl(); - boolean isURL = false; - try { - jj_consume_token(IMPORT_SYM); - label_10: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[13] = jj_gen; - break label_10; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STRING: - n = jj_consume_token(STRING); - uri = convertStringIndex(n.image, 1, n.image.length() - 1); - break; - case URL: - n = jj_consume_token(URL); - isURL = true; - uri = n.image.substring(4, n.image.length() - 1).trim(); - if ((uri.charAt(0) == '"') || (uri.charAt(0) == '\u005c'')) { - uri = uri.substring(1, uri.length() - 1); - } - break; - default: - jj_la1[14] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_11: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[15] = jj_gen; - break label_11; - } - jj_consume_token(S); - } - mediaStatement(ml); - jj_consume_token(SEMICOLON); - label_12: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[16] = jj_gen; - break label_12; - } - jj_consume_token(S); - } - if (ml.getLength() == 0) { - // see section 6.3 of the CSS2 recommandation. - ml.addItem("all"); - } - documentHandler.importStyle(uri, ml, isURL); - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void keyframes() throws ParseException { - Token n; - boolean start = false; - String keyframeName = null; - String animationname = ""; - try { - n = jj_consume_token(KEY_FRAME_SYM); - label_13: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[17] = jj_gen; - break label_13; - } - jj_consume_token(S); - } - keyframeName = n.image; - label_14: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - animationname += n.image; - break; - case INTERPOLATION: - n = jj_consume_token(INTERPOLATION); - animationname += n.image; - break; - default: - jj_la1[18] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[19] = jj_gen; - break label_14; - } - } - label_15: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[20] = jj_gen; - break label_15; - } - jj_consume_token(S); - } - start = true; - documentHandler.startKeyFrames(keyframeName, animationname); - jj_consume_token(LBRACE); - label_16: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[21] = jj_gen; - break label_16; - } - jj_consume_token(S); - } - label_17: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - case FROM: - case CONTENT_SYM: - case PERCENTAGE: - ; - break; - default: - jj_la1[22] = jj_gen; - break label_17; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - case FROM: - case PERCENTAGE: - keyframeSelector(); - break; - case CONTENT_SYM: - contentDirective(); - break; - default: - jj_la1[23] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_18: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[24] = jj_gen; - break label_18; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - } finally { - if (start) { - documentHandler.endKeyFrames(); - } - } - } - - final public void keyframeSelector() throws ParseException { - Token n; - String selector = ""; - boolean start = false; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FROM: - n = jj_consume_token(FROM); - break; - case TO: - n = jj_consume_token(TO); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - default: - jj_la1[25] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - selector += n.image; - label_19: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[26] = jj_gen; - break label_19; - } - jj_consume_token(S); - } - label_20: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[27] = jj_gen; - break label_20; - } - jj_consume_token(COMMA); - label_21: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[28] = jj_gen; - break label_21; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FROM: - n = jj_consume_token(FROM); - break; - case TO: - n = jj_consume_token(TO); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - default: - jj_la1[29] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - selector += (", " + n.image); - label_22: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[30] = jj_gen; - break label_22; - } - jj_consume_token(S); - } - } - jj_consume_token(LBRACE); - label_23: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[31] = jj_gen; - break label_23; - } - jj_consume_token(S); - } - start = true; - documentHandler.startKeyframeSelector(selector); - label_24: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case MICROSOFT_RULE: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[32] = jj_gen; - break label_24; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case MICROSOFT_RULE: - microsoftExtension(); - break; - default: - jj_la1[33] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_25: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[34] = jj_gen; - break label_25; - } - jj_consume_token(S); - } - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn - 1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endKeyframeSelector(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - /* see http://www.w3.org/TR/css3-mediaqueries/ */ - final public void media() throws ParseException { - boolean start = false; - String ret; - MediaListImpl ml = new MediaListImpl(); - try { - jj_consume_token(MEDIA_SYM); - label_26: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[35] = jj_gen; - break label_26; - } - jj_consume_token(S); - } - mediaStatement(ml); - start = true; - documentHandler.startMedia(ml); - jj_consume_token(LBRACE); - label_27: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[36] = jj_gen; - break label_27; - } - jj_consume_token(S); - } - label_28: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case LBRACE: - case DASHMATCH: - case INCLUDES: - case PLUS: - case MINUS: - case COMMA: - case SEMICOLON: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case NONASCII: - case DEBUG_SYM: - case WARN_SYM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case PERCENTAGE: - case HASH: - case IMPORT_SYM: - case MEDIA_SYM: - case CHARSET_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case ATKEYWORD: - case IMPORTANT_SYM: - case UNICODERANGE: - case FUNCTION: - case UNKNOWN: - ; - break; - default: - jj_la1[37] = jj_gen; - break label_28; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case CDO: - case LBRACE: - case DASHMATCH: - case INCLUDES: - case MINUS: - case COMMA: - case SEMICOLON: - case NONASCII: - case STRING: - case NUMBER: - case URL: - case PERCENTAGE: - case IMPORT_SYM: - case MEDIA_SYM: - case CHARSET_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case ATKEYWORD: - case IMPORTANT_SYM: - case UNICODERANGE: - case FUNCTION: - case UNKNOWN: - skipUnknownRule(); - break; - default: - jj_la1[38] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_29: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[39] = jj_gen; - break label_29; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } finally { - if (start) { - documentHandler.endMedia(ml); - } - } - } - - final public void mediaStatement(MediaListImpl ml) throws ParseException { - Token t; - t = getToken(1); - // loop over comma separated parts, add each to ml - while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) - && (t.kind != SEMICOLON)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - if (t.kind == COMMA) { - // skip the comma and the token before it that is still the - // active token - getNextToken(); - getNextToken(); - t = getToken(1); - } - String str = s.toString().trim(); - if (str.length() > 0) { - ml.addItem(str); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String medium() throws ParseException { - Token n; - n = jj_consume_token(IDENT); - { - if (true) { - return convertIdent(n.image); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void page() throws ParseException { - boolean start = false; - Token n = null; - String page = null; - String pseudo = null; - try { - jj_consume_token(PAGE_SYM); - label_30: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[40] = jj_gen; - break label_30; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - label_31: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[41] = jj_gen; - break label_31; - } - jj_consume_token(S); - } - break; - default: - jj_la1[42] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - pseudo = pseudo_page(); - break; - default: - jj_la1[43] = jj_gen; - ; - } - if (n != null) { - page = convertIdent(n.image); - } - jj_consume_token(LBRACE); - label_32: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[44] = jj_gen; - break label_32; - } - jj_consume_token(S); - } - start = true; - documentHandler.startPage(page, pseudo); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[45] = jj_gen; - ; - } - label_33: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[46] = jj_gen; - break label_33; - } - jj_consume_token(SEMICOLON); - label_34: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[47] = jj_gen; - break label_34; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[48] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_35: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[49] = jj_gen; - break label_35; - } - jj_consume_token(S); - } - } catch (ParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - skipStatement(); - // reportWarningSkipText(li, skipStatement()); - } else { - skipStatement(); - } - } finally { - if (start) { - documentHandler.endPage(page, pseudo); - } - } - } - - final public String pseudo_page() throws ParseException { - Token n; - jj_consume_token(COLON); - n = jj_consume_token(IDENT); - label_36: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[50] = jj_gen; - break label_36; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image); - } - } - throw new Error("Missing return statement in function"); - } - - final public void fontFace() throws ParseException { - boolean start = false; - try { - jj_consume_token(FONT_FACE_SYM); - label_37: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[51] = jj_gen; - break label_37; - } - jj_consume_token(S); - } - jj_consume_token(LBRACE); - label_38: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[52] = jj_gen; - break label_38; - } - jj_consume_token(S); - } - start = true; - documentHandler.startFontFace(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[53] = jj_gen; - ; - } - label_39: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[54] = jj_gen; - break label_39; - } - jj_consume_token(SEMICOLON); - label_40: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[55] = jj_gen; - break label_40; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[56] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_41: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[57] = jj_gen; - break label_41; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } finally { - if (start) { - documentHandler.endFontFace(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void atRuleDeclaration() throws ParseException { - Token n; - String ret; - n = jj_consume_token(ATKEYWORD); - ret = skipStatement(); - if ((ret != null) && (ret.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(getLocator(), ret); - } - } - - final public void skipUnknownRule() throws ParseException { - Token n; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ATKEYWORD: - n = jj_consume_token(ATKEYWORD); - break; - case CDO: - n = jj_consume_token(CDO); - break; - case CHARSET_SYM: - n = jj_consume_token(CHARSET_SYM); - break; - case COMMA: - n = jj_consume_token(COMMA); - break; - case DASHMATCH: - n = jj_consume_token(DASHMATCH); - break; - case FONT_FACE_SYM: - n = jj_consume_token(FONT_FACE_SYM); - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - break; - case IMPORTANT_SYM: - n = jj_consume_token(IMPORTANT_SYM); - break; - case IMPORT_SYM: - n = jj_consume_token(IMPORT_SYM); - break; - case INCLUDES: - n = jj_consume_token(INCLUDES); - break; - case LBRACE: - n = jj_consume_token(LBRACE); - break; - case MEDIA_SYM: - n = jj_consume_token(MEDIA_SYM); - break; - case NONASCII: - n = jj_consume_token(NONASCII); - break; - case NUMBER: - n = jj_consume_token(NUMBER); - break; - case PAGE_SYM: - n = jj_consume_token(PAGE_SYM); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - case STRING: - n = jj_consume_token(STRING); - break; - case UNICODERANGE: - n = jj_consume_token(UNICODERANGE); - break; - case URL: - n = jj_consume_token(URL); - break; - case SEMICOLON: - n = jj_consume_token(SEMICOLON); - break; - case MINUS: - n = jj_consume_token(MINUS); - break; - case UNKNOWN: - n = jj_consume_token(UNKNOWN); - break; - default: - jj_la1[58] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - String ret; - Locator loc = getLocator(); - ret = skipStatement(); - if ((ret != null) && (n.image.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(loc, ret); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public char combinator() throws ParseException { - char connector = ' '; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - connector = combinatorChar(); - break; - case S: - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - connector = combinatorChar(); - break; - default: - jj_la1[59] = jj_gen; - ; - } - break; - default: - jj_la1[60] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - { - if (true) { - return connector; - } - } - throw new Error("Missing return statement in function"); - } - - /** to refactor combinator and reuse in selector(). */ - final public char combinatorChar() throws ParseException { - Token t; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - t = jj_consume_token(PLUS); - break; - case PRECEDES: - t = jj_consume_token(PRECEDES); - break; - case SIBLING: - t = jj_consume_token(SIBLING); - break; - default: - jj_la1[61] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_42: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[62] = jj_gen; - break label_42; - } - jj_consume_token(S); - } - { - if (true) { - return t.image.charAt(0); - } - } - throw new Error("Missing return statement in function"); - } - - final public void microsoftExtension() throws ParseException { - Token n; - String name = ""; - String value = ""; - // This is not really taking the syntax of filter rules into account - n = jj_consume_token(MICROSOFT_RULE); - label_43: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[63] = jj_gen; - break label_43; - } - jj_consume_token(S); - } - name = n.image; - jj_consume_token(COLON); - label_44: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - value += n.image; - break; - case NUMBER: - n = jj_consume_token(NUMBER); - value += n.image; - break; - case STRING: - n = jj_consume_token(STRING); - value += n.image; - break; - case COMMA: - n = jj_consume_token(COMMA); - value += n.image; - break; - case INTERPOLATION: - n = jj_consume_token(INTERPOLATION); - value += n.image; - break; - case COLON: - n = jj_consume_token(COLON); - value += n.image; - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - value += n.image; - break; - case RPARAN: - n = jj_consume_token(RPARAN); - value += n.image; - break; - case EQ: - n = jj_consume_token(EQ); - value += n.image; - break; - case DOT: - n = jj_consume_token(DOT); - value += n.image; - break; - case S: - n = jj_consume_token(S); - if (value.lastIndexOf(' ') != value.length() - 1) { - value += n.image; - } - break; - default: - jj_la1[64] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case COMMA: - case DOT: - case RPARAN: - case COLON: - case INTERPOLATION: - case STRING: - case IDENT: - case NUMBER: - case FUNCTION: - ; - break; - default: - jj_la1[65] = jj_gen; - break label_44; - } - } - jj_consume_token(SEMICOLON); - label_45: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[66] = jj_gen; - break label_45; - } - jj_consume_token(S); - } - documentHandler.microsoftDirective(name, value); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String property() throws ParseException { - Token t; - String s = ""; - label_46: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[67] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[68] = jj_gen; - break label_46; - } - } - label_47: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[69] = jj_gen; - break label_47; - } - jj_consume_token(S); - } - { - if (true) { - return s; - } - } - throw new Error("Missing return statement in function"); - } - - final public String variableName() throws ParseException { - Token n; - n = jj_consume_token(VARIABLE); - label_48: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[70] = jj_gen; - break label_48; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image.substring(1)); - } - } - throw new Error("Missing return statement in function"); - } - - final public String functionName() throws ParseException { - Token n; - n = jj_consume_token(FUNCTION); - label_49: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[71] = jj_gen; - break label_49; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image.substring(0, n.image.length() - 1)); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void styleRule() throws ParseException { - boolean start = false; - ArrayList l = null; - Token save; - Locator loc; - try { - l = selectorList(); - save = token; - jj_consume_token(LBRACE); - label_50: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[72] = jj_gen; - break label_50; - } - jj_consume_token(S); - } - start = true; - documentHandler.startSelector(l); - label_51: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case MICROSOFT_RULE: - case IDENT: - case VARIABLE: - case HASH: - case IMPORT_SYM: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[73] = jj_gen; - break label_51; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case MICROSOFT_RULE: - microsoftExtension(); - break; - case IMPORT_SYM: - importDeclaration(); - break; - default: - jj_la1[74] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_52: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[75] = jj_gen; - break label_52; - } - jj_consume_token(S); - } - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn - 1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endSelector(); + throw new RuntimeException( + "Unable to load parser implementation." + + "Check whether you have generated parser " + + "class using build procedure", e); } } - } - final public ArrayList selectorList() throws ParseException { - ArrayList selectors = new ArrayList(); - String selector; - selector = selector(); - label_53: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[76] = jj_gen; - break label_53; - } - jj_consume_token(COMMA); - label_54: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[77] = jj_gen; - break label_54; - } - jj_consume_token(S); - } - selectors.add(selector); - selector = selector(); - } - selectors.add(selector); - { - if (true) { - return selectors; - } - } - throw new Error("Missing return statement in function"); } - - /** - * @exception ParseException - * exception during the parse - */ - final public String selector() throws ParseException { - String selector = null; - char comb; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - selector = simple_selector(null, ' '); - break; - case PLUS: - case PRECEDES: - case SIBLING: - comb = combinatorChar(); - selector = simple_selector(selector, comb); - break; - default: - jj_la1[78] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_55: while (true) { - if (jj_2_2(2)) { - ; - } else { - break label_55; - } - comb = combinator(); - selector = simple_selector(selector, comb); - } - label_56: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[79] = jj_gen; - break label_56; - } - jj_consume_token(S); - } - { - if (true) { - return selector; - } - } - } catch (ParseException e) { - /* - * Token t = getToken(1); StringBuffer s = new StringBuffer(); - * s.append(getToken(0).image); while ((t.kind != COMMA) && (t.kind - * != SEMICOLON) && (t.kind != LBRACE) && (t.kind != EOF)) { - * s.append(t.image); getNextToken(); t = getToken(1); } - * reportWarningSkipText(getLocator(), s.toString()); - */ - Token t = getToken(1); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - getNextToken(); - t = getToken(1); - } - - { - if (true) { - throw new ThrowedParseException(e); - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String simple_selector(String selector, char comb) - throws ParseException { - String simple_current = null; - String cond = null; - - pseudoElt = null; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ANY: - case PARENT: - case INTERPOLATION: - case IDENT: - simple_current = element_name(); - label_57: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case DOT: - case COLON: - case HASH: - ; - break; - default: - jj_la1[80] = jj_gen; - break label_57; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case HASH: - cond = hash(cond); - break; - case DOT: - cond = _class(cond); - break; - case LBRACKET: - cond = attrib(cond); - break; - case COLON: - cond = pseudo(cond); - break; - default: - jj_la1[81] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - break; - case LBRACKET: - case DOT: - case COLON: - case HASH: - label_58: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case HASH: - cond = hash(cond); - break; - case DOT: - cond = _class(cond); - break; - case LBRACKET: - cond = attrib(cond); - break; - case COLON: - cond = pseudo(cond); - break; - default: - jj_la1[82] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case DOT: - case COLON: - case HASH: - ; - break; - default: - jj_la1[83] = jj_gen; - break label_58; - } - } - break; - default: - jj_la1[84] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - if (simple_current == null) { - simple_current = ""; - } - if (cond != null) { - simple_current = simple_current + cond; - } - StringBuilder builder = new StringBuilder(); - switch (comb) { - case ' ': - if (selector != null) { - builder.append(selector).append(" "); - } - break; - case '+': - case '>': - case '~': - if (selector != null) { - builder.append(selector).append(" "); - } - builder.append(comb).append(" "); - break; - default: { - if (true) { - throw new ParseException("invalid state. send a bug report"); - } - } - } - builder.append(simple_current); - selector = builder.toString(); - - if (pseudoElt != null) { - selector = selector + pseudoElt; - } - { - if (true) { - return selector; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String _class(String pred) throws ParseException { - Token t; - String s = "."; - jj_consume_token(DOT); - label_59: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[85] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[86] = jj_gen; - break label_59; - } - } - if (pred == null) { - { - if (true) { - return s; - } - } - } else { - { - if (true) { - return pred + s; - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String element_name() throws ParseException { - Token t; - String s = ""; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - label_60: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[87] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[88] = jj_gen; - break label_60; - } - } - { - if (true) { - return s; - } - } - break; - case ANY: - jj_consume_token(ANY); - { - if (true) { - return "*"; - } - } - break; - case PARENT: - jj_consume_token(PARENT); - { - if (true) { - return "&"; - } - } - break; - default: - jj_la1[89] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String attrib(String pred) throws ParseException { - int cases = 0; - Token att = null; - Token val = null; - String attValue = null; - jj_consume_token(LBRACKET); - label_61: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[90] = jj_gen; - break label_61; - } - jj_consume_token(S); - } - att = jj_consume_token(IDENT); - label_62: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[91] = jj_gen; - break label_62; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DASHMATCH: - case CARETMATCH: - case DOLLARMATCH: - case STARMATCH: - case INCLUDES: - case EQ: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EQ: - jj_consume_token(EQ); - cases = 1; - break; - case INCLUDES: - jj_consume_token(INCLUDES); - cases = 2; - break; - case DASHMATCH: - jj_consume_token(DASHMATCH); - cases = 3; - break; - case CARETMATCH: - jj_consume_token(CARETMATCH); - cases = 4; - break; - case DOLLARMATCH: - jj_consume_token(DOLLARMATCH); - cases = 5; - break; - case STARMATCH: - jj_consume_token(STARMATCH); - cases = 6; - break; - default: - jj_la1[92] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_63: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[93] = jj_gen; - break label_63; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - val = jj_consume_token(IDENT); - attValue = val.image; - break; - case STRING: - val = jj_consume_token(STRING); - attValue = val.image; - break; - default: - jj_la1[94] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_64: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[95] = jj_gen; - break label_64; - } - jj_consume_token(S); - } - break; - default: - jj_la1[96] = jj_gen; - ; - } - jj_consume_token(RBRACKET); - String name = convertIdent(att.image); - String c; - switch (cases) { - case 0: - c = name; - break; - case 1: - c = name + "=" + attValue; - break; - case 2: - c = name + "~=" + attValue; - break; - case 3: - c = name + "|=" + attValue; - break; - case 4: - c = name + "^=" + attValue; - break; - case 5: - c = name + "$=" + attValue; - break; - case 6: - c = name + "*=" + attValue; - break; - default: - // never reached. - c = null; - } - c = "[" + c + "]"; - if (pred == null) { - { - if (true) { - return c; - } - } - } else { - { - if (true) { - return pred + c; - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String pseudo(String pred) throws ParseException { - Token n; - Token param; - String d; - boolean isPseudoElement = false; - jj_consume_token(COLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - isPseudoElement = true; - break; - default: - jj_la1[97] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - String s = ":" + convertIdent(n.image); - if (isPseudoElement) { - if (pseudoElt != null) { - { - if (true) { - throw new CSSParseException( - "duplicate pseudo element definition " + s, - getLocator()); - } - } - } else { - pseudoElt = ":" + s; - { - if (true) { - return pred; - } - } - } - } else { - String c = s; - if (pred == null) { - { - if (true) { - return c; - } - } - } else { - { - if (true) { - return pred + c; - } - } - } - } - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - label_65: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[98] = jj_gen; - break label_65; - } - jj_consume_token(S); - } - d = skipStatementUntilMatchingRightParan(); - jj_consume_token(RPARAN); - // accept anything between function and a right parenthesis - String f = convertIdent(n.image); - String colons = isPseudoElement ? "::" : ":"; - String pseudofn = colons + f + d + ")"; - if (pred == null) { - { - if (true) { - return pseudofn; - } - } - } else { - { - if (true) { - return pred + pseudofn; - } - } - } - break; - default: - jj_la1[99] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String hash(String pred) throws ParseException { - Token n; - n = jj_consume_token(HASH); - String d = n.image; - if (pred == null) { - { - if (true) { - return d; - } - } - } else { - { - if (true) { - return pred + d; - } - } - } - throw new Error("Missing return statement in function"); - } - - final public void variable() throws ParseException { - String name; - LexicalUnitImpl exp = null; - boolean guarded = false; - String raw; - try { - name = variableName(); - jj_consume_token(COLON); - label_66: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[100] = jj_gen; - break label_66; - } - jj_consume_token(S); - } - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case GUARDED_SYM: - guarded = guarded(); - break; - default: - jj_la1[101] = jj_gen; - ; - } - label_67: while (true) { - jj_consume_token(SEMICOLON); - label_68: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[102] = jj_gen; - break label_68; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[103] = jj_gen; - break label_67; - } - } - documentHandler.variable(name, exp, guarded); - } catch (JumpException e) { - skipAfterExpression(); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - } else { - skipAfterExpression(); - } - } - } - - final public void controlDirective() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IF_SYM: - ifDirective(); - break; - case EACH_SYM: - eachDirective(); - break; - default: - jj_la1[104] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public void ifContentStatement() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CONTENT_SYM: - contentDirective(); - break; - case INCLUDE_SYM: - includeDirective(); - break; - case MEDIA_SYM: - media(); - break; - case EXTEND_SYM: - extendDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case HASH: - styleRuleOrDeclarationOrNestedProperties(); - break; - case KEY_FRAME_SYM: - keyframes(); - break; - default: - jj_la1[105] = jj_gen; - if (jj_2_3(2147483647)) { - variable(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - listModifyDirective(); - break; - case EACH_SYM: - case IF_SYM: - controlDirective(); - break; - case ATKEYWORD: - atRuleDeclaration(); - break; - default: - jj_la1[106] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } - - final public void ifDirective() throws ParseException { - Token n = null; - String s = null; - String evaluator = ""; - jj_consume_token(IF_SYM); - label_69: while (true) { - s = booleanExpressionToken(); - evaluator += s; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case PLUS: - case MINUS: - case PRECEDES: - case SUCCEEDS: - case DIV: - case ANY: - case LPARAN: - case RPARAN: - case COMPARE: - case OR: - case AND: - case NOT_EQ: - case IDENT: - case NUMBER: - case VARIABLE: - case CONTAINS: - ; - break; - default: - jj_la1[107] = jj_gen; - break label_69; - } - } - jj_consume_token(LBRACE); - label_70: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[108] = jj_gen; - break label_70; - } - jj_consume_token(S); - } - documentHandler.startIfElseDirective(); - documentHandler.ifDirective(evaluator); - label_71: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[109] = jj_gen; - break label_71; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[110] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_72: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[111] = jj_gen; - break label_72; - } - jj_consume_token(S); - } - label_73: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ELSE_SYM: - ; - break; - default: - jj_la1[112] = jj_gen; - break label_73; - } - elseDirective(); - } - documentHandler.endIfElseDirective(); - } - - final public void elseDirective() throws ParseException { - String evaluator = ""; - Token n = null; - String s = null; - jj_consume_token(ELSE_SYM); - label_74: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[113] = jj_gen; - break label_74; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IF: - jj_consume_token(IF); - label_75: while (true) { - s = booleanExpressionToken(); - evaluator += s; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case PLUS: - case MINUS: - case PRECEDES: - case SUCCEEDS: - case DIV: - case ANY: - case LPARAN: - case RPARAN: - case COMPARE: - case OR: - case AND: - case NOT_EQ: - case IDENT: - case NUMBER: - case VARIABLE: - case CONTAINS: - ; - break; - default: - jj_la1[114] = jj_gen; - break label_75; - } - } - break; - default: - jj_la1[115] = jj_gen; - ; - } - jj_consume_token(LBRACE); - label_76: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[116] = jj_gen; - break label_76; - } - jj_consume_token(S); - } - if (!evaluator.trim().equals("")) { - documentHandler.ifDirective(evaluator); - } else { - documentHandler.elseDirective(); - } - label_77: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[117] = jj_gen; - break label_77; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[118] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_78: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[119] = jj_gen; - break label_78; - } - jj_consume_token(S); - } - } - - final public String booleanExpressionToken() throws ParseException { - Token n = null; - String s = null; - if (jj_2_4(2147483647)) { - s = containsDirective(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - n = jj_consume_token(VARIABLE); - break; - case IDENT: - n = jj_consume_token(IDENT); - break; - case NUMBER: - n = jj_consume_token(NUMBER); - break; - case LPARAN: - n = jj_consume_token(LPARAN); - break; - case RPARAN: - n = jj_consume_token(RPARAN); - break; - case PLUS: - n = jj_consume_token(PLUS); - break; - case MINUS: - n = jj_consume_token(MINUS); - break; - case DIV: - n = jj_consume_token(DIV); - break; - case ANY: - n = jj_consume_token(ANY); - break; - case COMPARE: - n = jj_consume_token(COMPARE); - break; - case EQ: - n = jj_consume_token(EQ); - break; - case PRECEDES: - n = jj_consume_token(PRECEDES); - break; - case SUCCEEDS: - n = jj_consume_token(SUCCEEDS); - break; - case OR: - n = jj_consume_token(OR); - break; - case AND: - n = jj_consume_token(AND); - break; - case S: - n = jj_consume_token(S); - break; - case NOT_EQ: - n = jj_consume_token(NOT_EQ); - break; - default: - jj_la1[120] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - if (n != null) { - { - if (true) { - return n.image; - } - } - } else { - { - if (true) { - return s; - } - } - } - throw new Error("Missing return statement in function"); - } - - final public void eachDirective() throws ParseException { - Token var; - ArrayList list = null; - String listVariable = null; - jj_consume_token(EACH_SYM); - label_79: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[121] = jj_gen; - break label_79; - } - jj_consume_token(S); - } - var = jj_consume_token(VARIABLE); - label_80: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[122] = jj_gen; - break label_80; - } - jj_consume_token(S); - } - jj_consume_token(EACH_IN); - label_81: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[123] = jj_gen; - break label_81; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - list = stringList(); - documentHandler.startEachDirective(var.image, list); - break; - case VARIABLE: - listVariable = variableName(); - documentHandler.startEachDirective(var.image, listVariable); - break; - default: - jj_la1[124] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(LBRACE); - label_82: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[125] = jj_gen; - break label_82; - } - jj_consume_token(S); - } - label_83: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[126] = jj_gen; - break label_83; - } - ifContentStatement(); - } - jj_consume_token(RBRACE); - label_84: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[127] = jj_gen; - break label_84; - } - jj_consume_token(S); - } - documentHandler.endEachDirective(); - } - - final public ArrayList stringList() throws ParseException { - ArrayList strings = new ArrayList(); - Token input; - input = jj_consume_token(IDENT); - label_85: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[128] = jj_gen; - break label_85; - } - jj_consume_token(S); - } - strings.add(input.image); - label_86: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[129] = jj_gen; - break label_86; - } - jj_consume_token(COMMA); - label_87: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[130] = jj_gen; - break label_87; - } - jj_consume_token(S); - } - input = jj_consume_token(IDENT); - strings.add(input.image); - label_88: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[131] = jj_gen; - break label_88; - } - jj_consume_token(S); - } - } - { - if (true) { - return strings; - } - } - throw new Error("Missing return statement in function"); - } - - final public void mixinDirective() throws ParseException { - String name; - ArrayList args = null; - String body; - jj_consume_token(MIXIN_SYM); - label_89: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[132] = jj_gen; - break label_89; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - name = property(); - break; - case FUNCTION: - name = functionName(); - args = arglist(); - jj_consume_token(RPARAN); - label_90: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[133] = jj_gen; - break label_90; - } - jj_consume_token(S); - } - break; - default: - jj_la1[134] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(LBRACE); - label_91: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[135] = jj_gen; - break label_91; - } - jj_consume_token(S); - } - documentHandler.startMixinDirective(name, args); - label_92: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[136] = jj_gen; - break label_92; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - case PAGE_SYM: - page(); - break; - default: - jj_la1[137] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_93: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[138] = jj_gen; - break label_93; - } - jj_consume_token(S); - } - documentHandler.endMixinDirective(name, args); - } - - final public ArrayList arglist() throws ParseException { - ArrayList args = new ArrayList(); - VariableNode arg; - boolean hasNonOptionalArgument = false; - arg = mixinArg(); - label_94: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[139] = jj_gen; - break label_94; - } - jj_consume_token(COMMA); - label_95: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[140] = jj_gen; - break label_95; - } - jj_consume_token(S); - } - hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, - hasNonOptionalArgument); - args.add(arg); - arg = mixinArg(); - } - hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, - hasNonOptionalArgument); - args.add(arg); - { - if (true) { - return args; - } - } - throw new Error("Missing return statement in function"); - } - - boolean checkMixinForNonOptionalArguments(VariableNode arg, - boolean hasNonOptionalArguments) throws ParseException { - boolean currentArgHasArguments = arg.getExpr() != null - && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE - && arg.getExpr().getNextLexicalUnit() != null; - - if (currentArgHasArguments) { - if (hasNonOptionalArguments) { - throw new ParseException("Sass Error: Required argument $" - + arg.getName() - + " must come before any optional arguments."); - } - return hasNonOptionalArguments; - } else { - return true; - } - } - - final public VariableNode mixinArg() throws ParseException { - String name; - Token variable = null; - LexicalUnitImpl first = null; - LexicalUnitImpl prev = null; - LexicalUnitImpl next = null; - name = variableName(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - case VARIABLE: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_96: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[141] = jj_gen; - break label_96; - } - jj_consume_token(S); - } - first = nonVariableTerm(null); - prev = first; - label_97: while (true) { - if (jj_2_5(3)) { - ; - } else { - break label_97; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_98: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[142] = jj_gen; - break label_98; - } - jj_consume_token(S); - } - break; - default: - jj_la1[143] = jj_gen; - ; - } - prev = nonVariableTerm(prev); - } - break; - case VARIABLE: - variable = jj_consume_token(VARIABLE); - first = LexicalUnitImpl.createVariable(token.beginLine, - token.beginColumn, prev, variable.image); - break; - default: - jj_la1[144] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[145] = jj_gen; - ; - } - VariableNode arg = new VariableNode(name, first, false); - { - if (true) { - return arg; - } - } - throw new Error("Missing return statement in function"); - } - - final public ArrayList argValuelist() - throws ParseException { - ArrayList args = new ArrayList(); - LexicalUnitImpl first = null; - LexicalUnitImpl next = null; - LexicalUnitImpl prev = null; - first = term(null); - args.add(first); - prev = first; - label_99: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case COLON: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - ; - break; - default: - jj_la1[146] = jj_gen; - break label_99; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_100: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[147] = jj_gen; - break label_100; - } - jj_consume_token(S); - } - break; - default: - jj_la1[148] = jj_gen; - ; - } - next = term(prev); - prev.setNextLexicalUnit(next); - prev = next; - } - label_101: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[149] = jj_gen; - break label_101; - } - jj_consume_token(COMMA); - label_102: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[150] = jj_gen; - break label_102; - } - jj_consume_token(S); - } - first = term(null); - args.add(first); - prev = first; - label_103: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case COLON: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - ; - break; - default: - jj_la1[151] = jj_gen; - break label_103; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_104: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[152] = jj_gen; - break label_104; - } - jj_consume_token(S); - } - break; - default: - jj_la1[153] = jj_gen; - ; - } - next = term(prev); - prev.setNextLexicalUnit(next); - prev = next; - } - } - { - if (true) { - return args; - } - } - throw new Error("Missing return statement in function"); - } - - final public void includeDirective() throws ParseException { - String name; - ArrayList args = null; - jj_consume_token(INCLUDE_SYM); - label_105: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[154] = jj_gen; - break label_105; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - name = property(); - break; - case VARIABLE: - name = variableName(); - name = "$" + name; - break; - case FUNCTION: - name = functionName(); - args = argValuelist(); - jj_consume_token(RPARAN); - label_106: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[155] = jj_gen; - break label_106; - } - jj_consume_token(S); - } - break; - default: - jj_la1[156] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - label_107: while (true) { - jj_consume_token(SEMICOLON); - label_108: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[157] = jj_gen; - break label_108; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[158] = jj_gen; - break label_107; - } - } - documentHandler.includeDirective(name, args); - break; - case LBRACE: - jj_consume_token(LBRACE); - label_109: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[159] = jj_gen; - break label_109; - } - jj_consume_token(S); - } - documentHandler.startIncludeContentBlock(name, args); - label_110: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case TO: - case FROM: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case PERCENTAGE: - case HASH: - ; - break; - default: - jj_la1[160] = jj_gen; - break label_110; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case HASH: - styleRuleOrDeclarationOrNestedProperties(); - break; - case TO: - case FROM: - case PERCENTAGE: - keyframeSelector(); - break; - default: - jj_la1[161] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_111: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[162] = jj_gen; - break label_111; - } - jj_consume_token(S); - } - documentHandler.endIncludeContentBlock(); - break; - default: - jj_la1[163] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public String interpolation() throws ParseException { - Token n; - n = jj_consume_token(INTERPOLATION); - { - if (true) { - return n.image; - } - } - throw new Error("Missing return statement in function"); - } - - final public void listModifyDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - Token type = null; - // refactor, remove those 3 LOOKAHEAD(5). - n = jj_consume_token(VARIABLE); - variable = n.image; - label_112: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[164] = jj_gen; - break label_112; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_113: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[165] = jj_gen; - break label_113; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case APPEND: - type = jj_consume_token(APPEND); - break; - case REMOVE: - type = jj_consume_token(REMOVE); - break; - case CONTAINS: - type = jj_consume_token(CONTAINS); - break; - default: - jj_la1[166] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_114: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[167] = jj_gen; - break label_114; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[168] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_115: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[169] = jj_gen; - break label_115; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_116: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[170] = jj_gen; - break label_116; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_117: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[171] = jj_gen; - break label_117; - } - jj_consume_token(S); - } - break; - default: - jj_la1[172] = jj_gen; - ; - } - jj_consume_token(RPARAN); - switch (type.kind) { - case APPEND: - documentHandler.appendDirective(variable, list, remove, separator); - break; - case REMOVE: - documentHandler.removeDirective(variable, list, remove, separator); - break; - case CONTAINS: - if (variable == null) { - variable = "$var_" + UUID.randomUUID(); - } - documentHandler - .containsDirective(variable, list, remove, separator); - break; - default: - break; - } - label_118: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[173] = jj_gen; - break label_118; - } - jj_consume_token(S); - } - jj_consume_token(SEMICOLON); - label_119: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[174] = jj_gen; - break label_119; - } - jj_consume_token(S); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void appendDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - n = jj_consume_token(VARIABLE); - variable = n.image; - label_120: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[175] = jj_gen; - break label_120; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_121: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[176] = jj_gen; - break label_121; - } - jj_consume_token(S); - } - jj_consume_token(APPEND); - label_122: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[177] = jj_gen; - break label_122; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[178] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_123: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[179] = jj_gen; - break label_123; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_124: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[180] = jj_gen; - break label_124; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_125: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[181] = jj_gen; - break label_125; - } - jj_consume_token(S); - } - break; - default: - jj_la1[182] = jj_gen; - ; - } - jj_consume_token(RPARAN); - documentHandler.appendDirective(variable, list, remove, separator); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void removeDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - n = jj_consume_token(VARIABLE); - variable = n.image; - label_126: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[183] = jj_gen; - break label_126; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_127: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[184] = jj_gen; - break label_127; - } - jj_consume_token(S); - } - jj_consume_token(REMOVE); - label_128: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[185] = jj_gen; - break label_128; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[186] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_129: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[187] = jj_gen; - break label_129; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_130: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[188] = jj_gen; - break label_130; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_131: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[189] = jj_gen; - break label_131; - } - jj_consume_token(S); - } - break; - default: - jj_la1[190] = jj_gen; - ; - } - jj_consume_token(RPARAN); - documentHandler.removeDirective(variable, list, remove, separator); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String containsDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - n = jj_consume_token(VARIABLE); - variable = n.image; - label_132: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[191] = jj_gen; - break label_132; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_133: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[192] = jj_gen; - break label_133; - } - jj_consume_token(S); - } - break; - default: - jj_la1[193] = jj_gen; - ; - } - jj_consume_token(CONTAINS); - label_134: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[194] = jj_gen; - break label_134; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[195] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_135: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[196] = jj_gen; - break label_135; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_136: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[197] = jj_gen; - break label_136; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_137: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[198] = jj_gen; - break label_137; - } - jj_consume_token(S); - } - break; - default: - jj_la1[199] = jj_gen; - ; - } - jj_consume_token(RPARAN); - /* - * if it is not in the form like - * "$contains : contains($items, .v-button);"for example in @if, like - * "@if (contains(a b c, b))", then create a tempvariable for contains(a - * b c, b); - */ - if (variable == null) { - variable = "$var_" + UUID.randomUUID(); - } - documentHandler.containsDirective(variable, list, remove, separator); - { - if (true) { - return variable; - } - } - throw new Error("Missing return statement in function"); - } - - String listModifyDirectiveArgs(int nest) throws ParseException { - String list = ""; - int nesting = nest; - Token t = null; - - while (true) { - t = getToken(1); - String s = t.image; - if (t.kind == VARIABLE || t.kind == IDENT) { - list += s; - } else if (s.toLowerCase().equals("auto") - || s.toLowerCase().equals("space") - || s.toLowerCase().equals("comma")) { - int i = 2; - Token temp = getToken(i); - boolean isLast = true; - while (temp.kind != SEMICOLON) { - if (temp.kind != RPARAN || temp.kind != S) { - isLast = false; - } - i++; - temp = getToken(i); - } - - if (isLast) { - return list; - } - } else if (t.kind == STRING) { - list += s.substring(1, s.length()).substring(0, s.length() - 2); - - } else if (t.kind == LPARAN) { - nesting++; - if (nesting > nest + 1) { - throw new CSSParseException( - "Only one ( ) pair per parameter allowed", - getLocator()); - } - } else if (t.kind == RPARAN) { - nesting--; - if (nesting == 0) { - return list; - } - } else if (t.kind == COMMA) { - if (nesting == nest) { - return list; - } else { - list += ","; - } - - } else if (t.kind == S) { - list += " "; - } else if (t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", - getLocator()); - } - - getNextToken(); - } - } - - final public Node returnDirective() throws ParseException { - String raw; - raw = skipStatement(); - { - if (true) { - return null; - } - } - throw new Error("Missing return statement in function"); - } - - final public void debuggingDirective() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - debugDirective(); - break; - case WARN_SYM: - warnDirective(); - break; - default: - jj_la1[200] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public void debugDirective() throws ParseException { - jj_consume_token(DEBUG_SYM); - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call - // documentHandler.debugDirective() etc. - System.out.println(content); - label_138: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[201] = jj_gen; - break label_138; - } - jj_consume_token(S); - } - } - - final public void warnDirective() throws ParseException { - jj_consume_token(WARN_SYM); - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call - // documentHandler.warnDirective() etc. - System.err.println(content); - label_139: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[202] = jj_gen; - break label_139; - } - jj_consume_token(S); - } - } - - final public Node forDirective() throws ParseException { - String var; - String from; - String to; - boolean exclusive; - String body; - Token tok; - var = variableName(); - int[] toThrough = { TO, THROUGH }; - from = skipStatementUntil(toThrough); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - tok = jj_consume_token(TO); - exclusive = true; - break; - case THROUGH: - tok = jj_consume_token(THROUGH); - exclusive = false; - break; - default: - jj_la1[203] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - to = skipStatementUntilLeftBrace(); - label_140: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[204] = jj_gen; - break label_140; - } - jj_consume_token(S); - } - body = skipStatement(); - { - if (true) { - return documentHandler.forDirective(var, from, to, exclusive, - body); - } - } - throw new Error("Missing return statement in function"); - } - - final public Node whileDirective() throws ParseException { - String condition; - String body; - condition = skipStatementUntilLeftBrace(); - body = skipStatement(); - { - if (true) { - return documentHandler.whileDirective(condition, body); - } - } - throw new Error("Missing return statement in function"); - } - - final public void extendDirective() throws ParseException { - ArrayList list; - jj_consume_token(EXTEND_SYM); - label_141: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[205] = jj_gen; - break label_141; - } - jj_consume_token(S); - } - list = selectorList(); - label_142: while (true) { - jj_consume_token(SEMICOLON); - label_143: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[206] = jj_gen; - break label_143; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[207] = jj_gen; - break label_142; - } - } - documentHandler.extendDirective(list); - } - - final public void contentDirective() throws ParseException { - jj_consume_token(CONTENT_SYM); - label_144: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[208] = jj_gen; - break label_144; - } - jj_consume_token(S); - } - label_145: while (true) { - jj_consume_token(SEMICOLON); - label_146: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[209] = jj_gen; - break label_146; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[210] = jj_gen; - break label_145; - } - } - documentHandler.contentDirective(); - } - - Node importDirective() throws ParseException { - return null; - } - - Node charsetDirective() throws ParseException { - return null; - } - - Node mozDocumentDirective() throws ParseException { - return null; - } - - Node supportsDirective() throws ParseException { - return null; - } - - final public void nestedProperties() throws ParseException { - String name; - LexicalUnit exp; - name = property(); - jj_consume_token(COLON); - label_147: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[211] = jj_gen; - break label_147; - } - jj_consume_token(S); - } - jj_consume_token(LBRACE); - label_148: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[212] = jj_gen; - break label_148; - } - jj_consume_token(S); - } - documentHandler.startNestedProperties(name); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[213] = jj_gen; - ; - } - label_149: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[214] = jj_gen; - break label_149; - } - jj_consume_token(SEMICOLON); - label_150: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[215] = jj_gen; - break label_150; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[216] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - documentHandler.endNestedProperties(name); - label_151: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[217] = jj_gen; - break label_151; - } - jj_consume_token(S); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void styleRuleOrDeclarationOrNestedProperties() - throws ParseException { - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - default: - jj_la1[218] = jj_gen; - if (jj_2_6(2147483647)) { - styleRule(); - } else if (jj_2_7(3)) { - declarationOrNestedProperties(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - default: - jj_la1[219] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void declarationOrNestedProperties() throws ParseException { - boolean important = false; - String name; - LexicalUnitImpl exp; - Token save; - String comment = null; - try { - name = property(); - save = token; - jj_consume_token(COLON); - label_152: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[220] = jj_gen; - break label_152; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORTANT_SYM: - important = prio(); - break; - default: - jj_la1[221] = jj_gen; - ; - } - Token next = getToken(1); - if (next.kind == SEMICOLON || next.kind == RBRACE) { - while (next.kind == SEMICOLON) { - skipStatement(); - next = getToken(1); - } - // only add special token kept for sprites '/**' - if (token.specialToken != null - && token.specialToken != null - && token.specialToken.image.startsWith("/**")) { - documentHandler.property(name, exp, important, - token.specialToken.image); - } else { - documentHandler.property(name, exp, important, null); - } - } - break; - case LBRACE: - jj_consume_token(LBRACE); - label_153: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[222] = jj_gen; - break label_153; - } - jj_consume_token(S); - } - documentHandler.startNestedProperties(name); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[223] = jj_gen; - ; - } - label_154: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[224] = jj_gen; - break label_154; - } - jj_consume_token(SEMICOLON); - label_155: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[225] = jj_gen; - break label_155; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[226] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_156: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[227] = jj_gen; - break label_156; - } - jj_consume_token(S); - } - documentHandler.endNestedProperties(name); - break; - default: - jj_la1[228] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void declaration() throws ParseException { - boolean important = false; - String name; - LexicalUnit exp; - Token save; - try { - name = property(); - save = token; - jj_consume_token(COLON); - label_157: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[229] = jj_gen; - break label_157; - } - jj_consume_token(S); - } - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORTANT_SYM: - important = prio(); - break; - default: - jj_la1[230] = jj_gen; - ; - } - documentHandler.property(name, exp, important); - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public boolean prio() throws ParseException { - jj_consume_token(IMPORTANT_SYM); - label_158: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[231] = jj_gen; - break label_158; - } - jj_consume_token(S); - } - { - if (true) { - return true; - } - } - throw new Error("Missing return statement in function"); - } - - final public boolean guarded() throws ParseException { - jj_consume_token(GUARDED_SYM); - label_159: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[232] = jj_gen; - break label_159; - } - jj_consume_token(S); - } - { - if (true) { - return true; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl operator(LexicalUnitImpl prev) - throws ParseException { - Token n; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - /* - * (comments copied from basic_arithmetics.scss)supports: 1. - * standard arithmetic operations (+, -, *, /, %) 2. / is treated as - * css operator, unless one of its operands is variable or there is - * another binary arithmetic operatorlimits: 1. cannot mix - * arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will - * fail 2. space between add and minus operator and their following - * operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not 3. - * parenthesis is not supported now. - */ - n = jj_consume_token(COMMA); - label_160: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[233] = jj_gen; - break label_160; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createComma(n.beginLine, - n.beginColumn, prev); - } - } - break; - case DIV: - n = jj_consume_token(DIV); - label_161: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[234] = jj_gen; - break label_161; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createSlash(n.beginLine, - n.beginColumn, prev); - } - } - break; - case ANY: - n = jj_consume_token(ANY); - label_162: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[235] = jj_gen; - break label_162; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createMultiply(n.beginLine, - n.beginColumn, prev); - } - } - break; - case MOD: - n = jj_consume_token(MOD); - label_163: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[236] = jj_gen; - break label_163; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createModulo(n.beginLine, - n.beginColumn, prev); - } - } - break; - case PLUS: - n = jj_consume_token(PLUS); - label_164: while (true) { - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[237] = jj_gen; - break label_164; - } - } - { - if (true) { - return LexicalUnitImpl.createAdd(n.beginLine, - n.beginColumn, prev); - } - } - break; - case MINUS: - n = jj_consume_token(MINUS); - label_165: while (true) { - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[238] = jj_gen; - break label_165; - } - } - { - if (true) { - return LexicalUnitImpl.createMinus(n.beginLine, - n.beginColumn, prev); - } - } - break; - default: - jj_la1[239] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl expr() throws ParseException { - LexicalUnitImpl first, res; - char op; - first = term(null); - res = first; - label_166: while (true) { - if (jj_2_8(2)) { - ; - } else { - break label_166; - } - if (jj_2_9(2)) { - res = operator(res); - } else { - ; - } - res = term(res); - } - { - if (true) { - return first; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public char unaryOperator() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case MINUS: - jj_consume_token(MINUS); - { - if (true) { - return '-'; - } - } - break; - case PLUS: - jj_consume_token(PLUS); - { - if (true) { - return '+'; - } - } - break; - default: - jj_la1[240] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl term(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - result = nonVariableTerm(prev); - break; - case VARIABLE: - result = variableTerm(prev); - break; - default: - jj_la1[241] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl variableTerm(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - String varName = ""; - varName = variableName(); - result = LexicalUnitImpl.createVariable(token.beginLine, - token.beginColumn, prev, varName); - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - String varName; - String s = ""; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case NUMBER: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case FUNCTION: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - op = unaryOperator(); - break; - default: - jj_la1[242] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case NUMBER: - n = jj_consume_token(NUMBER); - result = LexicalUnitImpl.createNumber(n.beginLine, - n.beginColumn, prev, number(op, n, 0)); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - result = LexicalUnitImpl.createPercentage(n.beginLine, - n.beginColumn, prev, number(op, n, 1)); - break; - case PT: - n = jj_consume_token(PT); - result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case CM: - n = jj_consume_token(CM); - result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case MM: - n = jj_consume_token(MM); - result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case PC: - n = jj_consume_token(PC); - result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case IN: - n = jj_consume_token(IN); - result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case PX: - n = jj_consume_token(PX); - result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case EMS: - n = jj_consume_token(EMS); - result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case LEM: - n = jj_consume_token(LEM); - result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case REM: - n = jj_consume_token(REM); - result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case EXS: - n = jj_consume_token(EXS); - result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case DEG: - n = jj_consume_token(DEG); - result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case RAD: - n = jj_consume_token(RAD); - result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case GRAD: - n = jj_consume_token(GRAD); - result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case SECOND: - n = jj_consume_token(SECOND); - result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); - break; - case MS: - n = jj_consume_token(MS); - result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case HZ: - n = jj_consume_token(HZ); - result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case KHZ: - n = jj_consume_token(KHZ); - result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case DIMEN: - n = jj_consume_token(DIMEN); - s = n.image; - int i = 0; - while (i < s.length() - && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { - i++; - } - - result = LexicalUnitImpl.createDimen(n.beginLine, - n.beginColumn, prev, number(op, n, s.length() - i), - s.substring(i)); - break; - case FUNCTION: - result = function(op, prev); - break; - default: - jj_la1[243] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case URL: - case HASH: - case UNICODERANGE: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STRING: - n = jj_consume_token(STRING); - result = LexicalUnitImpl.createString(n.beginLine, - n.beginColumn, prev, - convertStringIndex(n.image, 1, n.image.length() - 1)); - break; - case DOT: - case TO: - case THROUGH: - case FROM: - case IDENT: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DOT: - jj_consume_token(DOT); - s += "."; - break; - default: - jj_la1[244] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - break; - case TO: - n = jj_consume_token(TO); - break; - case THROUGH: - n = jj_consume_token(THROUGH); - break; - case FROM: - n = jj_consume_token(FROM); - break; - default: - jj_la1[245] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - s += convertIdent(n.image); - if ("inherit".equals(s)) { - result = LexicalUnitImpl.createInherit(n.beginLine, - n.beginColumn, prev); - } else { - result = LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, prev, convertIdent(n.image)); - } - - /* - * / Auto correction code used in the CSS Validator but must not - * be used by a conformant CSS2 parser. Common error : H1 { - * color : black background : white } - * - * Token t = getToken(1); Token semicolon = new Token(); - * semicolon.kind = SEMICOLON; semicolon.image = ";"; if (t.kind - * == COLON) { // @@SEEME. (generate a warning?) // @@SEEME if - * expression is a single ident, generate an error ? - * rejectToken(semicolon); - * - * result = prev; } / - */ - - break; - case HASH: - result = hexcolor(prev); - break; - case URL: - result = url(prev); - break; - case UNICODERANGE: - result = unicode(prev); - break; - default: - jj_la1[246] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[247] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_167: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[248] = jj_gen; - break label_167; - } - jj_consume_token(S); - } - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * Handle all CSS2 functions. - * - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) - throws ParseException { - Token n; - LexicalUnit params = null; - n = jj_consume_token(FUNCTION); - label_168: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[249] = jj_gen; - break label_168; - } - jj_consume_token(S); - } - String fname = convertIdent(n.image); - if ("alpha(".equals(fname)) { - String body = skipStatementUntilSemiColon(); - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, null, "alpha(" + body); - } - } - } else if ("expression(".equals(fname)) { - String body = skipStatementUntilSemiColon(); - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, null, "expression(" + body); - } - } - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - params = expr(); - break; - default: - jj_la1[250] = jj_gen; - ; - } - jj_consume_token(RPARAN); - if (operator != ' ') { - { - if (true) { - throw new CSSParseException( - "invalid operator before a function.", getLocator()); - } - } - } - String f = convertIdent(n.image); - LexicalUnitImpl l = (LexicalUnitImpl) params; - boolean loop = true; - if ("rgb(".equals(f)) { - // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 2: - case 4: - if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) - && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - if (loop) { - l = l.getNextLexicalUnit(); - i++; - } - } - if ((i == 5) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createRGBColor(n.beginLine, - n.beginColumn, prev, params); - } - } - } else { - if (errorHandler != null) { - String errorText; - Locator loc; - if (i < 5) { - if (params == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn - 1); - errorText = "not enough parameters."; - } else if (l == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn - 1); - errorText = "not enough parameters: " - + params.toString(); - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "invalid parameter: " + l.toString(); - } - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "too many parameters: " + l.toString(); - } - errorHandler.error(new CSSParseException(errorText, loc)); - } - - { - if (true) { - throw new JumpException(); - } - } - } - } else if ("counter".equals(f)) { - int i = 0; - while (loop && l != null && i < 3) { - switch (i) { - case 0: - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 1: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if (((i == 1) || (i == 3)) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createCounter(n.beginLine, - n.beginColumn, prev, params); - } - } - } - - } else if ("counters(".equals(f)) { - - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 4: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if (((i == 3) || (i == 5)) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createCounters(n.beginLine, - n.beginColumn, prev, params); - } - } - } - } else if ("attr(".equals(f)) { - if ((l != null) && (l.getNextLexicalUnit() == null) - && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { - { - if (true) { - return LexicalUnitImpl.createAttr(l.getLineNumber(), - l.getColumnNumber(), prev, l.getStringValue()); - } - } - } - } else if ("rect(".equals(f)) { - int i = 0; - while (loop && l != null && i < 7) { - switch (i) { - case 0: - case 2: - case 4: - case 6: - switch (l.getLexicalUnitType()) { - case LexicalUnit.SAC_INTEGER: - if (l.getIntegerValue() != 0) { - loop = false; - } - break; - case LexicalUnit.SAC_IDENT: - if (!l.getStringValue().equals("auto")) { - loop = false; - } - break; - case LexicalUnit.SAC_EM: - case LexicalUnit.SAC_EX: - case LexicalUnit.SAC_PIXEL: - case LexicalUnit.SAC_CENTIMETER: - case LexicalUnit.SAC_MILLIMETER: - case LexicalUnit.SAC_INCH: - case LexicalUnit.SAC_POINT: - case LexicalUnit.SAC_PICA: - // nothing - break; - default: - loop = false; - } - break; - case 1: - case 3: - case 5: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if ((i == 7) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createRect(n.beginLine, - n.beginColumn, prev, params); - } - } - } - } - { - if (true) { - return LexicalUnitImpl.createFunction(n.beginLine, - n.beginColumn, prev, f.substring(0, f.length() - 1), - params); - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl unicode(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(UNICODERANGE); - LexicalUnitImpl params = null; - String s = n.image.substring(2); - int index = s.indexOf('-'); - if (index == -1) { - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s, 16)); - } else { - String s1 = s.substring(0, index); - String s2 = s.substring(index); - - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s1, 16)); - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s2, 16)); - } - - { - if (true) { - return LexicalUnitImpl.createUnicodeRange(n.beginLine, - n.beginColumn, prev, params); - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl url(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(URL); - String urlname = n.image.substring(4, n.image.length() - 1).trim(); - { - if (true) { - return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, - prev, urlname); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl hexcolor(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(HASH); - int r; - LexicalUnitImpl first, params = null; - String s = n.image.substring(1); - - if (s.length() != 3 && s.length() != 6) { - first = null; - { - if (true) { - throw new CSSParseException( - "invalid hexadecimal notation for RGB: " + s, - getLocator()); - } - } - } - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, n.image); - } - } - throw new Error("Missing return statement in function"); - } - - float number(char operator, Token n, int lengthUnit) throws ParseException { - String image = n.image; - float f = 0; - - if (lengthUnit != 0) { - image = image.substring(0, image.length() - lengthUnit); - } - f = Float.valueOf(image).floatValue(); - return (operator == '-') ? -f : f; - } - - String skipStatementUntilSemiColon() throws ParseException { - int[] semicolon = { SEMICOLON }; - return skipStatementUntil(semicolon); - } - - String skipStatementUntilLeftBrace() throws ParseException { - int[] lBrace = { LBRACE }; - return skipStatementUntil(lBrace); - } - - String skipStatementUntilMatchingRightParan() throws ParseException { - int[] leftTokens = { LPARAN, FUNCTION }; // a FUNCTION also contains "(" - int[] rightTokens = { RPARAN }; - StringBuffer s = new StringBuffer(); - int difference = 1; - Token tok; - while (difference != 0) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - for (int sym : leftTokens) { - if (tok.kind == sym) { - difference++; - } - } - for (int sym : rightTokens) { - if (tok.kind == sym) { - difference--; - } - } - if (difference != 0) { - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); - } - - String skipStatementUntil(int[] symbols) throws ParseException { - StringBuffer s = new StringBuffer(); - boolean stop = false; - Token tok; - while (!stop) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - for (int sym : symbols) { - if (tok.kind == sym) { - stop = true; - break; - } - } - if (!stop) { - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); - } - - String skipStatement() throws ParseException { - StringBuffer s = new StringBuffer(); - Token tok = getToken(0); - if (tok.image != null) { - s.append(tok.image); - } - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - getNextToken(); - s.append(skip_to_matching_brace()); - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == RBRACE) { - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == SEMICOLON) { - getNextToken(); - tok = getToken(1); - break; - } - getNextToken(); - } - - // skip white space - while (true) { - if (tok.kind != S) { - break; - } - tok = getNextToken(); - tok = getToken(1); - } - - return s.toString().trim(); - } - - String skip_to_matching_brace() throws ParseException { - StringBuffer s = new StringBuffer(); - Token tok; - int nesting = 1; - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - break; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - nesting++; - } else if (tok.kind == RBRACE) { - nesting--; - if (nesting == 0) { - break; - } - } - getNextToken(); - } - return s.toString(); - } - - String convertStringIndex(String s, int start, int len) - throws ParseException { - StringBuffer buf = new StringBuffer(len); - int index = start; - - while (index < len) { - char c = s.charAt(index); - if (c == '\u005c\u005c') { - if (++index < len) { - c = s.charAt(index); - switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - buf.append('\u005c\u005c'); - while (index < len) { - buf.append(s.charAt(index++)); - } - break; - case '\u005cn': - case '\u005cf': - break; - case '\u005cr': - if (index + 1 < len) { - if (s.charAt(index + 1) == '\u005cn') { - index++; - } - } - break; - default: - buf.append(c); - } - } else { - throw new CSSParseException("invalid string " + s, - getLocator()); - } - } else { - buf.append(c); - } - index++; - } - - return buf.toString(); - } - - String convertIdent(String s) throws ParseException { - return convertStringIndex(s, 0, s.length()); - } - - String convertString(String s) throws ParseException { - return convertStringIndex(s, 0, s.length()); - } - - void comments() throws ParseException { - /* - * keeps only the multiple line comments, single line comments are - * skipped - */ - if (token.specialToken != null && token.specialToken.image != null - && token.specialToken.image.startsWith("/*")) { - Token tmp_t = token.specialToken; - while (tmp_t.specialToken != null) { - tmp_t = tmp_t.specialToken; - } - while (tmp_t != null) { - documentHandler.comment(tmp_t.image); - tmp_t = tmp_t.next; - } - } - } - - void rejectToken(Token t) throws ParseException { - Token fakeToken = new Token(); - t.next = token; - fakeToken.next = t; - token = fakeToken; - } - - String skipAfterExpression() throws ParseException { - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - - while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - - return s.toString(); - } - - /** - * The following functions are useful for a DOM CSS implementation only and - * are not part of the general CSS2 parser. - */ - // TODO required by original parser but not used by Vaadin? - final public void _parseRule() throws ParseException { - String ret = null; - label_169: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[251] = jj_gen; - break label_169; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT_SYM: - importDeclaration(); - break; - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case MEDIA_SYM: - media(); - break; - case PAGE_SYM: - page(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[252] = jj_gen; - ret = skipStatement(); - if ((ret == null) || (ret.length() == 0)) { - { - if (true) { - return; - } - } - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - { - if (true) { - throw new CSSParseException("unrecognize rule: " + ret, - getLocator()); - } - } - } - } - } - - final public void _parseImportRule() throws ParseException { - label_170: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[253] = jj_gen; - break label_170; - } - jj_consume_token(S); - } - importDeclaration(); - } - - final public void _parseMediaRule() throws ParseException { - label_171: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[254] = jj_gen; - break label_171; - } - jj_consume_token(S); - } - media(); - } - - final public void _parseDeclarationBlock() throws ParseException { - label_172: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[255] = jj_gen; - break label_172; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[256] = jj_gen; - ; - } - label_173: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[257] = jj_gen; - break label_173; - } - jj_consume_token(SEMICOLON); - label_174: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[258] = jj_gen; - break label_174; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[259] = jj_gen; - ; - } - } - } - - final public ArrayList _parseSelectors() throws ParseException { - ArrayList p = null; - try { - label_175: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[260] = jj_gen; - break label_175; - } - jj_consume_token(S); - } - p = selectorList(); - { - if (true) { - return p; - } - } - } catch (ThrowedParseException e) { - { - if (true) { - throw (ParseException) e.e.fillInStackTrace(); - } - } - } - throw new Error("Missing return statement in function"); - } - - private boolean jj_2_1(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_1(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(0, xla); - } - } - - private boolean jj_2_2(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_2(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(1, xla); - } - } - - private boolean jj_2_3(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_3(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(2, xla); - } - } - - private boolean jj_2_4(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_4(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(3, xla); - } - } - - private boolean jj_2_5(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_5(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(4, xla); - } - } - - private boolean jj_2_6(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_6(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(5, xla); - } - } - - private boolean jj_2_7(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_7(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(6, xla); - } - } - - private boolean jj_2_8(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_8(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(7, xla); - } - } - - private boolean jj_2_9(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_9(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(8, xla); - } - } - - private boolean jj_3R_209() { - if (jj_scan_token(MINUS)) { - return true; - } - Token xsp; - if (jj_scan_token(1)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_188() { - if (jj_3R_210()) { - return true; - } - return false; - } - - private boolean jj_3R_208() { - if (jj_scan_token(PLUS)) { - return true; - } - Token xsp; - if (jj_scan_token(1)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_207() { - if (jj_scan_token(MOD)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_206() { - if (jj_scan_token(ANY)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_205() { - if (jj_scan_token(DIV)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_204() { - if (jj_scan_token(COMMA)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_185() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_204()) { - jj_scanpos = xsp; - if (jj_3R_205()) { - jj_scanpos = xsp; - if (jj_3R_206()) { - jj_scanpos = xsp; - if (jj_3R_207()) { - jj_scanpos = xsp; - if (jj_3R_208()) { - jj_scanpos = xsp; - if (jj_3R_209()) { - return true; - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_212() { - if (jj_3R_211()) { - return true; - } - return false; - } - - private boolean jj_3R_211() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(18)) { - jj_scanpos = xsp; - if (jj_scan_token(22)) { - jj_scanpos = xsp; - if (jj_scan_token(23)) { - return true; - } - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_191() { - if (jj_scan_token(S)) { - return true; - } - Token xsp; - xsp = jj_scanpos; - if (jj_3R_212()) { - jj_scanpos = xsp; - } - return false; - } - - private boolean jj_3R_210() { - if (jj_scan_token(GUARDED_SYM)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_176() { - if (jj_3R_186()) { - return true; - } - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_3R_187()) { - return true; - } - xsp = jj_scanpos; - if (jj_3R_188()) { - jj_scanpos = xsp; - } - if (jj_3R_189()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_189()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_190() { - if (jj_3R_211()) { - return true; - } - return false; - } - - private boolean jj_3R_177() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_190()) { - jj_scanpos = xsp; - if (jj_3R_191()) { - return true; - } - } - return false; - } - - private boolean jj_3R_194() { - if (jj_scan_token(VARIABLE)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(COLON)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_179() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_194()) { - jj_scanpos = xsp; - } - if (jj_scan_token(CONTAINS)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (true) { - jj_la = 0; - jj_scanpos = jj_lastpos; - return false; - } - return false; - } - - private boolean jj_3R_262() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } - - private boolean jj_3R_279() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_280() { - if (jj_scan_token(FUNCTION)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (true) { - jj_la = 0; - jj_scanpos = jj_lastpos; - return false; - } - return false; - } - - private boolean jj_3R_278() { - if (jj_scan_token(COLON)) { - return true; - } - return false; - } - - private boolean jj_3R_265() { - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - xsp = jj_scanpos; - if (jj_3R_278()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_3R_279()) { - jj_scanpos = xsp; - if (jj_3R_280()) { - return true; - } - } - return false; - } - - private boolean jj_3_7() { - if (jj_3R_183()) { - return true; - } - return false; - } - - private boolean jj_3R_201() { - if (jj_scan_token(LBRACE)) { - return true; - } - return false; - } - - private boolean jj_3R_290() { - if (jj_scan_token(STRING)) { - return true; - } - return false; - } - - private boolean jj_3R_288() { - if (jj_scan_token(STARMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_287() { - if (jj_scan_token(DOLLARMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_289() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_286() { - if (jj_scan_token(CARETMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_285() { - if (jj_scan_token(DASHMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_284() { - if (jj_scan_token(INCLUDES)) { - return true; - } - return false; - } - - private boolean jj_3R_270() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } - - private boolean jj_3R_283() { - if (jj_scan_token(EQ)) { - return true; - } - return false; - } - - private boolean jj_3R_200() { - if (jj_3R_187()) { - return true; - } - return false; - } - - private boolean jj_3R_277() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_283()) { - jj_scanpos = xsp; - if (jj_3R_284()) { - jj_scanpos = xsp; - if (jj_3R_285()) { - jj_scanpos = xsp; - if (jj_3R_286()) { - jj_scanpos = xsp; - if (jj_3R_287()) { - jj_scanpos = xsp; - if (jj_3R_288()) { - return true; - } - } - } - } - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_289()) { - jj_scanpos = xsp; - if (jj_3R_290()) { - return true; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3_6() { - if (jj_3R_182()) { - return true; - } - if (jj_scan_token(LBRACE)) { - return true; - } - return false; - } - - private boolean jj_3R_264() { - if (jj_scan_token(LBRACKET)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(IDENT)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_277()) { - jj_scanpos = xsp; - } - if (jj_scan_token(RBRACKET)) { - return true; - } - return false; - } - - private boolean jj_3R_183() { - if (jj_3R_199()) { - return true; - } - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_200()) { - jj_scanpos = xsp; - if (jj_3R_201()) { - return true; - } - } - return false; - } - - private boolean jj_3R_282() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } - - private boolean jj_3R_268() { - if (jj_3R_187()) { - return true; - } - return false; - } - - private boolean jj_3R_248() { - if (jj_scan_token(PARENT)) { - return true; - } - return false; - } - - private boolean jj_3R_247() { - if (jj_scan_token(ANY)) { - return true; - } - return false; - } - - private boolean jj_3R_261() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_269()) { - jj_scanpos = xsp; - if (jj_3R_270()) { - return true; - } - } - return false; - } - - private boolean jj_3R_269() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_213() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_246()) { - jj_scanpos = xsp; - if (jj_3R_247()) { - jj_scanpos = xsp; - if (jj_3R_248()) { - return true; - } - } - } - return false; - } - - private boolean jj_3R_246() { - Token xsp; - if (jj_3R_261()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_261()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_254() { - if (jj_scan_token(FUNCTION)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_268()) { - jj_scanpos = xsp; - } - if (jj_scan_token(RPARAN)) { - return true; - } - return false; - } - - private boolean jj_3R_180() { - if (jj_scan_token(COMMA)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_241() { - if (jj_3R_258()) { - return true; - } - return false; - } - - private boolean jj_3R_276() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_281()) { - jj_scanpos = xsp; - if (jj_3R_282()) { - return true; - } - } - return false; - } - - private boolean jj_3R_281() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_240() { - if (jj_3R_257()) { - return true; - } - return false; - } - - private boolean jj_3R_239() { - if (jj_3R_256()) { - return true; - } - return false; - } - - private boolean jj_3_5() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_180()) { - jj_scanpos = xsp; - } - if (jj_3R_181()) { - return true; - } - return false; - } - - private boolean jj_3R_263() { - if (jj_scan_token(DOT)) { - return true; - } - Token xsp; - if (jj_3R_276()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_276()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_252() { - if (jj_3R_265()) { - return true; - } - return false; - } - - private boolean jj_3R_275() { - if (jj_3R_265()) { - return true; - } - return false; - } - - private boolean jj_3R_273() { - if (jj_3R_263()) { - return true; - } - return false; - } - - private boolean jj_3R_250() { - if (jj_3R_263()) { - return true; - } - return false; - } - - private boolean jj_3R_251() { - if (jj_3R_264()) { - return true; - } - return false; - } - - private boolean jj_3R_274() { - if (jj_3R_264()) { - return true; - } - return false; - } - - private boolean jj_3R_255() { - if (jj_scan_token(DOT)) { - return true; - } - return false; - } - - private boolean jj_3R_271() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_272()) { - jj_scanpos = xsp; - if (jj_3R_273()) { - jj_scanpos = xsp; - if (jj_3R_274()) { - jj_scanpos = xsp; - if (jj_3R_275()) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_272() { - if (jj_3R_262()) { - return true; - } - return false; - } - - private boolean jj_3R_238() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_255()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_scan_token(72)) { - jj_scanpos = xsp; - if (jj_scan_token(49)) { - jj_scanpos = xsp; - if (jj_scan_token(50)) { - jj_scanpos = xsp; - if (jj_scan_token(52)) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_237() { - if (jj_scan_token(STRING)) { - return true; - } - return false; - } - - private boolean jj_3R_214() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_249()) { - jj_scanpos = xsp; - if (jj_3R_250()) { - jj_scanpos = xsp; - if (jj_3R_251()) { - jj_scanpos = xsp; - if (jj_3R_252()) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_249() { - if (jj_3R_262()) { - return true; - } - return false; - } - - private boolean jj_3R_236() { - if (jj_3R_254()) { - return true; - } - return false; - } - - private boolean jj_3R_196() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_237()) { - jj_scanpos = xsp; - if (jj_3R_238()) { - jj_scanpos = xsp; - if (jj_3R_239()) { - jj_scanpos = xsp; - if (jj_3R_240()) { - jj_scanpos = xsp; - if (jj_3R_241()) { - return true; - } - } - } - } - } - return false; - } - - private boolean jj_3R_193() { - Token xsp; - if (jj_3R_214()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_214()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_192() { - if (jj_3R_213()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_271()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_178() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_192()) { - jj_scanpos = xsp; - if (jj_3R_193()) { - return true; - } - } - return false; - } - - private boolean jj_3R_243() { - if (jj_3R_211()) { - return true; - } - if (jj_3R_178()) { - return true; - } - return false; - } - - private boolean jj_3R_235() { - if (jj_scan_token(DIMEN)) { - return true; - } - return false; - } - - private boolean jj_3R_234() { - if (jj_scan_token(KHZ)) { - return true; - } - return false; - } - - private boolean jj_3R_233() { - if (jj_scan_token(HZ)) { - return true; - } - return false; - } - - private boolean jj_3R_232() { - if (jj_scan_token(MS)) { - return true; - } - return false; - } - - private boolean jj_3R_231() { - if (jj_scan_token(SECOND)) { - return true; - } - return false; - } - - private boolean jj_3R_230() { - if (jj_scan_token(GRAD)) { - return true; - } - return false; - } - - private boolean jj_3R_229() { - if (jj_scan_token(RAD)) { - return true; - } - return false; - } - - private boolean jj_3R_228() { - if (jj_scan_token(DEG)) { - return true; - } - return false; - } - - private boolean jj_3R_227() { - if (jj_scan_token(EXS)) { - return true; - } - return false; - } - - private boolean jj_3R_226() { - if (jj_scan_token(REM)) { - return true; - } - return false; - } - - private boolean jj_3_2() { - if (jj_3R_177()) { - return true; - } - if (jj_3R_178()) { - return true; - } - return false; - } - - private boolean jj_3R_225() { - if (jj_scan_token(LEM)) { - return true; - } - return false; - } - - private boolean jj_3R_224() { - if (jj_scan_token(EMS)) { - return true; - } - return false; - } - - private boolean jj_3R_198() { - if (jj_scan_token(COMMA)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_3R_197()) { - return true; - } - return false; - } - - private boolean jj_3R_242() { - if (jj_3R_178()) { - return true; - } - return false; - } - - private boolean jj_3R_223() { - if (jj_scan_token(PX)) { - return true; - } - return false; - } - - private boolean jj_3R_222() { - if (jj_scan_token(IN)) { - return true; - } - return false; - } - - private boolean jj_3R_197() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_242()) { - jj_scanpos = xsp; - if (jj_3R_243()) { - return true; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { - jj_scanpos = xsp; - break; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_221() { - if (jj_scan_token(PC)) { - return true; - } - return false; - } - - private boolean jj_3R_220() { - if (jj_scan_token(MM)) { - return true; - } - return false; - } - - private boolean jj_3R_219() { - if (jj_scan_token(CM)) { - return true; - } - return false; - } - - private boolean jj_3R_218() { - if (jj_scan_token(PT)) { - return true; - } - return false; - } - - private boolean jj_3R_217() { - if (jj_scan_token(PERCENTAGE)) { - return true; - } - return false; - } - - private boolean jj_3R_203() { - if (jj_3R_245()) { - return true; - } - return false; - } - - private boolean jj_3_1() { - if (jj_3R_176()) { - return true; - } - return false; - } - - private boolean jj_3R_182() { - if (jj_3R_197()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_198()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_216() { - if (jj_scan_token(NUMBER)) { - return true; - } - return false; - } - - private boolean jj_3R_215() { - if (jj_3R_253()) { - return true; - } - return false; - } - - private boolean jj_3R_195() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_215()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_3R_216()) { - jj_scanpos = xsp; - if (jj_3R_217()) { - jj_scanpos = xsp; - if (jj_3R_218()) { - jj_scanpos = xsp; - if (jj_3R_219()) { - jj_scanpos = xsp; - if (jj_3R_220()) { - jj_scanpos = xsp; - if (jj_3R_221()) { - jj_scanpos = xsp; - if (jj_3R_222()) { - jj_scanpos = xsp; - if (jj_3R_223()) { - jj_scanpos = xsp; - if (jj_3R_224()) { - jj_scanpos = xsp; - if (jj_3R_225()) { - jj_scanpos = xsp; - if (jj_3R_226()) { - jj_scanpos = xsp; - if (jj_3R_227()) { - jj_scanpos = xsp; - if (jj_3R_228()) { - jj_scanpos = xsp; - if (jj_3R_229()) { - jj_scanpos = xsp; - if (jj_3R_230()) { - jj_scanpos = xsp; - if (jj_3R_231()) { - jj_scanpos = xsp; - if (jj_3R_232()) { - jj_scanpos = xsp; - if (jj_3R_233()) { - jj_scanpos = xsp; - if (jj_3R_234()) { - jj_scanpos = xsp; - if (jj_3R_235()) { - jj_scanpos = xsp; - if (jj_3R_236()) { - return true; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_181() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_195()) { - jj_scanpos = xsp; - if (jj_3R_196()) { - return true; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_256() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } - - private boolean jj_3_4() { - if (jj_3R_179()) { - return true; - } - return false; - } - - private boolean jj_3R_245() { - if (jj_3R_186()) { - return true; - } - return false; - } - - private boolean jj_3R_257() { - if (jj_scan_token(URL)) { - return true; - } - return false; - } - - private boolean jj_3R_202() { - if (jj_3R_181()) { - return true; - } - return false; - } - - private boolean jj_3R_260() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } - - private boolean jj_3R_184() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_202()) { - jj_scanpos = xsp; - if (jj_3R_203()) { - return true; - } - } - return false; - } - - private boolean jj_3_9() { - if (jj_3R_185()) { - return true; - } - return false; - } - - private boolean jj_3_3() { - if (jj_3R_176()) { - return true; - } - return false; - } - - private boolean jj_3R_267() { - if (jj_scan_token(PLUS)) { - return true; - } - return false; - } - - private boolean jj_3R_253() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_266()) { - jj_scanpos = xsp; - if (jj_3R_267()) { - return true; - } - } - return false; - } - - private boolean jj_3R_266() { - if (jj_scan_token(MINUS)) { - return true; - } - return false; - } - - private boolean jj_3R_258() { - if (jj_scan_token(UNICODERANGE)) { - return true; - } - return false; - } - - private boolean jj_3_8() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_9()) { - jj_scanpos = xsp; - } - if (jj_3R_184()) { - return true; - } - return false; - } - - private boolean jj_3R_186() { - if (jj_scan_token(VARIABLE)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_189() { - if (jj_scan_token(SEMICOLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_187() { - if (jj_3R_184()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_8()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_244() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_259()) { - jj_scanpos = xsp; - if (jj_3R_260()) { - return true; - } - } - return false; - } - - private boolean jj_3R_259() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_199() { - Token xsp; - if (jj_3R_244()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_244()) { - jj_scanpos = xsp; - break; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - /** Generated Token Manager. */ - public ParserTokenManager token_source; - /** Current token. */ - public Token token; - /** Next token. */ - public Token jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - private int jj_gen; - final private int[] jj_la1 = new int[261]; - static private int[] jj_la1_0; - static private int[] jj_la1_1; - static private int[] jj_la1_2; - static private int[] jj_la1_3; - static { - jj_la1_init_0(); - jj_la1_init_1(); - jj_la1_init_2(); - jj_la1_init_3(); - } - - private static void jj_la1_init_0() { - jj_la1_0 = new int[] { 0x0, 0x302, 0x302, 0x0, 0x300, 0x2, 0x2, 0x2, - 0xd4c40000, 0x0, 0x300, 0x2, 0x300, 0x2, 0x0, 0x2, 0x2, 0x2, - 0x0, 0x0, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x100000, 0x2, - 0x0, 0x2, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x2, 0x2, - 0xd4fd1500, 0xd4fd1500, 0x2, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, - 0x200000, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, - 0x0, 0x2, 0x391500, 0xc40000, 0xc40002, 0xc40000, 0x2, 0x2, - 0x80120002, 0x80120002, 0x2, 0x0, 0x0, 0x2, 0x2, 0x2, 0x2, - 0xd4c40000, 0xd4c40000, 0x2, 0x100000, 0x2, 0xd4c40000, 0x2, - 0x84000000, 0x84000000, 0x84000000, 0x84000000, 0xd4000000, - 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x2, 0x2, 0x3f000, 0x2, 0x0, - 0x2, 0x3f000, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x200000, 0x0, - 0xd4c40000, 0x0, 0x134e0002, 0x2, 0xd4c40000, 0xd4c40000, 0x2, - 0x0, 0x2, 0x134e0002, 0x0, 0x2, 0xd4c40000, 0xd4c40000, 0x2, - 0x134e0002, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0x2, 0x2, - 0x100000, 0x2, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0xd4c40000, - 0x2, 0x100000, 0x2, 0x2, 0x2, 0x100000, 0x0, 0x0, 0x800c0000, - 0x2, 0x0, 0x100000, 0x2, 0x800c0000, 0x2, 0x0, 0x2, 0x2, 0x0, - 0x2, 0x200000, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x200400, 0x2, - 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, - 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, 0x0, - 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, - 0x2, 0x100000, 0x0, 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x200000, - 0x2, 0x2, 0x200000, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, - 0x0, 0xd4c40000, 0x2, 0x0, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, - 0x800c0400, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, - 0x321c0000, 0xc0000, 0x800c0000, 0xc0000, 0x0, 0x80000000, 0x0, - 0x80000000, 0x800c0000, 0x2, 0x2, 0x800c0000, 0x2, 0xd4c40000, - 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, }; - } - - private static void jj_la1_init_1() { - jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x566000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, - 0x80, 0x0, 0x0, 0x120000, 0x120000, 0x0, 0x120000, 0x0, 0x0, - 0x0, 0x120000, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, - 0x60001c0, 0x60001c0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x80, 0x0, - 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, - 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc2, 0xc2, 0x0, 0x80, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, - 0xc0, 0x0, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x64000c0, 0x50000000, 0x3f, - 0x0, 0x564000c0, 0x564000c0, 0x0, 0x80000000, 0x0, 0x3f, 0x0, - 0x0, 0x564000c0, 0x564000c0, 0x0, 0x3f, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, - 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, - 0x40, 0x160040, 0x0, 0x40, 0x0, 0x0, 0x160040, 0x0, 0x40, 0x0, - 0x0, 0x80, 0x0, 0x0, 0x0, 0x61200c0, 0x61200c0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, - 0x6000000, 0x0, 0x0, 0x60000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x6000000, 0xc0, 0x0, - 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x160000, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x160000, 0x0, - 0x0, 0x0, 0x160000, 0x160000, 0x160000, 0x0, 0x0, 0x160000, - 0x0, 0x60000c0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, }; - } - - private static void jj_la1_init_2() { - jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, - 0x1000, 0x0, 0x0, 0x0, 0x0, 0x880, 0x0, 0x0, 0x0, 0x100, 0x100, - 0x0, 0x0, 0x2008, 0x2008, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x2000, - 0x0, 0x0, 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x2b80, 0x2b80, 0x0, - 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, - 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x2a80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x380, 0x380, 0x0, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, - 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, - 0x180, 0x0, 0x0, 0x0, 0x0, 0x100, 0x0, 0x40, 0x0, 0x0, 0x0, - 0x109, 0x1000, 0x1300, 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, - 0x1300, 0x20, 0x0, 0x1109, 0x1109, 0x0, 0x1300, 0x0, 0x0, 0x0, - 0x1100, 0x0, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, - 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000, - 0x1000, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0x0, - 0x0, 0x0, 0x1100, 0x0, 0x0, 0x0, 0x2100, 0x2100, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x100, - 0x0, 0x0, 0x100, 0x0, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0xffffe200, 0x0, - 0x100, 0x980, 0xffffeb80, 0x0, 0x0, 0xfffffb80, 0x0, 0x100, - 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, }; - } - - private static void jj_la1_init_3() { - jj_la1_3 = new int[] { 0x8, 0x80, 0x80, 0x2, 0x80, 0x0, 0x0, 0x0, 0x75, - 0x0, 0x80, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, - 0xc5, 0x0, 0x0, 0x0, 0xc401bf, 0xc401bf, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xc401be, 0x0, 0x0, 0x0, 0x0, 0x0, 0x400000, - 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc7, 0xc7, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x80, 0x200000, 0x0, - 0xe5, 0xe5, 0x0, 0x0, 0x0, 0x200000, 0x0, 0x0, 0xe5, 0xe5, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x400000, 0x0, 0xf5, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x440001, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, - 0x0, 0x0, 0x0, 0x400000, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x380000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x100, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x100, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x400000, - 0x0, 0x0, 0x40001, 0x440001, 0x0, 0x0, 0x440001, 0x0, 0x37, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }; - } - - final private JJCalls[] jj_2_rtns = new JJCalls[9]; - private boolean jj_rescan = false; - private int jj_gc = 0; - - /** Constructor with user supplied CharStream. */ - public Parser(CharStream stream) { - token_source = new ParserTokenManager(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); - } - } - - /** Reinitialise. */ - public void ReInit(CharStream stream) { - token_source.ReInit(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); - } - } - - /** Constructor with generated Token Manager. */ - public Parser(ParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); - } - } - - /** Reinitialise. */ - public void ReInit(ParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); - } - } - - private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) { - token = token.next; - } else { - token = token.next = token_source.getNextToken(); - } - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - if (++jj_gc > 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) { - c.first = null; - } - c = c.next; - } - } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - static private final class LookaheadSuccess extends java.lang.Error { - } - - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - - private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source - .getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; - Token tok = token; - while (tok != null && tok != jj_scanpos) { - i++; - tok = tok.next; - } - if (tok != null) { - jj_add_error_token(kind, i); - } - } - if (jj_scanpos.kind != kind) { - return true; - } - if (jj_la == 0 && jj_scanpos == jj_lastpos) { - throw jj_ls; - } - return false; - } - - /** Get the next Token. */ - final public Token getNextToken() { - if (token.next != null) { - token = token.next; - } else { - token = token.next = token_source.getNextToken(); - } - jj_ntk = -1; - jj_gen++; - return token; - } - - /** Get the specific Token. */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) { - t = t.next; - } else { - t = t.next = token_source.getNextToken(); - } - } - return t; - } - - private int jj_ntk() { - if ((jj_nt = token.next) == null) { - return (jj_ntk = (token.next = token_source.getNextToken()).kind); - } else { - return (jj_ntk = jj_nt.kind); - } - } - - private java.util.List jj_expentries = new java.util.ArrayList(); - private int[] jj_expentry; - private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; - private int jj_endpos; - - private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) { - return; - } - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - jj_entries_loop: for (java.util.Iterator it = jj_expentries - .iterator(); it.hasNext();) { - int[] oldentry = (int[]) (it.next()); - if (oldentry.length == jj_expentry.length) { - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - continue jj_entries_loop; - } - } - jj_expentries.add(jj_expentry); - break jj_entries_loop; - } - } - if (pos != 0) { - jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } - } - - /** Generate ParseException. */ - public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[120]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 261; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1 << j)) != 0) { - la1tokens[j] = true; - } - if ((jj_la1_1[i] & (1 << j)) != 0) { - la1tokens[32 + j] = true; - } - if ((jj_la1_2[i] & (1 << j)) != 0) { - la1tokens[64 + j] = true; - } - if ((jj_la1_3[i] & (1 << j)) != 0) { - la1tokens[96 + j] = true; - } - } - } - } - for (int i = 0; i < 120; i++) { - if (la1tokens[i]) { - jj_expentry = new int[1]; - jj_expentry[0] = i; - jj_expentries.add(jj_expentry); - } - } - jj_endpos = 0; - jj_rescan_token(); - jj_add_error_token(0, 0); - int[][] exptokseq = new int[jj_expentries.size()][]; - for (int i = 0; i < jj_expentries.size(); i++) { - exptokseq[i] = jj_expentries.get(i); - } - return new ParseException(token, exptokseq, tokenImage); - } - - /** Enable tracing. */ - final public void enable_tracing() { - } - - /** Disable tracing. */ - final public void disable_tracing() { - } - - private void jj_rescan_token() { - jj_rescan = true; - for (int i = 0; i < 9; i++) { - try { - JJCalls p = jj_2_rtns[i]; - do { - if (p.gen > jj_gen) { - jj_la = p.arg; - jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: - jj_3_1(); - break; - case 1: - jj_3_2(); - break; - case 2: - jj_3_3(); - break; - case 3: - jj_3_4(); - break; - case 4: - jj_3_5(); - break; - case 5: - jj_3_6(); - break; - case 6: - jj_3_7(); - break; - case 7: - jj_3_8(); - break; - case 8: - jj_3_9(); - break; - } - } - p = p.next; - } while (p != null); - } catch (LookaheadSuccess ls) { - } - } - jj_rescan = false; - } - - private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { - p = p.next = new JJCalls(); - break; - } - p = p.next; - } - p.gen = jj_gen + xla - jj_la; - p.first = token; - p.arg = xla; - } - - static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; - } - } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj deleted file mode 100644 index 5fb7f2315f..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ /dev/null @@ -1,3028 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* -*-java-extended-*- - * Copyright (c) 1999 World Wide Web Consortium - * (Massachusetts Institute of Technology, Institut National de Recherche - * en Informatique et en Automatique, Keio University). - * All Rights Reserved. http://www.w3.org/Consortium/Legal/ - * - * $Id: Parser.jj,v 1.15 2000/10/27 21:09:37 plehegar Exp $ - */ - -options { - IGNORE_CASE = true; - STATIC = false; - USER_CHAR_STREAM = true; - /* DEBUG_TOKEN_MANAGER = true; - DEBUG_PARSER = true; */ -} - -PARSER_BEGIN(Parser) - -package com.vaadin.sass.internal.parser; - -import java.io.*; -import java.net.*; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; - -import org.w3c.css.sac.ConditionFactory; -import org.w3c.css.sac.Condition; -import org.w3c.css.sac.SelectorFactory; -import org.w3c.css.sac.SelectorList; -import org.w3c.css.sac.Selector; -import org.w3c.css.sac.SimpleSelector; -import org.w3c.css.sac.DocumentHandler; -import org.w3c.css.sac.InputSource; -import org.w3c.css.sac.ErrorHandler; -import org.w3c.css.sac.CSSException; -import org.w3c.css.sac.CSSParseException; -import org.w3c.css.sac.Locator; -import org.w3c.css.sac.LexicalUnit; - -import org.w3c.flute.parser.selectors.SelectorFactoryImpl; -import org.w3c.flute.parser.selectors.ConditionFactoryImpl; - -import org.w3c.flute.util.Encoding; - -import com.vaadin.sass.internal.handler.*; - -import com.vaadin.sass.internal.tree.*; - -/** - * A CSS2 parser - * - * @author Philippe Le H�garet - * @version $Revision: 1.15 $ - */ -public class Parser implements org.w3c.css.sac.Parser { - - // replaces all \t, \n, etc with this StringBuffer. - static final StringBuilder SPACE = new StringBuilder(" "); - - // the document handler for the parser - protected SCSSDocumentHandlerImpl documentHandler; - // the error handler for the parser - protected ErrorHandler errorHandler; - // the input source for the parser - protected InputSource source; - - protected ConditionFactory conditionFactory; - protected SelectorFactory selectorFactory; - - // temporary place holder for pseudo-element ... - private String pseudoElt; - - /** - * Creates a new Parser - */ - public Parser() { - this((CharStream) null); - } - - /** - * @@TODO - * @exception CSSException Not yet implemented - */ - public void setLocale(Locale locale) throws CSSException { - throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); - } - - public InputSource getInputSource(){ - return source; - } - - /** - * Set the document handler for this parser - */ - public void setDocumentHandler(DocumentHandler handler) { - this.documentHandler = (SCSSDocumentHandlerImpl) handler; - } - - public void setSelectorFactory(SelectorFactory selectorFactory) { - this.selectorFactory = selectorFactory; - } - - public void setConditionFactory(ConditionFactory conditionFactory) { - this.conditionFactory = conditionFactory; - } - - /** - * Set the error handler for this parser - */ - public void setErrorHandler(ErrorHandler error) { - this.errorHandler = error; - } - - /** - * Main parse methods - * - * @param source the source of the style sheet. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleSheet(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - - parserUnit(); - } - - /** - * Convenient method for URIs. - * - * @param systemId the fully resolved URI of the style sheet. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleSheet(String systemId) - throws CSSException, IOException { - parseStyleSheet(new InputSource(systemId)); - } - - /** - * This method parses only one rule (style rule or at-rule, except @charset). - * - * @param source the source of the rule. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - // TODO required by original parser but not used by Vaadin? - public void parseRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseRule(); - } - - /** - * This method parses a style declaration (including the surrounding curly - * braces). - * - * @param source the source of the style declaration. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleDeclaration(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseDeclarationBlock(); - } - - /** - * This methods returns "http://www.w3.org/TR/REC-CSS2". - * @return the string "http://www.w3.org/TR/REC-CSS2". - */ - public String getParserVersion() { - return "http://www.w3.org/TR/REC-CSS2"; - } - - /** - * Parse methods used by DOM Level 2 implementation. - */ - public void parseImportRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseImportRule(); - } - - public void parseMediaRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseMediaRule(); - } - - public SelectorList parseSelectors(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return null; - } - - public LexicalUnit parsePropertyValue(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return expr(); - } - - public boolean parsePriority(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return prio(); - } - - /** - * Convert the source into a Reader. Used only by DOM Level 2 parser methods. - */ - private Reader getReader(InputSource source) throws IOException { - if (source.getCharacterStream() != null) { - return source.getCharacterStream(); - } else if (source.getByteStream() != null) { - // My DOM level 2 implementation doesn't use this case. - if (source.getEncoding() == null) { - // unknown encoding, use ASCII as default. - return new InputStreamReader(source.getByteStream(), "ASCII"); - } else { - return new InputStreamReader(source.getByteStream(), - source.getEncoding()); - } - } else { - // systemId - // @@TODO - throw new CSSException("not yet implemented"); - } - } - - /** - * Convert the source into a CharStream with encoding informations. - * The encoding can be found in the InputSource or in the CSS document. - * Since this method marks the reader and make a reset after looking for - * the charset declaration, you'll find the charset declaration into the - * stream. - */ - private CharStream getCharStreamWithLurk(InputSource source) - throws CSSException, IOException { - if (source.getCharacterStream() != null) { - // all encoding are supposed to be resolved by the user - // return the reader - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } else if (source.getByteStream() == null) { - // @@CONTINUE ME. see also getReader() with systemId - try { - source.setByteStream(new URL(source.getURI()).openStream()); - } catch (Exception e) { - try { - source.setByteStream(new FileInputStream(source.getURI())); - } catch (IOException ex) { - throw new CSSException("invalid url ?"); - } - } - } - //use UTF-8 as the default encoding. - String encoding = source.getEncoding(); - InputStream input = source.getByteStream(); - if (!input.markSupported()) { - // If mark is not supported, wrap it in a stream which supports mark - input = new BufferedInputStream(input); - source.setByteStream(input); - } - // Mark either the original stream or the wrapped stream - input.mark(100); - if(encoding == null){ - encoding = "ASCII"; - - char c = ' '; - - c = (char) input.read(); - - if (c == '@') { - // hum, is it a charset ? - int size = 100; - byte[] buf = new byte[size]; - input.read(buf, 0, 7); - String keyword = new String(buf, 0, 7); - if (keyword.equals("charset")) { - // Yes, this is the charset declaration ! - - // here I don't use the right declaration : white space are ' '. - while ((c = (char) input.read()) == ' ') { - // find the first quote - } - char endChar = c; - int i = 0; - - if ((endChar != '"') && (endChar != '\'')) { - // hum this is not a quote. - throw new CSSException("invalid charset declaration"); - } - - while ((c = (char) input.read()) != endChar) { - buf[i++] = (byte) c; - if (i == size) { - byte[] old = buf; - buf = new byte[size + 100]; - System.arraycopy(old, 0, buf, 0, size); - size += 100; - } - } - while ((c = (char) input.read()) == ' ') { - // find the next relevant character - } - if (c != ';') { - // no semi colon at the end ? - throw new CSSException("invalid charset declaration: " - + "missing semi colon"); - } - encoding = new String(buf, 0, i); - if (source.getEncoding() != null) { - // compare the two encoding informations. - // For example, I don't accept to have ASCII and after UTF-8. - // Is it really good ? That is the question. - if (!encoding.equals(source.getEncoding())) { - throw new CSSException("invalid encoding information."); - } - } - } // else no charset declaration available - } - } - // ok set the real encoding of this source. - source.setEncoding(encoding); - // set the real reader of this source. - source.setCharacterStream(new InputStreamReader(source.getByteStream(), - Encoding.getJavaEncoding(encoding))); - // reset the stream (leave the charset declaration in the stream). - input.reset(); - - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } - - private LocatorImpl currentLocator; - private Locator getLocator() { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this); - return currentLocator; - } - return currentLocator.reInit(this); - } - private LocatorImpl getLocator(Token save) { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this, save); - return currentLocator; - } - return currentLocator.reInit(this, save); - } - - private void reportError(Locator l, Exception e) { - if (errorHandler != null) { - if (e instanceof ParseException) { - // construct a clean error message. - ParseException pe = (ParseException) e; - if (pe.specialConstructor) { - StringBuffer errorM = new StringBuffer(); - if (pe.currentToken != null) { - errorM.append("encountered \"") - .append(pe.currentToken.next); - } - errorM.append('"'); - if (pe.expectedTokenSequences.length != 0) { - errorM.append(". Was expecting one of: "); - for (int i = 0; i < pe.expectedTokenSequences.length; i++) { - for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { - int kind = pe.expectedTokenSequences[i][j]; - if (kind != S) { - errorM.append(pe.tokenImage[kind]); - errorM.append(' '); - } - } - } - } - errorHandler.error(new CSSParseException(errorM.toString(), - l, e)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), - l, e)); - } - } else if (e == null) { - errorHandler.error(new CSSParseException("error", l, null)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), l, e)); - } - } - } - - private void reportWarningSkipText(Locator l, String text) { - if (errorHandler != null && text != null) { - errorHandler.warning(new CSSParseException("Skipping: " + text, l)); - } - } -} - -PARSER_END(Parser) - -/* - * The tokenizer - */ - - -TOKEN : -{ - < S : ( [ " ", "\t" , "\n" , "\r", "\f" ] )+ > - { image = Parser.SPACE; } -} - -/* - * for fixing #11638: Ending an imported SCSS file with a comment causes an error in the Sass. - * now the single line comment is parsed as special token, before, they were simply skipped. - * solution got from http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.15 - */ - -SPECIAL_TOKEN : { -< SINGLE_LINE_COMMENT: "//"(~["\n","\r"])* ("\n"|"\r"|"\r\n")? > } - - -MORE : -{ - <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT -| - "/*" : IN_MULTI_LINE_COMMENT -} - -SPECIAL_TOKEN : -{ - : DEFAULT -} - - -SKIP : -{ - : DEFAULT -} - - -MORE : -{ - < ~[] > -} - - -TOKEN : -{ - < CDO : "" > - | < LBRACE : "{" > - | < RBRACE : "}"> - | < DASHMATCH : "|=" > - | < CARETMATCH : "^=" > - | < DOLLARMATCH : "$=" > - | < STARMATCH : "*=" > - | < INCLUDES : "~=" > - | < EQ : "=" > - | < PLUS : "+" > - | < MINUS : "-" > - | < COMMA : "," > - | < SEMICOLON : ";" > - | < PRECEDES : ">" > - | < SIBLING : "~" > - | < SUCCEEDS : "<" > - | < DIV : "/" > - | < LBRACKET : "[" > - | < RBRACKET : "]" > - | < ANY : "*" > - | < MOD : "%" > - | < PARENT : "&" > - | < DOT : "." > - | < LPARAN : "(" > - | < RPARAN : ")"> - | < COMPARE : "==" > - | < OR : "||" > - | < AND : "&&" > - | < NOT_EQ : "!=" > -} - - -TOKEN : -{ - < COLON : ":" > -} - -< DEFAULT > -TOKEN : -{ - < INTERPOLATION : "#{"< VARIABLE > "}"> -} - - -TOKEN : /* basic tokens */ -{ - < NONASCII : ["\200"-"\377"] > - | < #H : ["0"-"9", "a"-"f"] > - | < #UNICODE : "\\" ( )? /* I can't say {1,6} */ - ( )? ( )? - ( )? ( )? - ( [ " ", "\t" , "\n" , "\r", "\f" ] )? > - | < #ESCAPE : | ( "\\" [ " "-"~","\200"-"\377" ] ) > - | < #NMSTART : ("-")?[ "a"-"z","_"] | | > - | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > - | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"~" ] - | "\\\n" | "\\\r\n" | "\\\r" | "\\\f" - | | > - | < #D : ["0"-"9"] > - | < #NAME : ( )+ > - -} - - -TOKEN : -{ - - | - | - | -} - -/* DERECTIVES */ - -TOKEN : -{ - - | - | - | - | - | - | - | - | - | - | - | - | - | - | -} - -< DEFAULT > -TOKEN: -{ - < MICROSOFT_RULE : "filter"|"-ms-filter" > -} - -< DEFAULT > -TOKEN: -{ - < IF : "if" > -} - - -TOKEN: -{ - < GUARDED_SYM : "!" ( )? "default"> -} - - -TOKEN : -{ - < STRING : ( "\"" ( | "'" )* "\"" ) | - ( "'" ( | "\"" )* "'" ) > - | < IDENT : ( )* > - | < NUMBER : ( )+ | ( )* "." ( )+ > - | < #_URL : [ "!","#","$","%","&","*"-"~" ] | | > - | < URL : "url(" ( )* - ( | ( <_URL> )* ) ( )* ")" > -} - - -TOKEN: -{ - < VARIABLE : "$" > -} - - -TOKEN : -{ - < PERCENTAGE : "%" > - | < PT : "pt" > - | < MM : "mm" > - | < CM : "cm" > - | < PC : "pc" > - | < IN : "in" > - | < PX : "px" > - | < EMS : "em" > - | < LEM : "lem" > - | < REM : "rem" > - | < EXS : "ex" > - | < DEG : "deg" > - | < RAD : "rad" > - | < GRAD : "grad" > - | < MS : "ms" > - | < SECOND : "s" > - | < HZ : "Hz" > - | < KHZ : "kHz" > - | < DIMEN : > -} - - -TOKEN : -{ - < HASH : "#" > -} - -/* RESERVED ATRULE WORDS */ - -TOKEN : -{ - < IMPORT_SYM : "@import"> - | < MEDIA_SYM : "@media" > - | < CHARSET_SYM : "@charset" > - | < PAGE_SYM : "@page" > - | < FONT_FACE_SYM: "@font-face" > - | < KEY_FRAME_SYM: "@keyframes" | "@-moz-keyframes" | "@-o-keyframes" | "@-webkit-keyframes" | "@-ms-keyframes"> - | < ATKEYWORD : "@" > -} - - -TOKEN : -{ - < IMPORTANT_SYM : "!" ( )? "important" > -} - - -TOKEN : -{ - < #RANGE0 : > - | < #RANGE1 : ( "?" )? > - | < #RANGE2 : ( "?" )? ( "?" )? > - | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE : | | - | | | | > - | < #UNI : ( )? ( )? ( )? ( )? ( )? > - | < UNICODERANGE : "U+" - | "U+" "-" > -} - -< DEFAULT > -TOKEN : -{ - < REMOVE : "remove" (< S >)? "(" > - | < APPEND : "append" (< S >)? "(" > - | < CONTAINS : "contains" (< S >)? "(" > -} - - -TOKEN : -{ - < FUNCTION : (< S >)* "(" > -} - - -TOKEN : -{ /* avoid token manager error */ - < UNKNOWN : ~[] > -} - -/* - * The grammar of CSS2 - */ - -/** - * The main entry for the parser. - * - * @exception ParseException exception during the parse - */ -void parserUnit() : -{} -{ - try { - { documentHandler.startDocument(source); } - ( charset() )? - ( comments() - | ignoreStatement() )* - ( importDeclaration() ( ignoreStatement() ( )* )* )* - afterImportDeclaration() - - } finally { - documentHandler.endDocument(source); - } -} - -void charset() : -{ Token n; } -{ - try { - ( )* n= ( )* ";" - } catch (ParseException e) { - reportError(getLocator(e.currentToken.next), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (Exception e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } -} - -void afterImportDeclaration() : -{String ret; - Locator l; -} -{ - ( - ( debuggingDirective() | mixinDirective() | controlDirective() | includeDirective() | styleRule() | media() - | page() | fontFace() | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() - | { l = getLocator(); } ret=skipStatement() - { - if ((ret == null) || (ret.length() == 0)) { - return; - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(l, ret); - } - } - ) - ( ignoreStatement() ( )* )* )* -} - -void ignoreStatement() : -{} -{ - | | atRuleDeclaration() -} - -/** - * The import statement - * - * @exception ParseException exception during the parse - */ -void importDeclaration() : -{Token n; - String uri; - MediaListImpl ml = new MediaListImpl(); - boolean isURL = false; -} -{ - try { - - ( )* ( n= { uri = convertStringIndex(n.image, 1, - n.image.length() -1); } - | n= - { - isURL=true; - uri = n.image.substring(4, n.image.length()-1).trim(); - if ((uri.charAt(0) == '"') - || (uri.charAt(0) == '\'')) { - uri = uri.substring(1, uri.length()-1); - } - } - ) - ( )* mediaStatement(ml) ";" - ( )* - { - if (ml.getLength() == 0) { - // see section 6.3 of the CSS2 recommandation. - ml.addItem("all"); - } - documentHandler.importStyle(uri, ml, isURL); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } -} - -/** - * @exception ParseException exception during the parse - */ -void keyframes() : -{ - Token n; - boolean start = false; - String keyframeName = null; - String animationname = ""; -} -{ - try { - n= ( )* {keyframeName = n.image;} - (n = {animationname += n.image; }|n = < INTERPOLATION >{ animationname += n.image; })+()* - {start = true; documentHandler.startKeyFrames(keyframeName, animationname); } - ( )* ( keyframeSelector() | contentDirective() )* ( )* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - } finally { - if (start) { - documentHandler.endKeyFrames(); - } - } -} - -void keyframeSelector(): -{ - Token n; - String selector = ""; - boolean start = false; -} -{ - try{ - (n = | n = | n = ){selector += n.image;} ()* - ( ()* (n = | n = | n = ) {selector += (", " + n.image);} ()* )* - ()* - { - start = true; - documentHandler.startKeyframeSelector(selector); - } - (ifContentStatement() | microsoftExtension() )* - ()* - } - catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn-1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endKeyframeSelector(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -/* see http://www.w3.org/TR/css3-mediaqueries/ */ -void media() : -{ - boolean start = false; - String ret; - MediaListImpl ml = new MediaListImpl(); -} -{ - try { - ( )* - mediaStatement(ml) - { start = true; documentHandler.startMedia(ml); } - ( )* ( debuggingDirective() | styleRule() | skipUnknownRule() )* ( )* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endMedia(ml); - } - } -} - -void mediaStatement(MediaListImpl ml) : -{ - Token t; -} -{ - { - t = getToken(1); - // loop over comma separated parts, add each to ml - while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - if (t.kind == COMMA) { - // skip the comma and the token before it that is still the active token - getNextToken(); - getNextToken(); - t = getToken(1); - } - String str = s.toString().trim(); - if (str.length() > 0) { - ml.addItem(str); - } - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String medium() : /* tv, projection, screen, ... */ -{Token n;} -{ - n= { return convertIdent(n.image); } -} - -/** - * @exception ParseException exception during the parse - */ -void page() : -{ - boolean start = false; - Token n = null; - String page = null; - String pseudo = null; -} -{ - try { - ( )* ( n= ( )* )? - ( pseudo=pseudo_page() )? - { - if (n != null) { - page = convertIdent(n.image); - } - } - ()* - { - start = true; - documentHandler.startPage(page, pseudo); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - } catch (ParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - skipStatement(); - // reportWarningSkipText(li, skipStatement()); - } else { - skipStatement(); - } - } finally { - if (start) { - documentHandler.endPage(page, pseudo); - } - } -} - -String pseudo_page() : -{ Token n; } -{ - ":" n= ( )* { return convertIdent(n.image); } -} - -void fontFace() : -{ - boolean start = false; -} -{ - try { - ( )* - ()* - { start = true; documentHandler.startFontFace(); } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endFontFace(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -void atRuleDeclaration() : -{Token n; - String ret; -} -{ - n= - { - ret=skipStatement(); - if ((ret != null) && (ret.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(getLocator(), ret); - } - } -} - -void skipUnknownRule() : -{ Token n;} -{ - ( n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n=";" -| n="-" -| n= - ) { - String ret; - Locator loc = getLocator(); - ret=skipStatement(); - if ((ret != null) && (n.image.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(loc, ret); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -char combinator() : -{ -char connector = ' '; -} -{ - (connector = combinatorChar() - | (connector = combinatorChar())?) { return connector; } -} - -/**to refactor combinator and reuse in selector().*/ -char combinatorChar() : -{Token t;} -{ - (t = | t = | t = ) ()* - { - return t.image.charAt(0); - } -} - -void microsoftExtension() : -{ - Token n; - String name = ""; - String value = ""; -} - -{ - // This is not really taking the syntax of filter rules into account - n = < MICROSOFT_RULE > (< S >)* { name = n.image; } - < COLON > - ((n = < IDENT > { value += n.image; }) - | (n = < NUMBER > { value += n.image; }) - | (n = < STRING > { value += n.image; }) - | (n = < COMMA > { value += n.image; }) - | (n = < INTERPOLATION > { value += n.image; }) - | (n = < COLON > { value += n.image; }) - | (n = < FUNCTION > { value += n.image; }) - | (n = < RPARAN > { value += n.image; }) - | (n = < EQ > { value += n.image; }) - | (n = < DOT > { value += n.image; }) - | (n = < S > { if(value.lastIndexOf(' ') != value.length()-1) - { value += n.image; } } - ) )+ - < SEMICOLON > - (< S >)* - { documentHandler.microsoftDirective(name, value); } -} - -/** - * @exception ParseException exception during the parse - */ -String property() : -{Token t;String s = ""; -} -{ - (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+(< S >)* - { - return s; - } -} - -String variableName() : -{Token n;} -{ - n= ()* {return convertIdent(n.image.substring(1));} -} - -String functionName() : -{Token n;} -{ - n= ( )* {return convertIdent(n.image.substring(0, n.image.length()-1));} -} -/** - * @exception ParseException exception during the parse - */ -void styleRule() : -{ - boolean start = false; - ArrayList l = null; - Token save; - Locator loc; -} -{ - try { - l=selectorList() { save = token; } ()* - { - start = true; - documentHandler.startSelector(l); - } - // a CSS import here will not work - ( ifContentStatement() | microsoftExtension() | importDeclaration() )* - ()* - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn-1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endSelector(); - } - } -} - - ArrayList selectorList() : -{ - ArrayList selectors = new ArrayList(); - String selector; -} -{ - selector=selector() ( ()* { selectors.add(selector); } - selector=selector() )* - { selectors.add(selector); - return selectors; - } -} - -/** - * @exception ParseException exception during the parse - */ -String selector() : -{ - String selector = null; - char comb; -} -{ - try { - // the selector can begin either a simple_selector, or a combinatorChar(+, >, ~). - // when beginning with combinatorChar, the next one should be a simple_selector(). - (selector=simple_selector(null, ' ') | (comb=combinatorChar() selector=simple_selector(selector, comb))) - ( LOOKAHEAD(2) comb=combinator() - selector=simple_selector(selector, comb) )* ()* - { - return selector; - } - } catch (ParseException e) { - /* - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - reportWarningSkipText(getLocator(), s.toString()); - */ - Token t = getToken(1); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - getNextToken(); - t = getToken(1); - } - - throw new ThrowedParseException(e); - } -} - -/** - * @exception ParseException exception during the parse - */ -String simple_selector(String selector, char comb) : -{ - String simple_current = null; - String cond = null; - - pseudoElt = null; -} -{ - ( (simple_current=element_name() - ( cond=hash(cond) | cond=_class(cond) - | cond=attrib(cond) | cond=pseudo(cond) )* ) - | ( cond = hash(cond) | cond=_class(cond) - | cond=attrib(cond) | cond=pseudo(cond) )+ - ) - { - if (simple_current == null) { - simple_current = ""; - } - if (cond != null) { - simple_current = simple_current + cond; - } - StringBuilder builder = new StringBuilder(); - switch (comb) { - case ' ': - if(selector!=null){ - builder.append(selector).append(" "); - } - break; - case '+': - case '>': - case '~': - if(selector!=null){ - builder.append(selector).append(" "); - } - builder.append(comb).append(" "); - break; - default: - throw new ParseException("invalid state. send a bug report"); - } - builder.append(simple_current); - selector = builder.toString(); - - if (pseudoElt != null) { - selector = selector + pseudoElt; - } - return selector; - } -} - -/** - * @exception ParseException exception during the parse - */ -String _class(String pred) : -{Token t; -String s = "."; -} -{ - "." (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ - { - - if (pred == null) { - return s; - } else { - return pred + s; - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String element_name() : -{Token t; String s = "";} -{ - (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ - { - return s; - } - | "*" - { return "*"; } - | "&" - { return "&"; } -} - -/** - * @exception ParseException exception during the parse - */ -String attrib(String pred) : -{ - int cases = 0; - Token att = null; - Token val = null; - String attValue = null; -} -{ - "[" ( )* att= ( )* - ( ( "=" { cases = 1; } - | { cases = 2; } - | { cases = 3; } - | { cases = 4; } - | { cases = 5; } - | { cases = 6; } ) ( )* - ( val= { attValue = val.image; } - | val= { attValue = val.image; } - ) - ( )* )? - "]" - { - String name = convertIdent(att.image); - String c; - switch (cases) { - case 0: - c = name; - break; - case 1: - c = name + "=" + attValue; - break; - case 2: - c = name + "~=" + attValue; - break; - case 3: - c = name + "|=" +attValue; - break; - case 4: - c = name + "^=" +attValue; - break; - case 5: - c = name + "$=" +attValue; - break; - case 6: - c = name + "*=" +attValue; - break; - default: - // never reached. - c = null; - } - c = "[" + c + "]"; - if (pred == null) { - return c; - } else { - return pred + c; - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String pseudo(String pred) : -{Token n; -Token param; -String d; -boolean isPseudoElement = false; -} -{ - ":" (":"{isPseudoElement=true;})?( n= - { - String s = ":" + convertIdent(n.image); - if (isPseudoElement) { - if (pseudoElt != null) { - throw new CSSParseException("duplicate pseudo element definition " - + s, getLocator()); - } else { - pseudoElt = ":"+s; - return pred; - } - } else { - String c = s; - if (pred == null) { - return c; - } else { - return pred + c; - } - } - } - | ( n= ( )* d=skipStatementUntilMatchingRightParan() - { - // accept anything between function and a right parenthesis - String f = convertIdent(n.image); - String colons = isPseudoElement ? "::" : ":"; - String pseudofn = colons + f + d + ")"; - if (pred == null) { - return pseudofn; - } else { - return pred + pseudofn; - } - } - ) - ) -} - -/** - * @exception ParseException exception during the parse - */ -String hash(String pred) : -{Token n; } -{ - n= - { - String d = n.image; - if (pred == null) { - return d; - } else { - return pred + d; - } - } -} - -void variable() : -{ - String name; - LexicalUnitImpl exp = null; - boolean guarded = false; - String raw; -} -{ - try{ - name = variableName() - ":" ( )* exp=expr() ( guarded=guarded() )?(";"()*)+ - //raw=skipStatementUntilSemiColon() - { - documentHandler.variable(name, exp, guarded); - } - }catch (JumpException e) { - skipAfterExpression(); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - } else { - skipAfterExpression(); - } - } -} - -void controlDirective() : -{} -{ - ifDirective() | eachDirective() -} - -void ifContentStatement() : -{} -{ - contentDirective() | includeDirective() | media() | extendDirective() | styleRuleOrDeclarationOrNestedProperties() - | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() | controlDirective() | atRuleDeclaration() -} - -void ifDirective() : -{ - Token n = null; - String s = null; - String evaluator = ""; -} -{ - < IF_SYM > - ( s = booleanExpressionToken() { evaluator += s;} )+ - < LBRACE >(< S >)* - { documentHandler.startIfElseDirective(); - documentHandler.ifDirective(evaluator); - } - ( ifContentStatement() | fontFace() )* - < RBRACE >(< S >)* - (elseDirective())* - { documentHandler.endIfElseDirective(); } -} - -void elseDirective() : -{ - String evaluator = ""; - Token n = null; - String s = null; -} -{ - < ELSE_SYM >(< S >)* - ( < IF > ( s = booleanExpressionToken() { evaluator += s; } )+ )? - < LBRACE >(< S >)* - { if(!evaluator.trim().equals("")){ documentHandler.ifDirective(evaluator); } - else{ documentHandler.elseDirective(); } - } - ( ifContentStatement() | fontFace() )* - < RBRACE >(< S >)* -} - -String booleanExpressionToken() : -{ - Token n = null; - String s = null; -} -{ - ( - LOOKAHEAD(containsDirective()) - s = containsDirective() - |n = < VARIABLE > - |n = < IDENT > - |n = < NUMBER > - |n = < LPARAN > - |n = < RPARAN > - |n = < PLUS > - |n = < MINUS > - |n = < DIV > - |n = < ANY > - |n = < COMPARE > - |n = < EQ > - |n = < PRECEDES > - |n = < SUCCEEDS > - |n = < OR > - |n = < AND > - |n = < S > - |n = < NOT_EQ > -){ - if(n!=null){return n.image;} - else{return s;} - } -} - -void eachDirective() : -{ - Token var; - ArrayList list = null; - String listVariable = null; -} -{ - < EACH_SYM > - (< S >)* - var = < VARIABLE > (< S >)* < EACH_IN > (< S >)* - (list = stringList() - {documentHandler.startEachDirective(var.image, list);} - |listVariable = variableName() - {documentHandler.startEachDirective(var.image, listVariable);} - ) - < LBRACE >(< S >)* - ( ifContentStatement() )* - < RBRACE >(< S >)* - { documentHandler.endEachDirective();} -} - -ArrayList stringList(): -{ - ArrayList strings = new ArrayList(); - Token input; -} -{ - (input = < IDENT > (< S >)*) - { strings.add(input.image); } - - (< COMMA >(< S >)* input = < IDENT > { strings.add(input.image); } (< S >)*)* - { return strings; } - -} - -void mixinDirective() : -{ - String name; - ArrayList args = null; - String body; -} -{ - - ()* - (name = property() - |(name = functionName() - args = arglist()) ()*) ()* - {documentHandler.startMixinDirective(name, args);} - ( ifContentStatement() | fontFace() | page())* - ()* - {documentHandler.endMixinDirective(name, args);} -} - -ArrayList arglist() : -{ - ArrayList args = new ArrayList(); - VariableNode arg; - boolean hasNonOptionalArgument = false; -} -{ - arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } - arg=mixinArg() )* - { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); - return args; - } -} - -JAVACODE -boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { - boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; - if(currentArgHasArguments) { - if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); - } - return hasNonOptionalArguments; - }else { return true; - } -} - -VariableNode mixinArg() : -{ - String name; - Token variable = null; - LexicalUnitImpl first = null; - LexicalUnitImpl prev = null; - LexicalUnitImpl next = null; -} -{ - name=variableName() (< COLON > (< S >)* - - ( first = nonVariableTerm(null) { - prev = first; } - (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) - | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, variable.image);} - - ) - )? - { - VariableNode arg = new VariableNode(name, first, false); - return arg; - } -} - -ArrayList argValuelist() : -{ - ArrayList args = new ArrayList(); - LexicalUnitImpl first = null; - LexicalUnitImpl next = null; - LexicalUnitImpl prev = null; -} -{ - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - ( ()* - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - )* - {return args;} -} - -void includeDirective() : -{ - String name; - ArrayList args=null; -} -{ - - ()* - (name = property()|name = variableName(){ name = "$"+name;} - |(name = functionName() - args = argValuelist()) ()*) - ((";"()*)+ - {documentHandler.includeDirective(name, args);} - | ()* {documentHandler.startIncludeContentBlock(name, args);} - (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* - ()* {documentHandler.endIncludeContentBlock();} - ) -} - -String interpolation() : -{ - Token n; -} -{ - n = < INTERPOLATION > - { - return n.image; - } -} - -void listModifyDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - Token type = null; -} -{ - //refactor, remove those 3 LOOKAHEAD(5). - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - (type = < APPEND> | type = | type= )(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - { - switch (type.kind) { - case APPEND: - documentHandler.appendDirective(variable,list,remove,separator); - break; - case REMOVE: - documentHandler.removeDirective(variable,list,remove,separator); - break; - case CONTAINS: - if(variable == null){ - variable = "$var_"+UUID.randomUUID(); - } - documentHandler.containsDirective(variable,list,remove,separator); - break; - default: - break; - } - } - (< S >)*< SEMICOLON >()* -} - - -/** - * @exception ParseException exception during the parse - */ -void appendDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - < APPEND >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { documentHandler.appendDirective(variable,list,remove,separator); } -} - -/** - * @exception ParseException exception during the parse - */ -void removeDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - < REMOVE >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { documentHandler.removeDirective(variable,list,remove,separator); } -} - -/** - * @exception ParseException exception during the parse - */ -String containsDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - (n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)*)? - < CONTAINS >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { /* - *if it is not in the form like "$contains : contains($items, .v-button);" - *for example in @if, like "@if (contains(a b c, b))", then create a temp - *variable for contains(a b c, b); - */ - if(variable == null){ - variable = "$var_"+UUID.randomUUID(); - } - documentHandler.containsDirective(variable,list,remove,separator); - return variable; - } -} - -JAVACODE -String listModifyDirectiveArgs(int nest) -{ - String list = ""; - int nesting = nest; - Token t = null; - - while(true) - { - t = getToken(1); - String s = t.image; - if(t.kind == VARIABLE||t.kind == IDENT) { - list += s; - }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { - int i = 2; - Token temp = getToken(i); - boolean isLast = true; - while(temp.kind != SEMICOLON) - { if(temp.kind != RPARAN || temp.kind != S) - { isLast = false; } - i++; - temp = getToken(i); - } - - if(isLast) { return list; - } - } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); - - }else if(t.kind == LPARAN) { nesting++; - if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); - } - }else if(t.kind == RPARAN) { nesting--; - if(nesting == 0) { - return list; - } - } else if(t.kind == COMMA) { - if(nesting == nest) { - return list; }else { - list += ","; } - - }else if(t.kind == S) { - list += " "; } else if(t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", getLocator()); } - getNextToken(); - } -} - -Node returnDirective() : -{ - String raw; -} -{ - raw = skipStatement() - {return null;} -} - -void debuggingDirective() : -{} -{ - debugDirective() | warnDirective() -} - -void debugDirective() : -{} -{ - - { - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. - System.out.println(content); - } - ()* -} - -void warnDirective() : -{} -{ - - { - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. - System.err.println(content); - } - ()* -} - -Node forDirective() : -{ - String var; - String from; - String to; - boolean exclusive; - String body; - Token tok; -} -{ - var = variableName() - { - int[] toThrough = {TO, THROUGH}; - from = skipStatementUntil(toThrough); - } - (tok = {exclusive = true;} - | tok = {exclusive = false;}) - to = skipStatementUntilLeftBrace() - ()* - body = skipStatement() - {return documentHandler.forDirective(var, from, to, exclusive, body);} -} - -Node whileDirective() : -{ - String condition; - String body; -} -{ - condition = skipStatementUntilLeftBrace() - body = skipStatement() - { return documentHandler.whileDirective(condition, body);} -} - -void extendDirective() : -{ArrayList list;} -{ - - ()* - list = selectorList() - (";"()*)+ - {documentHandler.extendDirective(list);} -} - -void contentDirective() : -{} -{ - - ()* - (";"()*)+ - {documentHandler.contentDirective();} -} - -JAVACODE -Node importDirective(){ - return null; -} - -JAVACODE -Node charsetDirective(){ - return null; -} - -JAVACODE -Node mozDocumentDirective(){ - return null; -} - -JAVACODE -Node supportsDirective(){ - return null; -} - - -void nestedProperties(): -{String name; -LexicalUnit exp;} -{ - name=property() - ":" ( )* - ()* - { - documentHandler.startNestedProperties(name); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - - { - documentHandler.endNestedProperties(name); - } - ()* -} -/** - * @exception ParseException exception during the parse - */ -void styleRuleOrDeclarationOrNestedProperties() : -{ -} -{ - try { - // differentiate between the colon of a pseudo and the colon of nested properties and the colon of a simple property - // first check if it is a normal styleRule, if not check if it is declarationOrNestedProperties(), if still fails, most likely, it is - // is styleRule with pseudo selector with contains functions. have to do it in this way, because both the styleRule and declarationOrNestedProperties() - // have 'skipStatementUntilXXX', which cannot be LOOKAHEAD properly. - ( debuggingDirective() | LOOKAHEAD(selectorList()) styleRule() | LOOKAHEAD(3)declarationOrNestedProperties() | styleRule()) - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} -/** - * @exception ParseException exception during the parse - */ -void declarationOrNestedProperties() : -{ boolean important = false; - String name; - LexicalUnitImpl exp; - Token save; - String comment = null; -} -{ - try { - name=property() - { save = token; } - ":" ( )* - (exp=expr() ( important=prio() )? - { - Token next = getToken(1); - if(next.kind == SEMICOLON || next.kind == RBRACE){ - while(next.kind == SEMICOLON){ - skipStatement(); - next = getToken(1); - } - //only add special token kept for sprites '/**' - if(token.specialToken!=null && token.specialToken!=null && token.specialToken.image.startsWith("/**")){ - documentHandler.property(name, exp, important, token.specialToken.image); - }else{ - documentHandler.property(name, exp, important, null); - } - } - } - | ()* - { - documentHandler.startNestedProperties(name); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - { - documentHandler.endNestedProperties(name); - } - ) - - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -void declaration() : -{ boolean important = false; - String name; - LexicalUnit exp; - Token save; -} -{ - try { - name=property() - { save = token; } - ":" ( )* exp=expr() ( important=prio() )? - { - documentHandler.property(name, exp, important); - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -boolean prio() : -{} -{ - ( )* { return true; } -} - -boolean guarded() : -{} -{ - ()* {return true;} -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl operator(LexicalUnitImpl prev) : -{Token n;} -{ -/* (comments copied from basic_arithmetics.scss) -*supports: -* 1. standard arithmetic operations (+, -, *, /, %) -* 2. / is treated as css operator, unless one of its operands is variable or there is another binary arithmetic operator -*limits: -* 1. cannot mix arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will fail -* 2. space between add and minus operator and their following operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not -* 3. parenthesis is not supported now. -*/ -n="," ( )* { return LexicalUnitImpl.createComma(n.beginLine, - n.beginColumn, - prev); } -|n="/" ( )* { return LexicalUnitImpl.createSlash(n.beginLine, - n.beginColumn, - prev); } -| n="*" ( )* { return LexicalUnitImpl.createMultiply(n.beginLine, - n.beginColumn, - prev); } -| n="%" ( )* { return LexicalUnitImpl.createModulo(n.beginLine, - n.beginColumn, - prev); } -/* -* for '+', since it can be either a binary operator or an unary operator, -* which is ambiguous. To avoid this, the binary operator '+' always has -* a space before the following term. so '2+3' is not a valid binary expression, -* but '2 + 3' is. The same for '-' operator. -*/ - -| n="+" ( )+{ return LexicalUnitImpl.createAdd(n.beginLine, - n.beginColumn, - prev); } -| n="-" ( )+{ return LexicalUnitImpl.createMinus(n.beginLine, - n.beginColumn, - prev); } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl expr() : -{ - LexicalUnitImpl first, res; - char op; -} -{ - first=term(null){ res = first; } - ( LOOKAHEAD(2) ( LOOKAHEAD(2) res=operator(res) )? res=term(res))* - { return first; } -} - -/** - * @exception ParseException exception during the parse - */ -char unaryOperator() : -{} -{ - "-" { return '-'; } -| "+" { return '+'; } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl term(LexicalUnitImpl prev) : -{ LexicalUnitImpl result = null; - Token n = null; - char op = ' '; -} -{ - (result = nonVariableTerm(prev)| result = variableTerm(prev)) - { - return result; - } -} - -LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { - LexicalUnitImpl result = null; - String varName = ""; } { - varName = variableName() - {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, varName); return result;} } - -LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - String varName; - String s = ""; -} -{ -( ( ( - op=unaryOperator() )? - (n= - { result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn, - prev, number(op, n, 0)); } - | n= - { result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); } - | n= - { result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); } - | n= - { result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { - s = n.image; - int i = 0; - while (i < s.length() - && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { - i++; - } - - result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, - number(op,n,s.length()-i), - s.substring(i)); - } - | result=function(op, prev) ) ) - | ( n= - { result = - LexicalUnitImpl.createString(n.beginLine, n.beginColumn, prev, - convertStringIndex(n.image, 1, - n.image.length() -1));} - | (< DOT >{ s+="."; })?(n= | n= | n= | n=) - { s += convertIdent(n.image); - if ("inherit".equals(s)) { - result = LexicalUnitImpl.createInherit(n.beginLine, n.beginColumn, - prev); - } else { - result = LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, convertIdent(n.image)); - } - - /* / - Auto correction code used in the CSS Validator but must not - be used by a conformant CSS2 parser. - * Common error : - * H1 { - * color : black - * background : white - * } - * - Token t = getToken(1); - Token semicolon = new Token(); - semicolon.kind = SEMICOLON; - semicolon.image = ";"; - if (t.kind == COLON) { - // @@SEEME. (generate a warning?) - // @@SEEME if expression is a single ident, - generate an error ? - rejectToken(semicolon); - - result = prev; - } - / */ - } - | result=hexcolor(prev) - | result=url(prev) - | result=unicode(prev) - ) ) ( )* - { - return result; } } - -/** - * Handle all CSS2 functions. - * @exception ParseException exception during the parse - */ -LexicalUnitImpl function(char operator, LexicalUnitImpl prev) : -{Token n; - LexicalUnit params = null; -} -{ - n= ( )* - { - String fname = convertIdent(n.image); - if("alpha(".equals(fname)){ - String body = skipStatementUntilSemiColon(); - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - null, "alpha("+body); - }else if("expression(".equals(fname)){ - String body = skipStatementUntilSemiColon(); - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - null, "expression("+body); - } - } - ( params=expr() )? ")" - { - if (operator != ' ') { - throw new CSSParseException("invalid operator before a function.", - getLocator()); - } - String f = convertIdent(n.image); - LexicalUnitImpl l = (LexicalUnitImpl) params; - boolean loop = true; - if ("rgb(".equals(f)) { - // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 2: - case 4: - if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) - && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - if (loop) { - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - } - if ((i == 5) && loop && (l == null)) { - return LexicalUnitImpl.createRGBColor(n.beginLine, - n.beginColumn, - prev, params); - } else { - if (errorHandler != null) { - String errorText; - Locator loc; - if (i < 5) { - if (params == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn-1); - errorText = "not enough parameters."; - } else if (l == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn-1); - errorText = "not enough parameters: " - + params.toString(); - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "invalid parameter: " - + l.toString(); - } - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "too many parameters: " - + l.toString(); - } - errorHandler.error(new CSSParseException(errorText, loc)); - } - - throw new JumpException(); - } - } else if ("counter".equals(f)) { - int i = 0; - while (loop && l != null && i < 3) { - switch (i) { - case 0: - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 1: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if (((i == 1) || (i == 3)) && loop && (l == null)) { - return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn, - prev, params); - } - - } else if ("counters(".equals(f)) { - - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 4: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if (((i == 3) || (i == 5)) && loop && (l == null)) { - return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn, - prev, params); - } - } else if ("attr(".equals(f)) { - if ((l != null) - && (l.getNextLexicalUnit() == null) - && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { - return LexicalUnitImpl.createAttr(l.getLineNumber(), - l.getColumnNumber(), - prev, l.getStringValue()); - } - } else if ("rect(".equals(f)) { - int i = 0; - while (loop && l != null && i < 7) { - switch (i) { - case 0: - case 2: - case 4: - case 6: - switch (l.getLexicalUnitType()) { - case LexicalUnit.SAC_INTEGER: - if (l.getIntegerValue() != 0) { - loop = false; - } - break; - case LexicalUnit.SAC_IDENT: - if (!l.getStringValue().equals("auto")) { - loop = false; - } - break; - case LexicalUnit.SAC_EM: - case LexicalUnit.SAC_EX: - case LexicalUnit.SAC_PIXEL: - case LexicalUnit.SAC_CENTIMETER: - case LexicalUnit.SAC_MILLIMETER: - case LexicalUnit.SAC_INCH: - case LexicalUnit.SAC_POINT: - case LexicalUnit.SAC_PICA: - // nothing - break; - default: - loop = false; - } - break; - case 1: - case 3: - case 5: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if ((i == 7) && loop && (l == null)) { - return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn, - prev, params); - } - } - return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev, - f.substring(0, - f.length() -1), - params); - } -} - -LexicalUnitImpl unicode(LexicalUnitImpl prev) : -{ Token n; -} -{ - n= - { - LexicalUnitImpl params = null; - String s = n.image.substring(2); - int index = s.indexOf('-'); - if (index == -1) { - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s, 16)); - } else { - String s1 = s.substring(0, index); - String s2 = s.substring(index); - - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s1, 16)); - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s2, 16)); - } - - return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn, - prev, params); - } -} - -LexicalUnitImpl url(LexicalUnitImpl prev) : -{ Token n; -} -{ - n= - { - String urlname = n.image.substring(4, n.image.length()-1).trim(); - return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname); - } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl hexcolor(LexicalUnitImpl prev) : -{Token n; -} -{ - n= - { - int r; - LexicalUnitImpl first, params = null; - String s = n.image.substring(1); - - if(s.length()!=3 && s.length()!=6) { - first = null; - throw new CSSParseException("invalid hexadecimal notation for RGB: " + s, - getLocator()); - } - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, n.image); - } -} - -JAVACODE -float number(char operator, Token n, int lengthUnit) { - String image = n.image; - float f = 0; - - if (lengthUnit != 0) { - image = image.substring(0, image.length() - lengthUnit); - } - f = Float.valueOf(image).floatValue(); - return (operator == '-')? -f: f; -} - -JAVACODE -String skipStatementUntilSemiColon(){ - int[] semicolon = {SEMICOLON}; - return skipStatementUntil(semicolon); -} - -JAVACODE -String skipStatementUntilLeftBrace(){ - int[] lBrace = {LBRACE}; - return skipStatementUntil(lBrace); -} - -JAVACODE -String skipStatementUntilMatchingRightParan(){ - int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "(" - int[] rightTokens = {RPARAN}; - StringBuffer s = new StringBuffer(); - int difference = 1; - Token tok; - while(difference != 0){ - tok = getToken(1); - if(tok.kind == EOF) { - return null; - } - for(int sym : leftTokens){ - if(tok.kind == sym){ - difference++; - } - } - for(int sym : rightTokens){ - if(tok.kind == sym){ - difference--; - } - } - if(difference != 0){ - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); -} - -JAVACODE -String skipStatementUntil(int[] symbols){ - StringBuffer s = new StringBuffer(); - boolean stop = false; - Token tok; - while(!stop){ - tok = getToken(1); - if(tok.kind == EOF) { - return null; - } - for(int sym : symbols){ - if(tok.kind == sym){ - stop = true; - break; - } - } - if(!stop){ - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); -} - - -JAVACODE -String skipStatement() { - StringBuffer s = new StringBuffer(); - Token tok = getToken(0); - if (tok.image != null) { - s.append(tok.image); - } - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - getNextToken(); - s.append(skip_to_matching_brace()); - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == RBRACE) { - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == SEMICOLON) { - getNextToken(); - tok = getToken(1); - break; - } - getNextToken(); - } - - // skip white space - while (true) { - if (tok.kind != S) { - break; - } - tok = getNextToken(); - tok = getToken(1); - } - - return s.toString().trim(); -} - -JAVACODE -String skip_to_matching_brace() { - StringBuffer s = new StringBuffer(); - Token tok; - int nesting = 1; - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - break; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - nesting++; - } else if (tok.kind == RBRACE) { - nesting--; - if (nesting == 0) { - break; - } - } - getNextToken(); - } - return s.toString(); -} - -/* - * Here I handle all CSS2 unicode character stuffs. - * I convert all \XXXXXX character into a single character. - * Don't forget that the parser has recognize the token before. - * (So IDENT won't contain newline and stuffs like this). - */ -JAVACODE -String convertStringIndex(String s, int start, int len) { - StringBuffer buf = new StringBuffer(len); - int index = start; - - while (index < len) { - char c = s.charAt(index); - if (c == '\\') { - if (++index < len) { - c = s.charAt(index); - switch (c) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - buf.append('\\'); - while (index < len) { - buf.append(s.charAt(index++)); - } - break; - case '\n': - case '\f': - break; - case '\r': - if (index + 1 < len) { - if (s.charAt(index + 1) == '\n') { - index ++; - } - } - break; - default: - buf.append(c); - } - } else { - throw new CSSParseException("invalid string " + s, getLocator()); - } - } else { - buf.append(c); - } - index++; - } - - return buf.toString(); -} - -JAVACODE -String convertIdent(String s) { - return convertStringIndex(s, 0, s.length()); -} - -JAVACODE -String convertString(String s) { - return convertStringIndex(s, 0, s.length()); -} - -JAVACODE -void comments(){ - /*keeps only the multiple line comments, single line comments are skipped*/ - if (token.specialToken != null && token.specialToken.image!=null && token.specialToken.image.startsWith("/*")){ - Token tmp_t = token.specialToken; - while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; - while (tmp_t != null) { - documentHandler.comment(tmp_t.image); - tmp_t = tmp_t.next; - } - } -} - -/* - * @@HACK - * I can't insert a token into the tokens flow. - * It's jj_consume_token implementation dependant! :-( - */ -JAVACODE -void rejectToken(Token t) { - Token fakeToken = new Token(); - t.next = token; - fakeToken.next = t; - token = fakeToken; -} - -/** - * skip after an expression - */ -JAVACODE -String skipAfterExpression() { - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - - while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - - return s.toString(); -} - -/** - * The following functions are useful for a DOM CSS implementation only and are - * not part of the general CSS2 parser. - */ -// TODO required by original parser but not used by Vaadin? -void _parseRule() : -{String ret = null; -} -{ - ( )* - ( importDeclaration() | debuggingDirective() | styleRule() | media() | page() | fontFace() | ret=skipStatement() - { - if ((ret == null) || (ret.length() == 0)) { - return; - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - throw new CSSParseException("unrecognize rule: " + ret, - getLocator()); - } - } - ) -} - -void _parseImportRule() : -{ -} -{ - ( )* importDeclaration() -} - -void _parseMediaRule() : -{ -} -{ - ( )* media() -} - -void _parseDeclarationBlock() : -{ -} -{ - ( )* - ( declaration() )? ( ";" ( )* ( declaration() )? )* - } - -ArrayList _parseSelectors() : -{ ArrayList p = null; -} -{ - try { - ( )* p = selectorList() - { return p; } - } catch (ThrowedParseException e) { - throw (ParseException) e.e.fillInStackTrace(); - } -} - -/* - * Local Variables: - * compile-command: javacc Parser.jj & javac Parser.java - * End: - */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java deleted file mode 100644 index a3ab622ee9..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. ParserConstants.java */ -package com.vaadin.sass.internal.parser; - - -/** - * Token literal values and constants. - * Generated by org.javacc.parser.OtherFilesGen#start() - */ -public interface ParserConstants { - - /** End of File. */ - int EOF = 0; - /** RegularExpression Id. */ - int S = 1; - /** RegularExpression Id. */ - int SINGLE_LINE_COMMENT = 2; - /** RegularExpression Id. */ - int FORMAL_COMMENT = 5; - /** RegularExpression Id. */ - int MULTI_LINE_COMMENT = 6; - /** RegularExpression Id. */ - int CDO = 8; - /** RegularExpression Id. */ - int CDC = 9; - /** RegularExpression Id. */ - int LBRACE = 10; - /** RegularExpression Id. */ - int RBRACE = 11; - /** RegularExpression Id. */ - int DASHMATCH = 12; - /** RegularExpression Id. */ - int CARETMATCH = 13; - /** RegularExpression Id. */ - int DOLLARMATCH = 14; - /** RegularExpression Id. */ - int STARMATCH = 15; - /** RegularExpression Id. */ - int INCLUDES = 16; - /** RegularExpression Id. */ - int EQ = 17; - /** RegularExpression Id. */ - int PLUS = 18; - /** RegularExpression Id. */ - int MINUS = 19; - /** RegularExpression Id. */ - int COMMA = 20; - /** RegularExpression Id. */ - int SEMICOLON = 21; - /** RegularExpression Id. */ - int PRECEDES = 22; - /** RegularExpression Id. */ - int SIBLING = 23; - /** RegularExpression Id. */ - int SUCCEEDS = 24; - /** RegularExpression Id. */ - int DIV = 25; - /** RegularExpression Id. */ - int LBRACKET = 26; - /** RegularExpression Id. */ - int RBRACKET = 27; - /** RegularExpression Id. */ - int ANY = 28; - /** RegularExpression Id. */ - int MOD = 29; - /** RegularExpression Id. */ - int PARENT = 30; - /** RegularExpression Id. */ - int DOT = 31; - /** RegularExpression Id. */ - int LPARAN = 32; - /** RegularExpression Id. */ - int RPARAN = 33; - /** RegularExpression Id. */ - int COMPARE = 34; - /** RegularExpression Id. */ - int OR = 35; - /** RegularExpression Id. */ - int AND = 36; - /** RegularExpression Id. */ - int NOT_EQ = 37; - /** RegularExpression Id. */ - int COLON = 38; - /** RegularExpression Id. */ - int INTERPOLATION = 39; - /** RegularExpression Id. */ - int NONASCII = 40; - /** RegularExpression Id. */ - int H = 41; - /** RegularExpression Id. */ - int UNICODE = 42; - /** RegularExpression Id. */ - int ESCAPE = 43; - /** RegularExpression Id. */ - int NMSTART = 44; - /** RegularExpression Id. */ - int NMCHAR = 45; - /** RegularExpression Id. */ - int STRINGCHAR = 46; - /** RegularExpression Id. */ - int D = 47; - /** RegularExpression Id. */ - int NAME = 48; - /** RegularExpression Id. */ - int TO = 49; - /** RegularExpression Id. */ - int THROUGH = 50; - /** RegularExpression Id. */ - int EACH_IN = 51; - /** RegularExpression Id. */ - int FROM = 52; - /** RegularExpression Id. */ - int MIXIN_SYM = 53; - /** RegularExpression Id. */ - int INCLUDE_SYM = 54; - /** RegularExpression Id. */ - int FUNCTION_SYM = 55; - /** RegularExpression Id. */ - int RETURN_SYM = 56; - /** RegularExpression Id. */ - int DEBUG_SYM = 57; - /** RegularExpression Id. */ - int WARN_SYM = 58; - /** RegularExpression Id. */ - int FOR_SYM = 59; - /** RegularExpression Id. */ - int EACH_SYM = 60; - /** RegularExpression Id. */ - int WHILE_SYM = 61; - /** RegularExpression Id. */ - int IF_SYM = 62; - /** RegularExpression Id. */ - int ELSE_SYM = 63; - /** RegularExpression Id. */ - int EXTEND_SYM = 64; - /** RegularExpression Id. */ - int MOZ_DOCUMENT_SYM = 65; - /** RegularExpression Id. */ - int SUPPORTS_SYM = 66; - /** RegularExpression Id. */ - int CONTENT_SYM = 67; - /** RegularExpression Id. */ - int MICROSOFT_RULE = 68; - /** RegularExpression Id. */ - int IF = 69; - /** RegularExpression Id. */ - int GUARDED_SYM = 70; - /** RegularExpression Id. */ - int STRING = 71; - /** RegularExpression Id. */ - int IDENT = 72; - /** RegularExpression Id. */ - int NUMBER = 73; - /** RegularExpression Id. */ - int _URL = 74; - /** RegularExpression Id. */ - int URL = 75; - /** RegularExpression Id. */ - int VARIABLE = 76; - /** RegularExpression Id. */ - int PERCENTAGE = 77; - /** RegularExpression Id. */ - int PT = 78; - /** RegularExpression Id. */ - int MM = 79; - /** RegularExpression Id. */ - int CM = 80; - /** RegularExpression Id. */ - int PC = 81; - /** RegularExpression Id. */ - int IN = 82; - /** RegularExpression Id. */ - int PX = 83; - /** RegularExpression Id. */ - int EMS = 84; - /** RegularExpression Id. */ - int LEM = 85; - /** RegularExpression Id. */ - int REM = 86; - /** RegularExpression Id. */ - int EXS = 87; - /** RegularExpression Id. */ - int DEG = 88; - /** RegularExpression Id. */ - int RAD = 89; - /** RegularExpression Id. */ - int GRAD = 90; - /** RegularExpression Id. */ - int MS = 91; - /** RegularExpression Id. */ - int SECOND = 92; - /** RegularExpression Id. */ - int HZ = 93; - /** RegularExpression Id. */ - int KHZ = 94; - /** RegularExpression Id. */ - int DIMEN = 95; - /** RegularExpression Id. */ - int HASH = 96; - /** RegularExpression Id. */ - int IMPORT_SYM = 97; - /** RegularExpression Id. */ - int MEDIA_SYM = 98; - /** RegularExpression Id. */ - int CHARSET_SYM = 99; - /** RegularExpression Id. */ - int PAGE_SYM = 100; - /** RegularExpression Id. */ - int FONT_FACE_SYM = 101; - /** RegularExpression Id. */ - int KEY_FRAME_SYM = 102; - /** RegularExpression Id. */ - int ATKEYWORD = 103; - /** RegularExpression Id. */ - int IMPORTANT_SYM = 104; - /** RegularExpression Id. */ - int RANGE0 = 105; - /** RegularExpression Id. */ - int RANGE1 = 106; - /** RegularExpression Id. */ - int RANGE2 = 107; - /** RegularExpression Id. */ - int RANGE3 = 108; - /** RegularExpression Id. */ - int RANGE4 = 109; - /** RegularExpression Id. */ - int RANGE5 = 110; - /** RegularExpression Id. */ - int RANGE6 = 111; - /** RegularExpression Id. */ - int RANGE = 112; - /** RegularExpression Id. */ - int UNI = 113; - /** RegularExpression Id. */ - int UNICODERANGE = 114; - /** RegularExpression Id. */ - int REMOVE = 115; - /** RegularExpression Id. */ - int APPEND = 116; - /** RegularExpression Id. */ - int CONTAINS = 117; - /** RegularExpression Id. */ - int FUNCTION = 118; - /** RegularExpression Id. */ - int UNKNOWN = 119; - - /** Lexical state. */ - int DEFAULT = 0; - /** Lexical state. */ - int IN_FORMAL_COMMENT = 1; - /** Lexical state. */ - int IN_MULTI_LINE_COMMENT = 2; - - /** Literal token values. */ - String[] tokenImage = { - "", - "", - "", - "", - "\"/*\"", - "\"*/\"", - "\"*/\"", - "", - "\"\"", - "\"{\"", - "\"}\"", - "\"|=\"", - "\"^=\"", - "\"$=\"", - "\"*=\"", - "\"~=\"", - "\"=\"", - "\"+\"", - "\"-\"", - "\",\"", - "\";\"", - "\">\"", - "\"~\"", - "\"<\"", - "\"/\"", - "\"[\"", - "\"]\"", - "\"*\"", - "\"%\"", - "\"&\"", - "\".\"", - "\"(\"", - "\")\"", - "\"==\"", - "\"||\"", - "\"&&\"", - "\"!=\"", - "\":\"", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "\"to\"", - "\"through\"", - "\"in\"", - "\"from\"", - "\"@mixin\"", - "\"@include\"", - "\"@function\"", - "\"@return\"", - "\"@debug\"", - "\"@warn\"", - "\"@for\"", - "\"@each\"", - "\"@while\"", - "\"@if\"", - "\"@else\"", - "\"@extend\"", - "\"@-moz-document\"", - "\"@supports\"", - "\"@content\"", - "", - "\"if\"", - "", - "", - "", - "", - "<_URL>", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "\"@import\"", - "\"@media\"", - "\"@charset\"", - "\"@page\"", - "\"@font-face\"", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - }; - -} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj new file mode 100644 index 0000000000..0a69342d9a --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj @@ -0,0 +1,3028 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* -*-java-extended-*- + * Copyright (c) 1999 World Wide Web Consortium + * (Massachusetts Institute of Technology, Institut National de Recherche + * en Informatique et en Automatique, Keio University). + * All Rights Reserved. http://www.w3.org/Consortium/Legal/ + * + * $Id: Parser.jj,v 1.15 2000/10/27 21:09:37 plehegar Exp $ + */ + +options { + IGNORE_CASE = true; + STATIC = false; + USER_CHAR_STREAM = true; + /* DEBUG_TOKEN_MANAGER = true; + DEBUG_PARSER = true; */ +} + +PARSER_BEGIN(ParserImpl) + +package com.vaadin.sass.internal.parser; + +import java.io.*; +import java.net.*; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; + +import org.w3c.css.sac.ConditionFactory; +import org.w3c.css.sac.Condition; +import org.w3c.css.sac.SelectorFactory; +import org.w3c.css.sac.SelectorList; +import org.w3c.css.sac.Selector; +import org.w3c.css.sac.SimpleSelector; +import org.w3c.css.sac.DocumentHandler; +import org.w3c.css.sac.InputSource; +import org.w3c.css.sac.ErrorHandler; +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; +import org.w3c.css.sac.Locator; +import org.w3c.css.sac.LexicalUnit; + +import org.w3c.flute.parser.selectors.SelectorFactoryImpl; +import org.w3c.flute.parser.selectors.ConditionFactoryImpl; + +import org.w3c.flute.util.Encoding; + +import com.vaadin.sass.internal.handler.*; + +import com.vaadin.sass.internal.tree.*; + +/** + * A CSS2 parser + * + * @author Philippe Le H�garet + * @version $Revision: 1.15 $ + */ +public class ParserImpl implements org.w3c.css.sac.Parser, Parser { + + // replaces all \t, \n, etc with this StringBuffer. + static final StringBuilder SPACE = new StringBuilder(" "); + + // the document handler for the parser + protected SCSSDocumentHandlerImpl documentHandler; + // the error handler for the parser + protected ErrorHandler errorHandler; + // the input source for the parser + protected InputSource source; + + protected ConditionFactory conditionFactory; + protected SelectorFactory selectorFactory; + + // temporary place holder for pseudo-element ... + private String pseudoElt; + + /** + * Creates a new Parser + */ + public ParserImpl() { + this((CharStream) null); + } + + /** + * @@TODO + * @exception CSSException Not yet implemented + */ + public void setLocale(Locale locale) throws CSSException { + throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); + } + + public InputSource getInputSource(){ + return source; + } + + /** + * Set the document handler for this parser + */ + public void setDocumentHandler(DocumentHandler handler) { + this.documentHandler = (SCSSDocumentHandlerImpl) handler; + } + + public void setSelectorFactory(SelectorFactory selectorFactory) { + this.selectorFactory = selectorFactory; + } + + public void setConditionFactory(ConditionFactory conditionFactory) { + this.conditionFactory = conditionFactory; + } + + /** + * Set the error handler for this parser + */ + public void setErrorHandler(ErrorHandler error) { + this.errorHandler = error; + } + + /** + * Main parse methods + * + * @param source the source of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleSheet(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + + parserUnit(); + } + + /** + * Convenient method for URIs. + * + * @param systemId the fully resolved URI of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleSheet(String systemId) + throws CSSException, IOException { + parseStyleSheet(new InputSource(systemId)); + } + + /** + * This method parses only one rule (style rule or at-rule, except @charset). + * + * @param source the source of the rule. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + // TODO required by original parser but not used by Vaadin? + public void parseRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseRule(); + } + + /** + * This method parses a style declaration (including the surrounding curly + * braces). + * + * @param source the source of the style declaration. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleDeclaration(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseDeclarationBlock(); + } + + /** + * This methods returns "http://www.w3.org/TR/REC-CSS2". + * @return the string "http://www.w3.org/TR/REC-CSS2". + */ + public String getParserVersion() { + return "http://www.w3.org/TR/REC-CSS2"; + } + + /** + * Parse methods used by DOM Level 2 implementation. + */ + public void parseImportRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseImportRule(); + } + + public void parseMediaRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseMediaRule(); + } + + public SelectorList parseSelectors(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return null; + } + + public LexicalUnit parsePropertyValue(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return expr(); + } + + public boolean parsePriority(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return prio(); + } + + /** + * Convert the source into a Reader. Used only by DOM Level 2 parser methods. + */ + private Reader getReader(InputSource source) throws IOException { + if (source.getCharacterStream() != null) { + return source.getCharacterStream(); + } else if (source.getByteStream() != null) { + // My DOM level 2 implementation doesn't use this case. + if (source.getEncoding() == null) { + // unknown encoding, use ASCII as default. + return new InputStreamReader(source.getByteStream(), "ASCII"); + } else { + return new InputStreamReader(source.getByteStream(), + source.getEncoding()); + } + } else { + // systemId + // @@TODO + throw new CSSException("not yet implemented"); + } + } + + /** + * Convert the source into a CharStream with encoding informations. + * The encoding can be found in the InputSource or in the CSS document. + * Since this method marks the reader and make a reset after looking for + * the charset declaration, you'll find the charset declaration into the + * stream. + */ + private CharStream getCharStreamWithLurk(InputSource source) + throws CSSException, IOException { + if (source.getCharacterStream() != null) { + // all encoding are supposed to be resolved by the user + // return the reader + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } else if (source.getByteStream() == null) { + // @@CONTINUE ME. see also getReader() with systemId + try { + source.setByteStream(new URL(source.getURI()).openStream()); + } catch (Exception e) { + try { + source.setByteStream(new FileInputStream(source.getURI())); + } catch (IOException ex) { + throw new CSSException("invalid url ?"); + } + } + } + //use UTF-8 as the default encoding. + String encoding = source.getEncoding(); + InputStream input = source.getByteStream(); + if (!input.markSupported()) { + // If mark is not supported, wrap it in a stream which supports mark + input = new BufferedInputStream(input); + source.setByteStream(input); + } + // Mark either the original stream or the wrapped stream + input.mark(100); + if(encoding == null){ + encoding = "ASCII"; + + char c = ' '; + + c = (char) input.read(); + + if (c == '@') { + // hum, is it a charset ? + int size = 100; + byte[] buf = new byte[size]; + input.read(buf, 0, 7); + String keyword = new String(buf, 0, 7); + if (keyword.equals("charset")) { + // Yes, this is the charset declaration ! + + // here I don't use the right declaration : white space are ' '. + while ((c = (char) input.read()) == ' ') { + // find the first quote + } + char endChar = c; + int i = 0; + + if ((endChar != '"') && (endChar != '\'')) { + // hum this is not a quote. + throw new CSSException("invalid charset declaration"); + } + + while ((c = (char) input.read()) != endChar) { + buf[i++] = (byte) c; + if (i == size) { + byte[] old = buf; + buf = new byte[size + 100]; + System.arraycopy(old, 0, buf, 0, size); + size += 100; + } + } + while ((c = (char) input.read()) == ' ') { + // find the next relevant character + } + if (c != ';') { + // no semi colon at the end ? + throw new CSSException("invalid charset declaration: " + + "missing semi colon"); + } + encoding = new String(buf, 0, i); + if (source.getEncoding() != null) { + // compare the two encoding informations. + // For example, I don't accept to have ASCII and after UTF-8. + // Is it really good ? That is the question. + if (!encoding.equals(source.getEncoding())) { + throw new CSSException("invalid encoding information."); + } + } + } // else no charset declaration available + } + } + // ok set the real encoding of this source. + source.setEncoding(encoding); + // set the real reader of this source. + source.setCharacterStream(new InputStreamReader(source.getByteStream(), + Encoding.getJavaEncoding(encoding))); + // reset the stream (leave the charset declaration in the stream). + input.reset(); + + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } + + private LocatorImpl currentLocator; + private Locator getLocator() { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this, token.beginLine, token.beginColumn); + return currentLocator; + } + return currentLocator.reInit(this, token.beginLine, token.beginColumn); + } + private LocatorImpl getLocator(Token save) { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this, save.beginLine, save.beginColumn); + return currentLocator; + } + return currentLocator.reInit(this, save.beginLine, save.beginColumn); + } + + private void reportError(Locator l, Exception e) { + if (errorHandler != null) { + if (e instanceof ParseException) { + // construct a clean error message. + ParseException pe = (ParseException) e; + if (pe.specialConstructor) { + StringBuffer errorM = new StringBuffer(); + if (pe.currentToken != null) { + errorM.append("encountered \"") + .append(pe.currentToken.next); + } + errorM.append('"'); + if (pe.expectedTokenSequences.length != 0) { + errorM.append(". Was expecting one of: "); + for (int i = 0; i < pe.expectedTokenSequences.length; i++) { + for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { + int kind = pe.expectedTokenSequences[i][j]; + if (kind != S) { + errorM.append(pe.tokenImage[kind]); + errorM.append(' '); + } + } + } + } + errorHandler.error(new CSSParseException(errorM.toString(), + l, e)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), + l, e)); + } + } else if (e == null) { + errorHandler.error(new CSSParseException("error", l, null)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), l, e)); + } + } + } + + private void reportWarningSkipText(Locator l, String text) { + if (errorHandler != null && text != null) { + errorHandler.warning(new CSSParseException("Skipping: " + text, l)); + } + } +} + +PARSER_END(ParserImpl) + +/* + * The tokenizer + */ + + +TOKEN : +{ + < S : ( [ " ", "\t" , "\n" , "\r", "\f" ] )+ > + { image = ParserImpl.SPACE; } +} + +/* + * for fixing #11638: Ending an imported SCSS file with a comment causes an error in the Sass. + * now the single line comment is parsed as special token, before, they were simply skipped. + * solution got from http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.15 + */ + +SPECIAL_TOKEN : { +< SINGLE_LINE_COMMENT: "//"(~["\n","\r"])* ("\n"|"\r"|"\r\n")? > } + + +MORE : +{ + <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT +| + "/*" : IN_MULTI_LINE_COMMENT +} + +SPECIAL_TOKEN : +{ + : DEFAULT +} + + +SKIP : +{ + : DEFAULT +} + + +MORE : +{ + < ~[] > +} + + +TOKEN : +{ + < CDO : "" > + | < LBRACE : "{" > + | < RBRACE : "}"> + | < DASHMATCH : "|=" > + | < CARETMATCH : "^=" > + | < DOLLARMATCH : "$=" > + | < STARMATCH : "*=" > + | < INCLUDES : "~=" > + | < EQ : "=" > + | < PLUS : "+" > + | < MINUS : "-" > + | < COMMA : "," > + | < SEMICOLON : ";" > + | < PRECEDES : ">" > + | < SIBLING : "~" > + | < SUCCEEDS : "<" > + | < DIV : "/" > + | < LBRACKET : "[" > + | < RBRACKET : "]" > + | < ANY : "*" > + | < MOD : "%" > + | < PARENT : "&" > + | < DOT : "." > + | < LPARAN : "(" > + | < RPARAN : ")"> + | < COMPARE : "==" > + | < OR : "||" > + | < AND : "&&" > + | < NOT_EQ : "!=" > +} + + +TOKEN : +{ + < COLON : ":" > +} + +< DEFAULT > +TOKEN : +{ + < INTERPOLATION : "#{"< VARIABLE > "}"> +} + + +TOKEN : /* basic tokens */ +{ + < NONASCII : ["\200"-"\377"] > + | < #H : ["0"-"9", "a"-"f"] > + | < #UNICODE : "\\" ( )? /* I can't say {1,6} */ + ( )? ( )? + ( )? ( )? + ( [ " ", "\t" , "\n" , "\r", "\f" ] )? > + | < #ESCAPE : | ( "\\" [ " "-"~","\200"-"\377" ] ) > + | < #NMSTART : ("-")?[ "a"-"z","_"] | | > + | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > + | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"~" ] + | "\\\n" | "\\\r\n" | "\\\r" | "\\\f" + | | > + | < #D : ["0"-"9"] > + | < #NAME : ( )+ > + +} + + +TOKEN : +{ + + | + | + | +} + +/* DERECTIVES */ + +TOKEN : +{ + + | + | + | + | + | + | + | + | + | + | + | + | + | + | +} + +< DEFAULT > +TOKEN: +{ + < MICROSOFT_RULE : "filter"|"-ms-filter" > +} + +< DEFAULT > +TOKEN: +{ + < IF : "if" > +} + + +TOKEN: +{ + < GUARDED_SYM : "!" ( )? "default"> +} + + +TOKEN : +{ + < STRING : ( "\"" ( | "'" )* "\"" ) | + ( "'" ( | "\"" )* "'" ) > + | < IDENT : ( )* > + | < NUMBER : ( )+ | ( )* "." ( )+ > + | < #_URL : [ "!","#","$","%","&","*"-"~" ] | | > + | < URL : "url(" ( )* + ( | ( <_URL> )* ) ( )* ")" > +} + + +TOKEN: +{ + < VARIABLE : "$" > +} + + +TOKEN : +{ + < PERCENTAGE : "%" > + | < PT : "pt" > + | < MM : "mm" > + | < CM : "cm" > + | < PC : "pc" > + | < IN : "in" > + | < PX : "px" > + | < EMS : "em" > + | < LEM : "lem" > + | < REM : "rem" > + | < EXS : "ex" > + | < DEG : "deg" > + | < RAD : "rad" > + | < GRAD : "grad" > + | < MS : "ms" > + | < SECOND : "s" > + | < HZ : "Hz" > + | < KHZ : "kHz" > + | < DIMEN : > +} + + +TOKEN : +{ + < HASH : "#" > +} + +/* RESERVED ATRULE WORDS */ + +TOKEN : +{ + < IMPORT_SYM : "@import"> + | < MEDIA_SYM : "@media" > + | < CHARSET_SYM : "@charset" > + | < PAGE_SYM : "@page" > + | < FONT_FACE_SYM: "@font-face" > + | < KEY_FRAME_SYM: "@keyframes" | "@-moz-keyframes" | "@-o-keyframes" | "@-webkit-keyframes" | "@-ms-keyframes"> + | < ATKEYWORD : "@" > +} + + +TOKEN : +{ + < IMPORTANT_SYM : "!" ( )? "important" > +} + + +TOKEN : +{ + < #RANGE0 : > + | < #RANGE1 : ( "?" )? > + | < #RANGE2 : ( "?" )? ( "?" )? > + | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE : | | + | | | | > + | < #UNI : ( )? ( )? ( )? ( )? ( )? > + | < UNICODERANGE : "U+" + | "U+" "-" > +} + +< DEFAULT > +TOKEN : +{ + < REMOVE : "remove" (< S >)? "(" > + | < APPEND : "append" (< S >)? "(" > + | < CONTAINS : "contains" (< S >)? "(" > +} + + +TOKEN : +{ + < FUNCTION : (< S >)* "(" > +} + + +TOKEN : +{ /* avoid token manager error */ + < UNKNOWN : ~[] > +} + +/* + * The grammar of CSS2 + */ + +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ +void parserUnit() : +{} +{ + try { + { documentHandler.startDocument(source); } + ( charset() )? + ( comments() + | ignoreStatement() )* + ( importDeclaration() ( ignoreStatement() ( )* )* )* + afterImportDeclaration() + + } finally { + documentHandler.endDocument(source); + } +} + +void charset() : +{ Token n; } +{ + try { + ( )* n= ( )* ";" + } catch (ParseException e) { + reportError(getLocator(e.currentToken.next), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (Exception e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } +} + +void afterImportDeclaration() : +{String ret; + Locator l; +} +{ + ( + ( debuggingDirective() | mixinDirective() | controlDirective() | includeDirective() | styleRule() | media() + | page() | fontFace() | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() + | { l = getLocator(); } ret=skipStatement() + { + if ((ret == null) || (ret.length() == 0)) { + return; + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(l, ret); + } + } + ) + ( ignoreStatement() ( )* )* )* +} + +void ignoreStatement() : +{} +{ + | | atRuleDeclaration() +} + +/** + * The import statement + * + * @exception ParseException exception during the parse + */ +void importDeclaration() : +{Token n; + String uri; + MediaListImpl ml = new MediaListImpl(); + boolean isURL = false; +} +{ + try { + + ( )* ( n= { uri = convertStringIndex(n.image, 1, + n.image.length() -1); } + | n= + { + isURL=true; + uri = n.image.substring(4, n.image.length()-1).trim(); + if ((uri.charAt(0) == '"') + || (uri.charAt(0) == '\'')) { + uri = uri.substring(1, uri.length()-1); + } + } + ) + ( )* mediaStatement(ml) ";" + ( )* + { + if (ml.getLength() == 0) { + // see section 6.3 of the CSS2 recommandation. + ml.addItem("all"); + } + documentHandler.importStyle(uri, ml, isURL); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } +} + +/** + * @exception ParseException exception during the parse + */ +void keyframes() : +{ + Token n; + boolean start = false; + String keyframeName = null; + String animationname = ""; +} +{ + try { + n= ( )* {keyframeName = n.image;} + (n = {animationname += n.image; }|n = < INTERPOLATION >{ animationname += n.image; })+()* + {start = true; documentHandler.startKeyFrames(keyframeName, animationname); } + ( )* ( keyframeSelector() | contentDirective() )* ( )* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + } finally { + if (start) { + documentHandler.endKeyFrames(); + } + } +} + +void keyframeSelector(): +{ + Token n; + String selector = ""; + boolean start = false; +} +{ + try{ + (n = | n = | n = ){selector += n.image;} ()* + ( ()* (n = | n = | n = ) {selector += (", " + n.image);} ()* )* + ()* + { + start = true; + documentHandler.startKeyframeSelector(selector); + } + (ifContentStatement() | microsoftExtension() )* + ()* + } + catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endKeyframeSelector(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +/* see http://www.w3.org/TR/css3-mediaqueries/ */ +void media() : +{ + boolean start = false; + String ret; + MediaListImpl ml = new MediaListImpl(); +} +{ + try { + ( )* + mediaStatement(ml) + { start = true; documentHandler.startMedia(ml); } + ( )* ( debuggingDirective() | styleRule() | skipUnknownRule() )* ( )* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endMedia(ml); + } + } +} + +void mediaStatement(MediaListImpl ml) : +{ + Token t; +} +{ + { + t = getToken(1); + // loop over comma separated parts, add each to ml + while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + if (t.kind == COMMA) { + // skip the comma and the token before it that is still the active token + getNextToken(); + getNextToken(); + t = getToken(1); + } + String str = s.toString().trim(); + if (str.length() > 0) { + ml.addItem(str); + } + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String medium() : /* tv, projection, screen, ... */ +{Token n;} +{ + n= { return convertIdent(n.image); } +} + +/** + * @exception ParseException exception during the parse + */ +void page() : +{ + boolean start = false; + Token n = null; + String page = null; + String pseudo = null; +} +{ + try { + ( )* ( n= ( )* )? + ( pseudo=pseudo_page() )? + { + if (n != null) { + page = convertIdent(n.image); + } + } + ()* + { + start = true; + documentHandler.startPage(page, pseudo); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + } catch (ParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + skipStatement(); + // reportWarningSkipText(li, skipStatement()); + } else { + skipStatement(); + } + } finally { + if (start) { + documentHandler.endPage(page, pseudo); + } + } +} + +String pseudo_page() : +{ Token n; } +{ + ":" n= ( )* { return convertIdent(n.image); } +} + +void fontFace() : +{ + boolean start = false; +} +{ + try { + ( )* + ()* + { start = true; documentHandler.startFontFace(); } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endFontFace(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void atRuleDeclaration() : +{Token n; + String ret; +} +{ + n= + { + ret=skipStatement(); + if ((ret != null) && (ret.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(getLocator(), ret); + } + } +} + +void skipUnknownRule() : +{ Token n;} +{ + ( n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n=";" +| n="-" +| n= + ) { + String ret; + Locator loc = getLocator(); + ret=skipStatement(); + if ((ret != null) && (n.image.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(loc, ret); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +char combinator() : +{ +char connector = ' '; +} +{ + (connector = combinatorChar() + | (connector = combinatorChar())?) { return connector; } +} + +/**to refactor combinator and reuse in selector().*/ +char combinatorChar() : +{Token t;} +{ + (t = | t = | t = ) ()* + { + return t.image.charAt(0); + } +} + +void microsoftExtension() : +{ + Token n; + String name = ""; + String value = ""; +} + +{ + // This is not really taking the syntax of filter rules into account + n = < MICROSOFT_RULE > (< S >)* { name = n.image; } + < COLON > + ((n = < IDENT > { value += n.image; }) + | (n = < NUMBER > { value += n.image; }) + | (n = < STRING > { value += n.image; }) + | (n = < COMMA > { value += n.image; }) + | (n = < INTERPOLATION > { value += n.image; }) + | (n = < COLON > { value += n.image; }) + | (n = < FUNCTION > { value += n.image; }) + | (n = < RPARAN > { value += n.image; }) + | (n = < EQ > { value += n.image; }) + | (n = < DOT > { value += n.image; }) + | (n = < S > { if(value.lastIndexOf(' ') != value.length()-1) + { value += n.image; } } + ) )+ + < SEMICOLON > + (< S >)* + { documentHandler.microsoftDirective(name, value); } +} + +/** + * @exception ParseException exception during the parse + */ +String property() : +{Token t;String s = ""; +} +{ + (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+(< S >)* + { + return s; + } +} + +String variableName() : +{Token n;} +{ + n= ()* {return convertIdent(n.image.substring(1));} +} + +String functionName() : +{Token n;} +{ + n= ( )* {return convertIdent(n.image.substring(0, n.image.length()-1));} +} +/** + * @exception ParseException exception during the parse + */ +void styleRule() : +{ + boolean start = false; + ArrayList l = null; + Token save; + Locator loc; +} +{ + try { + l=selectorList() { save = token; } ()* + { + start = true; + documentHandler.startSelector(l); + } + // a CSS import here will not work + ( ifContentStatement() | microsoftExtension() | importDeclaration() )* + ()* + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endSelector(); + } + } +} + + ArrayList selectorList() : +{ + ArrayList selectors = new ArrayList(); + String selector; +} +{ + selector=selector() ( ()* { selectors.add(selector); } + selector=selector() )* + { selectors.add(selector); + return selectors; + } +} + +/** + * @exception ParseException exception during the parse + */ +String selector() : +{ + String selector = null; + char comb; +} +{ + try { + // the selector can begin either a simple_selector, or a combinatorChar(+, >, ~). + // when beginning with combinatorChar, the next one should be a simple_selector(). + (selector=simple_selector(null, ' ') | (comb=combinatorChar() selector=simple_selector(selector, comb))) + ( LOOKAHEAD(2) comb=combinator() + selector=simple_selector(selector, comb) )* ()* + { + return selector; + } + } catch (ParseException e) { + /* + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + reportWarningSkipText(getLocator(), s.toString()); + */ + Token t = getToken(1); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + getNextToken(); + t = getToken(1); + } + + throw new ThrowedParseException(e); + } +} + +/** + * @exception ParseException exception during the parse + */ +String simple_selector(String selector, char comb) : +{ + String simple_current = null; + String cond = null; + + pseudoElt = null; +} +{ + ( (simple_current=element_name() + ( cond=hash(cond) | cond=_class(cond) + | cond=attrib(cond) | cond=pseudo(cond) )* ) + | ( cond = hash(cond) | cond=_class(cond) + | cond=attrib(cond) | cond=pseudo(cond) )+ + ) + { + if (simple_current == null) { + simple_current = ""; + } + if (cond != null) { + simple_current = simple_current + cond; + } + StringBuilder builder = new StringBuilder(); + switch (comb) { + case ' ': + if(selector!=null){ + builder.append(selector).append(" "); + } + break; + case '+': + case '>': + case '~': + if(selector!=null){ + builder.append(selector).append(" "); + } + builder.append(comb).append(" "); + break; + default: + throw new ParseException("invalid state. send a bug report"); + } + builder.append(simple_current); + selector = builder.toString(); + + if (pseudoElt != null) { + selector = selector + pseudoElt; + } + return selector; + } +} + +/** + * @exception ParseException exception during the parse + */ +String _class(String pred) : +{Token t; +String s = "."; +} +{ + "." (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ + { + + if (pred == null) { + return s; + } else { + return pred + s; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String element_name() : +{Token t; String s = "";} +{ + (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ + { + return s; + } + | "*" + { return "*"; } + | "&" + { return "&"; } +} + +/** + * @exception ParseException exception during the parse + */ +String attrib(String pred) : +{ + int cases = 0; + Token att = null; + Token val = null; + String attValue = null; +} +{ + "[" ( )* att= ( )* + ( ( "=" { cases = 1; } + | { cases = 2; } + | { cases = 3; } + | { cases = 4; } + | { cases = 5; } + | { cases = 6; } ) ( )* + ( val= { attValue = val.image; } + | val= { attValue = val.image; } + ) + ( )* )? + "]" + { + String name = convertIdent(att.image); + String c; + switch (cases) { + case 0: + c = name; + break; + case 1: + c = name + "=" + attValue; + break; + case 2: + c = name + "~=" + attValue; + break; + case 3: + c = name + "|=" +attValue; + break; + case 4: + c = name + "^=" +attValue; + break; + case 5: + c = name + "$=" +attValue; + break; + case 6: + c = name + "*=" +attValue; + break; + default: + // never reached. + c = null; + } + c = "[" + c + "]"; + if (pred == null) { + return c; + } else { + return pred + c; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String pseudo(String pred) : +{Token n; +Token param; +String d; +boolean isPseudoElement = false; +} +{ + ":" (":"{isPseudoElement=true;})?( n= + { + String s = ":" + convertIdent(n.image); + if (isPseudoElement) { + if (pseudoElt != null) { + throw new CSSParseException("duplicate pseudo element definition " + + s, getLocator()); + } else { + pseudoElt = ":"+s; + return pred; + } + } else { + String c = s; + if (pred == null) { + return c; + } else { + return pred + c; + } + } + } + | ( n= ( )* d=skipStatementUntilMatchingRightParan() + { + // accept anything between function and a right parenthesis + String f = convertIdent(n.image); + String colons = isPseudoElement ? "::" : ":"; + String pseudofn = colons + f + d + ")"; + if (pred == null) { + return pseudofn; + } else { + return pred + pseudofn; + } + } + ) + ) +} + +/** + * @exception ParseException exception during the parse + */ +String hash(String pred) : +{Token n; } +{ + n= + { + String d = n.image; + if (pred == null) { + return d; + } else { + return pred + d; + } + } +} + +void variable() : +{ + String name; + LexicalUnitImpl exp = null; + boolean guarded = false; + String raw; +} +{ + try{ + name = variableName() + ":" ( )* exp=expr() ( guarded=guarded() )?(";"()*)+ + //raw=skipStatementUntilSemiColon() + { + documentHandler.variable(name, exp, guarded); + } + }catch (JumpException e) { + skipAfterExpression(); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + } else { + skipAfterExpression(); + } + } +} + +void controlDirective() : +{} +{ + ifDirective() | eachDirective() +} + +void ifContentStatement() : +{} +{ + contentDirective() | includeDirective() | media() | extendDirective() | styleRuleOrDeclarationOrNestedProperties() + | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() | controlDirective() | atRuleDeclaration() +} + +void ifDirective() : +{ + Token n = null; + String s = null; + String evaluator = ""; +} +{ + < IF_SYM > + ( s = booleanExpressionToken() { evaluator += s;} )+ + < LBRACE >(< S >)* + { documentHandler.startIfElseDirective(); + documentHandler.ifDirective(evaluator); + } + ( ifContentStatement() | fontFace() )* + < RBRACE >(< S >)* + (elseDirective())* + { documentHandler.endIfElseDirective(); } +} + +void elseDirective() : +{ + String evaluator = ""; + Token n = null; + String s = null; +} +{ + < ELSE_SYM >(< S >)* + ( < IF > ( s = booleanExpressionToken() { evaluator += s; } )+ )? + < LBRACE >(< S >)* + { if(!evaluator.trim().equals("")){ documentHandler.ifDirective(evaluator); } + else{ documentHandler.elseDirective(); } + } + ( ifContentStatement() | fontFace() )* + < RBRACE >(< S >)* +} + +String booleanExpressionToken() : +{ + Token n = null; + String s = null; +} +{ + ( + LOOKAHEAD(containsDirective()) + s = containsDirective() + |n = < VARIABLE > + |n = < IDENT > + |n = < NUMBER > + |n = < LPARAN > + |n = < RPARAN > + |n = < PLUS > + |n = < MINUS > + |n = < DIV > + |n = < ANY > + |n = < COMPARE > + |n = < EQ > + |n = < PRECEDES > + |n = < SUCCEEDS > + |n = < OR > + |n = < AND > + |n = < S > + |n = < NOT_EQ > +){ + if(n!=null){return n.image;} + else{return s;} + } +} + +void eachDirective() : +{ + Token var; + ArrayList list = null; + String listVariable = null; +} +{ + < EACH_SYM > + (< S >)* + var = < VARIABLE > (< S >)* < EACH_IN > (< S >)* + (list = stringList() + {documentHandler.startEachDirective(var.image, list);} + |listVariable = variableName() + {documentHandler.startEachDirective(var.image, listVariable);} + ) + < LBRACE >(< S >)* + ( ifContentStatement() )* + < RBRACE >(< S >)* + { documentHandler.endEachDirective();} +} + +ArrayList stringList(): +{ + ArrayList strings = new ArrayList(); + Token input; +} +{ + (input = < IDENT > (< S >)*) + { strings.add(input.image); } + + (< COMMA >(< S >)* input = < IDENT > { strings.add(input.image); } (< S >)*)* + { return strings; } + +} + +void mixinDirective() : +{ + String name; + ArrayList args = null; + String body; +} +{ + + ()* + (name = property() + |(name = functionName() + args = arglist()) ()*) ()* + {documentHandler.startMixinDirective(name, args);} + ( ifContentStatement() | fontFace() | page())* + ()* + {documentHandler.endMixinDirective(name, args);} +} + +ArrayList arglist() : +{ + ArrayList args = new ArrayList(); + VariableNode arg; + boolean hasNonOptionalArgument = false; +} +{ + arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } + arg=mixinArg() )* + { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + return args; + } +} + +JAVACODE +boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { + boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; + if(currentArgHasArguments) { + if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + } + return hasNonOptionalArguments; + }else { return true; + } +} + +VariableNode mixinArg() : +{ + String name; + Token variable = null; + LexicalUnitImpl first = null; + LexicalUnitImpl prev = null; + LexicalUnitImpl next = null; +} +{ + name=variableName() (< COLON > (< S >)* + + ( first = nonVariableTerm(null) { + prev = first; } + (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) + | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, variable.image);} + + ) + )? + { + VariableNode arg = new VariableNode(name, first, false); + return arg; + } +} + +ArrayList argValuelist() : +{ + ArrayList args = new ArrayList(); + LexicalUnitImpl first = null; + LexicalUnitImpl next = null; + LexicalUnitImpl prev = null; +} +{ + first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + ( ()* + first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + )* + {return args;} +} + +void includeDirective() : +{ + String name; + ArrayList args=null; +} +{ + + ()* + (name = property()|name = variableName(){ name = "$"+name;} + |(name = functionName() + args = argValuelist()) ()*) + ((";"()*)+ + {documentHandler.includeDirective(name, args);} + | ()* {documentHandler.startIncludeContentBlock(name, args);} + (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* + ()* {documentHandler.endIncludeContentBlock();} + ) +} + +String interpolation() : +{ + Token n; +} +{ + n = < INTERPOLATION > + { + return n.image; + } +} + +void listModifyDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + Token type = null; +} +{ + //refactor, remove those 3 LOOKAHEAD(5). + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + (type = < APPEND> | type = | type= )(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + { + switch (type.kind) { + case APPEND: + documentHandler.appendDirective(variable,list,remove,separator); + break; + case REMOVE: + documentHandler.removeDirective(variable,list,remove,separator); + break; + case CONTAINS: + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + break; + default: + break; + } + } + (< S >)*< SEMICOLON >()* +} + + +/** + * @exception ParseException exception during the parse + */ +void appendDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + < APPEND >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { documentHandler.appendDirective(variable,list,remove,separator); } +} + +/** + * @exception ParseException exception during the parse + */ +void removeDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + < REMOVE >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { documentHandler.removeDirective(variable,list,remove,separator); } +} + +/** + * @exception ParseException exception during the parse + */ +String containsDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + (n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)*)? + < CONTAINS >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { /* + *if it is not in the form like "$contains : contains($items, .v-button);" + *for example in @if, like "@if (contains(a b c, b))", then create a temp + *variable for contains(a b c, b); + */ + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + return variable; + } +} + +JAVACODE +String listModifyDirectiveArgs(int nest) +{ + String list = ""; + int nesting = nest; + Token t = null; + + while(true) + { + t = getToken(1); + String s = t.image; + if(t.kind == VARIABLE||t.kind == IDENT) { + list += s; + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { + int i = 2; + Token temp = getToken(i); + boolean isLast = true; + while(temp.kind != SEMICOLON) + { if(temp.kind != RPARAN || temp.kind != S) + { isLast = false; } + i++; + temp = getToken(i); + } + + if(isLast) { return list; + } + } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); + + }else if(t.kind == LPARAN) { nesting++; + if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + } + }else if(t.kind == RPARAN) { nesting--; + if(nesting == 0) { + return list; + } + } else if(t.kind == COMMA) { + if(nesting == nest) { + return list; }else { + list += ","; } + + }else if(t.kind == S) { + list += " "; } else if(t.kind == LBRACE) { + throw new CSSParseException("Invalid token,'{' found", getLocator()); } + getNextToken(); + } +} + +Node returnDirective() : +{ + String raw; +} +{ + raw = skipStatement() + {return null;} +} + +void debuggingDirective() : +{} +{ + debugDirective() | warnDirective() +} + +void debugDirective() : +{} +{ + + { + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. + System.out.println(content); + } + ()* +} + +void warnDirective() : +{} +{ + + { + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. + System.err.println(content); + } + ()* +} + +Node forDirective() : +{ + String var; + String from; + String to; + boolean exclusive; + String body; + Token tok; +} +{ + var = variableName() + { + int[] toThrough = {TO, THROUGH}; + from = skipStatementUntil(toThrough); + } + (tok = {exclusive = true;} + | tok = {exclusive = false;}) + to = skipStatementUntilLeftBrace() + ()* + body = skipStatement() + {return documentHandler.forDirective(var, from, to, exclusive, body);} +} + +Node whileDirective() : +{ + String condition; + String body; +} +{ + condition = skipStatementUntilLeftBrace() + body = skipStatement() + { return documentHandler.whileDirective(condition, body);} +} + +void extendDirective() : +{ArrayList list;} +{ + + ()* + list = selectorList() + (";"()*)+ + {documentHandler.extendDirective(list);} +} + +void contentDirective() : +{} +{ + + ()* + (";"()*)+ + {documentHandler.contentDirective();} +} + +JAVACODE +Node importDirective(){ + return null; +} + +JAVACODE +Node charsetDirective(){ + return null; +} + +JAVACODE +Node mozDocumentDirective(){ + return null; +} + +JAVACODE +Node supportsDirective(){ + return null; +} + + +void nestedProperties(): +{String name; +LexicalUnit exp;} +{ + name=property() + ":" ( )* + ()* + { + documentHandler.startNestedProperties(name); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + + { + documentHandler.endNestedProperties(name); + } + ()* +} +/** + * @exception ParseException exception during the parse + */ +void styleRuleOrDeclarationOrNestedProperties() : +{ +} +{ + try { + // differentiate between the colon of a pseudo and the colon of nested properties and the colon of a simple property + // first check if it is a normal styleRule, if not check if it is declarationOrNestedProperties(), if still fails, most likely, it is + // is styleRule with pseudo selector with contains functions. have to do it in this way, because both the styleRule and declarationOrNestedProperties() + // have 'skipStatementUntilXXX', which cannot be LOOKAHEAD properly. + ( debuggingDirective() | LOOKAHEAD(selectorList()) styleRule() | LOOKAHEAD(3)declarationOrNestedProperties() | styleRule()) + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} +/** + * @exception ParseException exception during the parse + */ +void declarationOrNestedProperties() : +{ boolean important = false; + String name; + LexicalUnitImpl exp; + Token save; + String comment = null; +} +{ + try { + name=property() + { save = token; } + ":" ( )* + (exp=expr() ( important=prio() )? + { + Token next = getToken(1); + if(next.kind == SEMICOLON || next.kind == RBRACE){ + while(next.kind == SEMICOLON){ + skipStatement(); + next = getToken(1); + } + //only add special token kept for sprites '/**' + if(token.specialToken!=null && token.specialToken!=null && token.specialToken.image.startsWith("/**")){ + documentHandler.property(name, exp, important, token.specialToken.image); + }else{ + documentHandler.property(name, exp, important, null); + } + } + } + | ()* + { + documentHandler.startNestedProperties(name); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + { + documentHandler.endNestedProperties(name); + } + ) + + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void declaration() : +{ boolean important = false; + String name; + LexicalUnit exp; + Token save; +} +{ + try { + name=property() + { save = token; } + ":" ( )* exp=expr() ( important=prio() )? + { + documentHandler.property(name, exp, important); + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +boolean prio() : +{} +{ + ( )* { return true; } +} + +boolean guarded() : +{} +{ + ()* {return true;} +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl operator(LexicalUnitImpl prev) : +{Token n;} +{ +/* (comments copied from basic_arithmetics.scss) +*supports: +* 1. standard arithmetic operations (+, -, *, /, %) +* 2. / is treated as css operator, unless one of its operands is variable or there is another binary arithmetic operator +*limits: +* 1. cannot mix arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will fail +* 2. space between add and minus operator and their following operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not +* 3. parenthesis is not supported now. +*/ +n="," ( )* { return LexicalUnitImpl.createComma(n.beginLine, + n.beginColumn, + prev); } +|n="/" ( )* { return LexicalUnitImpl.createSlash(n.beginLine, + n.beginColumn, + prev); } +| n="*" ( )* { return LexicalUnitImpl.createMultiply(n.beginLine, + n.beginColumn, + prev); } +| n="%" ( )* { return LexicalUnitImpl.createModulo(n.beginLine, + n.beginColumn, + prev); } +/* +* for '+', since it can be either a binary operator or an unary operator, +* which is ambiguous. To avoid this, the binary operator '+' always has +* a space before the following term. so '2+3' is not a valid binary expression, +* but '2 + 3' is. The same for '-' operator. +*/ + +| n="+" ( )+{ return LexicalUnitImpl.createAdd(n.beginLine, + n.beginColumn, + prev); } +| n="-" ( )+{ return LexicalUnitImpl.createMinus(n.beginLine, + n.beginColumn, + prev); } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl expr() : +{ + LexicalUnitImpl first, res; + char op; +} +{ + first=term(null){ res = first; } + ( LOOKAHEAD(2) ( LOOKAHEAD(2) res=operator(res) )? res=term(res))* + { return first; } +} + +/** + * @exception ParseException exception during the parse + */ +char unaryOperator() : +{} +{ + "-" { return '-'; } +| "+" { return '+'; } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl term(LexicalUnitImpl prev) : +{ LexicalUnitImpl result = null; + Token n = null; + char op = ' '; +} +{ + (result = nonVariableTerm(prev)| result = variableTerm(prev)) + { + return result; + } +} + +LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { + LexicalUnitImpl result = null; + String varName = ""; } { + varName = variableName() + {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, varName); return result;} } + +LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + String varName; + String s = ""; +} +{ +( ( ( + op=unaryOperator() )? + (n= + { result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn, + prev, number(op, n, 0)); } + | n= + { result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); } + | n= + { result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); } + | n= + { result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { + s = n.image; + int i = 0; + while (i < s.length() + && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { + i++; + } + + result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, + number(op,n,s.length()-i), + s.substring(i)); + } + | result=function(op, prev) ) ) + | ( n= + { result = + LexicalUnitImpl.createString(n.beginLine, n.beginColumn, prev, + convertStringIndex(n.image, 1, + n.image.length() -1));} + | (< DOT >{ s+="."; })?(n= | n= | n= | n=) + { s += convertIdent(n.image); + if ("inherit".equals(s)) { + result = LexicalUnitImpl.createInherit(n.beginLine, n.beginColumn, + prev); + } else { + result = LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, convertIdent(n.image)); + } + + /* / + Auto correction code used in the CSS Validator but must not + be used by a conformant CSS2 parser. + * Common error : + * H1 { + * color : black + * background : white + * } + * + Token t = getToken(1); + Token semicolon = new Token(); + semicolon.kind = SEMICOLON; + semicolon.image = ";"; + if (t.kind == COLON) { + // @@SEEME. (generate a warning?) + // @@SEEME if expression is a single ident, + generate an error ? + rejectToken(semicolon); + + result = prev; + } + / */ + } + | result=hexcolor(prev) + | result=url(prev) + | result=unicode(prev) + ) ) ( )* + { + return result; } } + +/** + * Handle all CSS2 functions. + * @exception ParseException exception during the parse + */ +LexicalUnitImpl function(char operator, LexicalUnitImpl prev) : +{Token n; + LexicalUnit params = null; +} +{ + n= ( )* + { + String fname = convertIdent(n.image); + if("alpha(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "alpha("+body); + }else if("expression(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "expression("+body); + } + } + ( params=expr() )? ")" + { + if (operator != ' ') { + throw new CSSParseException("invalid operator before a function.", + getLocator()); + } + String f = convertIdent(n.image); + LexicalUnitImpl l = (LexicalUnitImpl) params; + boolean loop = true; + if ("rgb(".equals(f)) { + // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 2: + case 4: + if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) + && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + if (loop) { + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + } + if ((i == 5) && loop && (l == null)) { + return LexicalUnitImpl.createRGBColor(n.beginLine, + n.beginColumn, + prev, params); + } else { + if (errorHandler != null) { + String errorText; + Locator loc; + if (i < 5) { + if (params == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters."; + } else if (l == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters: " + + params.toString(); + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "invalid parameter: " + + l.toString(); + } + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "too many parameters: " + + l.toString(); + } + errorHandler.error(new CSSParseException(errorText, loc)); + } + + throw new JumpException(); + } + } else if ("counter".equals(f)) { + int i = 0; + while (loop && l != null && i < 3) { + switch (i) { + case 0: + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 1: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if (((i == 1) || (i == 3)) && loop && (l == null)) { + return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn, + prev, params); + } + + } else if ("counters(".equals(f)) { + + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 4: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if (((i == 3) || (i == 5)) && loop && (l == null)) { + return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn, + prev, params); + } + } else if ("attr(".equals(f)) { + if ((l != null) + && (l.getNextLexicalUnit() == null) + && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { + return LexicalUnitImpl.createAttr(l.getLineNumber(), + l.getColumnNumber(), + prev, l.getStringValue()); + } + } else if ("rect(".equals(f)) { + int i = 0; + while (loop && l != null && i < 7) { + switch (i) { + case 0: + case 2: + case 4: + case 6: + switch (l.getLexicalUnitType()) { + case LexicalUnit.SAC_INTEGER: + if (l.getIntegerValue() != 0) { + loop = false; + } + break; + case LexicalUnit.SAC_IDENT: + if (!l.getStringValue().equals("auto")) { + loop = false; + } + break; + case LexicalUnit.SAC_EM: + case LexicalUnit.SAC_EX: + case LexicalUnit.SAC_PIXEL: + case LexicalUnit.SAC_CENTIMETER: + case LexicalUnit.SAC_MILLIMETER: + case LexicalUnit.SAC_INCH: + case LexicalUnit.SAC_POINT: + case LexicalUnit.SAC_PICA: + // nothing + break; + default: + loop = false; + } + break; + case 1: + case 3: + case 5: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if ((i == 7) && loop && (l == null)) { + return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn, + prev, params); + } + } + return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev, + f.substring(0, + f.length() -1), + params); + } +} + +LexicalUnitImpl unicode(LexicalUnitImpl prev) : +{ Token n; +} +{ + n= + { + LexicalUnitImpl params = null; + String s = n.image.substring(2); + int index = s.indexOf('-'); + if (index == -1) { + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s, 16)); + } else { + String s1 = s.substring(0, index); + String s2 = s.substring(index); + + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s1, 16)); + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s2, 16)); + } + + return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn, + prev, params); + } +} + +LexicalUnitImpl url(LexicalUnitImpl prev) : +{ Token n; +} +{ + n= + { + String urlname = n.image.substring(4, n.image.length()-1).trim(); + return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname); + } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl hexcolor(LexicalUnitImpl prev) : +{Token n; +} +{ + n= + { + int r; + LexicalUnitImpl first, params = null; + String s = n.image.substring(1); + + if(s.length()!=3 && s.length()!=6) { + first = null; + throw new CSSParseException("invalid hexadecimal notation for RGB: " + s, + getLocator()); + } + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, n.image); + } +} + +JAVACODE +float number(char operator, Token n, int lengthUnit) { + String image = n.image; + float f = 0; + + if (lengthUnit != 0) { + image = image.substring(0, image.length() - lengthUnit); + } + f = Float.valueOf(image).floatValue(); + return (operator == '-')? -f: f; +} + +JAVACODE +String skipStatementUntilSemiColon(){ + int[] semicolon = {SEMICOLON}; + return skipStatementUntil(semicolon); +} + +JAVACODE +String skipStatementUntilLeftBrace(){ + int[] lBrace = {LBRACE}; + return skipStatementUntil(lBrace); +} + +JAVACODE +String skipStatementUntilMatchingRightParan(){ + int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "(" + int[] rightTokens = {RPARAN}; + StringBuffer s = new StringBuffer(); + int difference = 1; + Token tok; + while(difference != 0){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; + } + for(int sym : leftTokens){ + if(tok.kind == sym){ + difference++; + } + } + for(int sym : rightTokens){ + if(tok.kind == sym){ + difference--; + } + } + if(difference != 0){ + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); +} + +JAVACODE +String skipStatementUntil(int[] symbols){ + StringBuffer s = new StringBuffer(); + boolean stop = false; + Token tok; + while(!stop){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; + } + for(int sym : symbols){ + if(tok.kind == sym){ + stop = true; + break; + } + } + if(!stop){ + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); +} + + +JAVACODE +String skipStatement() { + StringBuffer s = new StringBuffer(); + Token tok = getToken(0); + if (tok.image != null) { + s.append(tok.image); + } + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == RBRACE) { + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == SEMICOLON) { + getNextToken(); + tok = getToken(1); + break; + } + getNextToken(); + } + + // skip white space + while (true) { + if (tok.kind != S) { + break; + } + tok = getNextToken(); + tok = getToken(1); + } + + return s.toString().trim(); +} + +JAVACODE +String skip_to_matching_brace() { + StringBuffer s = new StringBuffer(); + Token tok; + int nesting = 1; + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + break; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + nesting++; + } else if (tok.kind == RBRACE) { + nesting--; + if (nesting == 0) { + break; + } + } + getNextToken(); + } + return s.toString(); +} + +/* + * Here I handle all CSS2 unicode character stuffs. + * I convert all \XXXXXX character into a single character. + * Don't forget that the parser has recognize the token before. + * (So IDENT won't contain newline and stuffs like this). + */ +JAVACODE +String convertStringIndex(String s, int start, int len) { + StringBuffer buf = new StringBuffer(len); + int index = start; + + while (index < len) { + char c = s.charAt(index); + if (c == '\\') { + if (++index < len) { + c = s.charAt(index); + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + buf.append('\\'); + while (index < len) { + buf.append(s.charAt(index++)); + } + break; + case '\n': + case '\f': + break; + case '\r': + if (index + 1 < len) { + if (s.charAt(index + 1) == '\n') { + index ++; + } + } + break; + default: + buf.append(c); + } + } else { + throw new CSSParseException("invalid string " + s, getLocator()); + } + } else { + buf.append(c); + } + index++; + } + + return buf.toString(); +} + +JAVACODE +String convertIdent(String s) { + return convertStringIndex(s, 0, s.length()); +} + +JAVACODE +String convertString(String s) { + return convertStringIndex(s, 0, s.length()); +} + +JAVACODE +void comments(){ + /*keeps only the multiple line comments, single line comments are skipped*/ + if (token.specialToken != null && token.specialToken.image!=null && token.specialToken.image.startsWith("/*")){ + Token tmp_t = token.specialToken; + while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; + while (tmp_t != null) { + documentHandler.comment(tmp_t.image); + tmp_t = tmp_t.next; + } + } +} + +/* + * @@HACK + * I can't insert a token into the tokens flow. + * It's jj_consume_token implementation dependant! :-( + */ +JAVACODE +void rejectToken(Token t) { + Token fakeToken = new Token(); + t.next = token; + fakeToken.next = t; + token = fakeToken; +} + +/** + * skip after an expression + */ +JAVACODE +String skipAfterExpression() { + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + + while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + + return s.toString(); +} + +/** + * The following functions are useful for a DOM CSS implementation only and are + * not part of the general CSS2 parser. + */ +// TODO required by original parser but not used by Vaadin? +void _parseRule() : +{String ret = null; +} +{ + ( )* + ( importDeclaration() | debuggingDirective() | styleRule() | media() | page() | fontFace() | ret=skipStatement() + { + if ((ret == null) || (ret.length() == 0)) { + return; + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + throw new CSSParseException("unrecognize rule: " + ret, + getLocator()); + } + } + ) +} + +void _parseImportRule() : +{ +} +{ + ( )* importDeclaration() +} + +void _parseMediaRule() : +{ +} +{ + ( )* media() +} + +void _parseDeclarationBlock() : +{ +} +{ + ( )* + ( declaration() )? ( ";" ( )* ( declaration() )? )* + } + +ArrayList _parseSelectors() : +{ ArrayList p = null; +} +{ + try { + ( )* p = selectorList() + { return p; } + } catch (ThrowedParseException e) { + throw (ParseException) e.e.fillInStackTrace(); + } +} + +/* + * Local Variables: + * compile-command: javacc Parser.jj & javac Parser.java + * End: + */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java deleted file mode 100644 index d54ab4fa7e..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java +++ /dev/null @@ -1,4997 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. ParserTokenManager.java */ -package com.vaadin.sass.internal.parser; -import java.io.*; -import java.net.*; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; -import org.w3c.css.sac.ConditionFactory; -import org.w3c.css.sac.Condition; -import org.w3c.css.sac.SelectorFactory; -import org.w3c.css.sac.SelectorList; -import org.w3c.css.sac.Selector; -import org.w3c.css.sac.SimpleSelector; -import org.w3c.css.sac.DocumentHandler; -import org.w3c.css.sac.InputSource; -import org.w3c.css.sac.ErrorHandler; -import org.w3c.css.sac.CSSException; -import org.w3c.css.sac.CSSParseException; -import org.w3c.css.sac.Locator; -import org.w3c.css.sac.LexicalUnit; -import org.w3c.flute.parser.selectors.SelectorFactoryImpl; -import org.w3c.flute.parser.selectors.ConditionFactoryImpl; -import org.w3c.flute.util.Encoding; -import com.vaadin.sass.internal.handler.*; -import com.vaadin.sass.internal.tree.*; - -/** Token Manager. */ -public class ParserTokenManager implements ParserConstants -{ - - /** Debug output. */ - public java.io.PrintStream debugStream = System.out; - /** Set debug output. */ - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) -{ - switch (pos) - { - case 0: - if ((active0 & 0xffe0000000000000L) != 0L || (active1 & 0x3e0000000fL) != 0L) - return 162; - if ((active0 & 0xe000000000000L) != 0L || (active1 & 0x20L) != 0L) - { - jjmatchedKind = 72; - return 522; - } - if ((active0 & 0x80000000L) != 0L) - return 523; - if ((active0 & 0x10000000000000L) != 0L) - { - jjmatchedKind = 72; - return 29; - } - if ((active0 & 0x4000L) != 0L) - return 75; - if ((active0 & 0x2000010L) != 0L) - return 216; - if ((active0 & 0x80200L) != 0L) - return 38; - if ((active0 & 0x2000000000L) != 0L) - return 524; - return -1; - case 1: - if ((active1 & 0x2L) != 0L) - return 174; - if ((active0 & 0xffe0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 1; - return 525; - } - if ((active0 & 0x14000000000000L) != 0L) - { - jjmatchedKind = 72; - jjmatchedPos = 1; - return 522; - } - if ((active0 & 0xa000000000000L) != 0L || (active1 & 0x20L) != 0L) - return 522; - if ((active0 & 0x10L) != 0L) - return 221; - return -1; - case 2: - if ((active0 & 0xbfe0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 2; - return 525; - } - if ((active0 & 0x4000000000000000L) != 0L) - return 525; - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 2; - return 173; - } - if ((active0 & 0x14000000000000L) != 0L) - { - jjmatchedKind = 72; - jjmatchedPos = 2; - return 522; - } - return -1; - case 3: - if ((active0 & 0xb7e0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 3; - return 525; - } - if ((active0 & 0x800000000000000L) != 0L) - return 525; - if ((active0 & 0x4000000000000L) != 0L) - { - jjmatchedKind = 72; - jjmatchedPos = 3; - return 522; - } - if ((active0 & 0x10000000000000L) != 0L) - return 522; - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 3; - return 172; - } - return -1; - case 4: - if ((active0 & 0x9400000000000000L) != 0L || (active1 & 0x1000000000L) != 0L) - return 525; - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 4; - return 171; - } - if ((active0 & 0x4000000000000L) != 0L) - { - jjmatchedKind = 72; - jjmatchedPos = 4; - return 522; - } - if ((active0 & 0x23e0000000000000L) != 0L || (active1 & 0x2e0000000dL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 4; - return 525; - } - return -1; - case 5: - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 5; - return 170; - } - if ((active0 & 0x4000000000000L) != 0L) - { - jjmatchedKind = 72; - jjmatchedPos = 5; - return 522; - } - if ((active0 & 0x2220000000000000L) != 0L || (active1 & 0x400000000L) != 0L) - return 525; - if ((active0 & 0x1c0000000000000L) != 0L || (active1 & 0x2a0000000dL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 5; - return 525; - } - return -1; - case 6: - if ((active0 & 0x100000000000000L) != 0L || (active1 & 0x200000001L) != 0L) - return 525; - if ((active0 & 0x4000000000000L) != 0L) - return 522; - if ((active0 & 0xc0000000000000L) != 0L || (active1 & 0x280000000eL) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 6; - return 525; - } - return -1; - case 7: - if ((active0 & 0x40000000000000L) != 0L || (active1 & 0x800000008L) != 0L) - return 525; - if ((active0 & 0x80000000000000L) != 0L || (active1 & 0x2000000006L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 7; - return 525; - } - return -1; - case 8: - if ((active1 & 0x2000000002L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 8; - return 525; - } - if ((active0 & 0x80000000000000L) != 0L || (active1 & 0x4L) != 0L) - return 525; - return -1; - case 9: - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 9; - return 525; - } - if ((active1 & 0x2000000000L) != 0L) - return 525; - return -1; - case 10: - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 10; - return 525; - } - return -1; - case 11: - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 11; - return 525; - } - return -1; - case 12: - if ((active1 & 0x2L) != 0L) - { - jjmatchedKind = 103; - jjmatchedPos = 12; - return 525; - } - return -1; - default : - return -1; - } -} -private final int jjStartNfa_0(int pos, long active0, long active1) -{ - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); -} -private int jjStopAtPos(int pos, int kind) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; -} -private int jjMoveStringLiteralDfa0_0() -{ - switch(curChar) - { - case 33: - return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L); - case 36: - return jjMoveStringLiteralDfa1_0(0x4000L, 0x0L); - case 37: - return jjStopAtPos(0, 29); - case 38: - jjmatchedKind = 30; - return jjMoveStringLiteralDfa1_0(0x1000000000L, 0x0L); - case 40: - return jjStopAtPos(0, 32); - case 41: - return jjStopAtPos(0, 33); - case 42: - jjmatchedKind = 28; - return jjMoveStringLiteralDfa1_0(0x8000L, 0x0L); - case 43: - return jjStopAtPos(0, 18); - case 44: - return jjStopAtPos(0, 20); - case 45: - jjmatchedKind = 19; - return jjMoveStringLiteralDfa1_0(0x200L, 0x0L); - case 46: - return jjStartNfaWithStates_0(0, 31, 523); - case 47: - jjmatchedKind = 25; - return jjMoveStringLiteralDfa1_0(0x10L, 0x0L); - case 58: - return jjStopAtPos(0, 38); - case 59: - return jjStopAtPos(0, 21); - case 60: - jjmatchedKind = 24; - return jjMoveStringLiteralDfa1_0(0x100L, 0x0L); - case 61: - jjmatchedKind = 17; - return jjMoveStringLiteralDfa1_0(0x400000000L, 0x0L); - case 62: - return jjStopAtPos(0, 22); - case 64: - return jjMoveStringLiteralDfa1_0(0xffe0000000000000L, 0x3e0000000fL); - case 91: - return jjStopAtPos(0, 26); - case 93: - return jjStopAtPos(0, 27); - case 94: - return jjMoveStringLiteralDfa1_0(0x2000L, 0x0L); - case 70: - case 102: - return jjMoveStringLiteralDfa1_0(0x10000000000000L, 0x0L); - case 73: - case 105: - return jjMoveStringLiteralDfa1_0(0x8000000000000L, 0x20L); - case 84: - case 116: - return jjMoveStringLiteralDfa1_0(0x6000000000000L, 0x0L); - case 123: - return jjStopAtPos(0, 10); - case 124: - return jjMoveStringLiteralDfa1_0(0x800001000L, 0x0L); - case 125: - return jjStopAtPos(0, 11); - case 126: - jjmatchedKind = 23; - return jjMoveStringLiteralDfa1_0(0x10000L, 0x0L); - default : - return jjMoveNfa_0(24, 0); - } -} -private int jjMoveStringLiteralDfa1_0(long active0, long active1) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0, active1); - return 1; - } - switch(curChar) - { - case 33: - return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L); - case 38: - if ((active0 & 0x1000000000L) != 0L) - return jjStopAtPos(1, 36); - break; - case 42: - if ((active0 & 0x10L) != 0L) - return jjStartNfaWithStates_0(1, 4, 221); - break; - case 45: - return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0x2L); - case 61: - if ((active0 & 0x1000L) != 0L) - return jjStopAtPos(1, 12); - else if ((active0 & 0x2000L) != 0L) - return jjStopAtPos(1, 13); - else if ((active0 & 0x4000L) != 0L) - return jjStopAtPos(1, 14); - else if ((active0 & 0x8000L) != 0L) - return jjStopAtPos(1, 15); - else if ((active0 & 0x10000L) != 0L) - return jjStopAtPos(1, 16); - else if ((active0 & 0x400000000L) != 0L) - return jjStopAtPos(1, 34); - else if ((active0 & 0x2000000000L) != 0L) - return jjStopAtPos(1, 37); - break; - case 67: - case 99: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x800000008L); - case 68: - case 100: - return jjMoveStringLiteralDfa2_0(active0, 0x200000000000000L, active1, 0L); - case 69: - case 101: - return jjMoveStringLiteralDfa2_0(active0, 0x9000000000000000L, active1, 0x1L); - case 70: - case 102: - if ((active1 & 0x20L) != 0L) - return jjStartNfaWithStates_0(1, 69, 522); - return jjMoveStringLiteralDfa2_0(active0, 0x880000000000000L, active1, 0x2000000000L); - case 72: - case 104: - return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L); - case 73: - case 105: - return jjMoveStringLiteralDfa2_0(active0, 0x4040000000000000L, active1, 0x200000000L); - case 77: - case 109: - return jjMoveStringLiteralDfa2_0(active0, 0x20000000000000L, active1, 0x400000000L); - case 78: - case 110: - if ((active0 & 0x8000000000000L) != 0L) - return jjStartNfaWithStates_0(1, 51, 522); - break; - case 79: - case 111: - if ((active0 & 0x2000000000000L) != 0L) - return jjStartNfaWithStates_0(1, 49, 522); - break; - case 80: - case 112: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x1000000000L); - case 82: - case 114: - return jjMoveStringLiteralDfa2_0(active0, 0x110000000000000L, active1, 0L); - case 83: - case 115: - return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4L); - case 87: - case 119: - return jjMoveStringLiteralDfa2_0(active0, 0x2400000000000000L, active1, 0L); - case 124: - if ((active0 & 0x800000000L) != 0L) - return jjStopAtPos(1, 35); - break; - default : - break; - } - return jjStartNfa_0(0, active0, active1); -} -private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(0, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0, active1); - return 2; - } - switch(curChar) - { - case 45: - return jjMoveStringLiteralDfa3_0(active0, 0x100L, active1, 0L); - case 62: - if ((active0 & 0x200L) != 0L) - return jjStopAtPos(2, 9); - break; - case 65: - case 97: - return jjMoveStringLiteralDfa3_0(active0, 0x1400000000000000L, active1, 0x1000000000L); - case 69: - case 101: - return jjMoveStringLiteralDfa3_0(active0, 0x300000000000000L, active1, 0x400000000L); - case 70: - case 102: - if ((active0 & 0x4000000000000000L) != 0L) - return jjStartNfaWithStates_0(2, 62, 525); - break; - case 72: - case 104: - return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0x800000000L); - case 73: - case 105: - return jjMoveStringLiteralDfa3_0(active0, 0x20000000000000L, active1, 0L); - case 76: - case 108: - return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000000L, active1, 0L); - case 77: - case 109: - return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x200000002L); - case 78: - case 110: - return jjMoveStringLiteralDfa3_0(active0, 0x40000000000000L, active1, 0L); - case 79: - case 111: - return jjMoveStringLiteralDfa3_0(active0, 0x810000000000000L, active1, 0x2000000008L); - case 82: - case 114: - return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L, active1, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa3_0(active0, 0x80000000000000L, active1, 0x4L); - case 88: - case 120: - return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x1L); - default : - break; - } - return jjStartNfa_0(1, active0, active1); -} -private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(1, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(2, active0, active1); - return 3; - } - switch(curChar) - { - case 45: - if ((active0 & 0x100L) != 0L) - return jjStopAtPos(3, 8); - break; - case 65: - case 97: - return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x800000000L); - case 66: - case 98: - return jjMoveStringLiteralDfa4_0(active0, 0x200000000000000L, active1, 0L); - case 67: - case 99: - return jjMoveStringLiteralDfa4_0(active0, 0x1040000000000000L, active1, 0L); - case 68: - case 100: - return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x400000000L); - case 71: - case 103: - return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x1000000000L); - case 73: - case 105: - return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000000L, active1, 0L); - case 77: - case 109: - if ((active0 & 0x10000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 52, 522); - break; - case 78: - case 110: - return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0x2000000008L); - case 79: - case 111: - return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L, active1, 0x2L); - case 80: - case 112: - return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x200000004L); - case 82: - case 114: - if ((active0 & 0x800000000000000L) != 0L) - return jjStartNfaWithStates_0(3, 59, 525); - return jjMoveStringLiteralDfa4_0(active0, 0x400000000000000L, active1, 0L); - case 83: - case 115: - return jjMoveStringLiteralDfa4_0(active0, 0x8000000000000000L, active1, 0L); - case 84: - case 116: - return jjMoveStringLiteralDfa4_0(active0, 0x100000000000000L, active1, 0x1L); - case 88: - case 120: - return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L, active1, 0L); - default : - break; - } - return jjStartNfa_0(2, active0, active1); -} -private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(2, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(3, active0, active1); - return 4; - } - switch(curChar) - { - case 67: - case 99: - return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L, active1, 0L); - case 69: - case 101: - if ((active0 & 0x8000000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 63, 525); - else if ((active1 & 0x1000000000L) != 0L) - return jjStartNfaWithStates_0(4, 100, 525); - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x1L); - case 72: - case 104: - if ((active0 & 0x1000000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 60, 525); - break; - case 73: - case 105: - return jjMoveStringLiteralDfa5_0(active0, 0x20000000000000L, active1, 0x400000000L); - case 76: - case 108: - return jjMoveStringLiteralDfa5_0(active0, 0x2040000000000000L, active1, 0L); - case 78: - case 110: - if ((active0 & 0x400000000000000L) != 0L) - return jjStartNfaWithStates_0(4, 58, 525); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x200000000L); - case 80: - case 112: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x4L); - case 82: - case 114: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x800000000L); - case 84: - case 116: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x2000000008L); - case 85: - case 117: - return jjMoveStringLiteralDfa5_0(active0, 0x304000000000000L, active1, 0L); - case 90: - case 122: - return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x2L); - default : - break; - } - return jjStartNfa_0(3, active0, active1); -} -private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(3, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(4, active0, active1); - return 5; - } - switch(curChar) - { - case 45: - return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x2000000002L); - case 65: - case 97: - if ((active1 & 0x400000000L) != 0L) - return jjStartNfaWithStates_0(5, 98, 525); - break; - case 69: - case 101: - if ((active0 & 0x2000000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 61, 525); - return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x8L); - case 71: - case 103: - if ((active0 & 0x200000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 57, 525); - return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000L, active1, 0L); - case 78: - case 110: - if ((active0 & 0x20000000000000L) != 0L) - return jjStartNfaWithStates_0(5, 53, 525); - return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x1L); - case 79: - case 111: - return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x4L); - case 82: - case 114: - return jjMoveStringLiteralDfa6_0(active0, 0x100000000000000L, active1, 0x200000000L); - case 83: - case 115: - return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x800000000L); - case 84: - case 116: - return jjMoveStringLiteralDfa6_0(active0, 0x80000000000000L, active1, 0L); - case 85: - case 117: - return jjMoveStringLiteralDfa6_0(active0, 0x40000000000000L, active1, 0L); - default : - break; - } - return jjStartNfa_0(4, active0, active1); -} -private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(4, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(5, active0, active1); - return 6; - } - switch(curChar) - { - case 68: - case 100: - if ((active1 & 0x1L) != 0L) - return jjStartNfaWithStates_0(6, 64, 525); - return jjMoveStringLiteralDfa7_0(active0, 0x40000000000000L, active1, 0x2L); - case 69: - case 101: - return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x800000000L); - case 70: - case 102: - return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x2000000000L); - case 72: - case 104: - if ((active0 & 0x4000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 50, 522); - break; - case 73: - case 105: - return jjMoveStringLiteralDfa7_0(active0, 0x80000000000000L, active1, 0L); - case 78: - case 110: - if ((active0 & 0x100000000000000L) != 0L) - return jjStartNfaWithStates_0(6, 56, 525); - return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x8L); - case 82: - case 114: - return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x4L); - case 84: - case 116: - if ((active1 & 0x200000000L) != 0L) - return jjStartNfaWithStates_0(6, 97, 525); - break; - default : - break; - } - return jjStartNfa_0(5, active0, active1); -} -private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(5, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(6, active0, active1); - return 7; - } - switch(curChar) - { - case 65: - case 97: - return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x2000000000L); - case 69: - case 101: - if ((active0 & 0x40000000000000L) != 0L) - return jjStartNfaWithStates_0(7, 54, 525); - break; - case 79: - case 111: - return jjMoveStringLiteralDfa8_0(active0, 0x80000000000000L, active1, 0x2L); - case 84: - case 116: - if ((active1 & 0x8L) != 0L) - return jjStartNfaWithStates_0(7, 67, 525); - else if ((active1 & 0x800000000L) != 0L) - return jjStartNfaWithStates_0(7, 99, 525); - return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x4L); - default : - break; - } - return jjStartNfa_0(6, active0, active1); -} -private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(6, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(7, active0, active1); - return 8; - } - switch(curChar) - { - case 67: - case 99: - return jjMoveStringLiteralDfa9_0(active0, 0L, active1, 0x2000000002L); - case 78: - case 110: - if ((active0 & 0x80000000000000L) != 0L) - return jjStartNfaWithStates_0(8, 55, 525); - break; - case 83: - case 115: - if ((active1 & 0x4L) != 0L) - return jjStartNfaWithStates_0(8, 66, 525); - break; - default : - break; - } - return jjStartNfa_0(7, active0, active1); -} -private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long active1) -{ - if (((active0 &= old0) | (active1 &= old1)) == 0L) - return jjStartNfa_0(7, old0, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(8, 0L, active1); - return 9; - } - switch(curChar) - { - case 69: - case 101: - if ((active1 & 0x2000000000L) != 0L) - return jjStartNfaWithStates_0(9, 101, 525); - break; - case 85: - case 117: - return jjMoveStringLiteralDfa10_0(active1, 0x2L); - default : - break; - } - return jjStartNfa_0(8, 0L, active1); -} -private int jjMoveStringLiteralDfa10_0(long old1, long active1) -{ - if (((active1 &= old1)) == 0L) - return jjStartNfa_0(8, 0L, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(9, 0L, active1); - return 10; - } - switch(curChar) - { - case 77: - case 109: - return jjMoveStringLiteralDfa11_0(active1, 0x2L); - default : - break; - } - return jjStartNfa_0(9, 0L, active1); -} -private int jjMoveStringLiteralDfa11_0(long old1, long active1) -{ - if (((active1 &= old1)) == 0L) - return jjStartNfa_0(9, 0L, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(10, 0L, active1); - return 11; - } - switch(curChar) - { - case 69: - case 101: - return jjMoveStringLiteralDfa12_0(active1, 0x2L); - default : - break; - } - return jjStartNfa_0(10, 0L, active1); -} -private int jjMoveStringLiteralDfa12_0(long old1, long active1) -{ - if (((active1 &= old1)) == 0L) - return jjStartNfa_0(10, 0L, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(11, 0L, active1); - return 12; - } - switch(curChar) - { - case 78: - case 110: - return jjMoveStringLiteralDfa13_0(active1, 0x2L); - default : - break; - } - return jjStartNfa_0(11, 0L, active1); -} -private int jjMoveStringLiteralDfa13_0(long old1, long active1) -{ - if (((active1 &= old1)) == 0L) - return jjStartNfa_0(11, 0L, old1); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(12, 0L, active1); - return 13; - } - switch(curChar) - { - case 84: - case 116: - if ((active1 & 0x2L) != 0L) - return jjStartNfaWithStates_0(13, 65, 525); - break; - default : - break; - } - return jjStartNfa_0(12, 0L, active1); -} -private int jjStartNfaWithStates_0(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_0(state, pos + 1); -} -static final long[] jjbitVec0 = { - 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL -}; -private int jjMoveNfa_0(int startState, int curPos) -{ - int startsAt = 0; - jjnewStateCnt = 522; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 524: - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(256, 265); - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(248, 255); - break; - case 162: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 108; - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 213; - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 201; - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 185; - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 174; - break; - case 29: - if ((0x3ff200000000000L & l) != 0L) - jjCheckNAddStates(0, 3); - else if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(236, 237); - else if (curChar == 40) - { - if (kind > 118) - kind = 118; - } - if ((0x3ff200000000000L & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - break; - case 171: - if ((0x3ff200000000000L & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 170; - break; - case 523: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(4, 8); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(327, 330); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(324, 326); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(322, 323); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(319, 321); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(314, 318); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(310, 313); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(306, 309); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(303, 305); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(299, 302); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(295, 298); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(292, 294); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(289, 291); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(286, 288); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(283, 285); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(280, 282); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(277, 279); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(274, 276); - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(272, 273); - if ((0x3ff000000000000L & l) != 0L) - { - if (kind > 73) - kind = 73; - jjCheckNAdd(271); - } - break; - case 525: - case 109: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 216: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 221; - else if (curChar == 47) - { - if (kind > 2) - kind = 2; - jjCheckNAddStates(9, 11); - } - break; - case 173: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 24: - if ((0x3ff000000000000L & l) != 0L) - { - if (kind > 73) - kind = 73; - jjCheckNAddStates(12, 93); - } - else if ((0x100003600L & l) != 0L) - { - if (kind > 1) - kind = 1; - jjCheckNAdd(0); - } - else if (curChar == 46) - jjCheckNAddStates(94, 113); - else if (curChar == 45) - jjAddStates(114, 115); - else if (curChar == 33) - jjCheckNAddStates(116, 119); - else if (curChar == 47) - jjAddStates(120, 121); - else if (curChar == 35) - jjCheckNAddTwoStates(96, 97); - else if (curChar == 36) - jjCheckNAddStates(122, 125); - else if (curChar == 39) - jjCheckNAddStates(126, 129); - else if (curChar == 34) - jjCheckNAddStates(130, 133); - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 38; - else if (curChar == 35) - jjstateSet[jjnewStateCnt++] = 1; - break; - case 172: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 170: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 75: - if (curChar == 45) - jjCheckNAdd(76); - break; - case 522: - if ((0x3ff200000000000L & l) != 0L) - jjCheckNAddStates(0, 3); - else if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(236, 237); - else if (curChar == 40) - { - if (kind > 118) - kind = 118; - } - if ((0x3ff200000000000L & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - break; - case 0: - if ((0x100003600L & l) == 0L) - break; - if (kind > 1) - kind = 1; - jjCheckNAdd(0); - break; - case 2: - if (curChar == 36) - jjCheckNAddStates(134, 137); - break; - case 3: - if (curChar == 45) - jjCheckNAdd(4); - break; - case 5: - if ((0x3ff200000000000L & l) != 0L) - jjCheckNAddStates(138, 140); - break; - case 8: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(138, 140); - break; - case 9: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(141, 145); - break; - case 10: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(138, 140); - break; - case 11: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(146, 153); - break; - case 12: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(154, 157); - break; - case 13: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(158, 162); - break; - case 14: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(163, 168); - break; - case 15: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(169, 175); - break; - case 18: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(176, 180); - break; - case 19: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(181, 188); - break; - case 20: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(189, 192); - break; - case 21: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(193, 197); - break; - case 22: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(198, 203); - break; - case 23: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(204, 210); - break; - case 36: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 35; - break; - case 39: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 38; - break; - case 40: - if (curChar == 34) - jjCheckNAddStates(130, 133); - break; - case 41: - if ((0xfffffffb00000200L & l) != 0L) - jjCheckNAddStates(130, 133); - break; - case 42: - if (curChar == 34 && kind > 71) - kind = 71; - break; - case 44: - if (curChar == 12) - jjCheckNAddStates(130, 133); - break; - case 46: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(130, 133); - break; - case 47: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(211, 216); - break; - case 48: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(130, 133); - break; - case 49: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(217, 225); - break; - case 50: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(226, 230); - break; - case 51: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(231, 236); - break; - case 52: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(237, 243); - break; - case 53: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(244, 251); - break; - case 54: - if (curChar == 13) - jjCheckNAddStates(130, 133); - break; - case 55: - if (curChar == 10) - jjCheckNAddStates(130, 133); - break; - case 56: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 55; - break; - case 57: - if (curChar == 39) - jjCheckNAddStates(126, 129); - break; - case 58: - if ((0xffffff7f00000200L & l) != 0L) - jjCheckNAddStates(126, 129); - break; - case 59: - if (curChar == 39 && kind > 71) - kind = 71; - break; - case 61: - if (curChar == 12) - jjCheckNAddStates(126, 129); - break; - case 63: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(126, 129); - break; - case 64: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(252, 257); - break; - case 65: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(126, 129); - break; - case 66: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(258, 266); - break; - case 67: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(267, 271); - break; - case 68: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(272, 277); - break; - case 69: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(278, 284); - break; - case 70: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(285, 292); - break; - case 71: - if (curChar == 13) - jjCheckNAddStates(126, 129); - break; - case 72: - if (curChar == 10) - jjCheckNAddStates(126, 129); - break; - case 73: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 72; - break; - case 74: - if (curChar == 36) - jjCheckNAddStates(122, 125); - break; - case 77: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 79: - if ((0xffffffff00000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 80: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(293, 296); - break; - case 81: - if ((0x100003600L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 82: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(297, 303); - break; - case 83: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(304, 306); - break; - case 84: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(307, 310); - break; - case 85: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(311, 315); - break; - case 86: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(316, 321); - break; - case 89: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(322, 325); - break; - case 90: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(326, 332); - break; - case 91: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(333, 335); - break; - case 92: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(336, 339); - break; - case 93: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(340, 344); - break; - case 94: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(345, 350); - break; - case 95: - if (curChar == 35) - jjCheckNAddTwoStates(96, 97); - break; - case 96: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 98: - if ((0xffffffff00000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 99: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(351, 354); - break; - case 100: - if ((0x100003600L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 101: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(355, 361); - break; - case 102: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(362, 364); - break; - case 103: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(365, 368); - break; - case 104: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(369, 373); - break; - case 105: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(374, 379); - break; - case 107: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 108; - break; - case 111: - if ((0xffffffff00000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 112: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(380, 383); - break; - case 113: - if ((0x100003600L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 114: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(384, 390); - break; - case 115: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(391, 393); - break; - case 116: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(394, 397); - break; - case 117: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(398, 402); - break; - case 118: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(403, 408); - break; - case 121: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(409, 412); - break; - case 122: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(413, 419); - break; - case 123: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(420, 422); - break; - case 124: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(423, 426); - break; - case 125: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(427, 431); - break; - case 126: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(432, 437); - break; - case 128: - if ((0x100003600L & l) != 0L) - jjAddStates(438, 439); - break; - case 129: - if (curChar == 40 && kind > 115) - kind = 115; - break; - case 136: - if ((0x100003600L & l) != 0L) - jjAddStates(440, 441); - break; - case 137: - if (curChar == 40 && kind > 116) - kind = 116; - break; - case 144: - if ((0x100003600L & l) != 0L) - jjAddStates(442, 443); - break; - case 145: - if (curChar == 40 && kind > 117) - kind = 117; - break; - case 175: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 174; - break; - case 184: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 183; - break; - case 186: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 185; - break; - case 195: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 194; - break; - case 202: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 201; - break; - case 211: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 210; - break; - case 214: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 213; - break; - case 215: - if (curChar == 47) - jjAddStates(120, 121); - break; - case 217: - if ((0xffffffffffffdbffL & l) == 0L) - break; - if (kind > 2) - kind = 2; - jjCheckNAddStates(9, 11); - break; - case 218: - if ((0x2400L & l) != 0L && kind > 2) - kind = 2; - break; - case 219: - if (curChar == 10 && kind > 2) - kind = 2; - break; - case 220: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 219; - break; - case 221: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 222; - break; - case 222: - if ((0xffff7fffffffffffL & l) != 0L && kind > 3) - kind = 3; - break; - case 223: - if (curChar == 42) - jjstateSet[jjnewStateCnt++] = 221; - break; - case 225: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 227: - if ((0xffffffff00000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 228: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(444, 447); - break; - case 229: - if ((0x100003600L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 230: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(448, 454); - break; - case 231: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(455, 457); - break; - case 232: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(458, 461); - break; - case 233: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(462, 466); - break; - case 234: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(467, 472); - break; - case 235: - if ((0x3ff200000000000L & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 236: - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(236, 237); - break; - case 237: - if (curChar == 40 && kind > 118) - kind = 118; - break; - case 239: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 240: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(473, 477); - break; - case 241: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 242: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(478, 485); - break; - case 243: - case 457: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(486, 489); - break; - case 244: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(490, 494); - break; - case 245: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(495, 500); - break; - case 246: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(501, 507); - break; - case 247: - if (curChar == 33) - jjCheckNAddStates(116, 119); - break; - case 248: - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(248, 255); - break; - case 256: - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(256, 265); - break; - case 266: - if (curChar == 45) - jjAddStates(114, 115); - break; - case 270: - if (curChar == 46) - jjCheckNAddStates(94, 113); - break; - case 271: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 73) - kind = 73; - jjCheckNAdd(271); - break; - case 272: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(272, 273); - break; - case 273: - if (curChar == 37 && kind > 77) - kind = 77; - break; - case 274: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(274, 276); - break; - case 277: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(277, 279); - break; - case 280: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(280, 282); - break; - case 283: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(283, 285); - break; - case 286: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(286, 288); - break; - case 289: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(289, 291); - break; - case 292: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(292, 294); - break; - case 295: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(295, 298); - break; - case 299: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(299, 302); - break; - case 303: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(303, 305); - break; - case 306: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(306, 309); - break; - case 310: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(310, 313); - break; - case 314: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(314, 318); - break; - case 319: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(319, 321); - break; - case 322: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(322, 323); - break; - case 324: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(324, 326); - break; - case 327: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(327, 330); - break; - case 331: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(4, 8); - break; - case 332: - if (curChar == 45) - jjCheckNAdd(333); - break; - case 334: - if ((0x3ff200000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 336: - if ((0xffffffff00000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 337: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(508, 511); - break; - case 338: - if ((0x100003600L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 339: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(512, 518); - break; - case 340: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(519, 521); - break; - case 341: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(522, 525); - break; - case 342: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(526, 530); - break; - case 343: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(531, 536); - break; - case 346: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(537, 540); - break; - case 347: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(541, 547); - break; - case 348: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(548, 550); - break; - case 349: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(551, 554); - break; - case 350: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(555, 559); - break; - case 351: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(560, 565); - break; - case 353: - if (curChar == 40) - jjCheckNAddStates(566, 571); - break; - case 354: - if ((0xfffffc7a00000000L & l) != 0L) - jjCheckNAddStates(572, 575); - break; - case 355: - if ((0x100003600L & l) != 0L) - jjCheckNAddTwoStates(355, 356); - break; - case 356: - if (curChar == 41 && kind > 75) - kind = 75; - break; - case 358: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(572, 575); - break; - case 359: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(576, 580); - break; - case 360: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(572, 575); - break; - case 361: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(581, 588); - break; - case 362: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(589, 592); - break; - case 363: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(593, 597); - break; - case 364: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(598, 603); - break; - case 365: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(604, 610); - break; - case 366: - if (curChar == 39) - jjCheckNAddStates(611, 614); - break; - case 367: - if ((0xffffff7f00000200L & l) != 0L) - jjCheckNAddStates(611, 614); - break; - case 368: - if (curChar == 39) - jjCheckNAddTwoStates(355, 356); - break; - case 370: - if (curChar == 12) - jjCheckNAddStates(611, 614); - break; - case 372: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(611, 614); - break; - case 373: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(615, 620); - break; - case 374: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(611, 614); - break; - case 375: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(621, 629); - break; - case 376: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(630, 634); - break; - case 377: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(635, 640); - break; - case 378: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(641, 647); - break; - case 379: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(648, 655); - break; - case 380: - if (curChar == 13) - jjCheckNAddStates(611, 614); - break; - case 381: - if (curChar == 10) - jjCheckNAddStates(611, 614); - break; - case 382: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 381; - break; - case 383: - if (curChar == 34) - jjCheckNAddStates(656, 659); - break; - case 384: - if ((0xfffffffb00000200L & l) != 0L) - jjCheckNAddStates(656, 659); - break; - case 385: - if (curChar == 34) - jjCheckNAddTwoStates(355, 356); - break; - case 387: - if (curChar == 12) - jjCheckNAddStates(656, 659); - break; - case 389: - if ((0xffffffff00000000L & l) != 0L) - jjCheckNAddStates(656, 659); - break; - case 390: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(660, 665); - break; - case 391: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(656, 659); - break; - case 392: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(666, 674); - break; - case 393: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(675, 679); - break; - case 394: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(680, 685); - break; - case 395: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(686, 692); - break; - case 396: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(693, 700); - break; - case 397: - if (curChar == 13) - jjCheckNAddStates(656, 659); - break; - case 398: - if (curChar == 10) - jjCheckNAddStates(656, 659); - break; - case 399: - if (curChar == 13) - jjstateSet[jjnewStateCnt++] = 398; - break; - case 400: - if ((0x100003600L & l) != 0L) - jjCheckNAddStates(701, 707); - break; - case 403: - if (curChar == 43) - jjAddStates(708, 709); - break; - case 404: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 405; - break; - case 405: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(710, 713); - break; - case 406: - if (curChar == 63 && kind > 114) - kind = 114; - break; - case 407: - case 422: - case 426: - case 429: - case 432: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAdd(406); - break; - case 408: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(406, 407); - break; - case 409: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(714, 716); - break; - case 410: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjAddStates(717, 722); - break; - case 411: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 412; - break; - case 412: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 413; - break; - case 413: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAdd(414); - break; - case 414: - if ((0x3ff000000000000L & l) != 0L && kind > 114) - kind = 114; - break; - case 415: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 416; - break; - case 416: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 417; - break; - case 417: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 418; - break; - case 418: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAdd(406); - break; - case 419: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 420; - break; - case 420: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 421; - break; - case 421: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 422; - break; - case 423: - if ((0x3ff000000000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 424; - break; - case 424: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 425; - break; - case 425: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(406, 426); - break; - case 427: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 428; - break; - case 428: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(723, 725); - break; - case 430: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(406, 429); - break; - case 431: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(726, 729); - break; - case 433: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(406, 432); - break; - case 434: - if (curChar != 63) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(730, 732); - break; - case 435: - if (curChar == 43) - jjstateSet[jjnewStateCnt++] = 436; - break; - case 436: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(437, 443); - break; - case 437: - if (curChar == 45) - jjstateSet[jjnewStateCnt++] = 438; - break; - case 438: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 439; - break; - case 439: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(733, 736); - break; - case 440: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAdd(414); - break; - case 441: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(414, 440); - break; - case 442: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(737, 739); - break; - case 443: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(740, 744); - break; - case 444: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAdd(437); - break; - case 445: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(444, 437); - break; - case 446: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(745, 747); - break; - case 447: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(748, 751); - break; - case 449: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(752, 755); - break; - case 450: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(756, 762); - break; - case 451: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(763, 765); - break; - case 452: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(766, 769); - break; - case 453: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(770, 774); - break; - case 454: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(775, 780); - break; - case 455: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(781, 785); - break; - case 456: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(786, 793); - break; - case 458: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(794, 798); - break; - case 459: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(799, 804); - break; - case 460: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(805, 811); - break; - case 461: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 73) - kind = 73; - jjCheckNAddStates(12, 93); - break; - case 462: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 73) - kind = 73; - jjCheckNAdd(462); - break; - case 463: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(463, 464); - break; - case 464: - if (curChar == 46) - jjCheckNAdd(271); - break; - case 465: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(465, 273); - break; - case 466: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(466, 467); - break; - case 467: - if (curChar == 46) - jjCheckNAdd(272); - break; - case 468: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(468, 276); - break; - case 469: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(469, 470); - break; - case 470: - if (curChar == 46) - jjCheckNAdd(274); - break; - case 471: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(471, 279); - break; - case 472: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(472, 473); - break; - case 473: - if (curChar == 46) - jjCheckNAdd(277); - break; - case 474: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(474, 282); - break; - case 475: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(475, 476); - break; - case 476: - if (curChar == 46) - jjCheckNAdd(280); - break; - case 477: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(477, 285); - break; - case 478: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(478, 479); - break; - case 479: - if (curChar == 46) - jjCheckNAdd(283); - break; - case 480: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(480, 288); - break; - case 481: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(481, 482); - break; - case 482: - if (curChar == 46) - jjCheckNAdd(286); - break; - case 483: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(483, 291); - break; - case 484: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(484, 485); - break; - case 485: - if (curChar == 46) - jjCheckNAdd(289); - break; - case 486: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(486, 294); - break; - case 487: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(487, 488); - break; - case 488: - if (curChar == 46) - jjCheckNAdd(292); - break; - case 489: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(489, 298); - break; - case 490: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(490, 491); - break; - case 491: - if (curChar == 46) - jjCheckNAdd(295); - break; - case 492: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(492, 302); - break; - case 493: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(493, 494); - break; - case 494: - if (curChar == 46) - jjCheckNAdd(299); - break; - case 495: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(495, 305); - break; - case 496: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(496, 497); - break; - case 497: - if (curChar == 46) - jjCheckNAdd(303); - break; - case 498: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(498, 309); - break; - case 499: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(499, 500); - break; - case 500: - if (curChar == 46) - jjCheckNAdd(306); - break; - case 501: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(501, 313); - break; - case 502: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(502, 503); - break; - case 503: - if (curChar == 46) - jjCheckNAdd(310); - break; - case 504: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(504, 318); - break; - case 505: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(505, 506); - break; - case 506: - if (curChar == 46) - jjCheckNAdd(314); - break; - case 507: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(507, 321); - break; - case 508: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(508, 509); - break; - case 509: - if (curChar == 46) - jjCheckNAdd(319); - break; - case 510: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(510, 323); - break; - case 511: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(511, 512); - break; - case 512: - if (curChar == 46) - jjCheckNAdd(322); - break; - case 513: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(513, 326); - break; - case 514: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(514, 515); - break; - case 515: - if (curChar == 46) - jjCheckNAdd(324); - break; - case 516: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(516, 330); - break; - case 517: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(517, 518); - break; - case 518: - if (curChar == 46) - jjCheckNAdd(327); - break; - case 519: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(812, 816); - break; - case 520: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(520, 521); - break; - case 521: - if (curChar == 46) - jjCheckNAdd(331); - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 524: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 264; - else if ((0x1000000010L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 254; - break; - case 162: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 121); - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 161; - break; - case 29: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(0, 3); - else if (curChar == 92) - jjCheckNAddTwoStates(227, 228); - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - else if (curChar == 92) - jjCheckNAddTwoStates(239, 240); - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 28; - break; - case 171: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - break; - case 525: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - break; - case 38: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(0, 3); - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 37; - break; - case 173: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - if ((0x8000000080000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 211; - else if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 172; - break; - case 24: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddStates(817, 822); - } - else if (curChar == 92) - jjCheckNAddStates(823, 826); - else if (curChar == 64) - jjAddStates(827, 831); - if ((0x20000000200000L & l) != 0L) - jjAddStates(832, 834); - else if ((0x800000008L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 151; - else if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 141; - else if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 133; - else if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 29; - else if (curChar == 64) - jjAddStates(835, 838); - break; - case 172: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - if ((0x400000004000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 171; - break; - case 170: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - else if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 169; - break; - case 174: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - } - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 212; - else if ((0x80000000800000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 200; - else if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 184; - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 173; - break; - case 75: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - } - else if (curChar == 92) - jjCheckNAddTwoStates(79, 89); - break; - case 522: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(0, 3); - else if (curChar == 92) - jjCheckNAddTwoStates(227, 228); - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - else if (curChar == 92) - jjCheckNAddTwoStates(239, 240); - break; - case 1: - if (curChar == 123) - jjstateSet[jjnewStateCnt++] = 2; - break; - case 4: - case 5: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(138, 140); - break; - case 6: - if (curChar == 125 && kind > 39) - kind = 39; - break; - case 7: - if (curChar == 92) - jjCheckNAddTwoStates(8, 9); - break; - case 8: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(138, 140); - break; - case 9: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(141, 145); - break; - case 11: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(146, 153); - break; - case 12: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(154, 157); - break; - case 13: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(158, 162); - break; - case 14: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(163, 168); - break; - case 15: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(169, 175); - break; - case 17: - if (curChar == 92) - jjCheckNAddTwoStates(8, 18); - break; - case 18: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(176, 180); - break; - case 19: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(181, 188); - break; - case 20: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(189, 192); - break; - case 21: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(193, 197); - break; - case 22: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(198, 203); - break; - case 23: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(204, 210); - break; - case 25: - if ((0x4000000040000L & l) != 0L && kind > 68) - kind = 68; - break; - case 26: - case 31: - if ((0x2000000020L & l) != 0L) - jjCheckNAdd(25); - break; - case 27: - if ((0x10000000100000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 26; - break; - case 28: - if ((0x100000001000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 27; - break; - case 30: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 29; - break; - case 32: - if ((0x10000000100000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 31; - break; - case 33: - if ((0x100000001000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 32; - break; - case 34: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 33; - break; - case 35: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 34; - break; - case 37: - if ((0x8000000080000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 36; - break; - case 41: - case 46: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(130, 133); - break; - case 43: - if (curChar == 92) - jjAddStates(839, 842); - break; - case 45: - if (curChar == 92) - jjAddStates(843, 844); - break; - case 47: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(211, 216); - break; - case 49: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(217, 225); - break; - case 50: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(226, 230); - break; - case 51: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(231, 236); - break; - case 52: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(237, 243); - break; - case 53: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(244, 251); - break; - case 58: - case 63: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(126, 129); - break; - case 60: - if (curChar == 92) - jjAddStates(845, 848); - break; - case 62: - if (curChar == 92) - jjAddStates(849, 850); - break; - case 64: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(252, 257); - break; - case 66: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(258, 266); - break; - case 67: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(267, 271); - break; - case 68: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(272, 277); - break; - case 69: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(278, 284); - break; - case 70: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(285, 292); - break; - case 76: - case 77: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 78: - if (curChar == 92) - jjCheckNAddTwoStates(79, 80); - break; - case 79: - if ((0x7fffffffffffffffL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 80: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(293, 296); - break; - case 82: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(297, 303); - break; - case 83: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(304, 306); - break; - case 84: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(307, 310); - break; - case 85: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(311, 315); - break; - case 86: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(316, 321); - break; - case 88: - if (curChar == 92) - jjCheckNAddTwoStates(79, 89); - break; - case 89: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(322, 325); - break; - case 90: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(326, 332); - break; - case 91: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(333, 335); - break; - case 92: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(336, 339); - break; - case 93: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(340, 344); - break; - case 94: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddStates(345, 350); - break; - case 96: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 97: - if (curChar == 92) - jjAddStates(851, 852); - break; - case 98: - if ((0x7fffffffffffffffL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 99: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(351, 354); - break; - case 101: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(355, 361); - break; - case 102: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(362, 364); - break; - case 103: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(365, 368); - break; - case 104: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(369, 373); - break; - case 105: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddStates(374, 379); - break; - case 106: - if (curChar == 64) - jjAddStates(835, 838); - break; - case 108: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 109: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 110: - if (curChar == 92) - jjCheckNAddTwoStates(111, 112); - break; - case 111: - if ((0x7fffffffffffffffL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 112: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(380, 383); - break; - case 114: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(384, 390); - break; - case 115: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(391, 393); - break; - case 116: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(394, 397); - break; - case 117: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(398, 402); - break; - case 118: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(403, 408); - break; - case 120: - if (curChar == 92) - jjCheckNAddTwoStates(111, 121); - break; - case 121: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(409, 412); - break; - case 122: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(413, 419); - break; - case 123: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(420, 422); - break; - case 124: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(423, 426); - break; - case 125: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(427, 431); - break; - case 126: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddStates(432, 437); - break; - case 127: - if ((0x2000000020L & l) != 0L) - jjAddStates(438, 439); - break; - case 130: - if ((0x40000000400000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 127; - break; - case 131: - if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 130; - break; - case 132: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 131; - break; - case 133: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 132; - break; - case 134: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 133; - break; - case 135: - if ((0x1000000010L & l) != 0L) - jjAddStates(440, 441); - break; - case 138: - if ((0x400000004000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 135; - break; - case 139: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 138; - break; - case 140: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 139; - break; - case 141: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 140; - break; - case 142: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 141; - break; - case 143: - if ((0x8000000080000L & l) != 0L) - jjAddStates(442, 443); - break; - case 146: - if ((0x400000004000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 143; - break; - case 147: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 146; - break; - case 148: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 147; - break; - case 149: - if ((0x10000000100000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 148; - break; - case 150: - if ((0x400000004000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 149; - break; - case 151: - if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 150; - break; - case 152: - if ((0x800000008L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 151; - break; - case 153: - if (curChar == 64) - jjAddStates(827, 831); - break; - case 154: - if ((0x8000000080000L & l) != 0L && kind > 102) - kind = 102; - break; - case 155: - case 163: - case 176: - case 187: - case 203: - if ((0x2000000020L & l) != 0L) - jjCheckNAdd(154); - break; - case 156: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 155; - break; - case 157: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 156; - break; - case 158: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 157; - break; - case 159: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 158; - break; - case 160: - if ((0x200000002000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 159; - break; - case 161: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 160; - break; - case 164: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 163; - break; - case 165: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 164; - break; - case 166: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 165; - break; - case 167: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 166; - break; - case 168: - if ((0x200000002000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 167; - break; - case 169: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 168; - break; - case 177: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 176; - break; - case 178: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 177; - break; - case 179: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 178; - break; - case 180: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 179; - break; - case 181: - if ((0x200000002000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 180; - break; - case 182: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 181; - break; - case 183: - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 182; - break; - case 185: - if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 184; - break; - case 188: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 187; - break; - case 189: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 188; - break; - case 190: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 189; - break; - case 191: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 190; - break; - case 192: - if ((0x200000002000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 191; - break; - case 193: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 192; - break; - case 194: - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 193; - break; - case 196: - if ((0x10000000100000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 195; - break; - case 197: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 196; - break; - case 198: - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 197; - break; - case 199: - if ((0x400000004L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 198; - break; - case 200: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 199; - break; - case 201: - if ((0x80000000800000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 200; - break; - case 204: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 203; - break; - case 205: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 204; - break; - case 206: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 205; - break; - case 207: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 206; - break; - case 208: - if ((0x200000002000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 207; - break; - case 209: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 208; - break; - case 210: - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 209; - break; - case 212: - if ((0x8000000080000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 211; - break; - case 213: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 212; - break; - case 217: - if (kind > 2) - kind = 2; - jjAddStates(9, 11); - break; - case 222: - if (kind > 3) - kind = 3; - break; - case 225: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 226: - if (curChar == 92) - jjCheckNAddTwoStates(227, 228); - break; - case 227: - if ((0x7fffffffffffffffL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 228: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(444, 447); - break; - case 230: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(448, 454); - break; - case 231: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(455, 457); - break; - case 232: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(458, 461); - break; - case 233: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(462, 466); - break; - case 234: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(467, 472); - break; - case 235: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 238: - if (curChar == 92) - jjCheckNAddTwoStates(239, 240); - break; - case 239: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 240: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(473, 477); - break; - case 242: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(478, 485); - break; - case 243: - case 457: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(486, 489); - break; - case 244: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(490, 494); - break; - case 245: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(495, 500); - break; - case 246: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(501, 507); - break; - case 249: - if ((0x10000000100000L & l) != 0L && kind > 70) - kind = 70; - break; - case 250: - if ((0x100000001000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 249; - break; - case 251: - if ((0x20000000200000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 250; - break; - case 252: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 251; - break; - case 253: - if ((0x4000000040L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 252; - break; - case 254: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 253; - break; - case 255: - if ((0x1000000010L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 254; - break; - case 257: - if ((0x10000000100000L & l) != 0L && kind > 104) - kind = 104; - break; - case 258: - if ((0x400000004000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 257; - break; - case 259: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 258; - break; - case 260: - if ((0x10000000100000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 259; - break; - case 261: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 260; - break; - case 262: - if ((0x800000008000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 261; - break; - case 263: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 262; - break; - case 264: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 263; - break; - case 265: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 264; - break; - case 267: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 268: - if ((0x7fffffe87fffffeL & l) != 0L) - jjCheckNAddStates(0, 3); - break; - case 269: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(817, 822); - break; - case 275: - if ((0x10000000100000L & l) != 0L && kind > 78) - kind = 78; - break; - case 276: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 275; - break; - case 278: - if ((0x200000002000L & l) != 0L && kind > 79) - kind = 79; - break; - case 279: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 278; - break; - case 281: - if ((0x200000002000L & l) != 0L && kind > 80) - kind = 80; - break; - case 282: - if ((0x800000008L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 281; - break; - case 284: - if ((0x800000008L & l) != 0L && kind > 81) - kind = 81; - break; - case 285: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 284; - break; - case 287: - if ((0x400000004000L & l) != 0L && kind > 82) - kind = 82; - break; - case 288: - if ((0x20000000200L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 287; - break; - case 290: - if ((0x100000001000000L & l) != 0L && kind > 83) - kind = 83; - break; - case 291: - if ((0x1000000010000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 290; - break; - case 293: - if ((0x200000002000L & l) != 0L && kind > 84) - kind = 84; - break; - case 294: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 293; - break; - case 296: - if ((0x200000002000L & l) != 0L && kind > 85) - kind = 85; - break; - case 297: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 296; - break; - case 298: - if ((0x100000001000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 297; - break; - case 300: - if ((0x200000002000L & l) != 0L && kind > 86) - kind = 86; - break; - case 301: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 300; - break; - case 302: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 301; - break; - case 304: - if ((0x100000001000000L & l) != 0L && kind > 87) - kind = 87; - break; - case 305: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 304; - break; - case 307: - if ((0x8000000080L & l) != 0L && kind > 88) - kind = 88; - break; - case 308: - if ((0x2000000020L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 307; - break; - case 309: - if ((0x1000000010L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 308; - break; - case 311: - if ((0x1000000010L & l) != 0L && kind > 89) - kind = 89; - break; - case 312: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 311; - break; - case 313: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 312; - break; - case 315: - if ((0x1000000010L & l) != 0L && kind > 90) - kind = 90; - break; - case 316: - if ((0x200000002L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 315; - break; - case 317: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 316; - break; - case 318: - if ((0x8000000080L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 317; - break; - case 320: - if ((0x8000000080000L & l) != 0L && kind > 91) - kind = 91; - break; - case 321: - if ((0x200000002000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 320; - break; - case 323: - if ((0x8000000080000L & l) != 0L && kind > 92) - kind = 92; - break; - case 325: - if ((0x400000004000000L & l) != 0L && kind > 93) - kind = 93; - break; - case 326: - if ((0x10000000100L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 325; - break; - case 328: - if ((0x400000004000000L & l) != 0L && kind > 94) - kind = 94; - break; - case 329: - if ((0x10000000100L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 328; - break; - case 330: - if ((0x80000000800L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 329; - break; - case 333: - case 334: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 335: - if (curChar == 92) - jjCheckNAddTwoStates(336, 337); - break; - case 336: - if ((0x7fffffffffffffffL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 337: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(508, 511); - break; - case 339: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(512, 518); - break; - case 340: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(519, 521); - break; - case 341: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(522, 525); - break; - case 342: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(526, 530); - break; - case 343: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(531, 536); - break; - case 345: - if (curChar == 92) - jjCheckNAddTwoStates(336, 346); - break; - case 346: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(537, 540); - break; - case 347: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(541, 547); - break; - case 348: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(548, 550); - break; - case 349: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(551, 554); - break; - case 350: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(555, 559); - break; - case 351: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddStates(560, 565); - break; - case 352: - if ((0x20000000200000L & l) != 0L) - jjAddStates(832, 834); - break; - case 354: - case 358: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(572, 575); - break; - case 357: - if (curChar == 92) - jjAddStates(853, 854); - break; - case 359: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(576, 580); - break; - case 361: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(581, 588); - break; - case 362: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(589, 592); - break; - case 363: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(593, 597); - break; - case 364: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(598, 603); - break; - case 365: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(604, 610); - break; - case 367: - case 372: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(611, 614); - break; - case 369: - if (curChar == 92) - jjAddStates(855, 858); - break; - case 371: - if (curChar == 92) - jjAddStates(859, 860); - break; - case 373: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(615, 620); - break; - case 375: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(621, 629); - break; - case 376: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(630, 634); - break; - case 377: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(635, 640); - break; - case 378: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(641, 647); - break; - case 379: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(648, 655); - break; - case 384: - case 389: - if ((0x7fffffffffffffffL & l) != 0L) - jjCheckNAddStates(656, 659); - break; - case 386: - if (curChar == 92) - jjAddStates(861, 864); - break; - case 388: - if (curChar == 92) - jjAddStates(865, 866); - break; - case 390: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(660, 665); - break; - case 392: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(666, 674); - break; - case 393: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(675, 679); - break; - case 394: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(680, 685); - break; - case 395: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(686, 692); - break; - case 396: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(693, 700); - break; - case 401: - if ((0x100000001000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 353; - break; - case 402: - if ((0x4000000040000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 401; - break; - case 410: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjAddStates(717, 722); - break; - case 411: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 412; - break; - case 412: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 413; - break; - case 413: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAdd(414); - break; - case 414: - if ((0x7e0000007eL & l) != 0L && kind > 114) - kind = 114; - break; - case 415: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 416; - break; - case 416: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 417; - break; - case 417: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 418; - break; - case 418: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 406; - break; - case 419: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 420; - break; - case 420: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 421; - break; - case 421: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 422; - break; - case 423: - if ((0x7e0000007eL & l) != 0L) - jjstateSet[jjnewStateCnt++] = 424; - break; - case 424: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 425; - break; - case 427: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 428; - break; - case 436: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddTwoStates(437, 443); - break; - case 438: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjstateSet[jjnewStateCnt++] = 439; - break; - case 439: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(733, 736); - break; - case 440: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAdd(414); - break; - case 441: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddTwoStates(414, 440); - break; - case 442: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 114) - kind = 114; - jjCheckNAddStates(737, 739); - break; - case 443: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(740, 744); - break; - case 444: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAdd(437); - break; - case 445: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddTwoStates(444, 437); - break; - case 446: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(745, 747); - break; - case 447: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(748, 751); - break; - case 448: - if (curChar == 92) - jjCheckNAddStates(823, 826); - break; - case 449: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(752, 755); - break; - case 450: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(756, 762); - break; - case 451: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(763, 765); - break; - case 452: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(766, 769); - break; - case 453: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(770, 774); - break; - case 454: - if ((0x7e0000007eL & l) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddStates(775, 780); - break; - case 455: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(781, 785); - break; - case 456: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(786, 793); - break; - case 458: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(794, 798); - break; - case 459: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(799, 804); - break; - case 460: - if ((0x7e0000007eL & l) != 0L) - jjCheckNAddStates(805, 811); - break; - default : break; - } - } while(i != startsAt); - } - else - { - int i2 = (curChar & 0xff) >> 6; - long l2 = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 162: - case 111: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 29: - if ((jjbitVec0[i2] & l2) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(0, 3); - break; - case 171: - case 109: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 525: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 173: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 24: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 40) - kind = 40; - jjCheckNAddStates(817, 822); - break; - case 172: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 170: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 103) - kind = 103; - jjCheckNAddTwoStates(109, 110); - break; - case 75: - case 77: - case 79: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 76) - kind = 76; - jjCheckNAddTwoStates(77, 78); - break; - case 522: - if ((jjbitVec0[i2] & l2) != 0L) - { - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - } - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(0, 3); - break; - case 5: - case 8: - case 16: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(138, 140); - break; - case 41: - case 46: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(130, 133); - break; - case 58: - case 63: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(126, 129); - break; - case 96: - case 98: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 96) - kind = 96; - jjCheckNAddTwoStates(96, 97); - break; - case 217: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 2) - kind = 2; - jjAddStates(9, 11); - break; - case 222: - if ((jjbitVec0[i2] & l2) != 0L && kind > 3) - kind = 3; - break; - case 225: - case 227: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 72) - kind = 72; - jjCheckNAddTwoStates(225, 226); - break; - case 235: - case 239: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(0, 3); - break; - case 334: - case 336: - case 344: - if ((jjbitVec0[i2] & l2) == 0L) - break; - if (kind > 95) - kind = 95; - jjCheckNAddTwoStates(334, 335); - break; - case 354: - case 358: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(572, 575); - break; - case 367: - case 372: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(611, 614); - break; - case 384: - case 389: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddStates(656, 659); - break; - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 522 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -private int jjMoveStringLiteralDfa0_2() -{ - switch(curChar) - { - case 42: - return jjMoveStringLiteralDfa1_2(0x40L); - default : - return 1; - } -} -private int jjMoveStringLiteralDfa1_2(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 47: - if ((active0 & 0x40L) != 0L) - return jjStopAtPos(1, 6); - break; - default : - return 2; - } - return 2; -} -private int jjMoveStringLiteralDfa0_1() -{ - switch(curChar) - { - case 42: - return jjMoveStringLiteralDfa1_1(0x20L); - default : - return 1; - } -} -private int jjMoveStringLiteralDfa1_1(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - return 1; - } - switch(curChar) - { - case 47: - if ((active0 & 0x20L) != 0L) - return jjStopAtPos(1, 5); - break; - default : - return 2; - } - return 2; -} -static final int[] jjnextStates = { - 235, 236, 237, 238, 331, 332, 333, 344, 345, 217, 218, 220, 462, 463, 464, 465, - 466, 467, 273, 468, 469, 470, 276, 471, 472, 473, 279, 474, 475, 476, 282, 477, - 478, 479, 285, 480, 481, 482, 288, 483, 484, 485, 291, 486, 487, 488, 294, 489, - 490, 491, 298, 492, 493, 494, 302, 495, 496, 497, 305, 498, 499, 500, 309, 501, - 502, 503, 313, 504, 505, 506, 318, 507, 508, 509, 321, 510, 511, 512, 323, 513, - 514, 515, 326, 516, 517, 518, 330, 519, 520, 521, 332, 333, 344, 345, 271, 272, - 274, 277, 280, 283, 286, 289, 292, 295, 299, 303, 306, 310, 314, 319, 322, 324, - 327, 331, 267, 268, 248, 255, 256, 265, 216, 223, 75, 76, 87, 88, 58, 59, - 60, 62, 41, 42, 43, 45, 3, 4, 16, 17, 5, 6, 7, 5, 10, 6, - 7, 11, 5, 12, 10, 6, 7, 13, 14, 15, 5, 10, 6, 7, 5, 12, - 10, 6, 7, 5, 12, 10, 6, 7, 13, 5, 12, 10, 6, 7, 13, 14, - 10, 5, 6, 7, 19, 20, 10, 5, 6, 7, 21, 22, 23, 10, 5, 6, - 7, 20, 10, 5, 6, 7, 20, 10, 5, 6, 7, 21, 20, 10, 5, 6, - 7, 21, 22, 41, 48, 42, 43, 45, 49, 41, 50, 48, 42, 43, 45, 51, - 52, 53, 41, 48, 42, 43, 45, 41, 50, 48, 42, 43, 45, 41, 50, 48, - 42, 43, 45, 51, 41, 50, 48, 42, 43, 45, 51, 52, 58, 65, 59, 60, - 62, 66, 58, 67, 65, 59, 60, 62, 68, 69, 70, 58, 65, 59, 60, 62, - 58, 67, 65, 59, 60, 62, 58, 67, 65, 59, 60, 62, 68, 58, 67, 65, - 59, 60, 62, 68, 69, 77, 81, 78, 82, 77, 83, 81, 78, 84, 85, 86, - 77, 81, 78, 77, 83, 81, 78, 77, 83, 81, 78, 84, 77, 83, 81, 78, - 84, 85, 81, 77, 78, 90, 91, 81, 77, 78, 92, 93, 94, 81, 77, 78, - 91, 81, 77, 78, 91, 81, 77, 78, 92, 91, 81, 77, 78, 92, 93, 96, - 100, 97, 101, 96, 102, 100, 97, 103, 104, 105, 96, 100, 97, 96, 102, 100, - 97, 96, 102, 100, 97, 103, 96, 102, 100, 97, 103, 104, 109, 113, 110, 114, - 109, 115, 113, 110, 116, 117, 118, 109, 113, 110, 109, 115, 113, 110, 109, 115, - 113, 110, 116, 109, 115, 113, 110, 116, 117, 113, 109, 110, 122, 123, 113, 109, - 110, 124, 125, 126, 113, 109, 110, 123, 113, 109, 110, 123, 113, 109, 110, 124, - 123, 113, 109, 110, 124, 125, 128, 129, 136, 137, 144, 145, 225, 229, 226, 230, - 225, 231, 229, 226, 232, 233, 234, 225, 229, 226, 225, 231, 229, 226, 225, 231, - 229, 226, 232, 225, 231, 229, 226, 232, 233, 235, 237, 238, 241, 242, 235, 243, - 237, 238, 241, 244, 245, 246, 235, 237, 238, 241, 235, 243, 237, 238, 241, 235, - 243, 237, 238, 241, 244, 235, 243, 237, 238, 241, 244, 245, 334, 338, 335, 339, - 334, 340, 338, 335, 341, 342, 343, 334, 338, 335, 334, 340, 338, 335, 334, 340, - 338, 335, 341, 334, 340, 338, 335, 341, 342, 338, 334, 335, 347, 348, 338, 334, - 335, 349, 350, 351, 338, 334, 335, 348, 338, 334, 335, 348, 338, 334, 335, 349, - 348, 338, 334, 335, 349, 350, 354, 366, 383, 356, 357, 400, 354, 355, 356, 357, - 354, 356, 357, 360, 361, 354, 362, 356, 357, 360, 363, 364, 365, 354, 356, 357, - 360, 354, 362, 356, 357, 360, 354, 362, 356, 357, 360, 363, 354, 362, 356, 357, - 360, 363, 364, 367, 368, 369, 371, 367, 374, 368, 369, 371, 375, 367, 376, 374, - 368, 369, 371, 377, 378, 379, 367, 374, 368, 369, 371, 367, 376, 374, 368, 369, - 371, 367, 376, 374, 368, 369, 371, 377, 367, 376, 374, 368, 369, 371, 377, 378, - 384, 385, 386, 388, 384, 391, 385, 386, 388, 392, 384, 393, 391, 385, 386, 388, - 394, 395, 396, 384, 391, 385, 386, 388, 384, 393, 391, 385, 386, 388, 384, 393, - 391, 385, 386, 388, 394, 384, 393, 391, 385, 386, 388, 394, 395, 354, 366, 383, - 355, 356, 357, 400, 404, 410, 406, 407, 408, 409, 406, 407, 408, 411, 415, 419, - 423, 427, 431, 406, 429, 430, 406, 432, 433, 434, 406, 432, 433, 414, 440, 441, - 442, 414, 440, 441, 444, 437, 445, 446, 447, 444, 437, 445, 444, 437, 445, 446, - 229, 225, 226, 450, 451, 229, 225, 226, 452, 453, 454, 229, 225, 226, 451, 229, - 225, 226, 451, 229, 225, 226, 452, 451, 229, 225, 226, 452, 453, 235, 237, 238, - 241, 456, 457, 235, 237, 238, 241, 458, 459, 460, 457, 235, 237, 238, 241, 457, - 235, 237, 238, 241, 458, 457, 235, 237, 238, 241, 458, 459, 519, 332, 333, 344, - 345, 225, 235, 236, 237, 238, 226, 227, 449, 239, 455, 162, 175, 186, 202, 214, - 402, 403, 435, 107, 108, 119, 120, 44, 54, 56, 55, 46, 47, 61, 71, 73, - 72, 63, 64, 98, 99, 358, 359, 370, 380, 382, 381, 372, 373, 387, 397, 399, - 398, 389, 390, -}; - -/** Token literal values. */ -public static final String[] jjstrLiteralImages = { -"", null, null, null, null, null, null, null, "\74\41\55\55", "\55\55\76", -"\173", "\175", "\174\75", "\136\75", "\44\75", "\52\75", "\176\75", "\75", "\53", -"\55", "\54", "\73", "\76", "\176", "\74", "\57", "\133", "\135", "\52", "\45", -"\46", "\56", "\50", "\51", "\75\75", "\174\174", "\46\46", "\41\75", "\72", null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, null, null, null, null, -null, null, null, null, null, null, null, null, null, null, }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "DEFAULT", - "IN_FORMAL_COMMENT", - "IN_MULTI_LINE_COMMENT", -}; - -/** Lex State array. */ -public static final int[] jjnewLexState = { - -1, -1, -1, 1, 2, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -}; -static final long[] jjtoToken = { - 0xfffe01ffffffff03L, 0xfc01fffffffbffL, -}; -static final long[] jjtoSkip = { - 0x64L, 0x0L, -}; -static final long[] jjtoSpecial = { - 0x24L, 0x0L, -}; -static final long[] jjtoMore = { - 0x98L, 0x0L, -}; -protected CharStream input_stream; -private final int[] jjrounds = new int[522]; -private final int[] jjstateSet = new int[1044]; -private final StringBuilder jjimage = new StringBuilder(); -private StringBuilder image = jjimage; -private int jjimageLen; -private int lengthOfMatch; -protected char curChar; -/** Constructor. */ -public ParserTokenManager(CharStream stream){ - input_stream = stream; -} - -/** Constructor. */ -public ParserTokenManager(CharStream stream, int lexState){ - this(stream); - SwitchTo(lexState); -} - -/** Reinitialise parser. */ -public void ReInit(CharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 522; i-- > 0;) - jjrounds[i] = 0x80000000; -} - -/** Reinitialise parser. */ -public void ReInit(CharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} - -/** Switch to specified lex state. */ -public void SwitchTo(int lexState) -{ - if (lexState >= 3 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - -protected Token jjFillToken() -{ - final Token t; - final String curTokenImage; - final int beginLine; - final int endLine; - final int beginColumn; - final int endColumn; - String im = jjstrLiteralImages[jjmatchedKind]; - curTokenImage = (im == null) ? input_stream.GetImage() : im; - beginLine = input_stream.getBeginLine(); - beginColumn = input_stream.getBeginColumn(); - endLine = input_stream.getEndLine(); - endColumn = input_stream.getEndColumn(); - t = Token.newToken(jjmatchedKind, curTokenImage); - - t.beginLine = beginLine; - t.endLine = endLine; - t.beginColumn = beginColumn; - t.endColumn = endColumn; - - return t; -} - -int curLexState = 0; -int defaultLexState = 0; -int jjnewStateCnt; -int jjround; -int jjmatchedPos; -int jjmatchedKind; - -/** Get the next Token. */ -public Token getNextToken() -{ - Token specialToken = null; - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (;;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch(java.io.IOException e) - { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - return matchedToken; - } - image = jjimage; - image.setLength(0); - jjimageLen = 0; - - for (;;) - { - switch(curLexState) - { - case 0: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedPos == 0 && jjmatchedKind > 119) - { - jjmatchedKind = 119; - } - break; - case 1: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_1(); - if (jjmatchedPos == 0 && jjmatchedKind > 7) - { - jjmatchedKind = 7; - } - break; - case 2: - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_2(); - if (jjmatchedPos == 0 && jjmatchedKind > 7) - { - jjmatchedKind = 7; - } - break; - } - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - matchedToken.specialToken = specialToken; - TokenLexicalActions(matchedToken); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - return matchedToken; - } - else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - if (specialToken == null) - specialToken = matchedToken; - else - { - matchedToken.specialToken = specialToken; - specialToken = (specialToken.next = matchedToken); - } - SkipLexicalActions(matchedToken); - } - else - SkipLexicalActions(null); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - continue EOFLoop; - } - MoreLexicalActions(); - if (jjnewLexState[jjmatchedKind] != -1) - curLexState = jjnewLexState[jjmatchedKind]; - curPos = 0; - jjmatchedKind = 0x7fffffff; - try { - curChar = input_stream.readChar(); - continue; - } - catch (java.io.IOException e1) { } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { input_stream.readChar(); input_stream.backup(1); } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } - } -} - -void SkipLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - default : - break; - } -} -void MoreLexicalActions() -{ - jjimageLen += (lengthOfMatch = jjmatchedPos + 1); - switch(jjmatchedKind) - { - case 3 : - image.append(input_stream.GetSuffix(jjimageLen)); - jjimageLen = 0; - input_stream.backup(1); - break; - default : - break; - } -} -void TokenLexicalActions(Token matchedToken) -{ - switch(jjmatchedKind) - { - case 1 : - image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); - image = Parser.SPACE; - break; - default : - break; - } -} -private void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} - -private void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} - -} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java deleted file mode 100644 index 26d1121f96..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ -/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package com.vaadin.sass.internal.parser; - -/** - * Describes the input token stream. - */ - -public class Token implements java.io.Serializable { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** The line number of the first character of this Token. */ - public int beginLine; - /** The column number of the first character of this Token. */ - public int beginColumn; - /** The line number of the last character of this Token. */ - public int endLine; - /** The column number of the last character of this Token. */ - public int endColumn; - - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * An optional attribute value of the Token. - * Tokens which are not used as syntactic sugar will often contain - * meaningful values that will be used later on by the compiler or - * interpreter. This attribute value is often different from the image. - * Any subclass of Token that actually wants to return a non-null value can - * override this method as appropriate. - */ - public Object getValue() { - return null; - } - - /** - * No-argument constructor - */ - public Token() {} - - /** - * Constructs a new token for the specified Image. - */ - public Token(int kind) - { - this(kind, null); - } - - /** - * Constructs a new token for the specified Image and Kind. - */ - public Token(int kind, String image) - { - this.kind = kind; - this.image = image; - } - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simply add something like : - * - * case MyParserConstants.ID : return new IDToken(ofKind, image); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use sit in your lexical actions. - */ - public static Token newToken(int ofKind, String image) - { - switch(ofKind) - { - default : return new Token(ofKind, image); - } - } - - public static Token newToken(int ofKind) - { - return newToken(ofKind, null); - } - -} -/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java deleted file mode 100644 index f093357e96..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ -/* JavaCCOptions: */ -package com.vaadin.sass.internal.parser; - -/** Token Manager Error. */ -public class TokenMgrError extends Error -{ - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occurred. - */ - static final int LEXICAL_ERROR = 0; - - /** - * An attempt was made to create a second instance of a static token manager. - */ - static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their escaped (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - /** No arg constructor. */ - public TokenMgrError() { - } - - /** Constructor with message and reason. */ - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} -/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ diff --git a/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java b/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java index 1ed5075bd5..e70201b11a 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java @@ -34,7 +34,7 @@ public class ParserTest { @Test public void testParsePropertyValue() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); LexicalUnit value = parser.parsePropertyValue(new InputSource( new StringReader("$margin/2;"))); @@ -53,7 +53,7 @@ public class ParserTest { @Test public void testCanIngoreSingleLineComment() { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); try { diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java index d823ccf860..32c4c37ce7 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java @@ -36,7 +36,7 @@ public class Interpolation extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java index 6a09917d99..9e110ecd97 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java @@ -38,7 +38,7 @@ public class Comments extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java index 1e3eb09f0c..915bbb0f46 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java @@ -42,7 +42,7 @@ public class CompassImports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scssOtherDirectory) diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java index 14cac4bb19..e11cb854c9 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java @@ -43,7 +43,7 @@ public class ControlDirectives extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java index b3c20b0ab6..649a5777c3 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java @@ -37,7 +37,7 @@ public class Extends extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java index 5c41494ac6..ce0875a884 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java @@ -36,7 +36,7 @@ public class Functions extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java index aaa1a1439a..128cc2fe06 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java @@ -37,7 +37,7 @@ public class Imports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java index e4faee6e2a..0c441c7c2d 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java @@ -42,7 +42,7 @@ public class Mixins extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java index 9a91df04ba..26b61a0888 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java @@ -38,7 +38,7 @@ public class NestedProperties extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java index 04aca5e8d3..cd213f9de4 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java @@ -37,7 +37,7 @@ public class Nesting extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java index daa7dbbf07..668d1e36f2 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java @@ -37,7 +37,7 @@ public class ParentImports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java index 443d4a1086..a6608b75d6 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java @@ -35,7 +35,7 @@ public class ParentSelector extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java index a0727736e4..732426497f 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java @@ -19,7 +19,7 @@ public class VariableGuarded extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java index 7f71d46f0d..d623b00112 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java @@ -40,7 +40,7 @@ public class Variables extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = new Parser(); + Parser parser = Parser.ParserAccessor.getParser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); -- cgit v1.2.3 From b9a6a48ab6ce9e3c7d8d025520e866643d19c004 Mon Sep 17 00:00:00 2001 From: Tomi Virtanen Date: Wed, 15 Jan 2014 10:39:02 +0200 Subject: Update textbox when Select item caption changes (#9250) Fixed logic that detects changed item caption and triggers update to textbox text. Changed test case description. Change-Id: I9fbb0cc686e73404bab8e624a5332644cca53737 --- .../client/ui/combobox/ComboBoxConnector.java | 33 +++++++++++++++++----- .../select/SelectItemCaptionRefresh.java | 4 +-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 24597d1d8c..8dec26cf90 100644 --- a/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -37,6 +37,10 @@ import com.vaadin.ui.ComboBox; public class ComboBoxConnector extends AbstractFieldConnector implements Paintable, SimpleManagedLayout { + // oldSuggestionTextMatchTheOldSelection is used to detect when it's safe to + // update textbox text by a changed item caption. + private boolean oldSuggestionTextMatchTheOldSelection; + /* * (non-Javadoc) * @@ -117,7 +121,10 @@ public class ComboBoxConnector extends AbstractFieldConnector implements boolean suggestionsChanged = !getWidget().initDone || !newSuggestions.equals(getWidget().currentSuggestions); + oldSuggestionTextMatchTheOldSelection = false; + if (suggestionsChanged) { + oldSuggestionTextMatchTheOldSelection = isWidgetsCurrentSelectionTextInTextBox(); getWidget().currentSuggestions.clear(); if (!getWidget().waitingForFilteringResponse) { @@ -217,13 +224,19 @@ public class ComboBoxConnector extends AbstractFieldConnector implements } if (!getWidget().waitingForFilteringResponse || getWidget().popupOpenerClicked) { - // Update text field if we've got a new - // selection - // Also update if we've got the same text to - // retain old text selection behavior - // OR if selected item caption is changed. - getWidget().setPromptingOff(suggestion.getReplacementString()); - getWidget().selectedOptionKey = suggestionKey; + if (!suggestionKey.equals(getWidget().selectedOptionKey) + || suggestion.getReplacementString().equals( + getWidget().tb.getText()) + || oldSuggestionTextMatchTheOldSelection) { + // Update text field if we've got a new + // selection + // Also update if we've got the same text to + // retain old text selection behavior + // OR if selected item caption is changed. + getWidget().setPromptingOff( + suggestion.getReplacementString()); + getWidget().selectedOptionKey = suggestionKey; + } } getWidget().currentSuggestion = suggestion; getWidget().setSelectedItemIcon(suggestion.getIconUri()); @@ -232,6 +245,12 @@ public class ComboBoxConnector extends AbstractFieldConnector implements } } + private boolean isWidgetsCurrentSelectionTextInTextBox() { + return getWidget().currentSuggestion != null + && getWidget().currentSuggestion.getReplacementString().equals( + getWidget().tb.getText()); + } + private void resetSelection() { if (!getWidget().waitingForFilteringResponse || getWidget().popupOpenerClicked) { diff --git a/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java index 1a1a8fa642..de068ed230 100644 --- a/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java +++ b/uitest/src/com/vaadin/tests/components/select/SelectItemCaptionRefresh.java @@ -49,7 +49,7 @@ public class SelectItemCaptionRefresh extends AbstractTestUI { select.setItemCaption(itemId, "start"); addComponent(select); - addComponent(new Button("click", clickListener)); + addComponent(new Button("Update item's caption", clickListener)); } /* @@ -59,7 +59,7 @@ public class SelectItemCaptionRefresh extends AbstractTestUI { */ @Override protected String getTestDescription() { - return "Selected option not updated when item caption changes in Select"; + return "Selected option should be updated when item caption changes in the Select."; } /* -- cgit v1.2.3 From bebf6ad77db394f987b9bb15b770ab304961530e Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 14 Jan 2014 16:52:12 +0200 Subject: Fixed always failing TooltipInWindowTest Test was failing due the TB2 returning different pixel values depending on which browser the test was run. Converted test to TB3 and made the test a bit more lenient to browser differences while still testing the essentials of tooltip handling in sub windows. Change-Id: Ib236094f20366eb79150ce4590252b51b9373587 --- .../tests/components/window/TooltipInWindow.html | 86 ------------------- .../tests/components/window/TooltipInWindow.java | 7 +- .../components/window/TooltipInWindowTest.java | 98 ++++++++++++++++++++++ 3 files changed, 102 insertions(+), 89 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html create mode 100644 uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html deleted file mode 100644 index 575eb652b7..0000000000 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - -TooltipInWindow - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TooltipInWindow
open/run/com.vaadin.tests.components.window.TooltipInWindow?restartApplication
showTooltipvaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VVerticalLayout[0]/VVerticalLayout[0]/VTextField[0]5,5
pause1000
assertTextvaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]My tooltip
showTooltipvaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VVerticalLayout[0]0,0
pause1000
assertElementPositionLeftvaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]-1000
showTooltipvaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/VTextField[0]5,5
pause1000
assertTextvaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]My tooltip
showTooltipvaadin=runcomvaadintestscomponentswindowTooltipInWindow::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]0,0
pause1000
assertElementPositionLeftvaadin=runcomvaadintestscomponentswindowTooltipInWindow::Root/VTooltip[0]/FlowPanel[0]/domChild[1]-1000
- - diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java index d3c7a616cd..02ec0c047b 100644 --- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindow.java @@ -31,15 +31,16 @@ public class TooltipInWindow extends AbstractTestUI { Window window = new Window("Window", layout); layout.setSizeUndefined(); window.center(); - layout.addComponent(createTextField()); + layout.addComponent(createTextField("tf1")); addWindow(window); - addComponent(createTextField()); + addComponent(createTextField("tf2")); } - private TextField createTextField() { + private TextField createTextField(String id) { TextField tf = new TextField("TextField with a tooltip"); tf.setDescription("My tooltip"); + tf.setId(id); return tf; } diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java new file mode 100644 index 0000000000..8f9538db7a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java @@ -0,0 +1,98 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.window; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * + * @since + * @author Vaadin Ltd + */ +public class TooltipInWindowTest extends MultiBrowserTest { + + @Test + public void testTooltipsInSubWindow() { + openTestURL(); + + WebElement textfield = vaadinElementById("tf1"); + Coordinates textfieldCoordinates = ((Locatable) textfield) + .getCoordinates(); + + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + + // Show tooltip + mouse.mouseMove(textfieldCoordinates, 10, 10); + sleep(1000); + + ensureVisibleTooltipPositionedCorrectly(); + assertEquals("My tooltip", getTooltipElement().getText()); + + // Hide tooltip + mouse.mouseMove(textfieldCoordinates, -100, -100); + sleep(1000); + + ensureHiddenTooltipPositionedCorrectly(); + assertEquals("", getTooltipElement().getText()); + + // Show tooltip again + mouse.mouseMove(textfieldCoordinates, 10, 10); + sleep(1000); + + ensureVisibleTooltipPositionedCorrectly(); + assertEquals("My tooltip", getTooltipElement().getText()); + + // Hide tooltip + mouse.mouseMove(textfieldCoordinates, -100, -100); + sleep(1000); + + ensureHiddenTooltipPositionedCorrectly(); + assertEquals("", getTooltipElement().getText()); + } + + private WebElement getTooltipElement() { + return getDriver().findElement(By.className("v-tooltip-text")); + } + + private WebElement getTooltipContainerElement() { + return getDriver().findElement(By.className("v-tooltip")); + } + + private void ensureVisibleTooltipPositionedCorrectly() { + WebElement textfield = vaadinElementById("tf1"); + int tooltipX = getTooltipContainerElement().getLocation().getX(); + int textfieldX = textfield.getLocation().getX(); + assertGreaterOrEqual("Tooltip should be positioned on the textfield (" + + tooltipX + " < " + textfieldX + ")", tooltipX, textfieldX); + } + + private void ensureHiddenTooltipPositionedCorrectly() { + int tooltipX = getTooltipContainerElement().getLocation().getX(); + assertLessThanOrEqual( + "Tooltip should be positioned outside of viewport (was at " + + tooltipX + ")", tooltipX, -1000); + } +} -- cgit v1.2.3 From c7b22da0738cb69ada42e23792d6c2bef7fb9cca Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 17 Dec 2013 20:36:03 +0100 Subject: Add support for using java.util.Date in communications (#13073) This adds support for using separate serializer classes on the server side, similarly to on the client side. Still it is not public API yet as you do not have the possibility to add your own serializers to the map used by JsonCodec. Change-Id: I2cc4f628c5a8eba90abbd57c128c6359cbe1b4d7 --- .../client/communication/Date_Serializer.java | 44 ++++++++ .../client/communication/JSONSerializer.java | 7 +- server/src/com/vaadin/server/JsonCodec.java | 15 +++ .../server/communication/DateSerializer.java | 42 ++++++++ .../server/communication/JSONSerializer.java | 76 ++++++++++++++ .../vaadin/tests/serialization/SerializerTest.html | 116 --------------------- .../vaadin/tests/serialization/SerializerTest.java | 8 ++ .../tests/serialization/SerializerTestTest.java | 81 ++++++++++++++ .../widgetset/client/SerializerTestConnector.java | 6 ++ .../tests/widgetset/client/SerializerTestRpc.java | 2 + 10 files changed, 279 insertions(+), 118 deletions(-) create mode 100644 client/src/com/vaadin/client/communication/Date_Serializer.java create mode 100644 server/src/com/vaadin/server/communication/DateSerializer.java create mode 100644 server/src/com/vaadin/server/communication/JSONSerializer.java delete mode 100644 uitest/src/com/vaadin/tests/serialization/SerializerTest.html create mode 100644 uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java diff --git a/client/src/com/vaadin/client/communication/Date_Serializer.java b/client/src/com/vaadin/client/communication/Date_Serializer.java new file mode 100644 index 0000000000..c6eb7af188 --- /dev/null +++ b/client/src/com/vaadin/client/communication/Date_Serializer.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.communication; + +import java.util.Date; + +import com.google.gwt.json.client.JSONNumber; +import com.google.gwt.json.client.JSONValue; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.metadata.Type; + +/** + * Client side serializer/deserializer for java.util.Date + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class Date_Serializer implements JSONSerializer { + + @Override + public Date deserialize(Type type, JSONValue jsonValue, + ApplicationConnection connection) { + return new Date((long) ((JSONNumber) jsonValue).doubleValue()); + } + + @Override + public JSONValue serialize(Date value, ApplicationConnection connection) { + return new JSONNumber(value.getTime()); + } + +} diff --git a/client/src/com/vaadin/client/communication/JSONSerializer.java b/client/src/com/vaadin/client/communication/JSONSerializer.java index e5829ece24..a4e78e503c 100644 --- a/client/src/com/vaadin/client/communication/JSONSerializer.java +++ b/client/src/com/vaadin/client/communication/JSONSerializer.java @@ -23,14 +23,17 @@ import com.vaadin.client.metadata.Type; /** * Implementors of this interface knows how to serialize an Object of a given * type to JSON and how to deserialize the JSON back into an object. - * + *

* The {@link #serialize(Object, ApplicationConnection)} and * {@link #deserialize(Type, JSONValue, ApplicationConnection)} methods must be * symmetric so they can be chained and produce the original result (or an equal * result). - * + *

* Each {@link JSONSerializer} implementation can handle an object of a single * type - see {@link Type#findSerializer()}. + *

+ * This is the client side interface, see + * com.vaadin.server.communication.JSONSerializer for the server side interface. * * @since 7.0 */ diff --git a/server/src/com/vaadin/server/JsonCodec.java b/server/src/com/vaadin/server/JsonCodec.java index d533ed99f3..129307e5c1 100644 --- a/server/src/com/vaadin/server/JsonCodec.java +++ b/server/src/com/vaadin/server/JsonCodec.java @@ -31,6 +31,7 @@ import java.lang.reflect.WildcardType; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -45,6 +46,8 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import com.vaadin.server.communication.DateSerializer; +import com.vaadin.server.communication.JSONSerializer; import com.vaadin.shared.Connector; import com.vaadin.shared.JsonConstants; import com.vaadin.shared.communication.UidlValue; @@ -176,6 +179,11 @@ public class JsonCodec implements Serializable { */ private static Map> transportTypeToType = new HashMap>(); + private static Map, JSONSerializer> customSerializers = new HashMap, JSONSerializer>(); + static { + customSerializers.put(Date.class, new DateSerializer()); + } + static { registerType(String.class, JsonConstants.VTYPE_STRING); registerType(Connector.class, JsonConstants.VTYPE_CONNECTOR); @@ -283,6 +291,9 @@ public class JsonCodec implements Serializable { Class classForType = getClassForType(targetType); return decodeEnum(classForType.asSubclass(Enum.class), (String) value); + } else if (customSerializers.containsKey(getClassForType(targetType))) { + return customSerializers.get(getClassForType(targetType)) + .deserialize(targetType, value, connectorTracker); } else { return decodeObject(targetType, (JSONObject) value, connectorTracker); @@ -676,6 +687,10 @@ public class JsonCodec implements Serializable { return encodeEnum((Enum) value, connectorTracker); } else if (value instanceof JSONArray || value instanceof JSONObject) { return new EncodeResult(value); + } else if (customSerializers.containsKey(value.getClass())) { + JSONSerializer serializer = customSerializers.get(value.getClass()); + return new EncodeResult(serializer.serialize(value, + connectorTracker)); } else if (valueType instanceof Class) { // Any object that we do not know how to encode we encode by looping // through fields diff --git a/server/src/com/vaadin/server/communication/DateSerializer.java b/server/src/com/vaadin/server/communication/DateSerializer.java new file mode 100644 index 0000000000..9179eb922b --- /dev/null +++ b/server/src/com/vaadin/server/communication/DateSerializer.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.server.communication; + +import java.lang.reflect.Type; +import java.util.Date; + +import com.vaadin.ui.ConnectorTracker; + +/** + * Server side serializer/deserializer for java.util.Date + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class DateSerializer implements JSONSerializer { + + @Override + public Date deserialize(Type type, Object jsonValue, + ConnectorTracker connectorTracker) { + return new Date(Long.valueOf(String.valueOf(jsonValue))); + } + + @Override + public Object serialize(Date value, ConnectorTracker connectorTracker) { + return value.getTime(); + } + +} diff --git a/server/src/com/vaadin/server/communication/JSONSerializer.java b/server/src/com/vaadin/server/communication/JSONSerializer.java new file mode 100644 index 0000000000..603942db61 --- /dev/null +++ b/server/src/com/vaadin/server/communication/JSONSerializer.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.server.communication; + +import java.lang.reflect.Type; + +import com.google.gwt.json.client.JSONValue; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.ui.ConnectorTracker; + +/** + * Implementors of this interface knows how to serialize an Object of a given + * type to JSON and how to deserialize the JSON back into an object. + *

+ * The {@link #serialize(Object, ApplicationConnection)} and + * {@link #deserialize(Type, JSONValue, ApplicationConnection)} methods must be + * symmetric so they can be chained and produce the original result (or an equal + * result). + *

+ * Each {@link JSONSerializer} implementation can handle an object of a single + * type. + *

+ * This is the server side interface, see + * com.vaadin.client.communication.JSONSerializer for the client side interface. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public interface JSONSerializer { + /** + * Creates and deserializes an object received from the client. Must be + * compatible with {@link #serialize(Object, ConnectorTracker)} and also + * with the client side + * {@link com.vaadin.client.communication.JSONSerializer#serialize(Object, ApplicationConnection)} + * method. + *

+ * The json parameter is of type Object as org.json JSON classes have no + * other common super class + * + * @param type + * The expected return type + * @param jsonValue + * the value from the JSON + * @param connectorTracker + * the connector tracker instance for the UI + * @return A deserialized object + */ + T deserialize(Type type, Object jsonValue, ConnectorTracker connectorTracker); + + /** + * Serialize the given object into JSON. Must be compatible with + * {@link #deserialize(Object, connectorTracker)} and the client side + * com.vaadin.client.communication.JSONSerializer + * + * @param value + * The object to serialize + * @param connectorTracker + * The connector tracker instance for the UI + * @return A JSON serialized version of the object + */ + Object serialize(T value, ConnectorTracker connectorTracker); + +} diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.html b/uitest/src/com/vaadin/tests/serialization/SerializerTest.html deleted file mode 100644 index 63219de5c2..0000000000 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.serialization.SerializerTest?restartApplication
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[18]sendBeanSubclass: 43
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[17]sendBoolean: false, false, [false, false, true, false, true, true]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[16]sendByte: 5, -12, [3, 1, 2]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[15]sendChar: Å, ∫, [a, b, c, d]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[14]sendInt: 2, 5, [2147483647, 0]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[13]sendLong: -57841235865, 577431841358, [57, 0]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[12]sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[11]sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[10]sendString: Taegghiiiinnrsssstt‡
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[9]sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[8]sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[7]sendNull: null, Not null
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[6]sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[5]sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[4]sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[3]sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[2]sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[1]sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}
assertTextvaadin=runcomvaadintestsserializationSerializerTest::/VVerticalLayout[0]/VVerticalLayout[0]/VVerticalLayout[0]/VLabel[0]sendEnum: PREFORMATTED, [HTML, RAW], [PREFORMATTED, XML]
- - diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java index 0561f73b21..1184be79d4 100644 --- a/uitest/src/com/vaadin/tests/serialization/SerializerTest.java +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTest.java @@ -19,6 +19,7 @@ package com.vaadin.tests.serialization; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -137,6 +138,8 @@ public class SerializerTest extends AbstractTestUI { ContentMode.PREFORMATTED, ContentMode.XML }, Arrays.asList(ContentMode.HTML, ContentMode.RAW)); + rpc.sendDate(new Date(1)); + rpc.sendDate(new Date(2013 - 1900, 5 - 1, 31, 11, 12, 13)); testExtension.registerRpc(new SerializerTestRpc() { @Override public void sendBoolean(boolean value, Boolean boxedValue, @@ -316,6 +319,11 @@ public class SerializerTest extends AbstractTestUI { log.log("sendBeanSubclass: " + bean.getValue()); } + @Override + public void sendDate(Date date) { + log.log("sendDate: " + date.toString()); + } + }); } diff --git a/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java new file mode 100644 index 0000000000..518c222bc3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/serialization/SerializerTestTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.serialization; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SerializerTestTest extends MultiBrowserTest { + + @Test + public void testSerialization() { + openTestURL(); + int logRow = 0; + + Assert.assertEquals("sendDate: Fri May 31 11:12:13 CEST 2013", + getLogRow(logRow++)); + Assert.assertEquals("sendDate: Thu Jan 01 01:00:00 CET 1970", + getLogRow(logRow++)); + Assert.assertEquals( + "sendEnum: PREFORMATTED, [HTML, RAW], [PREFORMATTED, XML]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendWrappedGenerics: {[SimpleTestBean(1)]={1=[SimpleTestBean(42)]}}", + getLogRow(logRow++)); + Assert.assertEquals( + "sendMap: {a=SimpleTestBean(1)}, [com.vaadin.tests.widgetset.server.SerializerTestExtension=SimpleTestBean(4)], [2=com.vaadin.tests.widgetset.server.SerializerTestExtension], {SimpleTestBean(4)=SimpleTestBean(-4), SimpleTestBean(-5)=SimpleTestBean(5)}", + getLogRow(logRow++)); + Assert.assertEquals( + "sendSet: [-12, -7, -4], class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(2), SimpleTestBean(3)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendArrayList: [[2], [2]], [[2, 1], [2, 3]], [[SimpleTestBean(7)]]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendList: [-234, 5, 8], class com.vaadin.tests.widgetset.server.SerializerTestExtension, class com.vaadin.tests.serialization.SerializerTest, [SimpleTestBean(-568), SimpleTestBean(234)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendNestedArray: [[7, 5]], [[SimpleTestBean(2)], [SimpleTestBean(4)]]", + getLogRow(logRow++)); + Assert.assertEquals("sendNull: null, Not null", getLogRow(logRow++)); + Assert.assertEquals( + "sendBean: ComplexTestBean [innerBean1=SimpleTestBean(1), innerBean2=SimpleTestBean(3), innerBeanCollection=[SimpleTestBean(6), SimpleTestBean(0)], privimite=6], SimpleTestBean(0), [SimpleTestBean(7)]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendConnector: com.vaadin.tests.widgetset.server.SerializerTestExtension", + getLogRow(logRow++)); + Assert.assertEquals("sendString: Taegghiiiinnrsssstt‡", + getLogRow(logRow++)); + Assert.assertEquals( + "sendDouble: 0.423310825130748, 5.859874482048838, [2.0, 1.7976931348623157E308, 4.9E-324]", + getLogRow(logRow++)); + Assert.assertEquals( + "sendFloat: 1.0000001, 3.14159, [-12.0, 0.0, 57.0]", + getLogRow(logRow++)); + Assert.assertEquals("sendLong: -57841235865, 577431841358, [57, 0]", + getLogRow(logRow++)); + Assert.assertEquals("sendInt: 2, 5, [2147483647, 0]", + getLogRow(logRow++)); + Assert.assertEquals("sendChar: Å, ∫, [a, b, c, d]", getLogRow(logRow++)); + Assert.assertEquals("sendByte: 5, -12, [3, 1, 2]", getLogRow(logRow++)); + Assert.assertEquals( + "sendBoolean: false, false, [false, false, true, false, true, true]", + getLogRow(logRow++)); + Assert.assertEquals("sendBeanSubclass: 43", getLogRow(logRow++)); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java index 0f6ad577ed..01ec6cc4bb 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestConnector.java @@ -19,6 +19,7 @@ package com.vaadin.tests.widgetset.client; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -251,6 +252,11 @@ public class SerializerTestConnector extends AbstractExtensionConnector { } }); } + + @Override + public void sendDate(Date date) { + rpc.sendDate(date); + } }); } diff --git a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java index 4bda067242..fb5b6a1980 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/SerializerTestRpc.java @@ -16,6 +16,7 @@ package com.vaadin.tests.widgetset.client; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; @@ -79,4 +80,5 @@ public interface SerializerTestRpc extends ServerRpc, ClientRpc { public void sendBeanSubclass(SimpleTestBean bean); + public void sendDate(Date date); } -- cgit v1.2.3 From 2483059bca6b925d548a0fd3bf51ff309a3b28e1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 15 Jan 2014 14:11:42 +0200 Subject: Fixed broken launch configuration (#13053) Change-Id: Ifa9f127d29cc3b4fb0a694ad2f7665b3ef34b028 --- eclipse/Development Server (vaadin).launch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eclipse/Development Server (vaadin).launch b/eclipse/Development Server (vaadin).launch index 87cee59f29..9505811c0b 100644 --- a/eclipse/Development Server (vaadin).launch +++ b/eclipse/Development Server (vaadin).launch @@ -9,7 +9,7 @@ - + -- cgit v1.2.3 From 4d2f1477ab105476d79ad8a99397b1c3c55d14b1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 15 Jan 2014 16:14:36 +0200 Subject: Remove client side dependencies in server side javadoc (#13073) Change-Id: I6601f7f34ea83cb7bb054969dcd4b8b1ebcb0801 --- server/src/com/vaadin/server/communication/JSONSerializer.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/src/com/vaadin/server/communication/JSONSerializer.java b/server/src/com/vaadin/server/communication/JSONSerializer.java index 603942db61..fe609c70b6 100644 --- a/server/src/com/vaadin/server/communication/JSONSerializer.java +++ b/server/src/com/vaadin/server/communication/JSONSerializer.java @@ -17,16 +17,14 @@ package com.vaadin.server.communication; import java.lang.reflect.Type; -import com.google.gwt.json.client.JSONValue; -import com.vaadin.client.ApplicationConnection; import com.vaadin.ui.ConnectorTracker; /** * Implementors of this interface knows how to serialize an Object of a given * type to JSON and how to deserialize the JSON back into an object. *

- * The {@link #serialize(Object, ApplicationConnection)} and - * {@link #deserialize(Type, JSONValue, ApplicationConnection)} methods must be + * The {@link #serialize(Object, ConnectorTracker)} and + * {@link #deserialize(Type, Object, ConnectorTracker)} methods must be * symmetric so they can be chained and produce the original result (or an equal * result). *

@@ -43,9 +41,7 @@ public interface JSONSerializer { /** * Creates and deserializes an object received from the client. Must be * compatible with {@link #serialize(Object, ConnectorTracker)} and also - * with the client side - * {@link com.vaadin.client.communication.JSONSerializer#serialize(Object, ApplicationConnection)} - * method. + * with the client side com.vaadin.client.communication.JSONSerializer. *

* The json parameter is of type Object as org.json JSON classes have no * other common super class -- cgit v1.2.3 From dd0479cdefa52091a33ff63f45fc32ae76c4b4f8 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 16 Jan 2014 07:03:16 +0000 Subject: Revert "Theme Parser is deleted, build procedure now generates it (#13161)." Causes a multitude of compile errors on the build server. This reverts commit d2874fde4b8c6afa24f0f6535e0d6fcabc489f51. Change-Id: I49787b347944b614b9e98778b3219b7045cf2bfe --- .gitignore | 10 - build/ide.xml | 13 +- theme-compiler/build.xml | 22 +- .../com/vaadin/sass/internal/ScssStylesheet.java | 2 +- .../vaadin/sass/internal/parser/CharStream.java | 130 + .../sass/internal/parser/Generic_CharStream.java | 370 + .../sass/internal/parser/Generic_CharStream.jj | 370 - .../vaadin/sass/internal/parser/LocatorImpl.java | 60 +- .../sass/internal/parser/ParseException.java | 174 +- .../vaadin/sass/internal/parser/ParseException.jj | 203 - .../com/vaadin/sass/internal/parser/Parser.java | 8605 +++++++++++++++++++- .../src/com/vaadin/sass/internal/parser/Parser.jj | 3028 +++++++ .../sass/internal/parser/ParserConstants.java | 392 + .../com/vaadin/sass/internal/parser/ParserImpl.jj | 3028 ------- .../sass/internal/parser/ParserTokenManager.java | 4997 ++++++++++++ .../src/com/vaadin/sass/internal/parser/Token.java | 146 + .../vaadin/sass/internal/parser/TokenMgrError.java | 162 + .../src/com/vaadin/sass/parser/ParserTest.java | 4 +- .../vaadin/sass/testcases/css/Interpolation.java | 2 +- .../com/vaadin/sass/testcases/scss/Comments.java | 2 +- .../vaadin/sass/testcases/scss/CompassImports.java | 2 +- .../sass/testcases/scss/ControlDirectives.java | 2 +- .../com/vaadin/sass/testcases/scss/Extends.java | 2 +- .../com/vaadin/sass/testcases/scss/Functions.java | 2 +- .../com/vaadin/sass/testcases/scss/Imports.java | 2 +- .../src/com/vaadin/sass/testcases/scss/Mixins.java | 2 +- .../sass/testcases/scss/NestedProperties.java | 2 +- .../com/vaadin/sass/testcases/scss/Nesting.java | 2 +- .../vaadin/sass/testcases/scss/ParentImports.java | 2 +- .../vaadin/sass/testcases/scss/ParentSelector.java | 2 +- .../sass/testcases/scss/VariableGuarded.java | 2 +- .../com/vaadin/sass/testcases/scss/Variables.java | 2 +- 32 files changed, 18065 insertions(+), 3679 deletions(-) create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java delete mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/Token.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java diff --git a/.gitignore b/.gitignore index 9b120c7c3a..30c8597b16 100644 --- a/.gitignore +++ b/.gitignore @@ -71,13 +71,3 @@ WebContent/VAADIN/vaadinPush.debug.js # build result folders */result result - -# /theme-compiler -/theme-compiler/result -/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java -/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.java -/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImplConstants.java -/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImplTokenManager.java -/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java -/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java -/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java diff --git a/build/ide.xml b/build/ide.xml index 51a9d82272..22e6818bea 100755 --- a/build/ide.xml +++ b/build/ide.xml @@ -36,6 +36,7 @@ + @@ -67,14 +68,9 @@ - - - - - - + - + @@ -146,7 +142,4 @@ - - - diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml index 623d2e4ec7..03d0531a68 100644 --- a/theme-compiler/build.xml +++ b/theme-compiler/build.xml @@ -23,7 +23,7 @@ - + @@ -32,29 +32,15 @@ - - - - - - + + + - - - - - - - - - - - diff --git a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java index 35400f7d40..ed6b98f5ac 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java +++ b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java @@ -171,7 +171,7 @@ public class ScssStylesheet extends Node { source.setEncoding(parentStylesheet.getCharset()); } - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); parser.setErrorHandler(errorHandler); parser.setDocumentHandler(documentHandler); diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java new file mode 100644 index 0000000000..c22f19451b --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java @@ -0,0 +1,130 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. CharStream.java Version 5.0 */ +/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.vaadin.sass.internal.parser; + +/** + * This interface describes a character stream that maintains line and + * column number positions of the characters. It also has the capability + * to backup the stream to some extent. An implementation of this + * interface is used in the TokenManager implementation generated by + * JavaCCParser. + * + * All the methods except backup can be implemented in any fashion. backup + * needs to be implemented correctly for the correct operation of the lexer. + * Rest of the methods are all used to get information like line number, + * column number and the String that constitutes a token and are not used + * by the lexer. Hence their implementation won't affect the generated lexer's + * operation. + */ + +public +interface CharStream { + + /** + * Returns the next character from the selected input. The method + * of selecting the input is the responsibility of the class + * implementing this interface. Can throw any java.io.IOException. + */ + char readChar() throws java.io.IOException; + + @Deprecated + /** + * Returns the column position of the character last read. + * @deprecated + * @see #getEndColumn + */ + int getColumn(); + + @Deprecated + /** + * Returns the line number of the character last read. + * @deprecated + * @see #getEndLine + */ + int getLine(); + + /** + * Returns the column number of the last character for current token (being + * matched after the last call to BeginTOken). + */ + int getEndColumn(); + + /** + * Returns the line number of the last character for current token (being + * matched after the last call to BeginTOken). + */ + int getEndLine(); + + /** + * Returns the column number of the first character for current token (being + * matched after the last call to BeginTOken). + */ + int getBeginColumn(); + + /** + * Returns the line number of the first character for current token (being + * matched after the last call to BeginTOken). + */ + int getBeginLine(); + + /** + * Backs up the input stream by amount steps. Lexer calls this method if it + * had already read some characters, but could not use them to match a + * (longer) token. So, they will be used again as the prefix of the next + * token and it is the implemetation's responsibility to do this right. + */ + void backup(int amount); + + /** + * Returns the next character that marks the beginning of the next token. + * All characters must remain in the buffer between two successive calls + * to this method to implement backup correctly. + */ + char BeginToken() throws java.io.IOException; + + /** + * Returns a string made up of characters from the marked token beginning + * to the current buffer position. Implementations have the choice of returning + * anything that they want to. For example, for efficiency, one might decide + * to just return null, which is a valid implementation. + */ + String GetImage(); + + /** + * Returns an array of characters that make up the suffix of length 'len' for + * the currently matched token. This is used to build up the matched string + * for use in actions in the case of MORE. A simple and inefficient + * implementation of this is as follows : + * + * { + * String t = GetImage(); + * return t.substring(t.length() - len, t.length()).toCharArray(); + * } + */ + char[] GetSuffix(int len); + + /** + * The lexer calls this function to indicate that it is done with the stream + * and hence implementations can free any resources held by this class. + * Again, the body of this function can be just empty and it will not + * affect the lexer's operation. + */ + void Done(); + +} +/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java new file mode 100644 index 0000000000..7bc2973311 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.java @@ -0,0 +1,370 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. Generic_CharStream.java Version 0.7pre6 */ +package com.vaadin.sass.internal.parser; + +/** + * An implementation of interface CharStream, where the stream is assumed to + * contain only ASCII characters (without unicode processing). + */ + +public final class Generic_CharStream implements CharStream +{ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + public int bufpos = -1; + private int bufline[]; + private int bufcolumn[]; + + private int column = 0; + private int line = 1; + + private boolean prevCharIsCR = false; + private boolean prevCharIsLF = false; + + private java.io.Reader reader; + + private char[] buffer; + private int maxNextCharInd = 0; + private int inBuf = 0; + + private final void ExpandBuff(boolean wrapAround) + { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try + { + if (wrapAround) + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } + else + { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } + catch (Throwable t) + { + throw new Error(t.getMessage()); + } + + + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } + + private final void FillBuff() throws java.io.IOException + { + if (maxNextCharInd == available) + { + if (available == bufsize) + { + if (tokenBegin > 2048) + { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } + else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } + else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; + } + + int i; + try { + if ((i = reader.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) + { + reader.close(); + throw new java.io.IOException(); + } + else + maxNextCharInd += i; + return; + } + catch(java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; + } + } + + public final char BeginToken() throws java.io.IOException + { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + private final void UpdateLineColumn(char c) + { + column++; + + if (prevCharIsLF) + { + prevCharIsLF = false; + line += (column = 1); + } + else if (prevCharIsCR) + { + prevCharIsCR = false; + if (c == '\n') + { + prevCharIsLF = true; + } + else + line += (column = 1); + } + + switch (c) + { + case '\r' : + prevCharIsCR = true; + break; + case '\n' : + prevCharIsLF = true; + break; + case '\t' : + column--; + column += (8 - (column & 07)); + break; + default : + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + public final char readChar() throws java.io.IOException + { + if (inBuf > 0) + { + --inBuf; + return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]); + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = (char)((char)0xff & buffer[bufpos]); + + UpdateLineColumn(c); + return (c); + } + + /** + * @deprecated + * @see #getEndColumn + */ + + public final int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @deprecated + * @see #getEndLine + */ + + public final int getLine() { + return bufline[bufpos]; + } + + public final int getEndColumn() { + return bufcolumn[bufpos]; + } + + public final int getEndLine() { + return bufline[bufpos]; + } + + public final int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + public final int getBeginLine() { + return bufline[tokenBegin]; + } + + public final void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + public Generic_CharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + reader = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + public Generic_CharStream(java.io.Reader dstream, int startline, + int startcolumn) + { + this(dstream, startline, startcolumn, 4096); + } + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) + { + reader = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) + { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) + { + ReInit(dstream, startline, startcolumn, 4096); + } + + public final String GetImage() + { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); + else + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + public final char[] GetSuffix(int len) + { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else + { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); + } + return ret; + } + + public void Done() + { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token.
+ */ + public void adjustBeginLineColumn(int newLine, int newCol) + { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) + { + len = bufpos - tokenBegin + inBuf + 1; + } + else + { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) + { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) + { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) + { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj deleted file mode 100644 index 7bc2973311..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Generic_CharStream.jj +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. Generic_CharStream.java Version 0.7pre6 */ -package com.vaadin.sass.internal.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - */ - -public final class Generic_CharStream implements CharStream -{ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; - public int bufpos = -1; - private int bufline[]; - private int bufcolumn[]; - - private int column = 0; - private int line = 1; - - private boolean prevCharIsCR = false; - private boolean prevCharIsLF = false; - - private java.io.Reader reader; - - private char[] buffer; - private int maxNextCharInd = 0; - private int inBuf = 0; - - private final void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - private final void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = reader.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) - { - reader.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - - public final char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - private final void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (8 - (column & 07)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - - public final char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]); - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = (char)((char)0xff & buffer[bufpos]); - - UpdateLineColumn(c); - return (c); - } - - /** - * @deprecated - * @see #getEndColumn - */ - - public final int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - - public final int getLine() { - return bufline[bufpos]; - } - - public final int getEndColumn() { - return bufcolumn[bufpos]; - } - - public final int getEndLine() { - return bufline[bufpos]; - } - - public final int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - public final int getBeginLine() { - return bufline[tokenBegin]; - } - - public final void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - public Generic_CharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - reader = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - public Generic_CharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - reader = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - public final String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - public final char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - return ret; - } - - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token.
- */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java b/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java index 825b65fa24..ac244a9582 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/LocatorImpl.java @@ -51,34 +51,82 @@ public class LocatorImpl implements Locator { int line; int column; - @Override public String getURI() { return uri; } - @Override public int getLineNumber() { return line; } - @Override public int getColumnNumber() { return column; } /** - * Creates a LocatorImpl + * Creates a new LocatorImpl + */ + public LocatorImpl(Parser p) { + if (W3CDebug) { + System.err.println("LocatorImpl::newLocator(" + p + ");"); + } + uri = p.source.getURI(); + line = p.token.beginLine; + column = p.token.beginColumn; + } + + /** + * Reinitializes a LocatorImpl + */ + public LocatorImpl(Parser p, Token tok) { + if (W3CDebug) { + System.err.println("LocatorImpl::newLocator(" + p + ", " + tok + + ");"); + } + uri = p.source.getURI(); + line = tok.beginLine; + column = tok.beginColumn; + } + + /** + * Reinitializes a LocatorImpl */ public LocatorImpl(Parser p, int line, int column) { if (W3CDebug) { System.err.println("LocatorImpl::newLocator(" + p + ", " + line + ", " + column + ");"); } - uri = p.getInputSource().getURI(); + uri = p.source.getURI(); this.line = line; this.column = column; } + /** + * Reinitializes a LocatorImpl + */ + public LocatorImpl reInit(Parser p) { + if (W3CDebug) { + System.err.println("LocatorImpl::reInit(" + p + ");"); + } + uri = p.source.getURI(); + line = p.token.beginLine; + column = p.token.beginColumn; + return this; + } + + /** + * Reinitializes a LocatorImpl + */ + public LocatorImpl reInit(Parser p, Token tok) { + if (W3CDebug) { + System.err.println("LocatorImpl::reInit(" + p + ", " + tok + ");"); + } + uri = p.source.getURI(); + line = tok.beginLine; + column = tok.beginColumn; + return this; + } + /** * Reinitializes a LocatorImpl */ @@ -87,7 +135,7 @@ public class LocatorImpl implements Locator { System.err.println("LocatorImpl::reInit(" + p + ", " + line + ", " + column + ");"); } - uri = p.getInputSource().getURI(); + uri = p.source.getURI(); this.line = line; this.column = column; return this; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java index d84decb771..392d71e767 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.java @@ -19,17 +19,185 @@ package com.vaadin.sass.internal.parser; import org.w3c.css.sac.CSSException; /** - * Do not modify this file. It will be regenerated by the build procedure. Edit - * ParseException.jj file instead. The reason of this file presence here: avoid - * compilation errors if build procedure hasn't been yet executed. + * This exception is thrown when parse errors are encountered. You can + * explicitly create objects of this exception type by calling the method + * generateParseException in the generated parser. + * + * You can modify this class to customize your error reporting mechanisms so + * long as you retain the public fields. */ public class ParseException extends CSSException { + private static final long serialVersionUID = -8556588037264585977L; + + /** + * This constructor is used by the method "generateParseException" in the + * generated parser. Calling this constructor generates a new object of this + * type with the fields "currentToken", "expectedTokenSequences", and + * "tokenImage" set. The boolean flag "specialConstructor" is also set to + * true to indicate that this constructor was used to create this object. + * This constructor calls its super class with the empty string to force the + * "toString" method of parent class "Throwable" to print the error message + * in the form: ParseException: + */ + public ParseException(Token currentTokenVal, + int[][] expectedTokenSequencesVal, String[] tokenImageVal) { + super(""); + specialConstructor = true; + currentToken = currentTokenVal; + expectedTokenSequences = expectedTokenSequencesVal; + tokenImage = tokenImageVal; + } + + /** + * The following constructors are for use by you for whatever purpose you + * can think of. Constructing the exception in this manner makes the + * exception behave in the normal way - i.e., as documented in the class + * "Throwable". The fields "errorToken", "expectedTokenSequences", and + * "tokenImage" do not contain relevant information. The JavaCC generated + * code does not use these constructors. + */ public ParseException() { super(); + specialConstructor = false; } public ParseException(String message) { super(message); + specialConstructor = false; + } + + /** + * This variable determines which constructor was used to create this object + * and thereby affects the semantics of the "getMessage" method (see below). + */ + protected boolean specialConstructor; + + /** + * This is the last token that has been consumed successfully. If this + * object has been created due to a parse error, the token followng this + * token will (therefore) be the first error token. + */ + public Token currentToken; + + /** + * Each entry in this array is an array of integers. Each array of integers + * represents a sequence of tokens (by their ordinal values) that is + * expected at this point of the parse. + */ + public int[][] expectedTokenSequences; + + /** + * This is a reference to the "tokenImage" array of the generated parser + * within which the parse error occurred. This array is defined in the + * generated ...Constants interface. + */ + public String[] tokenImage; + + /** + * This method has the standard behavior when this object has been created + * using the standard constructors. Otherwise, it uses "currentToken" and + * "expectedTokenSequences" to generate a parse error message and returns + * it. If this object has been created due to a parse error, and you do not + * catch it (it gets thrown from the parser), then this method is called + * during the printing of the final stack trace, and hence the correct error + * message gets displayed. + */ + @Override + public String getMessage() { + if (!specialConstructor) { + return super.getMessage(); + } + String expected = ""; + int maxSize = 0; + for (int i = 0; i < expectedTokenSequences.length; i++) { + if (maxSize < expectedTokenSequences[i].length) { + maxSize = expectedTokenSequences[i].length; + } + for (int j = 0; j < expectedTokenSequences[i].length; j++) { + expected += tokenImage[expectedTokenSequences[i][j]] + " "; + } + if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { + expected += "..."; + } + expected += eol + " "; + } + String retval = "Encountered \""; + Token tok = currentToken.next; + for (int i = 0; i < maxSize; i++) { + if (i != 0) { + retval += " "; + } + if (tok.kind == 0) { + retval += tokenImage[0]; + break; + } + retval += add_escapes(tok.image); + tok = tok.next; + } + retval += "\" at line " + currentToken.next.beginLine + ", column " + + currentToken.next.beginColumn + "." + eol; + if (expectedTokenSequences.length == 1) { + retval += "Was expecting:" + eol + " "; + } else { + retval += "Was expecting one of:" + eol + " "; + } + retval += expected; + return retval; } + + /** + * The end of line string for this machine. + */ + protected String eol = System.getProperty("line.separator", "\n"); + + /** + * Used to convert raw characters to their escaped version when these raw + * version cannot be used as part of an ASCII string literal. + */ + protected String add_escapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) { + case 0: + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj deleted file mode 100644 index 392d71e767..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParseException.jj +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */ -package com.vaadin.sass.internal.parser; - -import org.w3c.css.sac.CSSException; - -/** - * This exception is thrown when parse errors are encountered. You can - * explicitly create objects of this exception type by calling the method - * generateParseException in the generated parser. - * - * You can modify this class to customize your error reporting mechanisms so - * long as you retain the public fields. - */ -public class ParseException extends CSSException { - private static final long serialVersionUID = -8556588037264585977L; - - /** - * This constructor is used by the method "generateParseException" in the - * generated parser. Calling this constructor generates a new object of this - * type with the fields "currentToken", "expectedTokenSequences", and - * "tokenImage" set. The boolean flag "specialConstructor" is also set to - * true to indicate that this constructor was used to create this object. - * This constructor calls its super class with the empty string to force the - * "toString" method of parent class "Throwable" to print the error message - * in the form: ParseException: - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, String[] tokenImageVal) { - super(""); - specialConstructor = true; - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever purpose you - * can think of. Constructing the exception in this manner makes the - * exception behave in the normal way - i.e., as documented in the class - * "Throwable". The fields "errorToken", "expectedTokenSequences", and - * "tokenImage" do not contain relevant information. The JavaCC generated - * code does not use these constructors. - */ - - public ParseException() { - super(); - specialConstructor = false; - } - - public ParseException(String message) { - super(message); - specialConstructor = false; - } - - /** - * This variable determines which constructor was used to create this object - * and thereby affects the semantics of the "getMessage" method (see below). - */ - protected boolean specialConstructor; - - /** - * This is the last token that has been consumed successfully. If this - * object has been created due to a parse error, the token followng this - * token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array of integers - * represents a sequence of tokens (by their ordinal values) that is - * expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated parser - * within which the parse error occurred. This array is defined in the - * generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * This method has the standard behavior when this object has been created - * using the standard constructors. Otherwise, it uses "currentToken" and - * "expectedTokenSequences" to generate a parse error message and returns - * it. If this object has been created due to a parse error, and you do not - * catch it (it gets thrown from the parser), then this method is called - * during the printing of the final stack trace, and hence the correct error - * message gets displayed. - */ - @Override - public String getMessage() { - if (!specialConstructor) { - return super.getMessage(); - } - String expected = ""; - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected += tokenImage[expectedTokenSequences[i][j]] + " "; - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected += "..."; - } - expected += eol + " "; - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) { - retval += " "; - } - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += add_escapes(tok.image); - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " - + currentToken.next.beginColumn + "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected; - return retval; - } - - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version when these raw - * version cannot be used as part of an ASCII string literal. - */ - protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) { - case 0: - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" - + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - -} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index e66925ae2d..53d1ee78ca 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -13,34 +13,8611 @@ * License for the specific language governing permissions and limitations under * the License. */ +/* Generated By:JavaCC: Do not edit this line. Parser.java */ package com.vaadin.sass.internal.parser; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; +import java.util.ArrayList; +import java.util.Locale; +import java.util.UUID; + +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; +import org.w3c.css.sac.ConditionFactory; +import org.w3c.css.sac.DocumentHandler; +import org.w3c.css.sac.ErrorHandler; import org.w3c.css.sac.InputSource; +import org.w3c.css.sac.LexicalUnit; +import org.w3c.css.sac.Locator; +import org.w3c.css.sac.SelectorFactory; +import org.w3c.css.sac.SelectorList; +import org.w3c.flute.parser.selectors.ConditionFactoryImpl; +import org.w3c.flute.parser.selectors.SelectorFactoryImpl; +import org.w3c.flute.util.Encoding; + +import com.vaadin.sass.internal.handler.SCSSDocumentHandlerImpl; +import com.vaadin.sass.internal.tree.Node; +import com.vaadin.sass.internal.tree.VariableNode; /** + * A CSS2 parser * - * @since - * @author Vaadin Ltd + * @author Philippe Le H�garet + * @version $Revision: 1.15 $ */ -public interface Parser extends org.w3c.css.sac.Parser { +public class Parser implements org.w3c.css.sac.Parser, ParserConstants { + + // replaces all \t, \n, etc with this StringBuffer. + static final StringBuilder SPACE = new StringBuilder(" "); + + // the document handler for the parser + protected SCSSDocumentHandlerImpl documentHandler; + // the error handler for the parser + protected ErrorHandler errorHandler; + // the input source for the parser + protected InputSource source; + + protected ConditionFactory conditionFactory; + protected SelectorFactory selectorFactory; + + // temporary place holder for pseudo-element ... + private String pseudoElt; + + /** + * Creates a new Parser + */ + public Parser() { + this((CharStream) null); + } + + /** + * @@TODO + * @exception CSSException + * Not yet implemented + */ + @Override + public void setLocale(Locale locale) throws CSSException { + throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); + } + + public InputSource getInputSource() { + return source; + } + + /** + * Set the document handler for this parser + */ + @Override + public void setDocumentHandler(DocumentHandler handler) { + documentHandler = (SCSSDocumentHandlerImpl) handler; + } + + @Override + public void setSelectorFactory(SelectorFactory selectorFactory) { + this.selectorFactory = selectorFactory; + } + + @Override + public void setConditionFactory(ConditionFactory conditionFactory) { + this.conditionFactory = conditionFactory; + } + + /** + * Set the error handler for this parser + */ + @Override + public void setErrorHandler(ErrorHandler error) { + errorHandler = error; + } + + /** + * Main parse methods + * + * @param source + * the source of the style sheet. + * @exception IOException + * the source can't be parsed. + * @exception CSSException + * the source is not CSS valid. + */ + @Override + public void parseStyleSheet(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + + parserUnit(); + } + + /** + * Convenient method for URIs. + * + * @param systemId + * the fully resolved URI of the style sheet. + * @exception IOException + * the source can't be parsed. + * @exception CSSException + * the source is not CSS valid. + */ + @Override + public void parseStyleSheet(String systemId) throws CSSException, + IOException { + parseStyleSheet(new InputSource(systemId)); + } + + /** + * This method parses only one rule (style rule or at-rule, except + * @charset). + * + * @param source + * the source of the rule. + * @exception IOException + * the source can't be parsed. + * @exception CSSException + * the source is not CSS valid. + */ + // TODO required by original parser but not used by Vaadin? + @Override + public void parseRule(InputSource source) throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseRule(); + } - InputSource getInputSource(); + /** + * This method parses a style declaration (including the surrounding curly + * braces). + * + * @param source + * the source of the style declaration. + * @exception IOException + * the source can't be parsed. + * @exception CSSException + * the source is not CSS valid. + */ + @Override + public void parseStyleDeclaration(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); - class ParserAccessor { + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseDeclarationBlock(); + } + + /** + * This methods returns "http://www.w3.org/TR/REC-CSS2". + * + * @return the string "http://www.w3.org/TR/REC-CSS2". + */ + @Override + public String getParserVersion() { + return "http://www.w3.org/TR/REC-CSS2"; + } + + /** + * Parse methods used by DOM Level 2 implementation. + */ + public void parseImportRule(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseImportRule(); + } + + public void parseMediaRule(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseMediaRule(); + } + + @Override + public SelectorList parseSelectors(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); - public static Parser getParser() { + return null; + } + + @Override + public LexicalUnit parsePropertyValue(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return expr(); + } + + @Override + public boolean parsePriority(InputSource source) throws CSSException, + IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return prio(); + } + + /** + * Convert the source into a Reader. Used only by DOM Level 2 parser + * methods. + */ + private Reader getReader(InputSource source) throws IOException { + if (source.getCharacterStream() != null) { + return source.getCharacterStream(); + } else if (source.getByteStream() != null) { + // My DOM level 2 implementation doesn't use this case. + if (source.getEncoding() == null) { + // unknown encoding, use ASCII as default. + return new InputStreamReader(source.getByteStream(), "ASCII"); + } else { + return new InputStreamReader(source.getByteStream(), + source.getEncoding()); + } + } else { + // systemId + // @@TODO + throw new CSSException("not yet implemented"); + } + } + + /** + * Convert the source into a CharStream with encoding informations. The + * encoding can be found in the InputSource or in the CSS document. Since + * this method marks the reader and make a reset after looking for the + * charset declaration, you'll find the charset declaration into the stream. + */ + private CharStream getCharStreamWithLurk(InputSource source) + throws CSSException, IOException { + if (source.getCharacterStream() != null) { + // all encoding are supposed to be resolved by the user + // return the reader + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } else if (source.getByteStream() == null) { + // @@CONTINUE ME. see also getReader() with systemId try { - String implClassName = Parser.class.getPackage().getName() - + ".ParserImpl"; - Class clazz = Class.forName(implClassName); - return (Parser) clazz.newInstance(); + source.setByteStream(new URL(source.getURI()).openStream()); } catch (Exception e) { - throw new RuntimeException( - "Unable to load parser implementation." - + "Check whether you have generated parser " - + "class using build procedure", e); + try { + source.setByteStream(new FileInputStream(source.getURI())); + } catch (IOException ex) { + throw new CSSException("invalid url ?"); + } + } + } + // use UTF-8 as the default encoding. + String encoding = source.getEncoding(); + InputStream input = source.getByteStream(); + if (!input.markSupported()) { + // If mark is not supported, wrap it in a stream which supports mark + input = new BufferedInputStream(input); + source.setByteStream(input); + } + // Mark either the original stream or the wrapped stream + input.mark(100); + if (encoding == null) { + encoding = "ASCII"; + + char c = ' '; + + c = (char) input.read(); + + if (c == '@') { + // hum, is it a charset ? + int size = 100; + byte[] buf = new byte[size]; + input.read(buf, 0, 7); + String keyword = new String(buf, 0, 7); + if (keyword.equals("charset")) { + // Yes, this is the charset declaration ! + + // here I don't use the right declaration : white space are + // ' '. + while ((c = (char) input.read()) == ' ') { + // find the first quote + } + char endChar = c; + int i = 0; + + if ((endChar != '"') && (endChar != '\u005c'')) { + // hum this is not a quote. + throw new CSSException("invalid charset declaration"); + } + + while ((c = (char) input.read()) != endChar) { + buf[i++] = (byte) c; + if (i == size) { + byte[] old = buf; + buf = new byte[size + 100]; + System.arraycopy(old, 0, buf, 0, size); + size += 100; + } + } + while ((c = (char) input.read()) == ' ') { + // find the next relevant character + } + if (c != ';') { + // no semi colon at the end ? + throw new CSSException("invalid charset declaration: " + + "missing semi colon"); + } + encoding = new String(buf, 0, i); + if (source.getEncoding() != null) { + // compare the two encoding informations. + // For example, I don't accept to have ASCII and after + // UTF-8. + // Is it really good ? That is the question. + if (!encoding.equals(source.getEncoding())) { + throw new CSSException( + "invalid encoding information."); + } + } + } // else no charset declaration available + } + } + // ok set the real encoding of this source. + source.setEncoding(encoding); + // set the real reader of this source. + source.setCharacterStream(new InputStreamReader(source.getByteStream(), + Encoding.getJavaEncoding(encoding))); + // reset the stream (leave the charset declaration in the stream). + input.reset(); + + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } + + private LocatorImpl currentLocator; + + private Locator getLocator() { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this); + return currentLocator; + } + return currentLocator.reInit(this); + } + + private LocatorImpl getLocator(Token save) { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this, save); + return currentLocator; + } + return currentLocator.reInit(this, save); + } + + private void reportError(Locator l, Exception e) { + if (errorHandler != null) { + if (e instanceof ParseException) { + // construct a clean error message. + ParseException pe = (ParseException) e; + if (pe.specialConstructor) { + StringBuffer errorM = new StringBuffer(); + if (pe.currentToken != null) { + errorM.append("encountered \u005c"").append( + pe.currentToken.next); + } + errorM.append('"'); + if (pe.expectedTokenSequences.length != 0) { + errorM.append(". Was expecting one of: "); + for (int i = 0; i < pe.expectedTokenSequences.length; i++) { + for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { + int kind = pe.expectedTokenSequences[i][j]; + if (kind != S) { + errorM.append(pe.tokenImage[kind]); + errorM.append(' '); + } + } + } + } + errorHandler.error(new CSSParseException(errorM.toString(), + l, e)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), l, + e)); + } + } else if (e == null) { + errorHandler.error(new CSSParseException("error", l, null)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), l, e)); + } + } + } + + private void reportWarningSkipText(Locator l, String text) { + if (errorHandler != null && text != null) { + errorHandler.warning(new CSSParseException("Skipping: " + text, l)); + } + } + + /* + * The grammar of CSS2 + */ + + /** + * The main entry for the parser. + * + * @exception ParseException + * exception during the parse + */ + final public void parserUnit() throws ParseException { + try { + documentHandler.startDocument(source); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CHARSET_SYM: + charset(); + break; + default: + jj_la1[0] = jj_gen; + ; + } + label_1: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + case CDO: + case CDC: + case ATKEYWORD: + ; + break; + default: + jj_la1[1] = jj_gen; + break label_1; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + jj_consume_token(S); + comments(); + break; + case CDO: + case CDC: + case ATKEYWORD: + ignoreStatement(); + break; + default: + jj_la1[2] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + label_2: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORT_SYM: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_2; + } + importDeclaration(); + label_3: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CDO: + case CDC: + case ATKEYWORD: + ; + break; + default: + jj_la1[4] = jj_gen; + break label_3; + } + ignoreStatement(); + label_4: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[5] = jj_gen; + break label_4; + } + jj_consume_token(S); + } + } + } + afterImportDeclaration(); + jj_consume_token(0); + } finally { + documentHandler.endDocument(source); + } + } + + final public void charset() throws ParseException { + Token n; + try { + jj_consume_token(CHARSET_SYM); + label_5: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[6] = jj_gen; + break label_5; + } + jj_consume_token(S); + } + n = jj_consume_token(STRING); + label_6: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[7] = jj_gen; + break label_6; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + } catch (ParseException e) { + reportError(getLocator(e.currentToken.next), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } catch (Exception e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } + } + + final public void afterImportDeclaration() throws ParseException { + String ret; + Locator l; + label_7: while (true) { + ; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case MIXIN_SYM: + mixinDirective(); + break; + case EACH_SYM: + case IF_SYM: + controlDirective(); + break; + case INCLUDE_SYM: + includeDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case MEDIA_SYM: + media(); + break; + case PAGE_SYM: + page(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + case KEY_FRAME_SYM: + keyframes(); + break; + default: + jj_la1[8] = jj_gen; + if (jj_2_1(2147483647)) { + variable(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case VARIABLE: + listModifyDirective(); + break; + default: + jj_la1[9] = jj_gen; + l = getLocator(); + ret = skipStatement(); + if ((ret == null) || (ret.length() == 0)) { + { + if (true) { + return; + } + } + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(l, ret); + } + } + } + } + label_8: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CDO: + case CDC: + case ATKEYWORD: + ; + break; + default: + jj_la1[10] = jj_gen; + break label_8; + } + ignoreStatement(); + label_9: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[11] = jj_gen; + break label_9; + } + jj_consume_token(S); + } + } + } + } + + final public void ignoreStatement() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CDO: + jj_consume_token(CDO); + break; + case CDC: + jj_consume_token(CDC); + break; + case ATKEYWORD: + atRuleDeclaration(); + break; + default: + jj_la1[12] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + /** + * The import statement + * + * @exception ParseException + * exception during the parse + */ + final public void importDeclaration() throws ParseException { + Token n; + String uri; + MediaListImpl ml = new MediaListImpl(); + boolean isURL = false; + try { + jj_consume_token(IMPORT_SYM); + label_10: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[13] = jj_gen; + break label_10; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + uri = convertStringIndex(n.image, 1, n.image.length() - 1); + break; + case URL: + n = jj_consume_token(URL); + isURL = true; + uri = n.image.substring(4, n.image.length() - 1).trim(); + if ((uri.charAt(0) == '"') || (uri.charAt(0) == '\u005c'')) { + uri = uri.substring(1, uri.length() - 1); + } + break; + default: + jj_la1[14] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_11: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[15] = jj_gen; + break label_11; + } + jj_consume_token(S); + } + mediaStatement(ml); + jj_consume_token(SEMICOLON); + label_12: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[16] = jj_gen; + break label_12; + } + jj_consume_token(S); + } + if (ml.getLength() == 0) { + // see section 6.3 of the CSS2 recommandation. + ml.addItem("all"); + } + documentHandler.importStyle(uri, ml, isURL); + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void keyframes() throws ParseException { + Token n; + boolean start = false; + String keyframeName = null; + String animationname = ""; + try { + n = jj_consume_token(KEY_FRAME_SYM); + label_13: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[17] = jj_gen; + break label_13; + } + jj_consume_token(S); + } + keyframeName = n.image; + label_14: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + animationname += n.image; + break; + case INTERPOLATION: + n = jj_consume_token(INTERPOLATION); + animationname += n.image; + break; + default: + jj_la1[18] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[19] = jj_gen; + break label_14; + } + } + label_15: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[20] = jj_gen; + break label_15; + } + jj_consume_token(S); + } + start = true; + documentHandler.startKeyFrames(keyframeName, animationname); + jj_consume_token(LBRACE); + label_16: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[21] = jj_gen; + break label_16; + } + jj_consume_token(S); + } + label_17: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TO: + case FROM: + case CONTENT_SYM: + case PERCENTAGE: + ; + break; + default: + jj_la1[22] = jj_gen; + break label_17; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TO: + case FROM: + case PERCENTAGE: + keyframeSelector(); + break; + case CONTENT_SYM: + contentDirective(); + break; + default: + jj_la1[23] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_18: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[24] = jj_gen; + break label_18; + } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + } finally { + if (start) { + documentHandler.endKeyFrames(); + } + } + } + + final public void keyframeSelector() throws ParseException { + Token n; + String selector = ""; + boolean start = false; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case FROM: + n = jj_consume_token(FROM); + break; + case TO: + n = jj_consume_token(TO); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + default: + jj_la1[25] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + selector += n.image; + label_19: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[26] = jj_gen; + break label_19; + } + jj_consume_token(S); + } + label_20: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[27] = jj_gen; + break label_20; + } + jj_consume_token(COMMA); + label_21: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[28] = jj_gen; + break label_21; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case FROM: + n = jj_consume_token(FROM); + break; + case TO: + n = jj_consume_token(TO); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + default: + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + selector += (", " + n.image); + label_22: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[30] = jj_gen; + break label_22; + } + jj_consume_token(S); + } + } + jj_consume_token(LBRACE); + label_23: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[31] = jj_gen; + break label_23; + } + jj_consume_token(S); + } + start = true; + documentHandler.startKeyframeSelector(selector); + label_24: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case MICROSOFT_RULE: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[32] = jj_gen; + break label_24; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case MICROSOFT_RULE: + microsoftExtension(); + break; + default: + jj_la1[33] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_25: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[34] = jj_gen; + break label_25; + } + jj_consume_token(S); + } + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn - 1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endKeyframeSelector(); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + /* see http://www.w3.org/TR/css3-mediaqueries/ */ + final public void media() throws ParseException { + boolean start = false; + String ret; + MediaListImpl ml = new MediaListImpl(); + try { + jj_consume_token(MEDIA_SYM); + label_26: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[35] = jj_gen; + break label_26; + } + jj_consume_token(S); + } + mediaStatement(ml); + start = true; + documentHandler.startMedia(ml); + jj_consume_token(LBRACE); + label_27: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[36] = jj_gen; + break label_27; + } + jj_consume_token(S); + } + label_28: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CDO: + case LBRACE: + case DASHMATCH: + case INCLUDES: + case PLUS: + case MINUS: + case COMMA: + case SEMICOLON: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case NONASCII: + case DEBUG_SYM: + case WARN_SYM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case PERCENTAGE: + case HASH: + case IMPORT_SYM: + case MEDIA_SYM: + case CHARSET_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case ATKEYWORD: + case IMPORTANT_SYM: + case UNICODERANGE: + case FUNCTION: + case UNKNOWN: + ; + break; + default: + jj_la1[37] = jj_gen; + break label_28; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case CDO: + case LBRACE: + case DASHMATCH: + case INCLUDES: + case MINUS: + case COMMA: + case SEMICOLON: + case NONASCII: + case STRING: + case NUMBER: + case URL: + case PERCENTAGE: + case IMPORT_SYM: + case MEDIA_SYM: + case CHARSET_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case ATKEYWORD: + case IMPORTANT_SYM: + case UNICODERANGE: + case FUNCTION: + case UNKNOWN: + skipUnknownRule(); + break; + default: + jj_la1[38] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_29: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[39] = jj_gen; + break label_29; + } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } finally { + if (start) { + documentHandler.endMedia(ml); + } + } + } + + final public void mediaStatement(MediaListImpl ml) throws ParseException { + Token t; + t = getToken(1); + // loop over comma separated parts, add each to ml + while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) + && (t.kind != SEMICOLON)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + if (t.kind == COMMA) { + // skip the comma and the token before it that is still the + // active token + getNextToken(); + getNextToken(); + t = getToken(1); + } + String str = s.toString().trim(); + if (str.length() > 0) { + ml.addItem(str); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String medium() throws ParseException { + Token n; + n = jj_consume_token(IDENT); + { + if (true) { + return convertIdent(n.image); + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void page() throws ParseException { + boolean start = false; + Token n = null; + String page = null; + String pseudo = null; + try { + jj_consume_token(PAGE_SYM); + label_30: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[40] = jj_gen; + break label_30; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + label_31: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[41] = jj_gen; + break label_31; + } + jj_consume_token(S); + } + break; + default: + jj_la1[42] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + pseudo = pseudo_page(); + break; + default: + jj_la1[43] = jj_gen; + ; + } + if (n != null) { + page = convertIdent(n.image); + } + jj_consume_token(LBRACE); + label_32: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[44] = jj_gen; + break label_32; + } + jj_consume_token(S); + } + start = true; + documentHandler.startPage(page, pseudo); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[45] = jj_gen; + ; + } + label_33: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[46] = jj_gen; + break label_33; + } + jj_consume_token(SEMICOLON); + label_34: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[47] = jj_gen; + break label_34; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[48] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + label_35: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[49] = jj_gen; + break label_35; + } + jj_consume_token(S); + } + } catch (ParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn - 1); + reportError(li, e); + skipStatement(); + // reportWarningSkipText(li, skipStatement()); + } else { + skipStatement(); + } + } finally { + if (start) { + documentHandler.endPage(page, pseudo); + } + } + } + + final public String pseudo_page() throws ParseException { + Token n; + jj_consume_token(COLON); + n = jj_consume_token(IDENT); + label_36: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[50] = jj_gen; + break label_36; + } + jj_consume_token(S); + } + { + if (true) { + return convertIdent(n.image); + } + } + throw new Error("Missing return statement in function"); + } + + final public void fontFace() throws ParseException { + boolean start = false; + try { + jj_consume_token(FONT_FACE_SYM); + label_37: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[51] = jj_gen; + break label_37; + } + jj_consume_token(S); + } + jj_consume_token(LBRACE); + label_38: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[52] = jj_gen; + break label_38; + } + jj_consume_token(S); + } + start = true; + documentHandler.startFontFace(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[53] = jj_gen; + ; + } + label_39: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[54] = jj_gen; + break label_39; + } + jj_consume_token(SEMICOLON); + label_40: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[55] = jj_gen; + break label_40; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[56] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + label_41: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[57] = jj_gen; + break label_41; + } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } finally { + if (start) { + documentHandler.endFontFace(); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void atRuleDeclaration() throws ParseException { + Token n; + String ret; + n = jj_consume_token(ATKEYWORD); + ret = skipStatement(); + if ((ret != null) && (ret.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(getLocator(), ret); + } + } + + final public void skipUnknownRule() throws ParseException { + Token n; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ATKEYWORD: + n = jj_consume_token(ATKEYWORD); + break; + case CDO: + n = jj_consume_token(CDO); + break; + case CHARSET_SYM: + n = jj_consume_token(CHARSET_SYM); + break; + case COMMA: + n = jj_consume_token(COMMA); + break; + case DASHMATCH: + n = jj_consume_token(DASHMATCH); + break; + case FONT_FACE_SYM: + n = jj_consume_token(FONT_FACE_SYM); + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + break; + case IMPORTANT_SYM: + n = jj_consume_token(IMPORTANT_SYM); + break; + case IMPORT_SYM: + n = jj_consume_token(IMPORT_SYM); + break; + case INCLUDES: + n = jj_consume_token(INCLUDES); + break; + case LBRACE: + n = jj_consume_token(LBRACE); + break; + case MEDIA_SYM: + n = jj_consume_token(MEDIA_SYM); + break; + case NONASCII: + n = jj_consume_token(NONASCII); + break; + case NUMBER: + n = jj_consume_token(NUMBER); + break; + case PAGE_SYM: + n = jj_consume_token(PAGE_SYM); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + case STRING: + n = jj_consume_token(STRING); + break; + case UNICODERANGE: + n = jj_consume_token(UNICODERANGE); + break; + case URL: + n = jj_consume_token(URL); + break; + case SEMICOLON: + n = jj_consume_token(SEMICOLON); + break; + case MINUS: + n = jj_consume_token(MINUS); + break; + case UNKNOWN: + n = jj_consume_token(UNKNOWN); + break; + default: + jj_la1[58] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + String ret; + Locator loc = getLocator(); + ret = skipStatement(); + if ((ret != null) && (n.image.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(loc, ret); + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public char combinator() throws ParseException { + char connector = ' '; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + connector = combinatorChar(); + break; + case S: + jj_consume_token(S); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + connector = combinatorChar(); + break; + default: + jj_la1[59] = jj_gen; + ; + } + break; + default: + jj_la1[60] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + { + if (true) { + return connector; + } + } + throw new Error("Missing return statement in function"); + } + + /** to refactor combinator and reuse in selector(). */ + final public char combinatorChar() throws ParseException { + Token t; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + t = jj_consume_token(PLUS); + break; + case PRECEDES: + t = jj_consume_token(PRECEDES); + break; + case SIBLING: + t = jj_consume_token(SIBLING); + break; + default: + jj_la1[61] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_42: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[62] = jj_gen; + break label_42; + } + jj_consume_token(S); + } + { + if (true) { + return t.image.charAt(0); + } + } + throw new Error("Missing return statement in function"); + } + + final public void microsoftExtension() throws ParseException { + Token n; + String name = ""; + String value = ""; + // This is not really taking the syntax of filter rules into account + n = jj_consume_token(MICROSOFT_RULE); + label_43: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[63] = jj_gen; + break label_43; + } + jj_consume_token(S); + } + name = n.image; + jj_consume_token(COLON); + label_44: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + value += n.image; + break; + case NUMBER: + n = jj_consume_token(NUMBER); + value += n.image; + break; + case STRING: + n = jj_consume_token(STRING); + value += n.image; + break; + case COMMA: + n = jj_consume_token(COMMA); + value += n.image; + break; + case INTERPOLATION: + n = jj_consume_token(INTERPOLATION); + value += n.image; + break; + case COLON: + n = jj_consume_token(COLON); + value += n.image; + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + value += n.image; + break; + case RPARAN: + n = jj_consume_token(RPARAN); + value += n.image; + break; + case EQ: + n = jj_consume_token(EQ); + value += n.image; + break; + case DOT: + n = jj_consume_token(DOT); + value += n.image; + break; + case S: + n = jj_consume_token(S); + if (value.lastIndexOf(' ') != value.length() - 1) { + value += n.image; + } + break; + default: + jj_la1[64] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + case EQ: + case COMMA: + case DOT: + case RPARAN: + case COLON: + case INTERPOLATION: + case STRING: + case IDENT: + case NUMBER: + case FUNCTION: + ; + break; + default: + jj_la1[65] = jj_gen; + break label_44; + } + } + jj_consume_token(SEMICOLON); + label_45: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[66] = jj_gen; + break label_45; + } + jj_consume_token(S); + } + documentHandler.microsoftDirective(name, value); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String property() throws ParseException { + Token t; + String s = ""; + label_46: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[67] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[68] = jj_gen; + break label_46; + } + } + label_47: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[69] = jj_gen; + break label_47; + } + jj_consume_token(S); + } + { + if (true) { + return s; + } + } + throw new Error("Missing return statement in function"); + } + + final public String variableName() throws ParseException { + Token n; + n = jj_consume_token(VARIABLE); + label_48: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[70] = jj_gen; + break label_48; + } + jj_consume_token(S); + } + { + if (true) { + return convertIdent(n.image.substring(1)); + } + } + throw new Error("Missing return statement in function"); + } + + final public String functionName() throws ParseException { + Token n; + n = jj_consume_token(FUNCTION); + label_49: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[71] = jj_gen; + break label_49; + } + jj_consume_token(S); + } + { + if (true) { + return convertIdent(n.image.substring(0, n.image.length() - 1)); + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void styleRule() throws ParseException { + boolean start = false; + ArrayList l = null; + Token save; + Locator loc; + try { + l = selectorList(); + save = token; + jj_consume_token(LBRACE); + label_50: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[72] = jj_gen; + break label_50; + } + jj_consume_token(S); + } + start = true; + documentHandler.startSelector(l); + label_51: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case MICROSOFT_RULE: + case IDENT: + case VARIABLE: + case HASH: + case IMPORT_SYM: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[73] = jj_gen; + break label_51; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case MICROSOFT_RULE: + microsoftExtension(); + break; + case IMPORT_SYM: + importDeclaration(); + break; + default: + jj_la1[74] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_52: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[75] = jj_gen; + break label_52; + } + jj_consume_token(S); + } + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn - 1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endSelector(); } } + } + final public ArrayList selectorList() throws ParseException { + ArrayList selectors = new ArrayList(); + String selector; + selector = selector(); + label_53: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[76] = jj_gen; + break label_53; + } + jj_consume_token(COMMA); + label_54: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[77] = jj_gen; + break label_54; + } + jj_consume_token(S); + } + selectors.add(selector); + selector = selector(); + } + selectors.add(selector); + { + if (true) { + return selectors; + } + } + throw new Error("Missing return statement in function"); } + + /** + * @exception ParseException + * exception during the parse + */ + final public String selector() throws ParseException { + String selector = null; + char comb; + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + selector = simple_selector(null, ' '); + break; + case PLUS: + case PRECEDES: + case SIBLING: + comb = combinatorChar(); + selector = simple_selector(selector, comb); + break; + default: + jj_la1[78] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_55: while (true) { + if (jj_2_2(2)) { + ; + } else { + break label_55; + } + comb = combinator(); + selector = simple_selector(selector, comb); + } + label_56: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[79] = jj_gen; + break label_56; + } + jj_consume_token(S); + } + { + if (true) { + return selector; + } + } + } catch (ParseException e) { + /* + * Token t = getToken(1); StringBuffer s = new StringBuffer(); + * s.append(getToken(0).image); while ((t.kind != COMMA) && (t.kind + * != SEMICOLON) && (t.kind != LBRACE) && (t.kind != EOF)) { + * s.append(t.image); getNextToken(); t = getToken(1); } + * reportWarningSkipText(getLocator(), s.toString()); + */ + Token t = getToken(1); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + getNextToken(); + t = getToken(1); + } + + { + if (true) { + throw new ThrowedParseException(e); + } + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String simple_selector(String selector, char comb) + throws ParseException { + String simple_current = null; + String cond = null; + + pseudoElt = null; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ANY: + case PARENT: + case INTERPOLATION: + case IDENT: + simple_current = element_name(); + label_57: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + case DOT: + case COLON: + case HASH: + ; + break; + default: + jj_la1[80] = jj_gen; + break label_57; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case HASH: + cond = hash(cond); + break; + case DOT: + cond = _class(cond); + break; + case LBRACKET: + cond = attrib(cond); + break; + case COLON: + cond = pseudo(cond); + break; + default: + jj_la1[81] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + case LBRACKET: + case DOT: + case COLON: + case HASH: + label_58: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case HASH: + cond = hash(cond); + break; + case DOT: + cond = _class(cond); + break; + case LBRACKET: + cond = attrib(cond); + break; + case COLON: + cond = pseudo(cond); + break; + default: + jj_la1[82] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case LBRACKET: + case DOT: + case COLON: + case HASH: + ; + break; + default: + jj_la1[83] = jj_gen; + break label_58; + } + } + break; + default: + jj_la1[84] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + if (simple_current == null) { + simple_current = ""; + } + if (cond != null) { + simple_current = simple_current + cond; + } + StringBuilder builder = new StringBuilder(); + switch (comb) { + case ' ': + if (selector != null) { + builder.append(selector).append(" "); + } + break; + case '+': + case '>': + case '~': + if (selector != null) { + builder.append(selector).append(" "); + } + builder.append(comb).append(" "); + break; + default: { + if (true) { + throw new ParseException("invalid state. send a bug report"); + } + } + } + builder.append(simple_current); + selector = builder.toString(); + + if (pseudoElt != null) { + selector = selector + pseudoElt; + } + { + if (true) { + return selector; + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String _class(String pred) throws ParseException { + Token t; + String s = "."; + jj_consume_token(DOT); + label_59: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[85] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[86] = jj_gen; + break label_59; + } + } + if (pred == null) { + { + if (true) { + return s; + } + } + } else { + { + if (true) { + return pred + s; + } + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String element_name() throws ParseException { + Token t; + String s = ""; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + label_60: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[87] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[88] = jj_gen; + break label_60; + } + } + { + if (true) { + return s; + } + } + break; + case ANY: + jj_consume_token(ANY); + { + if (true) { + return "*"; + } + } + break; + case PARENT: + jj_consume_token(PARENT); + { + if (true) { + return "&"; + } + } + break; + default: + jj_la1[89] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String attrib(String pred) throws ParseException { + int cases = 0; + Token att = null; + Token val = null; + String attValue = null; + jj_consume_token(LBRACKET); + label_61: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[90] = jj_gen; + break label_61; + } + jj_consume_token(S); + } + att = jj_consume_token(IDENT); + label_62: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[91] = jj_gen; + break label_62; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DASHMATCH: + case CARETMATCH: + case DOLLARMATCH: + case STARMATCH: + case INCLUDES: + case EQ: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case EQ: + jj_consume_token(EQ); + cases = 1; + break; + case INCLUDES: + jj_consume_token(INCLUDES); + cases = 2; + break; + case DASHMATCH: + jj_consume_token(DASHMATCH); + cases = 3; + break; + case CARETMATCH: + jj_consume_token(CARETMATCH); + cases = 4; + break; + case DOLLARMATCH: + jj_consume_token(DOLLARMATCH); + cases = 5; + break; + case STARMATCH: + jj_consume_token(STARMATCH); + cases = 6; + break; + default: + jj_la1[92] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_63: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[93] = jj_gen; + break label_63; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + val = jj_consume_token(IDENT); + attValue = val.image; + break; + case STRING: + val = jj_consume_token(STRING); + attValue = val.image; + break; + default: + jj_la1[94] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_64: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[95] = jj_gen; + break label_64; + } + jj_consume_token(S); + } + break; + default: + jj_la1[96] = jj_gen; + ; + } + jj_consume_token(RBRACKET); + String name = convertIdent(att.image); + String c; + switch (cases) { + case 0: + c = name; + break; + case 1: + c = name + "=" + attValue; + break; + case 2: + c = name + "~=" + attValue; + break; + case 3: + c = name + "|=" + attValue; + break; + case 4: + c = name + "^=" + attValue; + break; + case 5: + c = name + "$=" + attValue; + break; + case 6: + c = name + "*=" + attValue; + break; + default: + // never reached. + c = null; + } + c = "[" + c + "]"; + if (pred == null) { + { + if (true) { + return c; + } + } + } else { + { + if (true) { + return pred + c; + } + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String pseudo(String pred) throws ParseException { + Token n; + Token param; + String d; + boolean isPseudoElement = false; + jj_consume_token(COLON); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + jj_consume_token(COLON); + isPseudoElement = true; + break; + default: + jj_la1[97] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + String s = ":" + convertIdent(n.image); + if (isPseudoElement) { + if (pseudoElt != null) { + { + if (true) { + throw new CSSParseException( + "duplicate pseudo element definition " + s, + getLocator()); + } + } + } else { + pseudoElt = ":" + s; + { + if (true) { + return pred; + } + } + } + } else { + String c = s; + if (pred == null) { + { + if (true) { + return c; + } + } + } else { + { + if (true) { + return pred + c; + } + } + } + } + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + label_65: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[98] = jj_gen; + break label_65; + } + jj_consume_token(S); + } + d = skipStatementUntilMatchingRightParan(); + jj_consume_token(RPARAN); + // accept anything between function and a right parenthesis + String f = convertIdent(n.image); + String colons = isPseudoElement ? "::" : ":"; + String pseudofn = colons + f + d + ")"; + if (pred == null) { + { + if (true) { + return pseudofn; + } + } + } else { + { + if (true) { + return pred + pseudofn; + } + } + } + break; + default: + jj_la1[99] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String hash(String pred) throws ParseException { + Token n; + n = jj_consume_token(HASH); + String d = n.image; + if (pred == null) { + { + if (true) { + return d; + } + } + } else { + { + if (true) { + return pred + d; + } + } + } + throw new Error("Missing return statement in function"); + } + + final public void variable() throws ParseException { + String name; + LexicalUnitImpl exp = null; + boolean guarded = false; + String raw; + try { + name = variableName(); + jj_consume_token(COLON); + label_66: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[100] = jj_gen; + break label_66; + } + jj_consume_token(S); + } + exp = expr(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case GUARDED_SYM: + guarded = guarded(); + break; + default: + jj_la1[101] = jj_gen; + ; + } + label_67: while (true) { + jj_consume_token(SEMICOLON); + label_68: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[102] = jj_gen; + break label_68; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[103] = jj_gen; + break label_67; + } + } + documentHandler.variable(name, exp, guarded); + } catch (JumpException e) { + skipAfterExpression(); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), getLocator(), e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn - 1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + } else { + skipAfterExpression(); + } + } + } + + final public void controlDirective() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IF_SYM: + ifDirective(); + break; + case EACH_SYM: + eachDirective(); + break; + default: + jj_la1[104] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void ifContentStatement() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case CONTENT_SYM: + contentDirective(); + break; + case INCLUDE_SYM: + includeDirective(); + break; + case MEDIA_SYM: + media(); + break; + case EXTEND_SYM: + extendDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case HASH: + styleRuleOrDeclarationOrNestedProperties(); + break; + case KEY_FRAME_SYM: + keyframes(); + break; + default: + jj_la1[105] = jj_gen; + if (jj_2_3(2147483647)) { + variable(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case VARIABLE: + listModifyDirective(); + break; + case EACH_SYM: + case IF_SYM: + controlDirective(); + break; + case ATKEYWORD: + atRuleDeclaration(); + break; + default: + jj_la1[106] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } + + final public void ifDirective() throws ParseException { + Token n = null; + String s = null; + String evaluator = ""; + jj_consume_token(IF_SYM); + label_69: while (true) { + s = booleanExpressionToken(); + evaluator += s; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + case EQ: + case PLUS: + case MINUS: + case PRECEDES: + case SUCCEEDS: + case DIV: + case ANY: + case LPARAN: + case RPARAN: + case COMPARE: + case OR: + case AND: + case NOT_EQ: + case IDENT: + case NUMBER: + case VARIABLE: + case CONTAINS: + ; + break; + default: + jj_la1[107] = jj_gen; + break label_69; + } + } + jj_consume_token(LBRACE); + label_70: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[108] = jj_gen; + break label_70; + } + jj_consume_token(S); + } + documentHandler.startIfElseDirective(); + documentHandler.ifDirective(evaluator); + label_71: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[109] = jj_gen; + break label_71; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[110] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_72: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[111] = jj_gen; + break label_72; + } + jj_consume_token(S); + } + label_73: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case ELSE_SYM: + ; + break; + default: + jj_la1[112] = jj_gen; + break label_73; + } + elseDirective(); + } + documentHandler.endIfElseDirective(); + } + + final public void elseDirective() throws ParseException { + String evaluator = ""; + Token n = null; + String s = null; + jj_consume_token(ELSE_SYM); + label_74: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[113] = jj_gen; + break label_74; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IF: + jj_consume_token(IF); + label_75: while (true) { + s = booleanExpressionToken(); + evaluator += s; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + case EQ: + case PLUS: + case MINUS: + case PRECEDES: + case SUCCEEDS: + case DIV: + case ANY: + case LPARAN: + case RPARAN: + case COMPARE: + case OR: + case AND: + case NOT_EQ: + case IDENT: + case NUMBER: + case VARIABLE: + case CONTAINS: + ; + break; + default: + jj_la1[114] = jj_gen; + break label_75; + } + } + break; + default: + jj_la1[115] = jj_gen; + ; + } + jj_consume_token(LBRACE); + label_76: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[116] = jj_gen; + break label_76; + } + jj_consume_token(S); + } + if (!evaluator.trim().equals("")) { + documentHandler.ifDirective(evaluator); + } else { + documentHandler.elseDirective(); + } + label_77: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[117] = jj_gen; + break label_77; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[118] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_78: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[119] = jj_gen; + break label_78; + } + jj_consume_token(S); + } + } + + final public String booleanExpressionToken() throws ParseException { + Token n = null; + String s = null; + if (jj_2_4(2147483647)) { + s = containsDirective(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case VARIABLE: + n = jj_consume_token(VARIABLE); + break; + case IDENT: + n = jj_consume_token(IDENT); + break; + case NUMBER: + n = jj_consume_token(NUMBER); + break; + case LPARAN: + n = jj_consume_token(LPARAN); + break; + case RPARAN: + n = jj_consume_token(RPARAN); + break; + case PLUS: + n = jj_consume_token(PLUS); + break; + case MINUS: + n = jj_consume_token(MINUS); + break; + case DIV: + n = jj_consume_token(DIV); + break; + case ANY: + n = jj_consume_token(ANY); + break; + case COMPARE: + n = jj_consume_token(COMPARE); + break; + case EQ: + n = jj_consume_token(EQ); + break; + case PRECEDES: + n = jj_consume_token(PRECEDES); + break; + case SUCCEEDS: + n = jj_consume_token(SUCCEEDS); + break; + case OR: + n = jj_consume_token(OR); + break; + case AND: + n = jj_consume_token(AND); + break; + case S: + n = jj_consume_token(S); + break; + case NOT_EQ: + n = jj_consume_token(NOT_EQ); + break; + default: + jj_la1[120] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + if (n != null) { + { + if (true) { + return n.image; + } + } + } else { + { + if (true) { + return s; + } + } + } + throw new Error("Missing return statement in function"); + } + + final public void eachDirective() throws ParseException { + Token var; + ArrayList list = null; + String listVariable = null; + jj_consume_token(EACH_SYM); + label_79: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[121] = jj_gen; + break label_79; + } + jj_consume_token(S); + } + var = jj_consume_token(VARIABLE); + label_80: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[122] = jj_gen; + break label_80; + } + jj_consume_token(S); + } + jj_consume_token(EACH_IN); + label_81: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[123] = jj_gen; + break label_81; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + list = stringList(); + documentHandler.startEachDirective(var.image, list); + break; + case VARIABLE: + listVariable = variableName(); + documentHandler.startEachDirective(var.image, listVariable); + break; + default: + jj_la1[124] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(LBRACE); + label_82: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[125] = jj_gen; + break label_82; + } + jj_consume_token(S); + } + label_83: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[126] = jj_gen; + break label_83; + } + ifContentStatement(); + } + jj_consume_token(RBRACE); + label_84: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[127] = jj_gen; + break label_84; + } + jj_consume_token(S); + } + documentHandler.endEachDirective(); + } + + final public ArrayList stringList() throws ParseException { + ArrayList strings = new ArrayList(); + Token input; + input = jj_consume_token(IDENT); + label_85: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[128] = jj_gen; + break label_85; + } + jj_consume_token(S); + } + strings.add(input.image); + label_86: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[129] = jj_gen; + break label_86; + } + jj_consume_token(COMMA); + label_87: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[130] = jj_gen; + break label_87; + } + jj_consume_token(S); + } + input = jj_consume_token(IDENT); + strings.add(input.image); + label_88: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[131] = jj_gen; + break label_88; + } + jj_consume_token(S); + } + } + { + if (true) { + return strings; + } + } + throw new Error("Missing return statement in function"); + } + + final public void mixinDirective() throws ParseException { + String name; + ArrayList args = null; + String body; + jj_consume_token(MIXIN_SYM); + label_89: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[132] = jj_gen; + break label_89; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + name = property(); + break; + case FUNCTION: + name = functionName(); + args = arglist(); + jj_consume_token(RPARAN); + label_90: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[133] = jj_gen; + break label_90; + } + jj_consume_token(S); + } + break; + default: + jj_la1[134] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(LBRACE); + label_91: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[135] = jj_gen; + break label_91; + } + jj_consume_token(S); + } + documentHandler.startMixinDirective(name, args); + label_92: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[136] = jj_gen; + break label_92; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + case PAGE_SYM: + page(); + break; + default: + jj_la1[137] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_93: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[138] = jj_gen; + break label_93; + } + jj_consume_token(S); + } + documentHandler.endMixinDirective(name, args); + } + + final public ArrayList arglist() throws ParseException { + ArrayList args = new ArrayList(); + VariableNode arg; + boolean hasNonOptionalArgument = false; + arg = mixinArg(); + label_94: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[139] = jj_gen; + break label_94; + } + jj_consume_token(COMMA); + label_95: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[140] = jj_gen; + break label_95; + } + jj_consume_token(S); + } + hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, + hasNonOptionalArgument); + args.add(arg); + arg = mixinArg(); + } + hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, + hasNonOptionalArgument); + args.add(arg); + { + if (true) { + return args; + } + } + throw new Error("Missing return statement in function"); + } + + boolean checkMixinForNonOptionalArguments(VariableNode arg, + boolean hasNonOptionalArguments) throws ParseException { + boolean currentArgHasArguments = arg.getExpr() != null + && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE + && arg.getExpr().getNextLexicalUnit() != null; + + if (currentArgHasArguments) { + if (hasNonOptionalArguments) { + throw new ParseException("Sass Error: Required argument $" + + arg.getName() + + " must come before any optional arguments."); + } + return hasNonOptionalArguments; + } else { + return true; + } + } + + final public VariableNode mixinArg() throws ParseException { + String name; + Token variable = null; + LexicalUnitImpl first = null; + LexicalUnitImpl prev = null; + LexicalUnitImpl next = null; + name = variableName(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + case VARIABLE: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_96: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[141] = jj_gen; + break label_96; + } + jj_consume_token(S); + } + first = nonVariableTerm(null); + prev = first; + label_97: while (true) { + if (jj_2_5(3)) { + ; + } else { + break label_97; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_98: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[142] = jj_gen; + break label_98; + } + jj_consume_token(S); + } + break; + default: + jj_la1[143] = jj_gen; + ; + } + prev = nonVariableTerm(prev); + } + break; + case VARIABLE: + variable = jj_consume_token(VARIABLE); + first = LexicalUnitImpl.createVariable(token.beginLine, + token.beginColumn, prev, variable.image); + break; + default: + jj_la1[144] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[145] = jj_gen; + ; + } + VariableNode arg = new VariableNode(name, first, false); + { + if (true) { + return arg; + } + } + throw new Error("Missing return statement in function"); + } + + final public ArrayList argValuelist() + throws ParseException { + ArrayList args = new ArrayList(); + LexicalUnitImpl first = null; + LexicalUnitImpl next = null; + LexicalUnitImpl prev = null; + first = term(null); + args.add(first); + prev = first; + label_99: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case COLON: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[146] = jj_gen; + break label_99; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_100: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[147] = jj_gen; + break label_100; + } + jj_consume_token(S); + } + break; + default: + jj_la1[148] = jj_gen; + ; + } + next = term(prev); + prev.setNextLexicalUnit(next); + prev = next; + } + label_101: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[149] = jj_gen; + break label_101; + } + jj_consume_token(COMMA); + label_102: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[150] = jj_gen; + break label_102; + } + jj_consume_token(S); + } + first = term(null); + args.add(first); + prev = first; + label_103: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case COLON: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[151] = jj_gen; + break label_103; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_104: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[152] = jj_gen; + break label_104; + } + jj_consume_token(S); + } + break; + default: + jj_la1[153] = jj_gen; + ; + } + next = term(prev); + prev.setNextLexicalUnit(next); + prev = next; + } + } + { + if (true) { + return args; + } + } + throw new Error("Missing return statement in function"); + } + + final public void includeDirective() throws ParseException { + String name; + ArrayList args = null; + jj_consume_token(INCLUDE_SYM); + label_105: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[154] = jj_gen; + break label_105; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + name = property(); + break; + case VARIABLE: + name = variableName(); + name = "$" + name; + break; + case FUNCTION: + name = functionName(); + args = argValuelist(); + jj_consume_token(RPARAN); + label_106: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[155] = jj_gen; + break label_106; + } + jj_consume_token(S); + } + break; + default: + jj_la1[156] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + label_107: while (true) { + jj_consume_token(SEMICOLON); + label_108: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[157] = jj_gen; + break label_108; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[158] = jj_gen; + break label_107; + } + } + documentHandler.includeDirective(name, args); + break; + case LBRACE: + jj_consume_token(LBRACE); + label_109: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[159] = jj_gen; + break label_109; + } + jj_consume_token(S); + } + documentHandler.startIncludeContentBlock(name, args); + label_110: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case TO: + case FROM: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case PERCENTAGE: + case HASH: + ; + break; + default: + jj_la1[160] = jj_gen; + break label_110; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case HASH: + styleRuleOrDeclarationOrNestedProperties(); + break; + case TO: + case FROM: + case PERCENTAGE: + keyframeSelector(); + break; + default: + jj_la1[161] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_111: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[162] = jj_gen; + break label_111; + } + jj_consume_token(S); + } + documentHandler.endIncludeContentBlock(); + break; + default: + jj_la1[163] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public String interpolation() throws ParseException { + Token n; + n = jj_consume_token(INTERPOLATION); + { + if (true) { + return n.image; + } + } + throw new Error("Missing return statement in function"); + } + + final public void listModifyDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + Token type = null; + // refactor, remove those 3 LOOKAHEAD(5). + n = jj_consume_token(VARIABLE); + variable = n.image; + label_112: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[164] = jj_gen; + break label_112; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_113: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[165] = jj_gen; + break label_113; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case APPEND: + type = jj_consume_token(APPEND); + break; + case REMOVE: + type = jj_consume_token(REMOVE); + break; + case CONTAINS: + type = jj_consume_token(CONTAINS); + break; + default: + jj_la1[166] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_114: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[167] = jj_gen; + break label_114; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[168] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_115: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[169] = jj_gen; + break label_115; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_116: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[170] = jj_gen; + break label_116; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_117: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[171] = jj_gen; + break label_117; + } + jj_consume_token(S); + } + break; + default: + jj_la1[172] = jj_gen; + ; + } + jj_consume_token(RPARAN); + switch (type.kind) { + case APPEND: + documentHandler.appendDirective(variable, list, remove, separator); + break; + case REMOVE: + documentHandler.removeDirective(variable, list, remove, separator); + break; + case CONTAINS: + if (variable == null) { + variable = "$var_" + UUID.randomUUID(); + } + documentHandler + .containsDirective(variable, list, remove, separator); + break; + default: + break; + } + label_118: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[173] = jj_gen; + break label_118; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + label_119: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[174] = jj_gen; + break label_119; + } + jj_consume_token(S); + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void appendDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + n = jj_consume_token(VARIABLE); + variable = n.image; + label_120: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[175] = jj_gen; + break label_120; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_121: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[176] = jj_gen; + break label_121; + } + jj_consume_token(S); + } + jj_consume_token(APPEND); + label_122: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[177] = jj_gen; + break label_122; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[178] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_123: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[179] = jj_gen; + break label_123; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_124: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[180] = jj_gen; + break label_124; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_125: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[181] = jj_gen; + break label_125; + } + jj_consume_token(S); + } + break; + default: + jj_la1[182] = jj_gen; + ; + } + jj_consume_token(RPARAN); + documentHandler.appendDirective(variable, list, remove, separator); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void removeDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + n = jj_consume_token(VARIABLE); + variable = n.image; + label_126: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[183] = jj_gen; + break label_126; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_127: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[184] = jj_gen; + break label_127; + } + jj_consume_token(S); + } + jj_consume_token(REMOVE); + label_128: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[185] = jj_gen; + break label_128; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[186] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_129: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[187] = jj_gen; + break label_129; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_130: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[188] = jj_gen; + break label_130; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_131: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[189] = jj_gen; + break label_131; + } + jj_consume_token(S); + } + break; + default: + jj_la1[190] = jj_gen; + ; + } + jj_consume_token(RPARAN); + documentHandler.removeDirective(variable, list, remove, separator); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public String containsDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case VARIABLE: + n = jj_consume_token(VARIABLE); + variable = n.image; + label_132: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[191] = jj_gen; + break label_132; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_133: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[192] = jj_gen; + break label_133; + } + jj_consume_token(S); + } + break; + default: + jj_la1[193] = jj_gen; + ; + } + jj_consume_token(CONTAINS); + label_134: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[194] = jj_gen; + break label_134; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[195] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_135: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[196] = jj_gen; + break label_135; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_136: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[197] = jj_gen; + break label_136; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_137: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[198] = jj_gen; + break label_137; + } + jj_consume_token(S); + } + break; + default: + jj_la1[199] = jj_gen; + ; + } + jj_consume_token(RPARAN); + /* + * if it is not in the form like + * "$contains : contains($items, .v-button);"for example in @if, like + * "@if (contains(a b c, b))", then create a tempvariable for contains(a + * b c, b); + */ + if (variable == null) { + variable = "$var_" + UUID.randomUUID(); + } + documentHandler.containsDirective(variable, list, remove, separator); + { + if (true) { + return variable; + } + } + throw new Error("Missing return statement in function"); + } + + String listModifyDirectiveArgs(int nest) throws ParseException { + String list = ""; + int nesting = nest; + Token t = null; + + while (true) { + t = getToken(1); + String s = t.image; + if (t.kind == VARIABLE || t.kind == IDENT) { + list += s; + } else if (s.toLowerCase().equals("auto") + || s.toLowerCase().equals("space") + || s.toLowerCase().equals("comma")) { + int i = 2; + Token temp = getToken(i); + boolean isLast = true; + while (temp.kind != SEMICOLON) { + if (temp.kind != RPARAN || temp.kind != S) { + isLast = false; + } + i++; + temp = getToken(i); + } + + if (isLast) { + return list; + } + } else if (t.kind == STRING) { + list += s.substring(1, s.length()).substring(0, s.length() - 2); + + } else if (t.kind == LPARAN) { + nesting++; + if (nesting > nest + 1) { + throw new CSSParseException( + "Only one ( ) pair per parameter allowed", + getLocator()); + } + } else if (t.kind == RPARAN) { + nesting--; + if (nesting == 0) { + return list; + } + } else if (t.kind == COMMA) { + if (nesting == nest) { + return list; + } else { + list += ","; + } + + } else if (t.kind == S) { + list += " "; + } else if (t.kind == LBRACE) { + throw new CSSParseException("Invalid token,'{' found", + getLocator()); + } + + getNextToken(); + } + } + + final public Node returnDirective() throws ParseException { + String raw; + raw = skipStatement(); + { + if (true) { + return null; + } + } + throw new Error("Missing return statement in function"); + } + + final public void debuggingDirective() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DEBUG_SYM: + debugDirective(); + break; + case WARN_SYM: + warnDirective(); + break; + default: + jj_la1[200] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void debugDirective() throws ParseException { + jj_consume_token(DEBUG_SYM); + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call + // documentHandler.debugDirective() etc. + System.out.println(content); + label_138: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[201] = jj_gen; + break label_138; + } + jj_consume_token(S); + } + } + + final public void warnDirective() throws ParseException { + jj_consume_token(WARN_SYM); + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call + // documentHandler.warnDirective() etc. + System.err.println(content); + label_139: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[202] = jj_gen; + break label_139; + } + jj_consume_token(S); + } + } + + final public Node forDirective() throws ParseException { + String var; + String from; + String to; + boolean exclusive; + String body; + Token tok; + var = variableName(); + int[] toThrough = { TO, THROUGH }; + from = skipStatementUntil(toThrough); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case TO: + tok = jj_consume_token(TO); + exclusive = true; + break; + case THROUGH: + tok = jj_consume_token(THROUGH); + exclusive = false; + break; + default: + jj_la1[203] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + to = skipStatementUntilLeftBrace(); + label_140: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[204] = jj_gen; + break label_140; + } + jj_consume_token(S); + } + body = skipStatement(); + { + if (true) { + return documentHandler.forDirective(var, from, to, exclusive, + body); + } + } + throw new Error("Missing return statement in function"); + } + + final public Node whileDirective() throws ParseException { + String condition; + String body; + condition = skipStatementUntilLeftBrace(); + body = skipStatement(); + { + if (true) { + return documentHandler.whileDirective(condition, body); + } + } + throw new Error("Missing return statement in function"); + } + + final public void extendDirective() throws ParseException { + ArrayList list; + jj_consume_token(EXTEND_SYM); + label_141: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[205] = jj_gen; + break label_141; + } + jj_consume_token(S); + } + list = selectorList(); + label_142: while (true) { + jj_consume_token(SEMICOLON); + label_143: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[206] = jj_gen; + break label_143; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[207] = jj_gen; + break label_142; + } + } + documentHandler.extendDirective(list); + } + + final public void contentDirective() throws ParseException { + jj_consume_token(CONTENT_SYM); + label_144: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[208] = jj_gen; + break label_144; + } + jj_consume_token(S); + } + label_145: while (true) { + jj_consume_token(SEMICOLON); + label_146: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[209] = jj_gen; + break label_146; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[210] = jj_gen; + break label_145; + } + } + documentHandler.contentDirective(); + } + + Node importDirective() throws ParseException { + return null; + } + + Node charsetDirective() throws ParseException { + return null; + } + + Node mozDocumentDirective() throws ParseException { + return null; + } + + Node supportsDirective() throws ParseException { + return null; + } + + final public void nestedProperties() throws ParseException { + String name; + LexicalUnit exp; + name = property(); + jj_consume_token(COLON); + label_147: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[211] = jj_gen; + break label_147; + } + jj_consume_token(S); + } + jj_consume_token(LBRACE); + label_148: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[212] = jj_gen; + break label_148; + } + jj_consume_token(S); + } + documentHandler.startNestedProperties(name); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[213] = jj_gen; + ; + } + label_149: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[214] = jj_gen; + break label_149; + } + jj_consume_token(SEMICOLON); + label_150: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[215] = jj_gen; + break label_150; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[216] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + documentHandler.endNestedProperties(name); + label_151: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[217] = jj_gen; + break label_151; + } + jj_consume_token(S); + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void styleRuleOrDeclarationOrNestedProperties() + throws ParseException { + try { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + default: + jj_la1[218] = jj_gen; + if (jj_2_6(2147483647)) { + styleRule(); + } else if (jj_2_7(3)) { + declarationOrNestedProperties(); + } else { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + default: + jj_la1[219] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn - 1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; + * reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void declarationOrNestedProperties() throws ParseException { + boolean important = false; + String name; + LexicalUnitImpl exp; + Token save; + String comment = null; + try { + name = property(); + save = token; + jj_consume_token(COLON); + label_152: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[220] = jj_gen; + break label_152; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + exp = expr(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[221] = jj_gen; + ; + } + Token next = getToken(1); + if (next.kind == SEMICOLON || next.kind == RBRACE) { + while (next.kind == SEMICOLON) { + skipStatement(); + next = getToken(1); + } + // only add special token kept for sprites '/**' + if (token.specialToken != null + && token.specialToken != null + && token.specialToken.image.startsWith("/**")) { + documentHandler.property(name, exp, important, + token.specialToken.image); + } else { + documentHandler.property(name, exp, important, null); + } + } + break; + case LBRACE: + jj_consume_token(LBRACE); + label_153: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[222] = jj_gen; + break label_153; + } + jj_consume_token(S); + } + documentHandler.startNestedProperties(name); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[223] = jj_gen; + ; + } + label_154: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[224] = jj_gen; + break label_154; + } + jj_consume_token(SEMICOLON); + label_155: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[225] = jj_gen; + break label_155; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[226] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + label_156: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[227] = jj_gen; + break label_156; + } + jj_consume_token(S); + } + documentHandler.endNestedProperties(name); + break; + default: + jj_la1[228] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), getLocator(), e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn - 1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; + * reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public void declaration() throws ParseException { + boolean important = false; + String name; + LexicalUnit exp; + Token save; + try { + name = property(); + save = token; + jj_consume_token(COLON); + label_157: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[229] = jj_gen; + break label_157; + } + jj_consume_token(S); + } + exp = expr(); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[230] = jj_gen; + ; + } + documentHandler.property(name, exp, important); + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), getLocator(), e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn - 1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; + * reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } + } + + /** + * @exception ParseException + * exception during the parse + */ + final public boolean prio() throws ParseException { + jj_consume_token(IMPORTANT_SYM); + label_158: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[231] = jj_gen; + break label_158; + } + jj_consume_token(S); + } + { + if (true) { + return true; + } + } + throw new Error("Missing return statement in function"); + } + + final public boolean guarded() throws ParseException { + jj_consume_token(GUARDED_SYM); + label_159: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[232] = jj_gen; + break label_159; + } + jj_consume_token(S); + } + { + if (true) { + return true; + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public LexicalUnitImpl operator(LexicalUnitImpl prev) + throws ParseException { + Token n; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case COMMA: + /* + * (comments copied from basic_arithmetics.scss)supports: 1. + * standard arithmetic operations (+, -, *, /, %) 2. / is treated as + * css operator, unless one of its operands is variable or there is + * another binary arithmetic operatorlimits: 1. cannot mix + * arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will + * fail 2. space between add and minus operator and their following + * operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not 3. + * parenthesis is not supported now. + */ + n = jj_consume_token(COMMA); + label_160: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[233] = jj_gen; + break label_160; + } + jj_consume_token(S); + } + { + if (true) { + return LexicalUnitImpl.createComma(n.beginLine, + n.beginColumn, prev); + } + } + break; + case DIV: + n = jj_consume_token(DIV); + label_161: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[234] = jj_gen; + break label_161; + } + jj_consume_token(S); + } + { + if (true) { + return LexicalUnitImpl.createSlash(n.beginLine, + n.beginColumn, prev); + } + } + break; + case ANY: + n = jj_consume_token(ANY); + label_162: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[235] = jj_gen; + break label_162; + } + jj_consume_token(S); + } + { + if (true) { + return LexicalUnitImpl.createMultiply(n.beginLine, + n.beginColumn, prev); + } + } + break; + case MOD: + n = jj_consume_token(MOD); + label_163: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[236] = jj_gen; + break label_163; + } + jj_consume_token(S); + } + { + if (true) { + return LexicalUnitImpl.createModulo(n.beginLine, + n.beginColumn, prev); + } + } + break; + case PLUS: + n = jj_consume_token(PLUS); + label_164: while (true) { + jj_consume_token(S); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[237] = jj_gen; + break label_164; + } + } + { + if (true) { + return LexicalUnitImpl.createAdd(n.beginLine, + n.beginColumn, prev); + } + } + break; + case MINUS: + n = jj_consume_token(MINUS); + label_165: while (true) { + jj_consume_token(S); + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[238] = jj_gen; + break label_165; + } + } + { + if (true) { + return LexicalUnitImpl.createMinus(n.beginLine, + n.beginColumn, prev); + } + } + break; + default: + jj_la1[239] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public LexicalUnitImpl expr() throws ParseException { + LexicalUnitImpl first, res; + char op; + first = term(null); + res = first; + label_166: while (true) { + if (jj_2_8(2)) { + ; + } else { + break label_166; + } + if (jj_2_9(2)) { + res = operator(res); + } else { + ; + } + res = term(res); + } + { + if (true) { + return first; + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public char unaryOperator() throws ParseException { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case MINUS: + jj_consume_token(MINUS); + { + if (true) { + return '-'; + } + } + break; + case PLUS: + jj_consume_token(PLUS); + { + if (true) { + return '+'; + } + } + break; + default: + jj_la1[240] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public LexicalUnitImpl term(LexicalUnitImpl prev) + throws ParseException { + LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + result = nonVariableTerm(prev); + break; + case VARIABLE: + result = variableTerm(prev); + break; + default: + jj_la1[241] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + { + if (true) { + return result; + } + } + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl variableTerm(LexicalUnitImpl prev) + throws ParseException { + LexicalUnitImpl result = null; + String varName = ""; + varName = variableName(); + result = LexicalUnitImpl.createVariable(token.beginLine, + token.beginColumn, prev, varName); + { + if (true) { + return result; + } + } + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) + throws ParseException { + LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + String varName; + String s = ""; + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case NUMBER: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case FUNCTION: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + op = unaryOperator(); + break; + default: + jj_la1[242] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case NUMBER: + n = jj_consume_token(NUMBER); + result = LexicalUnitImpl.createNumber(n.beginLine, + n.beginColumn, prev, number(op, n, 0)); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + result = LexicalUnitImpl.createPercentage(n.beginLine, + n.beginColumn, prev, number(op, n, 1)); + break; + case PT: + n = jj_consume_token(PT); + result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case CM: + n = jj_consume_token(CM); + result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case MM: + n = jj_consume_token(MM); + result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case PC: + n = jj_consume_token(PC); + result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case IN: + n = jj_consume_token(IN); + result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case PX: + n = jj_consume_token(PX); + result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case EMS: + n = jj_consume_token(EMS); + result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case LEM: + n = jj_consume_token(LEM); + result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case REM: + n = jj_consume_token(REM); + result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case EXS: + n = jj_consume_token(EXS); + result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case DEG: + n = jj_consume_token(DEG); + result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case RAD: + n = jj_consume_token(RAD); + result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case GRAD: + n = jj_consume_token(GRAD); + result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case SECOND: + n = jj_consume_token(SECOND); + result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); + break; + case MS: + n = jj_consume_token(MS); + result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case HZ: + n = jj_consume_token(HZ); + result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case KHZ: + n = jj_consume_token(KHZ); + result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case DIMEN: + n = jj_consume_token(DIMEN); + s = n.image; + int i = 0; + while (i < s.length() + && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { + i++; + } + + result = LexicalUnitImpl.createDimen(n.beginLine, + n.beginColumn, prev, number(op, n, s.length() - i), + s.substring(i)); + break; + case FUNCTION: + result = function(op, prev); + break; + default: + jj_la1[243] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case URL: + case HASH: + case UNICODERANGE: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + result = LexicalUnitImpl.createString(n.beginLine, + n.beginColumn, prev, + convertStringIndex(n.image, 1, n.image.length() - 1)); + break; + case DOT: + case TO: + case THROUGH: + case FROM: + case IDENT: + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case DOT: + jj_consume_token(DOT); + s += "."; + break; + default: + jj_la1[244] = jj_gen; + ; + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + break; + case TO: + n = jj_consume_token(TO); + break; + case THROUGH: + n = jj_consume_token(THROUGH); + break; + case FROM: + n = jj_consume_token(FROM); + break; + default: + jj_la1[245] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + s += convertIdent(n.image); + if ("inherit".equals(s)) { + result = LexicalUnitImpl.createInherit(n.beginLine, + n.beginColumn, prev); + } else { + result = LexicalUnitImpl.createIdent(n.beginLine, + n.beginColumn, prev, convertIdent(n.image)); + } + + /* + * / Auto correction code used in the CSS Validator but must not + * be used by a conformant CSS2 parser. Common error : H1 { + * color : black background : white } + * + * Token t = getToken(1); Token semicolon = new Token(); + * semicolon.kind = SEMICOLON; semicolon.image = ";"; if (t.kind + * == COLON) { // @@SEEME. (generate a warning?) // @@SEEME if + * expression is a single ident, generate an error ? + * rejectToken(semicolon); + * + * result = prev; } / + */ + + break; + case HASH: + result = hexcolor(prev); + break; + case URL: + result = url(prev); + break; + case UNICODERANGE: + result = unicode(prev); + break; + default: + jj_la1[246] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[247] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_167: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[248] = jj_gen; + break label_167; + } + jj_consume_token(S); + } + { + if (true) { + return result; + } + } + throw new Error("Missing return statement in function"); + } + + /** + * Handle all CSS2 functions. + * + * @exception ParseException + * exception during the parse + */ + final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) + throws ParseException { + Token n; + LexicalUnit params = null; + n = jj_consume_token(FUNCTION); + label_168: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[249] = jj_gen; + break label_168; + } + jj_consume_token(S); + } + String fname = convertIdent(n.image); + if ("alpha(".equals(fname)) { + String body = skipStatementUntilSemiColon(); + { + if (true) { + return LexicalUnitImpl.createIdent(n.beginLine, + n.beginColumn, null, "alpha(" + body); + } + } + } else if ("expression(".equals(fname)) { + String body = skipStatementUntilSemiColon(); + { + if (true) { + return LexicalUnitImpl.createIdent(n.beginLine, + n.beginColumn, null, "expression(" + body); + } + } + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + params = expr(); + break; + default: + jj_la1[250] = jj_gen; + ; + } + jj_consume_token(RPARAN); + if (operator != ' ') { + { + if (true) { + throw new CSSParseException( + "invalid operator before a function.", getLocator()); + } + } + } + String f = convertIdent(n.image); + LexicalUnitImpl l = (LexicalUnitImpl) params; + boolean loop = true; + if ("rgb(".equals(f)) { + // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 2: + case 4: + if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) + && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: { + if (true) { + throw new ParseException("implementation error"); + } + } + } + if (loop) { + l = l.getNextLexicalUnit(); + i++; + } + } + if ((i == 5) && loop && (l == null)) { + { + if (true) { + return LexicalUnitImpl.createRGBColor(n.beginLine, + n.beginColumn, prev, params); + } + } + } else { + if (errorHandler != null) { + String errorText; + Locator loc; + if (i < 5) { + if (params == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn - 1); + errorText = "not enough parameters."; + } else if (l == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn - 1); + errorText = "not enough parameters: " + + params.toString(); + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "invalid parameter: " + l.toString(); + } + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "too many parameters: " + l.toString(); + } + errorHandler.error(new CSSParseException(errorText, loc)); + } + + { + if (true) { + throw new JumpException(); + } + } + } + } else if ("counter".equals(f)) { + int i = 0; + while (loop && l != null && i < 3) { + switch (i) { + case 0: + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 1: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: { + if (true) { + throw new ParseException("implementation error"); + } + } + } + l = l.getNextLexicalUnit(); + i++; + } + if (((i == 1) || (i == 3)) && loop && (l == null)) { + { + if (true) { + return LexicalUnitImpl.createCounter(n.beginLine, + n.beginColumn, prev, params); + } + } + } + + } else if ("counters(".equals(f)) { + + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 4: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: { + if (true) { + throw new ParseException("implementation error"); + } + } + } + l = l.getNextLexicalUnit(); + i++; + } + if (((i == 3) || (i == 5)) && loop && (l == null)) { + { + if (true) { + return LexicalUnitImpl.createCounters(n.beginLine, + n.beginColumn, prev, params); + } + } + } + } else if ("attr(".equals(f)) { + if ((l != null) && (l.getNextLexicalUnit() == null) + && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { + { + if (true) { + return LexicalUnitImpl.createAttr(l.getLineNumber(), + l.getColumnNumber(), prev, l.getStringValue()); + } + } + } + } else if ("rect(".equals(f)) { + int i = 0; + while (loop && l != null && i < 7) { + switch (i) { + case 0: + case 2: + case 4: + case 6: + switch (l.getLexicalUnitType()) { + case LexicalUnit.SAC_INTEGER: + if (l.getIntegerValue() != 0) { + loop = false; + } + break; + case LexicalUnit.SAC_IDENT: + if (!l.getStringValue().equals("auto")) { + loop = false; + } + break; + case LexicalUnit.SAC_EM: + case LexicalUnit.SAC_EX: + case LexicalUnit.SAC_PIXEL: + case LexicalUnit.SAC_CENTIMETER: + case LexicalUnit.SAC_MILLIMETER: + case LexicalUnit.SAC_INCH: + case LexicalUnit.SAC_POINT: + case LexicalUnit.SAC_PICA: + // nothing + break; + default: + loop = false; + } + break; + case 1: + case 3: + case 5: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: { + if (true) { + throw new ParseException("implementation error"); + } + } + } + l = l.getNextLexicalUnit(); + i++; + } + if ((i == 7) && loop && (l == null)) { + { + if (true) { + return LexicalUnitImpl.createRect(n.beginLine, + n.beginColumn, prev, params); + } + } + } + } + { + if (true) { + return LexicalUnitImpl.createFunction(n.beginLine, + n.beginColumn, prev, f.substring(0, f.length() - 1), + params); + } + } + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl unicode(LexicalUnitImpl prev) + throws ParseException { + Token n; + n = jj_consume_token(UNICODERANGE); + LexicalUnitImpl params = null; + String s = n.image.substring(2); + int index = s.indexOf('-'); + if (index == -1) { + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s, 16)); + } else { + String s1 = s.substring(0, index); + String s2 = s.substring(index); + + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s1, 16)); + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s2, 16)); + } + + { + if (true) { + return LexicalUnitImpl.createUnicodeRange(n.beginLine, + n.beginColumn, prev, params); + } + } + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl url(LexicalUnitImpl prev) + throws ParseException { + Token n; + n = jj_consume_token(URL); + String urlname = n.image.substring(4, n.image.length() - 1).trim(); + { + if (true) { + return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, + prev, urlname); + } + } + throw new Error("Missing return statement in function"); + } + + /** + * @exception ParseException + * exception during the parse + */ + final public LexicalUnitImpl hexcolor(LexicalUnitImpl prev) + throws ParseException { + Token n; + n = jj_consume_token(HASH); + int r; + LexicalUnitImpl first, params = null; + String s = n.image.substring(1); + + if (s.length() != 3 && s.length() != 6) { + first = null; + { + if (true) { + throw new CSSParseException( + "invalid hexadecimal notation for RGB: " + s, + getLocator()); + } + } + } + { + if (true) { + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, n.image); + } + } + throw new Error("Missing return statement in function"); + } + + float number(char operator, Token n, int lengthUnit) throws ParseException { + String image = n.image; + float f = 0; + + if (lengthUnit != 0) { + image = image.substring(0, image.length() - lengthUnit); + } + f = Float.valueOf(image).floatValue(); + return (operator == '-') ? -f : f; + } + + String skipStatementUntilSemiColon() throws ParseException { + int[] semicolon = { SEMICOLON }; + return skipStatementUntil(semicolon); + } + + String skipStatementUntilLeftBrace() throws ParseException { + int[] lBrace = { LBRACE }; + return skipStatementUntil(lBrace); + } + + String skipStatementUntilMatchingRightParan() throws ParseException { + int[] leftTokens = { LPARAN, FUNCTION }; // a FUNCTION also contains "(" + int[] rightTokens = { RPARAN }; + StringBuffer s = new StringBuffer(); + int difference = 1; + Token tok; + while (difference != 0) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; + } + for (int sym : leftTokens) { + if (tok.kind == sym) { + difference++; + } + } + for (int sym : rightTokens) { + if (tok.kind == sym) { + difference--; + } + } + if (difference != 0) { + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); + } + + String skipStatementUntil(int[] symbols) throws ParseException { + StringBuffer s = new StringBuffer(); + boolean stop = false; + Token tok; + while (!stop) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; + } + for (int sym : symbols) { + if (tok.kind == sym) { + stop = true; + break; + } + } + if (!stop) { + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); + } + + String skipStatement() throws ParseException { + StringBuffer s = new StringBuffer(); + Token tok = getToken(0); + if (tok.image != null) { + s.append(tok.image); + } + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == RBRACE) { + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == SEMICOLON) { + getNextToken(); + tok = getToken(1); + break; + } + getNextToken(); + } + + // skip white space + while (true) { + if (tok.kind != S) { + break; + } + tok = getNextToken(); + tok = getToken(1); + } + + return s.toString().trim(); + } + + String skip_to_matching_brace() throws ParseException { + StringBuffer s = new StringBuffer(); + Token tok; + int nesting = 1; + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + break; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + nesting++; + } else if (tok.kind == RBRACE) { + nesting--; + if (nesting == 0) { + break; + } + } + getNextToken(); + } + return s.toString(); + } + + String convertStringIndex(String s, int start, int len) + throws ParseException { + StringBuffer buf = new StringBuffer(len); + int index = start; + + while (index < len) { + char c = s.charAt(index); + if (c == '\u005c\u005c') { + if (++index < len) { + c = s.charAt(index); + switch (c) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + buf.append('\u005c\u005c'); + while (index < len) { + buf.append(s.charAt(index++)); + } + break; + case '\u005cn': + case '\u005cf': + break; + case '\u005cr': + if (index + 1 < len) { + if (s.charAt(index + 1) == '\u005cn') { + index++; + } + } + break; + default: + buf.append(c); + } + } else { + throw new CSSParseException("invalid string " + s, + getLocator()); + } + } else { + buf.append(c); + } + index++; + } + + return buf.toString(); + } + + String convertIdent(String s) throws ParseException { + return convertStringIndex(s, 0, s.length()); + } + + String convertString(String s) throws ParseException { + return convertStringIndex(s, 0, s.length()); + } + + void comments() throws ParseException { + /* + * keeps only the multiple line comments, single line comments are + * skipped + */ + if (token.specialToken != null && token.specialToken.image != null + && token.specialToken.image.startsWith("/*")) { + Token tmp_t = token.specialToken; + while (tmp_t.specialToken != null) { + tmp_t = tmp_t.specialToken; + } + while (tmp_t != null) { + documentHandler.comment(tmp_t.image); + tmp_t = tmp_t.next; + } + } + } + + void rejectToken(Token t) throws ParseException { + Token fakeToken = new Token(); + t.next = token; + fakeToken.next = t; + token = fakeToken; + } + + String skipAfterExpression() throws ParseException { + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + + while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + + return s.toString(); + } + + /** + * The following functions are useful for a DOM CSS implementation only and + * are not part of the general CSS2 parser. + */ + // TODO required by original parser but not used by Vaadin? + final public void _parseRule() throws ParseException { + String ret = null; + label_169: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[251] = jj_gen; + break label_169; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case IMPORT_SYM: + importDeclaration(); + break; + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case MEDIA_SYM: + media(); + break; + case PAGE_SYM: + page(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[252] = jj_gen; + ret = skipStatement(); + if ((ret == null) || (ret.length() == 0)) { + { + if (true) { + return; + } + } + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + { + if (true) { + throw new CSSParseException("unrecognize rule: " + ret, + getLocator()); + } + } + } + } + } + + final public void _parseImportRule() throws ParseException { + label_170: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[253] = jj_gen; + break label_170; + } + jj_consume_token(S); + } + importDeclaration(); + } + + final public void _parseMediaRule() throws ParseException { + label_171: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[254] = jj_gen; + break label_171; + } + jj_consume_token(S); + } + media(); + } + + final public void _parseDeclarationBlock() throws ParseException { + label_172: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[255] = jj_gen; + break label_172; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[256] = jj_gen; + ; + } + label_173: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[257] = jj_gen; + break label_173; + } + jj_consume_token(SEMICOLON); + label_174: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[258] = jj_gen; + break label_174; + } + jj_consume_token(S); + } + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[259] = jj_gen; + ; + } + } + } + + final public ArrayList _parseSelectors() throws ParseException { + ArrayList p = null; + try { + label_175: while (true) { + switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { + case S: + ; + break; + default: + jj_la1[260] = jj_gen; + break label_175; + } + jj_consume_token(S); + } + p = selectorList(); + { + if (true) { + return p; + } + } + } catch (ThrowedParseException e) { + { + if (true) { + throw (ParseException) e.e.fillInStackTrace(); + } + } + } + throw new Error("Missing return statement in function"); + } + + private boolean jj_2_1(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_1(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(0, xla); + } + } + + private boolean jj_2_2(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_2(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(1, xla); + } + } + + private boolean jj_2_3(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_3(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(2, xla); + } + } + + private boolean jj_2_4(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_4(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(3, xla); + } + } + + private boolean jj_2_5(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_5(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(4, xla); + } + } + + private boolean jj_2_6(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_6(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(5, xla); + } + } + + private boolean jj_2_7(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_7(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(6, xla); + } + } + + private boolean jj_2_8(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_8(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(7, xla); + } + } + + private boolean jj_2_9(int xla) { + jj_la = xla; + jj_lastpos = jj_scanpos = token; + try { + return !jj_3_9(); + } catch (LookaheadSuccess ls) { + return true; + } finally { + jj_save(8, xla); + } + } + + private boolean jj_3R_209() { + if (jj_scan_token(MINUS)) { + return true; + } + Token xsp; + if (jj_scan_token(1)) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_188() { + if (jj_3R_210()) { + return true; + } + return false; + } + + private boolean jj_3R_208() { + if (jj_scan_token(PLUS)) { + return true; + } + Token xsp; + if (jj_scan_token(1)) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_207() { + if (jj_scan_token(MOD)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_206() { + if (jj_scan_token(ANY)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_205() { + if (jj_scan_token(DIV)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_204() { + if (jj_scan_token(COMMA)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_185() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_204()) { + jj_scanpos = xsp; + if (jj_3R_205()) { + jj_scanpos = xsp; + if (jj_3R_206()) { + jj_scanpos = xsp; + if (jj_3R_207()) { + jj_scanpos = xsp; + if (jj_3R_208()) { + jj_scanpos = xsp; + if (jj_3R_209()) { + return true; + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_212() { + if (jj_3R_211()) { + return true; + } + return false; + } + + private boolean jj_3R_211() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(18)) { + jj_scanpos = xsp; + if (jj_scan_token(22)) { + jj_scanpos = xsp; + if (jj_scan_token(23)) { + return true; + } + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_191() { + if (jj_scan_token(S)) { + return true; + } + Token xsp; + xsp = jj_scanpos; + if (jj_3R_212()) { + jj_scanpos = xsp; + } + return false; + } + + private boolean jj_3R_210() { + if (jj_scan_token(GUARDED_SYM)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_176() { + if (jj_3R_186()) { + return true; + } + if (jj_scan_token(COLON)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (jj_3R_187()) { + return true; + } + xsp = jj_scanpos; + if (jj_3R_188()) { + jj_scanpos = xsp; + } + if (jj_3R_189()) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3R_189()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_190() { + if (jj_3R_211()) { + return true; + } + return false; + } + + private boolean jj_3R_177() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_190()) { + jj_scanpos = xsp; + if (jj_3R_191()) { + return true; + } + } + return false; + } + + private boolean jj_3R_194() { + if (jj_scan_token(VARIABLE)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(COLON)) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_179() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_194()) { + jj_scanpos = xsp; + } + if (jj_scan_token(CONTAINS)) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (true) { + jj_la = 0; + jj_scanpos = jj_lastpos; + return false; + } + return false; + } + + private boolean jj_3R_262() { + if (jj_scan_token(HASH)) { + return true; + } + return false; + } + + private boolean jj_3R_279() { + if (jj_scan_token(IDENT)) { + return true; + } + return false; + } + + private boolean jj_3R_280() { + if (jj_scan_token(FUNCTION)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (true) { + jj_la = 0; + jj_scanpos = jj_lastpos; + return false; + } + return false; + } + + private boolean jj_3R_278() { + if (jj_scan_token(COLON)) { + return true; + } + return false; + } + + private boolean jj_3R_265() { + if (jj_scan_token(COLON)) { + return true; + } + Token xsp; + xsp = jj_scanpos; + if (jj_3R_278()) { + jj_scanpos = xsp; + } + xsp = jj_scanpos; + if (jj_3R_279()) { + jj_scanpos = xsp; + if (jj_3R_280()) { + return true; + } + } + return false; + } + + private boolean jj_3_7() { + if (jj_3R_183()) { + return true; + } + return false; + } + + private boolean jj_3R_201() { + if (jj_scan_token(LBRACE)) { + return true; + } + return false; + } + + private boolean jj_3R_290() { + if (jj_scan_token(STRING)) { + return true; + } + return false; + } + + private boolean jj_3R_288() { + if (jj_scan_token(STARMATCH)) { + return true; + } + return false; + } + + private boolean jj_3R_287() { + if (jj_scan_token(DOLLARMATCH)) { + return true; + } + return false; + } + + private boolean jj_3R_289() { + if (jj_scan_token(IDENT)) { + return true; + } + return false; + } + + private boolean jj_3R_286() { + if (jj_scan_token(CARETMATCH)) { + return true; + } + return false; + } + + private boolean jj_3R_285() { + if (jj_scan_token(DASHMATCH)) { + return true; + } + return false; + } + + private boolean jj_3R_284() { + if (jj_scan_token(INCLUDES)) { + return true; + } + return false; + } + + private boolean jj_3R_270() { + if (jj_scan_token(INTERPOLATION)) { + return true; + } + return false; + } + + private boolean jj_3R_283() { + if (jj_scan_token(EQ)) { + return true; + } + return false; + } + + private boolean jj_3R_200() { + if (jj_3R_187()) { + return true; + } + return false; + } + + private boolean jj_3R_277() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_283()) { + jj_scanpos = xsp; + if (jj_3R_284()) { + jj_scanpos = xsp; + if (jj_3R_285()) { + jj_scanpos = xsp; + if (jj_3R_286()) { + jj_scanpos = xsp; + if (jj_3R_287()) { + jj_scanpos = xsp; + if (jj_3R_288()) { + return true; + } + } + } + } + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_289()) { + jj_scanpos = xsp; + if (jj_3R_290()) { + return true; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3_6() { + if (jj_3R_182()) { + return true; + } + if (jj_scan_token(LBRACE)) { + return true; + } + return false; + } + + private boolean jj_3R_264() { + if (jj_scan_token(LBRACKET)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (jj_scan_token(IDENT)) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_277()) { + jj_scanpos = xsp; + } + if (jj_scan_token(RBRACKET)) { + return true; + } + return false; + } + + private boolean jj_3R_183() { + if (jj_3R_199()) { + return true; + } + if (jj_scan_token(COLON)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_200()) { + jj_scanpos = xsp; + if (jj_3R_201()) { + return true; + } + } + return false; + } + + private boolean jj_3R_282() { + if (jj_scan_token(INTERPOLATION)) { + return true; + } + return false; + } + + private boolean jj_3R_268() { + if (jj_3R_187()) { + return true; + } + return false; + } + + private boolean jj_3R_248() { + if (jj_scan_token(PARENT)) { + return true; + } + return false; + } + + private boolean jj_3R_247() { + if (jj_scan_token(ANY)) { + return true; + } + return false; + } + + private boolean jj_3R_261() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_269()) { + jj_scanpos = xsp; + if (jj_3R_270()) { + return true; + } + } + return false; + } + + private boolean jj_3R_269() { + if (jj_scan_token(IDENT)) { + return true; + } + return false; + } + + private boolean jj_3R_213() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_246()) { + jj_scanpos = xsp; + if (jj_3R_247()) { + jj_scanpos = xsp; + if (jj_3R_248()) { + return true; + } + } + } + return false; + } + + private boolean jj_3R_246() { + Token xsp; + if (jj_3R_261()) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3R_261()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_254() { + if (jj_scan_token(FUNCTION)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + xsp = jj_scanpos; + if (jj_3R_268()) { + jj_scanpos = xsp; + } + if (jj_scan_token(RPARAN)) { + return true; + } + return false; + } + + private boolean jj_3R_180() { + if (jj_scan_token(COMMA)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_241() { + if (jj_3R_258()) { + return true; + } + return false; + } + + private boolean jj_3R_276() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_281()) { + jj_scanpos = xsp; + if (jj_3R_282()) { + return true; + } + } + return false; + } + + private boolean jj_3R_281() { + if (jj_scan_token(IDENT)) { + return true; + } + return false; + } + + private boolean jj_3R_240() { + if (jj_3R_257()) { + return true; + } + return false; + } + + private boolean jj_3R_239() { + if (jj_3R_256()) { + return true; + } + return false; + } + + private boolean jj_3_5() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_180()) { + jj_scanpos = xsp; + } + if (jj_3R_181()) { + return true; + } + return false; + } + + private boolean jj_3R_263() { + if (jj_scan_token(DOT)) { + return true; + } + Token xsp; + if (jj_3R_276()) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3R_276()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_252() { + if (jj_3R_265()) { + return true; + } + return false; + } + + private boolean jj_3R_275() { + if (jj_3R_265()) { + return true; + } + return false; + } + + private boolean jj_3R_273() { + if (jj_3R_263()) { + return true; + } + return false; + } + + private boolean jj_3R_250() { + if (jj_3R_263()) { + return true; + } + return false; + } + + private boolean jj_3R_251() { + if (jj_3R_264()) { + return true; + } + return false; + } + + private boolean jj_3R_274() { + if (jj_3R_264()) { + return true; + } + return false; + } + + private boolean jj_3R_255() { + if (jj_scan_token(DOT)) { + return true; + } + return false; + } + + private boolean jj_3R_271() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_272()) { + jj_scanpos = xsp; + if (jj_3R_273()) { + jj_scanpos = xsp; + if (jj_3R_274()) { + jj_scanpos = xsp; + if (jj_3R_275()) { + return true; + } + } + } + } + return false; + } + + private boolean jj_3R_272() { + if (jj_3R_262()) { + return true; + } + return false; + } + + private boolean jj_3R_238() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_255()) { + jj_scanpos = xsp; + } + xsp = jj_scanpos; + if (jj_scan_token(72)) { + jj_scanpos = xsp; + if (jj_scan_token(49)) { + jj_scanpos = xsp; + if (jj_scan_token(50)) { + jj_scanpos = xsp; + if (jj_scan_token(52)) { + return true; + } + } + } + } + return false; + } + + private boolean jj_3R_237() { + if (jj_scan_token(STRING)) { + return true; + } + return false; + } + + private boolean jj_3R_214() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) { + jj_scanpos = xsp; + if (jj_3R_251()) { + jj_scanpos = xsp; + if (jj_3R_252()) { + return true; + } + } + } + } + return false; + } + + private boolean jj_3R_249() { + if (jj_3R_262()) { + return true; + } + return false; + } + + private boolean jj_3R_236() { + if (jj_3R_254()) { + return true; + } + return false; + } + + private boolean jj_3R_196() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_237()) { + jj_scanpos = xsp; + if (jj_3R_238()) { + jj_scanpos = xsp; + if (jj_3R_239()) { + jj_scanpos = xsp; + if (jj_3R_240()) { + jj_scanpos = xsp; + if (jj_3R_241()) { + return true; + } + } + } + } + } + return false; + } + + private boolean jj_3R_193() { + Token xsp; + if (jj_3R_214()) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3R_214()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_192() { + if (jj_3R_213()) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_271()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_178() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_192()) { + jj_scanpos = xsp; + if (jj_3R_193()) { + return true; + } + } + return false; + } + + private boolean jj_3R_243() { + if (jj_3R_211()) { + return true; + } + if (jj_3R_178()) { + return true; + } + return false; + } + + private boolean jj_3R_235() { + if (jj_scan_token(DIMEN)) { + return true; + } + return false; + } + + private boolean jj_3R_234() { + if (jj_scan_token(KHZ)) { + return true; + } + return false; + } + + private boolean jj_3R_233() { + if (jj_scan_token(HZ)) { + return true; + } + return false; + } + + private boolean jj_3R_232() { + if (jj_scan_token(MS)) { + return true; + } + return false; + } + + private boolean jj_3R_231() { + if (jj_scan_token(SECOND)) { + return true; + } + return false; + } + + private boolean jj_3R_230() { + if (jj_scan_token(GRAD)) { + return true; + } + return false; + } + + private boolean jj_3R_229() { + if (jj_scan_token(RAD)) { + return true; + } + return false; + } + + private boolean jj_3R_228() { + if (jj_scan_token(DEG)) { + return true; + } + return false; + } + + private boolean jj_3R_227() { + if (jj_scan_token(EXS)) { + return true; + } + return false; + } + + private boolean jj_3R_226() { + if (jj_scan_token(REM)) { + return true; + } + return false; + } + + private boolean jj_3_2() { + if (jj_3R_177()) { + return true; + } + if (jj_3R_178()) { + return true; + } + return false; + } + + private boolean jj_3R_225() { + if (jj_scan_token(LEM)) { + return true; + } + return false; + } + + private boolean jj_3R_224() { + if (jj_scan_token(EMS)) { + return true; + } + return false; + } + + private boolean jj_3R_198() { + if (jj_scan_token(COMMA)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + if (jj_3R_197()) { + return true; + } + return false; + } + + private boolean jj_3R_242() { + if (jj_3R_178()) { + return true; + } + return false; + } + + private boolean jj_3R_223() { + if (jj_scan_token(PX)) { + return true; + } + return false; + } + + private boolean jj_3R_222() { + if (jj_scan_token(IN)) { + return true; + } + return false; + } + + private boolean jj_3R_197() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_242()) { + jj_scanpos = xsp; + if (jj_3R_243()) { + return true; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { + jj_scanpos = xsp; + break; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_221() { + if (jj_scan_token(PC)) { + return true; + } + return false; + } + + private boolean jj_3R_220() { + if (jj_scan_token(MM)) { + return true; + } + return false; + } + + private boolean jj_3R_219() { + if (jj_scan_token(CM)) { + return true; + } + return false; + } + + private boolean jj_3R_218() { + if (jj_scan_token(PT)) { + return true; + } + return false; + } + + private boolean jj_3R_217() { + if (jj_scan_token(PERCENTAGE)) { + return true; + } + return false; + } + + private boolean jj_3R_203() { + if (jj_3R_245()) { + return true; + } + return false; + } + + private boolean jj_3_1() { + if (jj_3R_176()) { + return true; + } + return false; + } + + private boolean jj_3R_182() { + if (jj_3R_197()) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_198()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_216() { + if (jj_scan_token(NUMBER)) { + return true; + } + return false; + } + + private boolean jj_3R_215() { + if (jj_3R_253()) { + return true; + } + return false; + } + + private boolean jj_3R_195() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_215()) { + jj_scanpos = xsp; + } + xsp = jj_scanpos; + if (jj_3R_216()) { + jj_scanpos = xsp; + if (jj_3R_217()) { + jj_scanpos = xsp; + if (jj_3R_218()) { + jj_scanpos = xsp; + if (jj_3R_219()) { + jj_scanpos = xsp; + if (jj_3R_220()) { + jj_scanpos = xsp; + if (jj_3R_221()) { + jj_scanpos = xsp; + if (jj_3R_222()) { + jj_scanpos = xsp; + if (jj_3R_223()) { + jj_scanpos = xsp; + if (jj_3R_224()) { + jj_scanpos = xsp; + if (jj_3R_225()) { + jj_scanpos = xsp; + if (jj_3R_226()) { + jj_scanpos = xsp; + if (jj_3R_227()) { + jj_scanpos = xsp; + if (jj_3R_228()) { + jj_scanpos = xsp; + if (jj_3R_229()) { + jj_scanpos = xsp; + if (jj_3R_230()) { + jj_scanpos = xsp; + if (jj_3R_231()) { + jj_scanpos = xsp; + if (jj_3R_232()) { + jj_scanpos = xsp; + if (jj_3R_233()) { + jj_scanpos = xsp; + if (jj_3R_234()) { + jj_scanpos = xsp; + if (jj_3R_235()) { + jj_scanpos = xsp; + if (jj_3R_236()) { + return true; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3R_181() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_195()) { + jj_scanpos = xsp; + if (jj_3R_196()) { + return true; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_256() { + if (jj_scan_token(HASH)) { + return true; + } + return false; + } + + private boolean jj_3_4() { + if (jj_3R_179()) { + return true; + } + return false; + } + + private boolean jj_3R_245() { + if (jj_3R_186()) { + return true; + } + return false; + } + + private boolean jj_3R_257() { + if (jj_scan_token(URL)) { + return true; + } + return false; + } + + private boolean jj_3R_202() { + if (jj_3R_181()) { + return true; + } + return false; + } + + private boolean jj_3R_260() { + if (jj_scan_token(INTERPOLATION)) { + return true; + } + return false; + } + + private boolean jj_3R_184() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_202()) { + jj_scanpos = xsp; + if (jj_3R_203()) { + return true; + } + } + return false; + } + + private boolean jj_3_9() { + if (jj_3R_185()) { + return true; + } + return false; + } + + private boolean jj_3_3() { + if (jj_3R_176()) { + return true; + } + return false; + } + + private boolean jj_3R_267() { + if (jj_scan_token(PLUS)) { + return true; + } + return false; + } + + private boolean jj_3R_253() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_266()) { + jj_scanpos = xsp; + if (jj_3R_267()) { + return true; + } + } + return false; + } + + private boolean jj_3R_266() { + if (jj_scan_token(MINUS)) { + return true; + } + return false; + } + + private boolean jj_3R_258() { + if (jj_scan_token(UNICODERANGE)) { + return true; + } + return false; + } + + private boolean jj_3_8() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_9()) { + jj_scanpos = xsp; + } + if (jj_3R_184()) { + return true; + } + return false; + } + + private boolean jj_3R_186() { + if (jj_scan_token(VARIABLE)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_189() { + if (jj_scan_token(SEMICOLON)) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_187() { + if (jj_3R_184()) { + return true; + } + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_8()) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + private boolean jj_3R_244() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_259()) { + jj_scanpos = xsp; + if (jj_3R_260()) { + return true; + } + } + return false; + } + + private boolean jj_3R_259() { + if (jj_scan_token(IDENT)) { + return true; + } + return false; + } + + private boolean jj_3R_199() { + Token xsp; + if (jj_3R_244()) { + return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3R_244()) { + jj_scanpos = xsp; + break; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { + jj_scanpos = xsp; + break; + } + } + return false; + } + + /** Generated Token Manager. */ + public ParserTokenManager token_source; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + private int jj_gen; + final private int[] jj_la1 = new int[261]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static private int[] jj_la1_2; + static private int[] jj_la1_3; + static { + jj_la1_init_0(); + jj_la1_init_1(); + jj_la1_init_2(); + jj_la1_init_3(); + } + + private static void jj_la1_init_0() { + jj_la1_0 = new int[] { 0x0, 0x302, 0x302, 0x0, 0x300, 0x2, 0x2, 0x2, + 0xd4c40000, 0x0, 0x300, 0x2, 0x300, 0x2, 0x0, 0x2, 0x2, 0x2, + 0x0, 0x0, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x100000, 0x2, + 0x0, 0x2, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x2, 0x2, + 0xd4fd1500, 0xd4fd1500, 0x2, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, + 0x200000, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, + 0x0, 0x2, 0x391500, 0xc40000, 0xc40002, 0xc40000, 0x2, 0x2, + 0x80120002, 0x80120002, 0x2, 0x0, 0x0, 0x2, 0x2, 0x2, 0x2, + 0xd4c40000, 0xd4c40000, 0x2, 0x100000, 0x2, 0xd4c40000, 0x2, + 0x84000000, 0x84000000, 0x84000000, 0x84000000, 0xd4000000, + 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x2, 0x2, 0x3f000, 0x2, 0x0, + 0x2, 0x3f000, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x200000, 0x0, + 0xd4c40000, 0x0, 0x134e0002, 0x2, 0xd4c40000, 0xd4c40000, 0x2, + 0x0, 0x2, 0x134e0002, 0x0, 0x2, 0xd4c40000, 0xd4c40000, 0x2, + 0x134e0002, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0x2, 0x2, + 0x100000, 0x2, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0xd4c40000, + 0x2, 0x100000, 0x2, 0x2, 0x2, 0x100000, 0x0, 0x0, 0x800c0000, + 0x2, 0x0, 0x100000, 0x2, 0x800c0000, 0x2, 0x0, 0x2, 0x2, 0x0, + 0x2, 0x200000, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x200400, 0x2, + 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, + 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, 0x0, + 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, + 0x2, 0x100000, 0x0, 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x200000, + 0x2, 0x2, 0x200000, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, + 0x0, 0xd4c40000, 0x2, 0x0, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, + 0x800c0400, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, + 0x321c0000, 0xc0000, 0x800c0000, 0xc0000, 0x0, 0x80000000, 0x0, + 0x80000000, 0x800c0000, 0x2, 0x2, 0x800c0000, 0x2, 0xd4c40000, + 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, }; + } + + private static void jj_la1_init_1() { + jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x566000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, + 0x80, 0x0, 0x0, 0x120000, 0x120000, 0x0, 0x120000, 0x0, 0x0, + 0x0, 0x120000, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, + 0x60001c0, 0x60001c0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x80, 0x0, + 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, + 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc2, 0xc2, 0x0, 0x80, 0x80, + 0x0, 0x0, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, + 0xc0, 0x0, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x64000c0, 0x50000000, 0x3f, + 0x0, 0x564000c0, 0x564000c0, 0x0, 0x80000000, 0x0, 0x3f, 0x0, + 0x0, 0x564000c0, 0x564000c0, 0x0, 0x3f, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, + 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, + 0x40, 0x160040, 0x0, 0x40, 0x0, 0x0, 0x160040, 0x0, 0x40, 0x0, + 0x0, 0x80, 0x0, 0x0, 0x0, 0x61200c0, 0x61200c0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, + 0x6000000, 0x0, 0x0, 0x60000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x6000000, 0xc0, 0x0, + 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x160000, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x160000, 0x0, + 0x0, 0x0, 0x160000, 0x160000, 0x160000, 0x0, 0x0, 0x160000, + 0x0, 0x60000c0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, }; + } + + private static void jj_la1_init_2() { + jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, + 0x1000, 0x0, 0x0, 0x0, 0x0, 0x880, 0x0, 0x0, 0x0, 0x100, 0x100, + 0x0, 0x0, 0x2008, 0x2008, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x2000, + 0x0, 0x0, 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x2b80, 0x2b80, 0x0, + 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, + 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x2a80, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x380, 0x380, 0x0, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, + 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, + 0x180, 0x0, 0x0, 0x0, 0x0, 0x100, 0x0, 0x40, 0x0, 0x0, 0x0, + 0x109, 0x1000, 0x1300, 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, + 0x1300, 0x20, 0x0, 0x1109, 0x1109, 0x0, 0x1300, 0x0, 0x0, 0x0, + 0x1100, 0x0, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, + 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000, + 0x1000, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0x0, + 0x0, 0x0, 0x1100, 0x0, 0x0, 0x0, 0x2100, 0x2100, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x100, + 0x0, 0x0, 0x100, 0x0, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0xffffe200, 0x0, + 0x100, 0x980, 0xffffeb80, 0x0, 0x0, 0xfffffb80, 0x0, 0x100, + 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, }; + } + + private static void jj_la1_init_3() { + jj_la1_3 = new int[] { 0x8, 0x80, 0x80, 0x2, 0x80, 0x0, 0x0, 0x0, 0x75, + 0x0, 0x80, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, + 0xc5, 0x0, 0x0, 0x0, 0xc401bf, 0xc401bf, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0xc401be, 0x0, 0x0, 0x0, 0x0, 0x0, 0x400000, + 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc7, 0xc7, 0x0, + 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x80, 0x200000, 0x0, + 0xe5, 0xe5, 0x0, 0x0, 0x0, 0x200000, 0x0, 0x0, 0xe5, 0xe5, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x400000, 0x0, 0xf5, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x440001, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, + 0x0, 0x0, 0x0, 0x400000, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, + 0x0, 0x0, 0x380000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x100, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x100, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x400000, + 0x0, 0x0, 0x40001, 0x440001, 0x0, 0x0, 0x440001, 0x0, 0x37, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }; + } + + final private JJCalls[] jj_2_rtns = new JJCalls[9]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + /** Constructor with user supplied CharStream. */ + public Parser(CharStream stream) { + token_source = new ParserTokenManager(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) { + jj_la1[i] = -1; + } + for (int i = 0; i < jj_2_rtns.length; i++) { + jj_2_rtns[i] = new JJCalls(); + } + } + + /** Reinitialise. */ + public void ReInit(CharStream stream) { + token_source.ReInit(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) { + jj_la1[i] = -1; + } + for (int i = 0; i < jj_2_rtns.length; i++) { + jj_2_rtns[i] = new JJCalls(); + } + } + + /** Constructor with generated Token Manager. */ + public Parser(ParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) { + jj_la1[i] = -1; + } + for (int i = 0; i < jj_2_rtns.length; i++) { + jj_2_rtns[i] = new JJCalls(); + } + } + + /** Reinitialise. */ + public void ReInit(ParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) { + jj_la1[i] = -1; + } + for (int i = 0; i < jj_2_rtns.length; i++) { + jj_2_rtns[i] = new JJCalls(); + } + } + + private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) { + token = token.next; + } else { + token = token.next = token_source.getNextToken(); + } + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) { + c.first = null; + } + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { + } + + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + + private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source + .getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; + Token tok = token; + while (tok != null && tok != jj_scanpos) { + i++; + tok = tok.next; + } + if (tok != null) { + jj_add_error_token(kind, i); + } + } + if (jj_scanpos.kind != kind) { + return true; + } + if (jj_la == 0 && jj_scanpos == jj_lastpos) { + throw jj_ls; + } + return false; + } + + /** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) { + token = token.next; + } else { + token = token.next = token_source.getNextToken(); + } + jj_ntk = -1; + jj_gen++; + return token; + } + + /** Get the specific Token. */ + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) { + t = t.next; + } else { + t = t.next = token_source.getNextToken(); + } + } + return t; + } + + private int jj_ntk() { + if ((jj_nt = token.next) == null) { + return (jj_ntk = (token.next = token_source.getNextToken()).kind); + } else { + return (jj_ntk = jj_nt.kind); + } + } + + private java.util.List jj_expentries = new java.util.ArrayList(); + private int[] jj_expentry; + private int jj_kind = -1; + private int[] jj_lasttokens = new int[100]; + private int jj_endpos; + + private void jj_add_error_token(int kind, int pos) { + if (pos >= 100) { + return; + } + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + jj_entries_loop: for (java.util.Iterator it = jj_expentries + .iterator(); it.hasNext();) { + int[] oldentry = (int[]) (it.next()); + if (oldentry.length == jj_expentry.length) { + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + continue jj_entries_loop; + } + } + jj_expentries.add(jj_expentry); + break jj_entries_loop; + } + } + if (pos != 0) { + jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + } + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[120]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 261; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1 << j)) != 0) { + la1tokens[j] = true; + } + if ((jj_la1_1[i] & (1 << j)) != 0) { + la1tokens[32 + j] = true; + } + if ((jj_la1_2[i] & (1 << j)) != 0) { + la1tokens[64 + j] = true; + } + if ((jj_la1_3[i] & (1 << j)) != 0) { + la1tokens[96 + j] = true; + } + } + } + } + for (int i = 0; i < 120; i++) { + if (la1tokens[i]) { + jj_expentry = new int[1]; + jj_expentry[0] = i; + jj_expentries.add(jj_expentry); + } + } + jj_endpos = 0; + jj_rescan_token(); + jj_add_error_token(0, 0); + int[][] exptokseq = new int[jj_expentries.size()][]; + for (int i = 0; i < jj_expentries.size(); i++) { + exptokseq[i] = jj_expentries.get(i); + } + return new ParseException(token, exptokseq, tokenImage); + } + + /** Enable tracing. */ + final public void enable_tracing() { + } + + /** Disable tracing. */ + final public void disable_tracing() { + } + + private void jj_rescan_token() { + jj_rescan = true; + for (int i = 0; i < 9; i++) { + try { + JJCalls p = jj_2_rtns[i]; + do { + if (p.gen > jj_gen) { + jj_la = p.arg; + jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: + jj_3_1(); + break; + case 1: + jj_3_2(); + break; + case 2: + jj_3_3(); + break; + case 3: + jj_3_4(); + break; + case 4: + jj_3_5(); + break; + case 5: + jj_3_6(); + break; + case 6: + jj_3_7(); + break; + case 7: + jj_3_8(); + break; + case 8: + jj_3_9(); + break; + } + } + p = p.next; + } while (p != null); + } catch (LookaheadSuccess ls) { + } + } + jj_rescan = false; + } + + private void jj_save(int index, int xla) { + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { + p = p.next = new JJCalls(); + break; + } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; + p.first = token; + p.arg = xla; + } + + static final class JJCalls { + int gen; + Token first; + int arg; + JJCalls next; + } + } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj new file mode 100644 index 0000000000..5fb7f2315f --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -0,0 +1,3028 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* -*-java-extended-*- + * Copyright (c) 1999 World Wide Web Consortium + * (Massachusetts Institute of Technology, Institut National de Recherche + * en Informatique et en Automatique, Keio University). + * All Rights Reserved. http://www.w3.org/Consortium/Legal/ + * + * $Id: Parser.jj,v 1.15 2000/10/27 21:09:37 plehegar Exp $ + */ + +options { + IGNORE_CASE = true; + STATIC = false; + USER_CHAR_STREAM = true; + /* DEBUG_TOKEN_MANAGER = true; + DEBUG_PARSER = true; */ +} + +PARSER_BEGIN(Parser) + +package com.vaadin.sass.internal.parser; + +import java.io.*; +import java.net.*; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; + +import org.w3c.css.sac.ConditionFactory; +import org.w3c.css.sac.Condition; +import org.w3c.css.sac.SelectorFactory; +import org.w3c.css.sac.SelectorList; +import org.w3c.css.sac.Selector; +import org.w3c.css.sac.SimpleSelector; +import org.w3c.css.sac.DocumentHandler; +import org.w3c.css.sac.InputSource; +import org.w3c.css.sac.ErrorHandler; +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; +import org.w3c.css.sac.Locator; +import org.w3c.css.sac.LexicalUnit; + +import org.w3c.flute.parser.selectors.SelectorFactoryImpl; +import org.w3c.flute.parser.selectors.ConditionFactoryImpl; + +import org.w3c.flute.util.Encoding; + +import com.vaadin.sass.internal.handler.*; + +import com.vaadin.sass.internal.tree.*; + +/** + * A CSS2 parser + * + * @author Philippe Le H�garet + * @version $Revision: 1.15 $ + */ +public class Parser implements org.w3c.css.sac.Parser { + + // replaces all \t, \n, etc with this StringBuffer. + static final StringBuilder SPACE = new StringBuilder(" "); + + // the document handler for the parser + protected SCSSDocumentHandlerImpl documentHandler; + // the error handler for the parser + protected ErrorHandler errorHandler; + // the input source for the parser + protected InputSource source; + + protected ConditionFactory conditionFactory; + protected SelectorFactory selectorFactory; + + // temporary place holder for pseudo-element ... + private String pseudoElt; + + /** + * Creates a new Parser + */ + public Parser() { + this((CharStream) null); + } + + /** + * @@TODO + * @exception CSSException Not yet implemented + */ + public void setLocale(Locale locale) throws CSSException { + throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); + } + + public InputSource getInputSource(){ + return source; + } + + /** + * Set the document handler for this parser + */ + public void setDocumentHandler(DocumentHandler handler) { + this.documentHandler = (SCSSDocumentHandlerImpl) handler; + } + + public void setSelectorFactory(SelectorFactory selectorFactory) { + this.selectorFactory = selectorFactory; + } + + public void setConditionFactory(ConditionFactory conditionFactory) { + this.conditionFactory = conditionFactory; + } + + /** + * Set the error handler for this parser + */ + public void setErrorHandler(ErrorHandler error) { + this.errorHandler = error; + } + + /** + * Main parse methods + * + * @param source the source of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleSheet(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + + parserUnit(); + } + + /** + * Convenient method for URIs. + * + * @param systemId the fully resolved URI of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleSheet(String systemId) + throws CSSException, IOException { + parseStyleSheet(new InputSource(systemId)); + } + + /** + * This method parses only one rule (style rule or at-rule, except @charset). + * + * @param source the source of the rule. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + // TODO required by original parser but not used by Vaadin? + public void parseRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseRule(); + } + + /** + * This method parses a style declaration (including the surrounding curly + * braces). + * + * @param source the source of the style declaration. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. + */ + public void parseStyleDeclaration(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseDeclarationBlock(); + } + + /** + * This methods returns "http://www.w3.org/TR/REC-CSS2". + * @return the string "http://www.w3.org/TR/REC-CSS2". + */ + public String getParserVersion() { + return "http://www.w3.org/TR/REC-CSS2"; + } + + /** + * Parse methods used by DOM Level 2 implementation. + */ + public void parseImportRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseImportRule(); + } + + public void parseMediaRule(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + if (selectorFactory == null) { + selectorFactory = new SelectorFactoryImpl(); + } + if (conditionFactory == null) { + conditionFactory = new ConditionFactoryImpl(); + } + _parseMediaRule(); + } + + public SelectorList parseSelectors(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return null; + } + + public LexicalUnit parsePropertyValue(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return expr(); + } + + public boolean parsePriority(InputSource source) + throws CSSException, IOException { + this.source = source; + ReInit(getCharStreamWithLurk(source)); + + return prio(); + } + + /** + * Convert the source into a Reader. Used only by DOM Level 2 parser methods. + */ + private Reader getReader(InputSource source) throws IOException { + if (source.getCharacterStream() != null) { + return source.getCharacterStream(); + } else if (source.getByteStream() != null) { + // My DOM level 2 implementation doesn't use this case. + if (source.getEncoding() == null) { + // unknown encoding, use ASCII as default. + return new InputStreamReader(source.getByteStream(), "ASCII"); + } else { + return new InputStreamReader(source.getByteStream(), + source.getEncoding()); + } + } else { + // systemId + // @@TODO + throw new CSSException("not yet implemented"); + } + } + + /** + * Convert the source into a CharStream with encoding informations. + * The encoding can be found in the InputSource or in the CSS document. + * Since this method marks the reader and make a reset after looking for + * the charset declaration, you'll find the charset declaration into the + * stream. + */ + private CharStream getCharStreamWithLurk(InputSource source) + throws CSSException, IOException { + if (source.getCharacterStream() != null) { + // all encoding are supposed to be resolved by the user + // return the reader + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } else if (source.getByteStream() == null) { + // @@CONTINUE ME. see also getReader() with systemId + try { + source.setByteStream(new URL(source.getURI()).openStream()); + } catch (Exception e) { + try { + source.setByteStream(new FileInputStream(source.getURI())); + } catch (IOException ex) { + throw new CSSException("invalid url ?"); + } + } + } + //use UTF-8 as the default encoding. + String encoding = source.getEncoding(); + InputStream input = source.getByteStream(); + if (!input.markSupported()) { + // If mark is not supported, wrap it in a stream which supports mark + input = new BufferedInputStream(input); + source.setByteStream(input); + } + // Mark either the original stream or the wrapped stream + input.mark(100); + if(encoding == null){ + encoding = "ASCII"; + + char c = ' '; + + c = (char) input.read(); + + if (c == '@') { + // hum, is it a charset ? + int size = 100; + byte[] buf = new byte[size]; + input.read(buf, 0, 7); + String keyword = new String(buf, 0, 7); + if (keyword.equals("charset")) { + // Yes, this is the charset declaration ! + + // here I don't use the right declaration : white space are ' '. + while ((c = (char) input.read()) == ' ') { + // find the first quote + } + char endChar = c; + int i = 0; + + if ((endChar != '"') && (endChar != '\'')) { + // hum this is not a quote. + throw new CSSException("invalid charset declaration"); + } + + while ((c = (char) input.read()) != endChar) { + buf[i++] = (byte) c; + if (i == size) { + byte[] old = buf; + buf = new byte[size + 100]; + System.arraycopy(old, 0, buf, 0, size); + size += 100; + } + } + while ((c = (char) input.read()) == ' ') { + // find the next relevant character + } + if (c != ';') { + // no semi colon at the end ? + throw new CSSException("invalid charset declaration: " + + "missing semi colon"); + } + encoding = new String(buf, 0, i); + if (source.getEncoding() != null) { + // compare the two encoding informations. + // For example, I don't accept to have ASCII and after UTF-8. + // Is it really good ? That is the question. + if (!encoding.equals(source.getEncoding())) { + throw new CSSException("invalid encoding information."); + } + } + } // else no charset declaration available + } + } + // ok set the real encoding of this source. + source.setEncoding(encoding); + // set the real reader of this source. + source.setCharacterStream(new InputStreamReader(source.getByteStream(), + Encoding.getJavaEncoding(encoding))); + // reset the stream (leave the charset declaration in the stream). + input.reset(); + + return new Generic_CharStream(source.getCharacterStream(), 1, 1); + } + + private LocatorImpl currentLocator; + private Locator getLocator() { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this); + return currentLocator; + } + return currentLocator.reInit(this); + } + private LocatorImpl getLocator(Token save) { + if (currentLocator == null) { + currentLocator = new LocatorImpl(this, save); + return currentLocator; + } + return currentLocator.reInit(this, save); + } + + private void reportError(Locator l, Exception e) { + if (errorHandler != null) { + if (e instanceof ParseException) { + // construct a clean error message. + ParseException pe = (ParseException) e; + if (pe.specialConstructor) { + StringBuffer errorM = new StringBuffer(); + if (pe.currentToken != null) { + errorM.append("encountered \"") + .append(pe.currentToken.next); + } + errorM.append('"'); + if (pe.expectedTokenSequences.length != 0) { + errorM.append(". Was expecting one of: "); + for (int i = 0; i < pe.expectedTokenSequences.length; i++) { + for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { + int kind = pe.expectedTokenSequences[i][j]; + if (kind != S) { + errorM.append(pe.tokenImage[kind]); + errorM.append(' '); + } + } + } + } + errorHandler.error(new CSSParseException(errorM.toString(), + l, e)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), + l, e)); + } + } else if (e == null) { + errorHandler.error(new CSSParseException("error", l, null)); + } else { + errorHandler.error(new CSSParseException(e.getMessage(), l, e)); + } + } + } + + private void reportWarningSkipText(Locator l, String text) { + if (errorHandler != null && text != null) { + errorHandler.warning(new CSSParseException("Skipping: " + text, l)); + } + } +} + +PARSER_END(Parser) + +/* + * The tokenizer + */ + + +TOKEN : +{ + < S : ( [ " ", "\t" , "\n" , "\r", "\f" ] )+ > + { image = Parser.SPACE; } +} + +/* + * for fixing #11638: Ending an imported SCSS file with a comment causes an error in the Sass. + * now the single line comment is parsed as special token, before, they were simply skipped. + * solution got from http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.15 + */ + +SPECIAL_TOKEN : { +< SINGLE_LINE_COMMENT: "//"(~["\n","\r"])* ("\n"|"\r"|"\r\n")? > } + + +MORE : +{ + <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT +| + "/*" : IN_MULTI_LINE_COMMENT +} + +SPECIAL_TOKEN : +{ + : DEFAULT +} + + +SKIP : +{ + : DEFAULT +} + + +MORE : +{ + < ~[] > +} + + +TOKEN : +{ + < CDO : "" > + | < LBRACE : "{" > + | < RBRACE : "}"> + | < DASHMATCH : "|=" > + | < CARETMATCH : "^=" > + | < DOLLARMATCH : "$=" > + | < STARMATCH : "*=" > + | < INCLUDES : "~=" > + | < EQ : "=" > + | < PLUS : "+" > + | < MINUS : "-" > + | < COMMA : "," > + | < SEMICOLON : ";" > + | < PRECEDES : ">" > + | < SIBLING : "~" > + | < SUCCEEDS : "<" > + | < DIV : "/" > + | < LBRACKET : "[" > + | < RBRACKET : "]" > + | < ANY : "*" > + | < MOD : "%" > + | < PARENT : "&" > + | < DOT : "." > + | < LPARAN : "(" > + | < RPARAN : ")"> + | < COMPARE : "==" > + | < OR : "||" > + | < AND : "&&" > + | < NOT_EQ : "!=" > +} + + +TOKEN : +{ + < COLON : ":" > +} + +< DEFAULT > +TOKEN : +{ + < INTERPOLATION : "#{"< VARIABLE > "}"> +} + + +TOKEN : /* basic tokens */ +{ + < NONASCII : ["\200"-"\377"] > + | < #H : ["0"-"9", "a"-"f"] > + | < #UNICODE : "\\" ( )? /* I can't say {1,6} */ + ( )? ( )? + ( )? ( )? + ( [ " ", "\t" , "\n" , "\r", "\f" ] )? > + | < #ESCAPE : | ( "\\" [ " "-"~","\200"-"\377" ] ) > + | < #NMSTART : ("-")?[ "a"-"z","_"] | | > + | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > + | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"~" ] + | "\\\n" | "\\\r\n" | "\\\r" | "\\\f" + | | > + | < #D : ["0"-"9"] > + | < #NAME : ( )+ > + +} + + +TOKEN : +{ + + | + | + | +} + +/* DERECTIVES */ + +TOKEN : +{ + + | + | + | + | + | + | + | + | + | + | + | + | + | + | +} + +< DEFAULT > +TOKEN: +{ + < MICROSOFT_RULE : "filter"|"-ms-filter" > +} + +< DEFAULT > +TOKEN: +{ + < IF : "if" > +} + + +TOKEN: +{ + < GUARDED_SYM : "!" ( )? "default"> +} + + +TOKEN : +{ + < STRING : ( "\"" ( | "'" )* "\"" ) | + ( "'" ( | "\"" )* "'" ) > + | < IDENT : ( )* > + | < NUMBER : ( )+ | ( )* "." ( )+ > + | < #_URL : [ "!","#","$","%","&","*"-"~" ] | | > + | < URL : "url(" ( )* + ( | ( <_URL> )* ) ( )* ")" > +} + + +TOKEN: +{ + < VARIABLE : "$" > +} + + +TOKEN : +{ + < PERCENTAGE : "%" > + | < PT : "pt" > + | < MM : "mm" > + | < CM : "cm" > + | < PC : "pc" > + | < IN : "in" > + | < PX : "px" > + | < EMS : "em" > + | < LEM : "lem" > + | < REM : "rem" > + | < EXS : "ex" > + | < DEG : "deg" > + | < RAD : "rad" > + | < GRAD : "grad" > + | < MS : "ms" > + | < SECOND : "s" > + | < HZ : "Hz" > + | < KHZ : "kHz" > + | < DIMEN : > +} + + +TOKEN : +{ + < HASH : "#" > +} + +/* RESERVED ATRULE WORDS */ + +TOKEN : +{ + < IMPORT_SYM : "@import"> + | < MEDIA_SYM : "@media" > + | < CHARSET_SYM : "@charset" > + | < PAGE_SYM : "@page" > + | < FONT_FACE_SYM: "@font-face" > + | < KEY_FRAME_SYM: "@keyframes" | "@-moz-keyframes" | "@-o-keyframes" | "@-webkit-keyframes" | "@-ms-keyframes"> + | < ATKEYWORD : "@" > +} + + +TOKEN : +{ + < IMPORTANT_SYM : "!" ( )? "important" > +} + + +TOKEN : +{ + < #RANGE0 : > + | < #RANGE1 : ( "?" )? > + | < #RANGE2 : ( "?" )? ( "?" )? > + | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > + | < #RANGE : | | + | | | | > + | < #UNI : ( )? ( )? ( )? ( )? ( )? > + | < UNICODERANGE : "U+" + | "U+" "-" > +} + +< DEFAULT > +TOKEN : +{ + < REMOVE : "remove" (< S >)? "(" > + | < APPEND : "append" (< S >)? "(" > + | < CONTAINS : "contains" (< S >)? "(" > +} + + +TOKEN : +{ + < FUNCTION : (< S >)* "(" > +} + + +TOKEN : +{ /* avoid token manager error */ + < UNKNOWN : ~[] > +} + +/* + * The grammar of CSS2 + */ + +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ +void parserUnit() : +{} +{ + try { + { documentHandler.startDocument(source); } + ( charset() )? + ( comments() + | ignoreStatement() )* + ( importDeclaration() ( ignoreStatement() ( )* )* )* + afterImportDeclaration() + + } finally { + documentHandler.endDocument(source); + } +} + +void charset() : +{ Token n; } +{ + try { + ( )* n= ( )* ";" + } catch (ParseException e) { + reportError(getLocator(e.currentToken.next), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (Exception e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } +} + +void afterImportDeclaration() : +{String ret; + Locator l; +} +{ + ( + ( debuggingDirective() | mixinDirective() | controlDirective() | includeDirective() | styleRule() | media() + | page() | fontFace() | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() + | { l = getLocator(); } ret=skipStatement() + { + if ((ret == null) || (ret.length() == 0)) { + return; + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(l, ret); + } + } + ) + ( ignoreStatement() ( )* )* )* +} + +void ignoreStatement() : +{} +{ + | | atRuleDeclaration() +} + +/** + * The import statement + * + * @exception ParseException exception during the parse + */ +void importDeclaration() : +{Token n; + String uri; + MediaListImpl ml = new MediaListImpl(); + boolean isURL = false; +} +{ + try { + + ( )* ( n= { uri = convertStringIndex(n.image, 1, + n.image.length() -1); } + | n= + { + isURL=true; + uri = n.image.substring(4, n.image.length()-1).trim(); + if ((uri.charAt(0) == '"') + || (uri.charAt(0) == '\'')) { + uri = uri.substring(1, uri.length()-1); + } + } + ) + ( )* mediaStatement(ml) ";" + ( )* + { + if (ml.getLength() == 0) { + // see section 6.3 of the CSS2 recommandation. + ml.addItem("all"); + } + documentHandler.importStyle(uri, ml, isURL); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } +} + +/** + * @exception ParseException exception during the parse + */ +void keyframes() : +{ + Token n; + boolean start = false; + String keyframeName = null; + String animationname = ""; +} +{ + try { + n= ( )* {keyframeName = n.image;} + (n = {animationname += n.image; }|n = < INTERPOLATION >{ animationname += n.image; })+()* + {start = true; documentHandler.startKeyFrames(keyframeName, animationname); } + ( )* ( keyframeSelector() | contentDirective() )* ( )* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + } finally { + if (start) { + documentHandler.endKeyFrames(); + } + } +} + +void keyframeSelector(): +{ + Token n; + String selector = ""; + boolean start = false; +} +{ + try{ + (n = | n = | n = ){selector += n.image;} ()* + ( ()* (n = | n = | n = ) {selector += (", " + n.image);} ()* )* + ()* + { + start = true; + documentHandler.startKeyframeSelector(selector); + } + (ifContentStatement() | microsoftExtension() )* + ()* + } + catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endKeyframeSelector(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +/* see http://www.w3.org/TR/css3-mediaqueries/ */ +void media() : +{ + boolean start = false; + String ret; + MediaListImpl ml = new MediaListImpl(); +} +{ + try { + ( )* + mediaStatement(ml) + { start = true; documentHandler.startMedia(ml); } + ( )* ( debuggingDirective() | styleRule() | skipUnknownRule() )* ( )* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endMedia(ml); + } + } +} + +void mediaStatement(MediaListImpl ml) : +{ + Token t; +} +{ + { + t = getToken(1); + // loop over comma separated parts, add each to ml + while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + if (t.kind == COMMA) { + // skip the comma and the token before it that is still the active token + getNextToken(); + getNextToken(); + t = getToken(1); + } + String str = s.toString().trim(); + if (str.length() > 0) { + ml.addItem(str); + } + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String medium() : /* tv, projection, screen, ... */ +{Token n;} +{ + n= { return convertIdent(n.image); } +} + +/** + * @exception ParseException exception during the parse + */ +void page() : +{ + boolean start = false; + Token n = null; + String page = null; + String pseudo = null; +} +{ + try { + ( )* ( n= ( )* )? + ( pseudo=pseudo_page() )? + { + if (n != null) { + page = convertIdent(n.image); + } + } + ()* + { + start = true; + documentHandler.startPage(page, pseudo); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + } catch (ParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + skipStatement(); + // reportWarningSkipText(li, skipStatement()); + } else { + skipStatement(); + } + } finally { + if (start) { + documentHandler.endPage(page, pseudo); + } + } +} + +String pseudo_page() : +{ Token n; } +{ + ":" n= ( )* { return convertIdent(n.image); } +} + +void fontFace() : +{ + boolean start = false; +} +{ + try { + ( )* + ()* + { start = true; documentHandler.startFontFace(); } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endFontFace(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void atRuleDeclaration() : +{Token n; + String ret; +} +{ + n= + { + ret=skipStatement(); + if ((ret != null) && (ret.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(getLocator(), ret); + } + } +} + +void skipUnknownRule() : +{ Token n;} +{ + ( n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n= +| n=";" +| n="-" +| n= + ) { + String ret; + Locator loc = getLocator(); + ret=skipStatement(); + if ((ret != null) && (n.image.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(loc, ret); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +char combinator() : +{ +char connector = ' '; +} +{ + (connector = combinatorChar() + | (connector = combinatorChar())?) { return connector; } +} + +/**to refactor combinator and reuse in selector().*/ +char combinatorChar() : +{Token t;} +{ + (t = | t = | t = ) ()* + { + return t.image.charAt(0); + } +} + +void microsoftExtension() : +{ + Token n; + String name = ""; + String value = ""; +} + +{ + // This is not really taking the syntax of filter rules into account + n = < MICROSOFT_RULE > (< S >)* { name = n.image; } + < COLON > + ((n = < IDENT > { value += n.image; }) + | (n = < NUMBER > { value += n.image; }) + | (n = < STRING > { value += n.image; }) + | (n = < COMMA > { value += n.image; }) + | (n = < INTERPOLATION > { value += n.image; }) + | (n = < COLON > { value += n.image; }) + | (n = < FUNCTION > { value += n.image; }) + | (n = < RPARAN > { value += n.image; }) + | (n = < EQ > { value += n.image; }) + | (n = < DOT > { value += n.image; }) + | (n = < S > { if(value.lastIndexOf(' ') != value.length()-1) + { value += n.image; } } + ) )+ + < SEMICOLON > + (< S >)* + { documentHandler.microsoftDirective(name, value); } +} + +/** + * @exception ParseException exception during the parse + */ +String property() : +{Token t;String s = ""; +} +{ + (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+(< S >)* + { + return s; + } +} + +String variableName() : +{Token n;} +{ + n= ()* {return convertIdent(n.image.substring(1));} +} + +String functionName() : +{Token n;} +{ + n= ( )* {return convertIdent(n.image.substring(0, n.image.length()-1));} +} +/** + * @exception ParseException exception during the parse + */ +void styleRule() : +{ + boolean start = false; + ArrayList l = null; + Token save; + Locator loc; +} +{ + try { + l=selectorList() { save = token; } ()* + { + start = true; + documentHandler.startSelector(l); + } + // a CSS import here will not work + ( ifContentStatement() | microsoftExtension() | importDeclaration() )* + ()* + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endSelector(); + } + } +} + + ArrayList selectorList() : +{ + ArrayList selectors = new ArrayList(); + String selector; +} +{ + selector=selector() ( ()* { selectors.add(selector); } + selector=selector() )* + { selectors.add(selector); + return selectors; + } +} + +/** + * @exception ParseException exception during the parse + */ +String selector() : +{ + String selector = null; + char comb; +} +{ + try { + // the selector can begin either a simple_selector, or a combinatorChar(+, >, ~). + // when beginning with combinatorChar, the next one should be a simple_selector(). + (selector=simple_selector(null, ' ') | (comb=combinatorChar() selector=simple_selector(selector, comb))) + ( LOOKAHEAD(2) comb=combinator() + selector=simple_selector(selector, comb) )* ()* + { + return selector; + } + } catch (ParseException e) { + /* + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + reportWarningSkipText(getLocator(), s.toString()); + */ + Token t = getToken(1); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + getNextToken(); + t = getToken(1); + } + + throw new ThrowedParseException(e); + } +} + +/** + * @exception ParseException exception during the parse + */ +String simple_selector(String selector, char comb) : +{ + String simple_current = null; + String cond = null; + + pseudoElt = null; +} +{ + ( (simple_current=element_name() + ( cond=hash(cond) | cond=_class(cond) + | cond=attrib(cond) | cond=pseudo(cond) )* ) + | ( cond = hash(cond) | cond=_class(cond) + | cond=attrib(cond) | cond=pseudo(cond) )+ + ) + { + if (simple_current == null) { + simple_current = ""; + } + if (cond != null) { + simple_current = simple_current + cond; + } + StringBuilder builder = new StringBuilder(); + switch (comb) { + case ' ': + if(selector!=null){ + builder.append(selector).append(" "); + } + break; + case '+': + case '>': + case '~': + if(selector!=null){ + builder.append(selector).append(" "); + } + builder.append(comb).append(" "); + break; + default: + throw new ParseException("invalid state. send a bug report"); + } + builder.append(simple_current); + selector = builder.toString(); + + if (pseudoElt != null) { + selector = selector + pseudoElt; + } + return selector; + } +} + +/** + * @exception ParseException exception during the parse + */ +String _class(String pred) : +{Token t; +String s = "."; +} +{ + "." (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ + { + + if (pred == null) { + return s; + } else { + return pred + s; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String element_name() : +{Token t; String s = "";} +{ + (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ + { + return s; + } + | "*" + { return "*"; } + | "&" + { return "&"; } +} + +/** + * @exception ParseException exception during the parse + */ +String attrib(String pred) : +{ + int cases = 0; + Token att = null; + Token val = null; + String attValue = null; +} +{ + "[" ( )* att= ( )* + ( ( "=" { cases = 1; } + | { cases = 2; } + | { cases = 3; } + | { cases = 4; } + | { cases = 5; } + | { cases = 6; } ) ( )* + ( val= { attValue = val.image; } + | val= { attValue = val.image; } + ) + ( )* )? + "]" + { + String name = convertIdent(att.image); + String c; + switch (cases) { + case 0: + c = name; + break; + case 1: + c = name + "=" + attValue; + break; + case 2: + c = name + "~=" + attValue; + break; + case 3: + c = name + "|=" +attValue; + break; + case 4: + c = name + "^=" +attValue; + break; + case 5: + c = name + "$=" +attValue; + break; + case 6: + c = name + "*=" +attValue; + break; + default: + // never reached. + c = null; + } + c = "[" + c + "]"; + if (pred == null) { + return c; + } else { + return pred + c; + } + } +} + +/** + * @exception ParseException exception during the parse + */ +String pseudo(String pred) : +{Token n; +Token param; +String d; +boolean isPseudoElement = false; +} +{ + ":" (":"{isPseudoElement=true;})?( n= + { + String s = ":" + convertIdent(n.image); + if (isPseudoElement) { + if (pseudoElt != null) { + throw new CSSParseException("duplicate pseudo element definition " + + s, getLocator()); + } else { + pseudoElt = ":"+s; + return pred; + } + } else { + String c = s; + if (pred == null) { + return c; + } else { + return pred + c; + } + } + } + | ( n= ( )* d=skipStatementUntilMatchingRightParan() + { + // accept anything between function and a right parenthesis + String f = convertIdent(n.image); + String colons = isPseudoElement ? "::" : ":"; + String pseudofn = colons + f + d + ")"; + if (pred == null) { + return pseudofn; + } else { + return pred + pseudofn; + } + } + ) + ) +} + +/** + * @exception ParseException exception during the parse + */ +String hash(String pred) : +{Token n; } +{ + n= + { + String d = n.image; + if (pred == null) { + return d; + } else { + return pred + d; + } + } +} + +void variable() : +{ + String name; + LexicalUnitImpl exp = null; + boolean guarded = false; + String raw; +} +{ + try{ + name = variableName() + ":" ( )* exp=expr() ( guarded=guarded() )?(";"()*)+ + //raw=skipStatementUntilSemiColon() + { + documentHandler.variable(name, exp, guarded); + } + }catch (JumpException e) { + skipAfterExpression(); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + } else { + skipAfterExpression(); + } + } +} + +void controlDirective() : +{} +{ + ifDirective() | eachDirective() +} + +void ifContentStatement() : +{} +{ + contentDirective() | includeDirective() | media() | extendDirective() | styleRuleOrDeclarationOrNestedProperties() + | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() | controlDirective() | atRuleDeclaration() +} + +void ifDirective() : +{ + Token n = null; + String s = null; + String evaluator = ""; +} +{ + < IF_SYM > + ( s = booleanExpressionToken() { evaluator += s;} )+ + < LBRACE >(< S >)* + { documentHandler.startIfElseDirective(); + documentHandler.ifDirective(evaluator); + } + ( ifContentStatement() | fontFace() )* + < RBRACE >(< S >)* + (elseDirective())* + { documentHandler.endIfElseDirective(); } +} + +void elseDirective() : +{ + String evaluator = ""; + Token n = null; + String s = null; +} +{ + < ELSE_SYM >(< S >)* + ( < IF > ( s = booleanExpressionToken() { evaluator += s; } )+ )? + < LBRACE >(< S >)* + { if(!evaluator.trim().equals("")){ documentHandler.ifDirective(evaluator); } + else{ documentHandler.elseDirective(); } + } + ( ifContentStatement() | fontFace() )* + < RBRACE >(< S >)* +} + +String booleanExpressionToken() : +{ + Token n = null; + String s = null; +} +{ + ( + LOOKAHEAD(containsDirective()) + s = containsDirective() + |n = < VARIABLE > + |n = < IDENT > + |n = < NUMBER > + |n = < LPARAN > + |n = < RPARAN > + |n = < PLUS > + |n = < MINUS > + |n = < DIV > + |n = < ANY > + |n = < COMPARE > + |n = < EQ > + |n = < PRECEDES > + |n = < SUCCEEDS > + |n = < OR > + |n = < AND > + |n = < S > + |n = < NOT_EQ > +){ + if(n!=null){return n.image;} + else{return s;} + } +} + +void eachDirective() : +{ + Token var; + ArrayList list = null; + String listVariable = null; +} +{ + < EACH_SYM > + (< S >)* + var = < VARIABLE > (< S >)* < EACH_IN > (< S >)* + (list = stringList() + {documentHandler.startEachDirective(var.image, list);} + |listVariable = variableName() + {documentHandler.startEachDirective(var.image, listVariable);} + ) + < LBRACE >(< S >)* + ( ifContentStatement() )* + < RBRACE >(< S >)* + { documentHandler.endEachDirective();} +} + +ArrayList stringList(): +{ + ArrayList strings = new ArrayList(); + Token input; +} +{ + (input = < IDENT > (< S >)*) + { strings.add(input.image); } + + (< COMMA >(< S >)* input = < IDENT > { strings.add(input.image); } (< S >)*)* + { return strings; } + +} + +void mixinDirective() : +{ + String name; + ArrayList args = null; + String body; +} +{ + + ()* + (name = property() + |(name = functionName() + args = arglist()) ()*) ()* + {documentHandler.startMixinDirective(name, args);} + ( ifContentStatement() | fontFace() | page())* + ()* + {documentHandler.endMixinDirective(name, args);} +} + +ArrayList arglist() : +{ + ArrayList args = new ArrayList(); + VariableNode arg; + boolean hasNonOptionalArgument = false; +} +{ + arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } + arg=mixinArg() )* + { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + return args; + } +} + +JAVACODE +boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { + boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; + if(currentArgHasArguments) { + if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + } + return hasNonOptionalArguments; + }else { return true; + } +} + +VariableNode mixinArg() : +{ + String name; + Token variable = null; + LexicalUnitImpl first = null; + LexicalUnitImpl prev = null; + LexicalUnitImpl next = null; +} +{ + name=variableName() (< COLON > (< S >)* + + ( first = nonVariableTerm(null) { + prev = first; } + (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) + | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, variable.image);} + + ) + )? + { + VariableNode arg = new VariableNode(name, first, false); + return arg; + } +} + +ArrayList argValuelist() : +{ + ArrayList args = new ArrayList(); + LexicalUnitImpl first = null; + LexicalUnitImpl next = null; + LexicalUnitImpl prev = null; +} +{ + first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + ( ()* + first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* + )* + {return args;} +} + +void includeDirective() : +{ + String name; + ArrayList args=null; +} +{ + + ()* + (name = property()|name = variableName(){ name = "$"+name;} + |(name = functionName() + args = argValuelist()) ()*) + ((";"()*)+ + {documentHandler.includeDirective(name, args);} + | ()* {documentHandler.startIncludeContentBlock(name, args);} + (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* + ()* {documentHandler.endIncludeContentBlock();} + ) +} + +String interpolation() : +{ + Token n; +} +{ + n = < INTERPOLATION > + { + return n.image; + } +} + +void listModifyDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + Token type = null; +} +{ + //refactor, remove those 3 LOOKAHEAD(5). + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + (type = < APPEND> | type = | type= )(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + { + switch (type.kind) { + case APPEND: + documentHandler.appendDirective(variable,list,remove,separator); + break; + case REMOVE: + documentHandler.removeDirective(variable,list,remove,separator); + break; + case CONTAINS: + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + break; + default: + break; + } + } + (< S >)*< SEMICOLON >()* +} + + +/** + * @exception ParseException exception during the parse + */ +void appendDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + < APPEND >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { documentHandler.appendDirective(variable,list,remove,separator); } +} + +/** + * @exception ParseException exception during the parse + */ +void removeDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* + < REMOVE >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { documentHandler.removeDirective(variable,list,remove,separator); } +} + +/** + * @exception ParseException exception during the parse + */ +String containsDirective() : +{ + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; +} +{ + (n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)*)? + < CONTAINS >(< S >)* + (list = listModifyDirectiveArgs(0)) + (< RPARAN >)? < COMMA >(< S >)* + (remove = listModifyDirectiveArgs(1)) + ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? + < RPARAN > + + { /* + *if it is not in the form like "$contains : contains($items, .v-button);" + *for example in @if, like "@if (contains(a b c, b))", then create a temp + *variable for contains(a b c, b); + */ + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + return variable; + } +} + +JAVACODE +String listModifyDirectiveArgs(int nest) +{ + String list = ""; + int nesting = nest; + Token t = null; + + while(true) + { + t = getToken(1); + String s = t.image; + if(t.kind == VARIABLE||t.kind == IDENT) { + list += s; + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { + int i = 2; + Token temp = getToken(i); + boolean isLast = true; + while(temp.kind != SEMICOLON) + { if(temp.kind != RPARAN || temp.kind != S) + { isLast = false; } + i++; + temp = getToken(i); + } + + if(isLast) { return list; + } + } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); + + }else if(t.kind == LPARAN) { nesting++; + if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + } + }else if(t.kind == RPARAN) { nesting--; + if(nesting == 0) { + return list; + } + } else if(t.kind == COMMA) { + if(nesting == nest) { + return list; }else { + list += ","; } + + }else if(t.kind == S) { + list += " "; } else if(t.kind == LBRACE) { + throw new CSSParseException("Invalid token,'{' found", getLocator()); } + getNextToken(); + } +} + +Node returnDirective() : +{ + String raw; +} +{ + raw = skipStatement() + {return null;} +} + +void debuggingDirective() : +{} +{ + debugDirective() | warnDirective() +} + +void debugDirective() : +{} +{ + + { + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. + System.out.println(content); + } + ()* +} + +void warnDirective() : +{} +{ + + { + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. + System.err.println(content); + } + ()* +} + +Node forDirective() : +{ + String var; + String from; + String to; + boolean exclusive; + String body; + Token tok; +} +{ + var = variableName() + { + int[] toThrough = {TO, THROUGH}; + from = skipStatementUntil(toThrough); + } + (tok = {exclusive = true;} + | tok = {exclusive = false;}) + to = skipStatementUntilLeftBrace() + ()* + body = skipStatement() + {return documentHandler.forDirective(var, from, to, exclusive, body);} +} + +Node whileDirective() : +{ + String condition; + String body; +} +{ + condition = skipStatementUntilLeftBrace() + body = skipStatement() + { return documentHandler.whileDirective(condition, body);} +} + +void extendDirective() : +{ArrayList list;} +{ + + ()* + list = selectorList() + (";"()*)+ + {documentHandler.extendDirective(list);} +} + +void contentDirective() : +{} +{ + + ()* + (";"()*)+ + {documentHandler.contentDirective();} +} + +JAVACODE +Node importDirective(){ + return null; +} + +JAVACODE +Node charsetDirective(){ + return null; +} + +JAVACODE +Node mozDocumentDirective(){ + return null; +} + +JAVACODE +Node supportsDirective(){ + return null; +} + + +void nestedProperties(): +{String name; +LexicalUnit exp;} +{ + name=property() + ":" ( )* + ()* + { + documentHandler.startNestedProperties(name); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + + { + documentHandler.endNestedProperties(name); + } + ()* +} +/** + * @exception ParseException exception during the parse + */ +void styleRuleOrDeclarationOrNestedProperties() : +{ +} +{ + try { + // differentiate between the colon of a pseudo and the colon of nested properties and the colon of a simple property + // first check if it is a normal styleRule, if not check if it is declarationOrNestedProperties(), if still fails, most likely, it is + // is styleRule with pseudo selector with contains functions. have to do it in this way, because both the styleRule and declarationOrNestedProperties() + // have 'skipStatementUntilXXX', which cannot be LOOKAHEAD properly. + ( debuggingDirective() | LOOKAHEAD(selectorList()) styleRule() | LOOKAHEAD(3)declarationOrNestedProperties() | styleRule()) + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} +/** + * @exception ParseException exception during the parse + */ +void declarationOrNestedProperties() : +{ boolean important = false; + String name; + LexicalUnitImpl exp; + Token save; + String comment = null; +} +{ + try { + name=property() + { save = token; } + ":" ( )* + (exp=expr() ( important=prio() )? + { + Token next = getToken(1); + if(next.kind == SEMICOLON || next.kind == RBRACE){ + while(next.kind == SEMICOLON){ + skipStatement(); + next = getToken(1); + } + //only add special token kept for sprites '/**' + if(token.specialToken!=null && token.specialToken!=null && token.specialToken.image.startsWith("/**")){ + documentHandler.property(name, exp, important, token.specialToken.image); + }else{ + documentHandler.property(name, exp, important, null); + } + } + } + | ()* + { + documentHandler.startNestedProperties(name); + } + ( declaration() )? ( ";" ( )* ( declaration() )? )* + ()* + { + documentHandler.endNestedProperties(name); + } + ) + + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +void declaration() : +{ boolean important = false; + String name; + LexicalUnit exp; + Token save; +} +{ + try { + name=property() + { save = token; } + ":" ( )* exp=expr() ( important=prio() )? + { + documentHandler.property(name, exp, important); + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } +} + +/** + * @exception ParseException exception during the parse + */ +boolean prio() : +{} +{ + ( )* { return true; } +} + +boolean guarded() : +{} +{ + ()* {return true;} +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl operator(LexicalUnitImpl prev) : +{Token n;} +{ +/* (comments copied from basic_arithmetics.scss) +*supports: +* 1. standard arithmetic operations (+, -, *, /, %) +* 2. / is treated as css operator, unless one of its operands is variable or there is another binary arithmetic operator +*limits: +* 1. cannot mix arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will fail +* 2. space between add and minus operator and their following operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not +* 3. parenthesis is not supported now. +*/ +n="," ( )* { return LexicalUnitImpl.createComma(n.beginLine, + n.beginColumn, + prev); } +|n="/" ( )* { return LexicalUnitImpl.createSlash(n.beginLine, + n.beginColumn, + prev); } +| n="*" ( )* { return LexicalUnitImpl.createMultiply(n.beginLine, + n.beginColumn, + prev); } +| n="%" ( )* { return LexicalUnitImpl.createModulo(n.beginLine, + n.beginColumn, + prev); } +/* +* for '+', since it can be either a binary operator or an unary operator, +* which is ambiguous. To avoid this, the binary operator '+' always has +* a space before the following term. so '2+3' is not a valid binary expression, +* but '2 + 3' is. The same for '-' operator. +*/ + +| n="+" ( )+{ return LexicalUnitImpl.createAdd(n.beginLine, + n.beginColumn, + prev); } +| n="-" ( )+{ return LexicalUnitImpl.createMinus(n.beginLine, + n.beginColumn, + prev); } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl expr() : +{ + LexicalUnitImpl first, res; + char op; +} +{ + first=term(null){ res = first; } + ( LOOKAHEAD(2) ( LOOKAHEAD(2) res=operator(res) )? res=term(res))* + { return first; } +} + +/** + * @exception ParseException exception during the parse + */ +char unaryOperator() : +{} +{ + "-" { return '-'; } +| "+" { return '+'; } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl term(LexicalUnitImpl prev) : +{ LexicalUnitImpl result = null; + Token n = null; + char op = ' '; +} +{ + (result = nonVariableTerm(prev)| result = variableTerm(prev)) + { + return result; + } +} + +LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { + LexicalUnitImpl result = null; + String varName = ""; } { + varName = variableName() + {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, varName); return result;} } + +LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + String varName; + String s = ""; +} +{ +( ( ( + op=unaryOperator() )? + (n= + { result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn, + prev, number(op, n, 0)); } + | n= + { result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); } + | n= + { result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); } + | n= + { result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); } + | n= + { result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); } + | n= + { + s = n.image; + int i = 0; + while (i < s.length() + && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { + i++; + } + + result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, + number(op,n,s.length()-i), + s.substring(i)); + } + | result=function(op, prev) ) ) + | ( n= + { result = + LexicalUnitImpl.createString(n.beginLine, n.beginColumn, prev, + convertStringIndex(n.image, 1, + n.image.length() -1));} + | (< DOT >{ s+="."; })?(n= | n= | n= | n=) + { s += convertIdent(n.image); + if ("inherit".equals(s)) { + result = LexicalUnitImpl.createInherit(n.beginLine, n.beginColumn, + prev); + } else { + result = LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, convertIdent(n.image)); + } + + /* / + Auto correction code used in the CSS Validator but must not + be used by a conformant CSS2 parser. + * Common error : + * H1 { + * color : black + * background : white + * } + * + Token t = getToken(1); + Token semicolon = new Token(); + semicolon.kind = SEMICOLON; + semicolon.image = ";"; + if (t.kind == COLON) { + // @@SEEME. (generate a warning?) + // @@SEEME if expression is a single ident, + generate an error ? + rejectToken(semicolon); + + result = prev; + } + / */ + } + | result=hexcolor(prev) + | result=url(prev) + | result=unicode(prev) + ) ) ( )* + { + return result; } } + +/** + * Handle all CSS2 functions. + * @exception ParseException exception during the parse + */ +LexicalUnitImpl function(char operator, LexicalUnitImpl prev) : +{Token n; + LexicalUnit params = null; +} +{ + n= ( )* + { + String fname = convertIdent(n.image); + if("alpha(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "alpha("+body); + }else if("expression(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "expression("+body); + } + } + ( params=expr() )? ")" + { + if (operator != ' ') { + throw new CSSParseException("invalid operator before a function.", + getLocator()); + } + String f = convertIdent(n.image); + LexicalUnitImpl l = (LexicalUnitImpl) params; + boolean loop = true; + if ("rgb(".equals(f)) { + // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 2: + case 4: + if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) + && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + if (loop) { + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + } + if ((i == 5) && loop && (l == null)) { + return LexicalUnitImpl.createRGBColor(n.beginLine, + n.beginColumn, + prev, params); + } else { + if (errorHandler != null) { + String errorText; + Locator loc; + if (i < 5) { + if (params == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters."; + } else if (l == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters: " + + params.toString(); + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "invalid parameter: " + + l.toString(); + } + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "too many parameters: " + + l.toString(); + } + errorHandler.error(new CSSParseException(errorText, loc)); + } + + throw new JumpException(); + } + } else if ("counter".equals(f)) { + int i = 0; + while (loop && l != null && i < 3) { + switch (i) { + case 0: + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 1: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if (((i == 1) || (i == 3)) && loop && (l == null)) { + return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn, + prev, params); + } + + } else if ("counters(".equals(f)) { + + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 4: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if (((i == 3) || (i == 5)) && loop && (l == null)) { + return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn, + prev, params); + } + } else if ("attr(".equals(f)) { + if ((l != null) + && (l.getNextLexicalUnit() == null) + && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { + return LexicalUnitImpl.createAttr(l.getLineNumber(), + l.getColumnNumber(), + prev, l.getStringValue()); + } + } else if ("rect(".equals(f)) { + int i = 0; + while (loop && l != null && i < 7) { + switch (i) { + case 0: + case 2: + case 4: + case 6: + switch (l.getLexicalUnitType()) { + case LexicalUnit.SAC_INTEGER: + if (l.getIntegerValue() != 0) { + loop = false; + } + break; + case LexicalUnit.SAC_IDENT: + if (!l.getStringValue().equals("auto")) { + loop = false; + } + break; + case LexicalUnit.SAC_EM: + case LexicalUnit.SAC_EX: + case LexicalUnit.SAC_PIXEL: + case LexicalUnit.SAC_CENTIMETER: + case LexicalUnit.SAC_MILLIMETER: + case LexicalUnit.SAC_INCH: + case LexicalUnit.SAC_POINT: + case LexicalUnit.SAC_PICA: + // nothing + break; + default: + loop = false; + } + break; + case 1: + case 3: + case 5: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + throw new ParseException("implementation error"); + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if ((i == 7) && loop && (l == null)) { + return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn, + prev, params); + } + } + return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev, + f.substring(0, + f.length() -1), + params); + } +} + +LexicalUnitImpl unicode(LexicalUnitImpl prev) : +{ Token n; +} +{ + n= + { + LexicalUnitImpl params = null; + String s = n.image.substring(2); + int index = s.indexOf('-'); + if (index == -1) { + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s, 16)); + } else { + String s1 = s.substring(0, index); + String s2 = s.substring(index); + + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s1, 16)); + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s2, 16)); + } + + return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn, + prev, params); + } +} + +LexicalUnitImpl url(LexicalUnitImpl prev) : +{ Token n; +} +{ + n= + { + String urlname = n.image.substring(4, n.image.length()-1).trim(); + return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname); + } +} + +/** + * @exception ParseException exception during the parse + */ +LexicalUnitImpl hexcolor(LexicalUnitImpl prev) : +{Token n; +} +{ + n= + { + int r; + LexicalUnitImpl first, params = null; + String s = n.image.substring(1); + + if(s.length()!=3 && s.length()!=6) { + first = null; + throw new CSSParseException("invalid hexadecimal notation for RGB: " + s, + getLocator()); + } + return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, n.image); + } +} + +JAVACODE +float number(char operator, Token n, int lengthUnit) { + String image = n.image; + float f = 0; + + if (lengthUnit != 0) { + image = image.substring(0, image.length() - lengthUnit); + } + f = Float.valueOf(image).floatValue(); + return (operator == '-')? -f: f; +} + +JAVACODE +String skipStatementUntilSemiColon(){ + int[] semicolon = {SEMICOLON}; + return skipStatementUntil(semicolon); +} + +JAVACODE +String skipStatementUntilLeftBrace(){ + int[] lBrace = {LBRACE}; + return skipStatementUntil(lBrace); +} + +JAVACODE +String skipStatementUntilMatchingRightParan(){ + int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "(" + int[] rightTokens = {RPARAN}; + StringBuffer s = new StringBuffer(); + int difference = 1; + Token tok; + while(difference != 0){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; + } + for(int sym : leftTokens){ + if(tok.kind == sym){ + difference++; + } + } + for(int sym : rightTokens){ + if(tok.kind == sym){ + difference--; + } + } + if(difference != 0){ + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); +} + +JAVACODE +String skipStatementUntil(int[] symbols){ + StringBuffer s = new StringBuffer(); + boolean stop = false; + Token tok; + while(!stop){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; + } + for(int sym : symbols){ + if(tok.kind == sym){ + stop = true; + break; + } + } + if(!stop){ + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); + } + } + return s.toString().trim(); +} + + +JAVACODE +String skipStatement() { + StringBuffer s = new StringBuffer(); + Token tok = getToken(0); + if (tok.image != null) { + s.append(tok.image); + } + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == RBRACE) { + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == SEMICOLON) { + getNextToken(); + tok = getToken(1); + break; + } + getNextToken(); + } + + // skip white space + while (true) { + if (tok.kind != S) { + break; + } + tok = getNextToken(); + tok = getToken(1); + } + + return s.toString().trim(); +} + +JAVACODE +String skip_to_matching_brace() { + StringBuffer s = new StringBuffer(); + Token tok; + int nesting = 1; + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + break; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + nesting++; + } else if (tok.kind == RBRACE) { + nesting--; + if (nesting == 0) { + break; + } + } + getNextToken(); + } + return s.toString(); +} + +/* + * Here I handle all CSS2 unicode character stuffs. + * I convert all \XXXXXX character into a single character. + * Don't forget that the parser has recognize the token before. + * (So IDENT won't contain newline and stuffs like this). + */ +JAVACODE +String convertStringIndex(String s, int start, int len) { + StringBuffer buf = new StringBuffer(len); + int index = start; + + while (index < len) { + char c = s.charAt(index); + if (c == '\\') { + if (++index < len) { + c = s.charAt(index); + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + buf.append('\\'); + while (index < len) { + buf.append(s.charAt(index++)); + } + break; + case '\n': + case '\f': + break; + case '\r': + if (index + 1 < len) { + if (s.charAt(index + 1) == '\n') { + index ++; + } + } + break; + default: + buf.append(c); + } + } else { + throw new CSSParseException("invalid string " + s, getLocator()); + } + } else { + buf.append(c); + } + index++; + } + + return buf.toString(); +} + +JAVACODE +String convertIdent(String s) { + return convertStringIndex(s, 0, s.length()); +} + +JAVACODE +String convertString(String s) { + return convertStringIndex(s, 0, s.length()); +} + +JAVACODE +void comments(){ + /*keeps only the multiple line comments, single line comments are skipped*/ + if (token.specialToken != null && token.specialToken.image!=null && token.specialToken.image.startsWith("/*")){ + Token tmp_t = token.specialToken; + while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; + while (tmp_t != null) { + documentHandler.comment(tmp_t.image); + tmp_t = tmp_t.next; + } + } +} + +/* + * @@HACK + * I can't insert a token into the tokens flow. + * It's jj_consume_token implementation dependant! :-( + */ +JAVACODE +void rejectToken(Token t) { + Token fakeToken = new Token(); + t.next = token; + fakeToken.next = t; + token = fakeToken; +} + +/** + * skip after an expression + */ +JAVACODE +String skipAfterExpression() { + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + + while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + + return s.toString(); +} + +/** + * The following functions are useful for a DOM CSS implementation only and are + * not part of the general CSS2 parser. + */ +// TODO required by original parser but not used by Vaadin? +void _parseRule() : +{String ret = null; +} +{ + ( )* + ( importDeclaration() | debuggingDirective() | styleRule() | media() | page() | fontFace() | ret=skipStatement() + { + if ((ret == null) || (ret.length() == 0)) { + return; + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + throw new CSSParseException("unrecognize rule: " + ret, + getLocator()); + } + } + ) +} + +void _parseImportRule() : +{ +} +{ + ( )* importDeclaration() +} + +void _parseMediaRule() : +{ +} +{ + ( )* media() +} + +void _parseDeclarationBlock() : +{ +} +{ + ( )* + ( declaration() )? ( ";" ( )* ( declaration() )? )* + } + +ArrayList _parseSelectors() : +{ ArrayList p = null; +} +{ + try { + ( )* p = selectorList() + { return p; } + } catch (ThrowedParseException e) { + throw (ParseException) e.e.fillInStackTrace(); + } +} + +/* + * Local Variables: + * compile-command: javacc Parser.jj & javac Parser.java + * End: + */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java new file mode 100644 index 0000000000..a3ab622ee9 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserConstants.java @@ -0,0 +1,392 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. ParserConstants.java */ +package com.vaadin.sass.internal.parser; + + +/** + * Token literal values and constants. + * Generated by org.javacc.parser.OtherFilesGen#start() + */ +public interface ParserConstants { + + /** End of File. */ + int EOF = 0; + /** RegularExpression Id. */ + int S = 1; + /** RegularExpression Id. */ + int SINGLE_LINE_COMMENT = 2; + /** RegularExpression Id. */ + int FORMAL_COMMENT = 5; + /** RegularExpression Id. */ + int MULTI_LINE_COMMENT = 6; + /** RegularExpression Id. */ + int CDO = 8; + /** RegularExpression Id. */ + int CDC = 9; + /** RegularExpression Id. */ + int LBRACE = 10; + /** RegularExpression Id. */ + int RBRACE = 11; + /** RegularExpression Id. */ + int DASHMATCH = 12; + /** RegularExpression Id. */ + int CARETMATCH = 13; + /** RegularExpression Id. */ + int DOLLARMATCH = 14; + /** RegularExpression Id. */ + int STARMATCH = 15; + /** RegularExpression Id. */ + int INCLUDES = 16; + /** RegularExpression Id. */ + int EQ = 17; + /** RegularExpression Id. */ + int PLUS = 18; + /** RegularExpression Id. */ + int MINUS = 19; + /** RegularExpression Id. */ + int COMMA = 20; + /** RegularExpression Id. */ + int SEMICOLON = 21; + /** RegularExpression Id. */ + int PRECEDES = 22; + /** RegularExpression Id. */ + int SIBLING = 23; + /** RegularExpression Id. */ + int SUCCEEDS = 24; + /** RegularExpression Id. */ + int DIV = 25; + /** RegularExpression Id. */ + int LBRACKET = 26; + /** RegularExpression Id. */ + int RBRACKET = 27; + /** RegularExpression Id. */ + int ANY = 28; + /** RegularExpression Id. */ + int MOD = 29; + /** RegularExpression Id. */ + int PARENT = 30; + /** RegularExpression Id. */ + int DOT = 31; + /** RegularExpression Id. */ + int LPARAN = 32; + /** RegularExpression Id. */ + int RPARAN = 33; + /** RegularExpression Id. */ + int COMPARE = 34; + /** RegularExpression Id. */ + int OR = 35; + /** RegularExpression Id. */ + int AND = 36; + /** RegularExpression Id. */ + int NOT_EQ = 37; + /** RegularExpression Id. */ + int COLON = 38; + /** RegularExpression Id. */ + int INTERPOLATION = 39; + /** RegularExpression Id. */ + int NONASCII = 40; + /** RegularExpression Id. */ + int H = 41; + /** RegularExpression Id. */ + int UNICODE = 42; + /** RegularExpression Id. */ + int ESCAPE = 43; + /** RegularExpression Id. */ + int NMSTART = 44; + /** RegularExpression Id. */ + int NMCHAR = 45; + /** RegularExpression Id. */ + int STRINGCHAR = 46; + /** RegularExpression Id. */ + int D = 47; + /** RegularExpression Id. */ + int NAME = 48; + /** RegularExpression Id. */ + int TO = 49; + /** RegularExpression Id. */ + int THROUGH = 50; + /** RegularExpression Id. */ + int EACH_IN = 51; + /** RegularExpression Id. */ + int FROM = 52; + /** RegularExpression Id. */ + int MIXIN_SYM = 53; + /** RegularExpression Id. */ + int INCLUDE_SYM = 54; + /** RegularExpression Id. */ + int FUNCTION_SYM = 55; + /** RegularExpression Id. */ + int RETURN_SYM = 56; + /** RegularExpression Id. */ + int DEBUG_SYM = 57; + /** RegularExpression Id. */ + int WARN_SYM = 58; + /** RegularExpression Id. */ + int FOR_SYM = 59; + /** RegularExpression Id. */ + int EACH_SYM = 60; + /** RegularExpression Id. */ + int WHILE_SYM = 61; + /** RegularExpression Id. */ + int IF_SYM = 62; + /** RegularExpression Id. */ + int ELSE_SYM = 63; + /** RegularExpression Id. */ + int EXTEND_SYM = 64; + /** RegularExpression Id. */ + int MOZ_DOCUMENT_SYM = 65; + /** RegularExpression Id. */ + int SUPPORTS_SYM = 66; + /** RegularExpression Id. */ + int CONTENT_SYM = 67; + /** RegularExpression Id. */ + int MICROSOFT_RULE = 68; + /** RegularExpression Id. */ + int IF = 69; + /** RegularExpression Id. */ + int GUARDED_SYM = 70; + /** RegularExpression Id. */ + int STRING = 71; + /** RegularExpression Id. */ + int IDENT = 72; + /** RegularExpression Id. */ + int NUMBER = 73; + /** RegularExpression Id. */ + int _URL = 74; + /** RegularExpression Id. */ + int URL = 75; + /** RegularExpression Id. */ + int VARIABLE = 76; + /** RegularExpression Id. */ + int PERCENTAGE = 77; + /** RegularExpression Id. */ + int PT = 78; + /** RegularExpression Id. */ + int MM = 79; + /** RegularExpression Id. */ + int CM = 80; + /** RegularExpression Id. */ + int PC = 81; + /** RegularExpression Id. */ + int IN = 82; + /** RegularExpression Id. */ + int PX = 83; + /** RegularExpression Id. */ + int EMS = 84; + /** RegularExpression Id. */ + int LEM = 85; + /** RegularExpression Id. */ + int REM = 86; + /** RegularExpression Id. */ + int EXS = 87; + /** RegularExpression Id. */ + int DEG = 88; + /** RegularExpression Id. */ + int RAD = 89; + /** RegularExpression Id. */ + int GRAD = 90; + /** RegularExpression Id. */ + int MS = 91; + /** RegularExpression Id. */ + int SECOND = 92; + /** RegularExpression Id. */ + int HZ = 93; + /** RegularExpression Id. */ + int KHZ = 94; + /** RegularExpression Id. */ + int DIMEN = 95; + /** RegularExpression Id. */ + int HASH = 96; + /** RegularExpression Id. */ + int IMPORT_SYM = 97; + /** RegularExpression Id. */ + int MEDIA_SYM = 98; + /** RegularExpression Id. */ + int CHARSET_SYM = 99; + /** RegularExpression Id. */ + int PAGE_SYM = 100; + /** RegularExpression Id. */ + int FONT_FACE_SYM = 101; + /** RegularExpression Id. */ + int KEY_FRAME_SYM = 102; + /** RegularExpression Id. */ + int ATKEYWORD = 103; + /** RegularExpression Id. */ + int IMPORTANT_SYM = 104; + /** RegularExpression Id. */ + int RANGE0 = 105; + /** RegularExpression Id. */ + int RANGE1 = 106; + /** RegularExpression Id. */ + int RANGE2 = 107; + /** RegularExpression Id. */ + int RANGE3 = 108; + /** RegularExpression Id. */ + int RANGE4 = 109; + /** RegularExpression Id. */ + int RANGE5 = 110; + /** RegularExpression Id. */ + int RANGE6 = 111; + /** RegularExpression Id. */ + int RANGE = 112; + /** RegularExpression Id. */ + int UNI = 113; + /** RegularExpression Id. */ + int UNICODERANGE = 114; + /** RegularExpression Id. */ + int REMOVE = 115; + /** RegularExpression Id. */ + int APPEND = 116; + /** RegularExpression Id. */ + int CONTAINS = 117; + /** RegularExpression Id. */ + int FUNCTION = 118; + /** RegularExpression Id. */ + int UNKNOWN = 119; + + /** Lexical state. */ + int DEFAULT = 0; + /** Lexical state. */ + int IN_FORMAL_COMMENT = 1; + /** Lexical state. */ + int IN_MULTI_LINE_COMMENT = 2; + + /** Literal token values. */ + String[] tokenImage = { + "", + "", + "", + "", + "\"/*\"", + "\"*/\"", + "\"*/\"", + "", + "\"\"", + "\"{\"", + "\"}\"", + "\"|=\"", + "\"^=\"", + "\"$=\"", + "\"*=\"", + "\"~=\"", + "\"=\"", + "\"+\"", + "\"-\"", + "\",\"", + "\";\"", + "\">\"", + "\"~\"", + "\"<\"", + "\"/\"", + "\"[\"", + "\"]\"", + "\"*\"", + "\"%\"", + "\"&\"", + "\".\"", + "\"(\"", + "\")\"", + "\"==\"", + "\"||\"", + "\"&&\"", + "\"!=\"", + "\":\"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "\"to\"", + "\"through\"", + "\"in\"", + "\"from\"", + "\"@mixin\"", + "\"@include\"", + "\"@function\"", + "\"@return\"", + "\"@debug\"", + "\"@warn\"", + "\"@for\"", + "\"@each\"", + "\"@while\"", + "\"@if\"", + "\"@else\"", + "\"@extend\"", + "\"@-moz-document\"", + "\"@supports\"", + "\"@content\"", + "", + "\"if\"", + "", + "", + "", + "", + "<_URL>", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "\"@import\"", + "\"@media\"", + "\"@charset\"", + "\"@page\"", + "\"@font-face\"", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj deleted file mode 100644 index 0a69342d9a..0000000000 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserImpl.jj +++ /dev/null @@ -1,3028 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -/* -*-java-extended-*- - * Copyright (c) 1999 World Wide Web Consortium - * (Massachusetts Institute of Technology, Institut National de Recherche - * en Informatique et en Automatique, Keio University). - * All Rights Reserved. http://www.w3.org/Consortium/Legal/ - * - * $Id: Parser.jj,v 1.15 2000/10/27 21:09:37 plehegar Exp $ - */ - -options { - IGNORE_CASE = true; - STATIC = false; - USER_CHAR_STREAM = true; - /* DEBUG_TOKEN_MANAGER = true; - DEBUG_PARSER = true; */ -} - -PARSER_BEGIN(ParserImpl) - -package com.vaadin.sass.internal.parser; - -import java.io.*; -import java.net.*; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Map; -import java.util.UUID; - -import org.w3c.css.sac.ConditionFactory; -import org.w3c.css.sac.Condition; -import org.w3c.css.sac.SelectorFactory; -import org.w3c.css.sac.SelectorList; -import org.w3c.css.sac.Selector; -import org.w3c.css.sac.SimpleSelector; -import org.w3c.css.sac.DocumentHandler; -import org.w3c.css.sac.InputSource; -import org.w3c.css.sac.ErrorHandler; -import org.w3c.css.sac.CSSException; -import org.w3c.css.sac.CSSParseException; -import org.w3c.css.sac.Locator; -import org.w3c.css.sac.LexicalUnit; - -import org.w3c.flute.parser.selectors.SelectorFactoryImpl; -import org.w3c.flute.parser.selectors.ConditionFactoryImpl; - -import org.w3c.flute.util.Encoding; - -import com.vaadin.sass.internal.handler.*; - -import com.vaadin.sass.internal.tree.*; - -/** - * A CSS2 parser - * - * @author Philippe Le H�garet - * @version $Revision: 1.15 $ - */ -public class ParserImpl implements org.w3c.css.sac.Parser, Parser { - - // replaces all \t, \n, etc with this StringBuffer. - static final StringBuilder SPACE = new StringBuilder(" "); - - // the document handler for the parser - protected SCSSDocumentHandlerImpl documentHandler; - // the error handler for the parser - protected ErrorHandler errorHandler; - // the input source for the parser - protected InputSource source; - - protected ConditionFactory conditionFactory; - protected SelectorFactory selectorFactory; - - // temporary place holder for pseudo-element ... - private String pseudoElt; - - /** - * Creates a new Parser - */ - public ParserImpl() { - this((CharStream) null); - } - - /** - * @@TODO - * @exception CSSException Not yet implemented - */ - public void setLocale(Locale locale) throws CSSException { - throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); - } - - public InputSource getInputSource(){ - return source; - } - - /** - * Set the document handler for this parser - */ - public void setDocumentHandler(DocumentHandler handler) { - this.documentHandler = (SCSSDocumentHandlerImpl) handler; - } - - public void setSelectorFactory(SelectorFactory selectorFactory) { - this.selectorFactory = selectorFactory; - } - - public void setConditionFactory(ConditionFactory conditionFactory) { - this.conditionFactory = conditionFactory; - } - - /** - * Set the error handler for this parser - */ - public void setErrorHandler(ErrorHandler error) { - this.errorHandler = error; - } - - /** - * Main parse methods - * - * @param source the source of the style sheet. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleSheet(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - - parserUnit(); - } - - /** - * Convenient method for URIs. - * - * @param systemId the fully resolved URI of the style sheet. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleSheet(String systemId) - throws CSSException, IOException { - parseStyleSheet(new InputSource(systemId)); - } - - /** - * This method parses only one rule (style rule or at-rule, except @charset). - * - * @param source the source of the rule. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - // TODO required by original parser but not used by Vaadin? - public void parseRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseRule(); - } - - /** - * This method parses a style declaration (including the surrounding curly - * braces). - * - * @param source the source of the style declaration. - * @exception IOException the source can't be parsed. - * @exception CSSException the source is not CSS valid. - */ - public void parseStyleDeclaration(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseDeclarationBlock(); - } - - /** - * This methods returns "http://www.w3.org/TR/REC-CSS2". - * @return the string "http://www.w3.org/TR/REC-CSS2". - */ - public String getParserVersion() { - return "http://www.w3.org/TR/REC-CSS2"; - } - - /** - * Parse methods used by DOM Level 2 implementation. - */ - public void parseImportRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseImportRule(); - } - - public void parseMediaRule(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - if (selectorFactory == null) { - selectorFactory = new SelectorFactoryImpl(); - } - if (conditionFactory == null) { - conditionFactory = new ConditionFactoryImpl(); - } - _parseMediaRule(); - } - - public SelectorList parseSelectors(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return null; - } - - public LexicalUnit parsePropertyValue(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return expr(); - } - - public boolean parsePriority(InputSource source) - throws CSSException, IOException { - this.source = source; - ReInit(getCharStreamWithLurk(source)); - - return prio(); - } - - /** - * Convert the source into a Reader. Used only by DOM Level 2 parser methods. - */ - private Reader getReader(InputSource source) throws IOException { - if (source.getCharacterStream() != null) { - return source.getCharacterStream(); - } else if (source.getByteStream() != null) { - // My DOM level 2 implementation doesn't use this case. - if (source.getEncoding() == null) { - // unknown encoding, use ASCII as default. - return new InputStreamReader(source.getByteStream(), "ASCII"); - } else { - return new InputStreamReader(source.getByteStream(), - source.getEncoding()); - } - } else { - // systemId - // @@TODO - throw new CSSException("not yet implemented"); - } - } - - /** - * Convert the source into a CharStream with encoding informations. - * The encoding can be found in the InputSource or in the CSS document. - * Since this method marks the reader and make a reset after looking for - * the charset declaration, you'll find the charset declaration into the - * stream. - */ - private CharStream getCharStreamWithLurk(InputSource source) - throws CSSException, IOException { - if (source.getCharacterStream() != null) { - // all encoding are supposed to be resolved by the user - // return the reader - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } else if (source.getByteStream() == null) { - // @@CONTINUE ME. see also getReader() with systemId - try { - source.setByteStream(new URL(source.getURI()).openStream()); - } catch (Exception e) { - try { - source.setByteStream(new FileInputStream(source.getURI())); - } catch (IOException ex) { - throw new CSSException("invalid url ?"); - } - } - } - //use UTF-8 as the default encoding. - String encoding = source.getEncoding(); - InputStream input = source.getByteStream(); - if (!input.markSupported()) { - // If mark is not supported, wrap it in a stream which supports mark - input = new BufferedInputStream(input); - source.setByteStream(input); - } - // Mark either the original stream or the wrapped stream - input.mark(100); - if(encoding == null){ - encoding = "ASCII"; - - char c = ' '; - - c = (char) input.read(); - - if (c == '@') { - // hum, is it a charset ? - int size = 100; - byte[] buf = new byte[size]; - input.read(buf, 0, 7); - String keyword = new String(buf, 0, 7); - if (keyword.equals("charset")) { - // Yes, this is the charset declaration ! - - // here I don't use the right declaration : white space are ' '. - while ((c = (char) input.read()) == ' ') { - // find the first quote - } - char endChar = c; - int i = 0; - - if ((endChar != '"') && (endChar != '\'')) { - // hum this is not a quote. - throw new CSSException("invalid charset declaration"); - } - - while ((c = (char) input.read()) != endChar) { - buf[i++] = (byte) c; - if (i == size) { - byte[] old = buf; - buf = new byte[size + 100]; - System.arraycopy(old, 0, buf, 0, size); - size += 100; - } - } - while ((c = (char) input.read()) == ' ') { - // find the next relevant character - } - if (c != ';') { - // no semi colon at the end ? - throw new CSSException("invalid charset declaration: " - + "missing semi colon"); - } - encoding = new String(buf, 0, i); - if (source.getEncoding() != null) { - // compare the two encoding informations. - // For example, I don't accept to have ASCII and after UTF-8. - // Is it really good ? That is the question. - if (!encoding.equals(source.getEncoding())) { - throw new CSSException("invalid encoding information."); - } - } - } // else no charset declaration available - } - } - // ok set the real encoding of this source. - source.setEncoding(encoding); - // set the real reader of this source. - source.setCharacterStream(new InputStreamReader(source.getByteStream(), - Encoding.getJavaEncoding(encoding))); - // reset the stream (leave the charset declaration in the stream). - input.reset(); - - return new Generic_CharStream(source.getCharacterStream(), 1, 1); - } - - private LocatorImpl currentLocator; - private Locator getLocator() { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this, token.beginLine, token.beginColumn); - return currentLocator; - } - return currentLocator.reInit(this, token.beginLine, token.beginColumn); - } - private LocatorImpl getLocator(Token save) { - if (currentLocator == null) { - currentLocator = new LocatorImpl(this, save.beginLine, save.beginColumn); - return currentLocator; - } - return currentLocator.reInit(this, save.beginLine, save.beginColumn); - } - - private void reportError(Locator l, Exception e) { - if (errorHandler != null) { - if (e instanceof ParseException) { - // construct a clean error message. - ParseException pe = (ParseException) e; - if (pe.specialConstructor) { - StringBuffer errorM = new StringBuffer(); - if (pe.currentToken != null) { - errorM.append("encountered \"") - .append(pe.currentToken.next); - } - errorM.append('"'); - if (pe.expectedTokenSequences.length != 0) { - errorM.append(". Was expecting one of: "); - for (int i = 0; i < pe.expectedTokenSequences.length; i++) { - for (int j = 0; j < pe.expectedTokenSequences[i].length; j++) { - int kind = pe.expectedTokenSequences[i][j]; - if (kind != S) { - errorM.append(pe.tokenImage[kind]); - errorM.append(' '); - } - } - } - } - errorHandler.error(new CSSParseException(errorM.toString(), - l, e)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), - l, e)); - } - } else if (e == null) { - errorHandler.error(new CSSParseException("error", l, null)); - } else { - errorHandler.error(new CSSParseException(e.getMessage(), l, e)); - } - } - } - - private void reportWarningSkipText(Locator l, String text) { - if (errorHandler != null && text != null) { - errorHandler.warning(new CSSParseException("Skipping: " + text, l)); - } - } -} - -PARSER_END(ParserImpl) - -/* - * The tokenizer - */ - - -TOKEN : -{ - < S : ( [ " ", "\t" , "\n" , "\r", "\f" ] )+ > - { image = ParserImpl.SPACE; } -} - -/* - * for fixing #11638: Ending an imported SCSS file with a comment causes an error in the Sass. - * now the single line comment is parsed as special token, before, they were simply skipped. - * solution got from http://www.engr.mun.ca/~theo/JavaCC-FAQ/javacc-faq-moz.htm#tth_sEc3.15 - */ - -SPECIAL_TOKEN : { -< SINGLE_LINE_COMMENT: "//"(~["\n","\r"])* ("\n"|"\r"|"\r\n")? > } - - -MORE : -{ - <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT -| - "/*" : IN_MULTI_LINE_COMMENT -} - -SPECIAL_TOKEN : -{ - : DEFAULT -} - - -SKIP : -{ - : DEFAULT -} - - -MORE : -{ - < ~[] > -} - - -TOKEN : -{ - < CDO : "" > - | < LBRACE : "{" > - | < RBRACE : "}"> - | < DASHMATCH : "|=" > - | < CARETMATCH : "^=" > - | < DOLLARMATCH : "$=" > - | < STARMATCH : "*=" > - | < INCLUDES : "~=" > - | < EQ : "=" > - | < PLUS : "+" > - | < MINUS : "-" > - | < COMMA : "," > - | < SEMICOLON : ";" > - | < PRECEDES : ">" > - | < SIBLING : "~" > - | < SUCCEEDS : "<" > - | < DIV : "/" > - | < LBRACKET : "[" > - | < RBRACKET : "]" > - | < ANY : "*" > - | < MOD : "%" > - | < PARENT : "&" > - | < DOT : "." > - | < LPARAN : "(" > - | < RPARAN : ")"> - | < COMPARE : "==" > - | < OR : "||" > - | < AND : "&&" > - | < NOT_EQ : "!=" > -} - - -TOKEN : -{ - < COLON : ":" > -} - -< DEFAULT > -TOKEN : -{ - < INTERPOLATION : "#{"< VARIABLE > "}"> -} - - -TOKEN : /* basic tokens */ -{ - < NONASCII : ["\200"-"\377"] > - | < #H : ["0"-"9", "a"-"f"] > - | < #UNICODE : "\\" ( )? /* I can't say {1,6} */ - ( )? ( )? - ( )? ( )? - ( [ " ", "\t" , "\n" , "\r", "\f" ] )? > - | < #ESCAPE : | ( "\\" [ " "-"~","\200"-"\377" ] ) > - | < #NMSTART : ("-")?[ "a"-"z","_"] | | > - | < #NMCHAR : ["a"-"z", "0"-"9", "-", "_"] | | > - | < #STRINGCHAR : [ "\t"," ","!","#","$","%","&","("-"~" ] - | "\\\n" | "\\\r\n" | "\\\r" | "\\\f" - | | > - | < #D : ["0"-"9"] > - | < #NAME : ( )+ > - -} - - -TOKEN : -{ - - | - | - | -} - -/* DERECTIVES */ - -TOKEN : -{ - - | - | - | - | - | - | - | - | - | - | - | - | - | - | -} - -< DEFAULT > -TOKEN: -{ - < MICROSOFT_RULE : "filter"|"-ms-filter" > -} - -< DEFAULT > -TOKEN: -{ - < IF : "if" > -} - - -TOKEN: -{ - < GUARDED_SYM : "!" ( )? "default"> -} - - -TOKEN : -{ - < STRING : ( "\"" ( | "'" )* "\"" ) | - ( "'" ( | "\"" )* "'" ) > - | < IDENT : ( )* > - | < NUMBER : ( )+ | ( )* "." ( )+ > - | < #_URL : [ "!","#","$","%","&","*"-"~" ] | | > - | < URL : "url(" ( )* - ( | ( <_URL> )* ) ( )* ")" > -} - - -TOKEN: -{ - < VARIABLE : "$" > -} - - -TOKEN : -{ - < PERCENTAGE : "%" > - | < PT : "pt" > - | < MM : "mm" > - | < CM : "cm" > - | < PC : "pc" > - | < IN : "in" > - | < PX : "px" > - | < EMS : "em" > - | < LEM : "lem" > - | < REM : "rem" > - | < EXS : "ex" > - | < DEG : "deg" > - | < RAD : "rad" > - | < GRAD : "grad" > - | < MS : "ms" > - | < SECOND : "s" > - | < HZ : "Hz" > - | < KHZ : "kHz" > - | < DIMEN : > -} - - -TOKEN : -{ - < HASH : "#" > -} - -/* RESERVED ATRULE WORDS */ - -TOKEN : -{ - < IMPORT_SYM : "@import"> - | < MEDIA_SYM : "@media" > - | < CHARSET_SYM : "@charset" > - | < PAGE_SYM : "@page" > - | < FONT_FACE_SYM: "@font-face" > - | < KEY_FRAME_SYM: "@keyframes" | "@-moz-keyframes" | "@-o-keyframes" | "@-webkit-keyframes" | "@-ms-keyframes"> - | < ATKEYWORD : "@" > -} - - -TOKEN : -{ - < IMPORTANT_SYM : "!" ( )? "important" > -} - - -TOKEN : -{ - < #RANGE0 : > - | < #RANGE1 : ( "?" )? > - | < #RANGE2 : ( "?" )? ( "?" )? > - | < #RANGE3 : ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE4 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE5 : ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE6 : "?" ( "?" )? ( "?" )? ( "?" )? ( "?" )? ( "?" )? > - | < #RANGE : | | - | | | | > - | < #UNI : ( )? ( )? ( )? ( )? ( )? > - | < UNICODERANGE : "U+" - | "U+" "-" > -} - -< DEFAULT > -TOKEN : -{ - < REMOVE : "remove" (< S >)? "(" > - | < APPEND : "append" (< S >)? "(" > - | < CONTAINS : "contains" (< S >)? "(" > -} - - -TOKEN : -{ - < FUNCTION : (< S >)* "(" > -} - - -TOKEN : -{ /* avoid token manager error */ - < UNKNOWN : ~[] > -} - -/* - * The grammar of CSS2 - */ - -/** - * The main entry for the parser. - * - * @exception ParseException exception during the parse - */ -void parserUnit() : -{} -{ - try { - { documentHandler.startDocument(source); } - ( charset() )? - ( comments() - | ignoreStatement() )* - ( importDeclaration() ( ignoreStatement() ( )* )* )* - afterImportDeclaration() - - } finally { - documentHandler.endDocument(source); - } -} - -void charset() : -{ Token n; } -{ - try { - ( )* n= ( )* ";" - } catch (ParseException e) { - reportError(getLocator(e.currentToken.next), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (Exception e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } -} - -void afterImportDeclaration() : -{String ret; - Locator l; -} -{ - ( - ( debuggingDirective() | mixinDirective() | controlDirective() | includeDirective() | styleRule() | media() - | page() | fontFace() | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() - | { l = getLocator(); } ret=skipStatement() - { - if ((ret == null) || (ret.length() == 0)) { - return; - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(l, ret); - } - } - ) - ( ignoreStatement() ( )* )* )* -} - -void ignoreStatement() : -{} -{ - | | atRuleDeclaration() -} - -/** - * The import statement - * - * @exception ParseException exception during the parse - */ -void importDeclaration() : -{Token n; - String uri; - MediaListImpl ml = new MediaListImpl(); - boolean isURL = false; -} -{ - try { - - ( )* ( n= { uri = convertStringIndex(n.image, 1, - n.image.length() -1); } - | n= - { - isURL=true; - uri = n.image.substring(4, n.image.length()-1).trim(); - if ((uri.charAt(0) == '"') - || (uri.charAt(0) == '\'')) { - uri = uri.substring(1, uri.length()-1); - } - } - ) - ( )* mediaStatement(ml) ";" - ( )* - { - if (ml.getLength() == 0) { - // see section 6.3 of the CSS2 recommandation. - ml.addItem("all"); - } - documentHandler.importStyle(uri, ml, isURL); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } -} - -/** - * @exception ParseException exception during the parse - */ -void keyframes() : -{ - Token n; - boolean start = false; - String keyframeName = null; - String animationname = ""; -} -{ - try { - n= ( )* {keyframeName = n.image;} - (n = {animationname += n.image; }|n = < INTERPOLATION >{ animationname += n.image; })+()* - {start = true; documentHandler.startKeyFrames(keyframeName, animationname); } - ( )* ( keyframeSelector() | contentDirective() )* ( )* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - } finally { - if (start) { - documentHandler.endKeyFrames(); - } - } -} - -void keyframeSelector(): -{ - Token n; - String selector = ""; - boolean start = false; -} -{ - try{ - (n = | n = | n = ){selector += n.image;} ()* - ( ()* (n = | n = | n = ) {selector += (", " + n.image);} ()* )* - ()* - { - start = true; - documentHandler.startKeyframeSelector(selector); - } - (ifContentStatement() | microsoftExtension() )* - ()* - } - catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn-1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endKeyframeSelector(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -/* see http://www.w3.org/TR/css3-mediaqueries/ */ -void media() : -{ - boolean start = false; - String ret; - MediaListImpl ml = new MediaListImpl(); -} -{ - try { - ( )* - mediaStatement(ml) - { start = true; documentHandler.startMedia(ml); } - ( )* ( debuggingDirective() | styleRule() | skipUnknownRule() )* ( )* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endMedia(ml); - } - } -} - -void mediaStatement(MediaListImpl ml) : -{ - Token t; -} -{ - { - t = getToken(1); - // loop over comma separated parts, add each to ml - while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - if (t.kind == COMMA) { - // skip the comma and the token before it that is still the active token - getNextToken(); - getNextToken(); - t = getToken(1); - } - String str = s.toString().trim(); - if (str.length() > 0) { - ml.addItem(str); - } - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String medium() : /* tv, projection, screen, ... */ -{Token n;} -{ - n= { return convertIdent(n.image); } -} - -/** - * @exception ParseException exception during the parse - */ -void page() : -{ - boolean start = false; - Token n = null; - String page = null; - String pseudo = null; -} -{ - try { - ( )* ( n= ( )* )? - ( pseudo=pseudo_page() )? - { - if (n != null) { - page = convertIdent(n.image); - } - } - ()* - { - start = true; - documentHandler.startPage(page, pseudo); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - } catch (ParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - skipStatement(); - // reportWarningSkipText(li, skipStatement()); - } else { - skipStatement(); - } - } finally { - if (start) { - documentHandler.endPage(page, pseudo); - } - } -} - -String pseudo_page() : -{ Token n; } -{ - ":" n= ( )* { return convertIdent(n.image); } -} - -void fontFace() : -{ - boolean start = false; -} -{ - try { - ( )* - ()* - { start = true; documentHandler.startFontFace(); } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endFontFace(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -void atRuleDeclaration() : -{Token n; - String ret; -} -{ - n= - { - ret=skipStatement(); - if ((ret != null) && (ret.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(getLocator(), ret); - } - } -} - -void skipUnknownRule() : -{ Token n;} -{ - ( n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n= -| n=";" -| n="-" -| n= - ) { - String ret; - Locator loc = getLocator(); - ret=skipStatement(); - if ((ret != null) && (n.image.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(loc, ret); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -char combinator() : -{ -char connector = ' '; -} -{ - (connector = combinatorChar() - | (connector = combinatorChar())?) { return connector; } -} - -/**to refactor combinator and reuse in selector().*/ -char combinatorChar() : -{Token t;} -{ - (t = | t = | t = ) ()* - { - return t.image.charAt(0); - } -} - -void microsoftExtension() : -{ - Token n; - String name = ""; - String value = ""; -} - -{ - // This is not really taking the syntax of filter rules into account - n = < MICROSOFT_RULE > (< S >)* { name = n.image; } - < COLON > - ((n = < IDENT > { value += n.image; }) - | (n = < NUMBER > { value += n.image; }) - | (n = < STRING > { value += n.image; }) - | (n = < COMMA > { value += n.image; }) - | (n = < INTERPOLATION > { value += n.image; }) - | (n = < COLON > { value += n.image; }) - | (n = < FUNCTION > { value += n.image; }) - | (n = < RPARAN > { value += n.image; }) - | (n = < EQ > { value += n.image; }) - | (n = < DOT > { value += n.image; }) - | (n = < S > { if(value.lastIndexOf(' ') != value.length()-1) - { value += n.image; } } - ) )+ - < SEMICOLON > - (< S >)* - { documentHandler.microsoftDirective(name, value); } -} - -/** - * @exception ParseException exception during the parse - */ -String property() : -{Token t;String s = ""; -} -{ - (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+(< S >)* - { - return s; - } -} - -String variableName() : -{Token n;} -{ - n= ()* {return convertIdent(n.image.substring(1));} -} - -String functionName() : -{Token n;} -{ - n= ( )* {return convertIdent(n.image.substring(0, n.image.length()-1));} -} -/** - * @exception ParseException exception during the parse - */ -void styleRule() : -{ - boolean start = false; - ArrayList l = null; - Token save; - Locator loc; -} -{ - try { - l=selectorList() { save = token; } ()* - { - start = true; - documentHandler.startSelector(l); - } - // a CSS import here will not work - ( ifContentStatement() | microsoftExtension() | importDeclaration() )* - ()* - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn-1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endSelector(); - } - } -} - - ArrayList selectorList() : -{ - ArrayList selectors = new ArrayList(); - String selector; -} -{ - selector=selector() ( ()* { selectors.add(selector); } - selector=selector() )* - { selectors.add(selector); - return selectors; - } -} - -/** - * @exception ParseException exception during the parse - */ -String selector() : -{ - String selector = null; - char comb; -} -{ - try { - // the selector can begin either a simple_selector, or a combinatorChar(+, >, ~). - // when beginning with combinatorChar, the next one should be a simple_selector(). - (selector=simple_selector(null, ' ') | (comb=combinatorChar() selector=simple_selector(selector, comb))) - ( LOOKAHEAD(2) comb=combinator() - selector=simple_selector(selector, comb) )* ()* - { - return selector; - } - } catch (ParseException e) { - /* - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - reportWarningSkipText(getLocator(), s.toString()); - */ - Token t = getToken(1); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - getNextToken(); - t = getToken(1); - } - - throw new ThrowedParseException(e); - } -} - -/** - * @exception ParseException exception during the parse - */ -String simple_selector(String selector, char comb) : -{ - String simple_current = null; - String cond = null; - - pseudoElt = null; -} -{ - ( (simple_current=element_name() - ( cond=hash(cond) | cond=_class(cond) - | cond=attrib(cond) | cond=pseudo(cond) )* ) - | ( cond = hash(cond) | cond=_class(cond) - | cond=attrib(cond) | cond=pseudo(cond) )+ - ) - { - if (simple_current == null) { - simple_current = ""; - } - if (cond != null) { - simple_current = simple_current + cond; - } - StringBuilder builder = new StringBuilder(); - switch (comb) { - case ' ': - if(selector!=null){ - builder.append(selector).append(" "); - } - break; - case '+': - case '>': - case '~': - if(selector!=null){ - builder.append(selector).append(" "); - } - builder.append(comb).append(" "); - break; - default: - throw new ParseException("invalid state. send a bug report"); - } - builder.append(simple_current); - selector = builder.toString(); - - if (pseudoElt != null) { - selector = selector + pseudoElt; - } - return selector; - } -} - -/** - * @exception ParseException exception during the parse - */ -String _class(String pred) : -{Token t; -String s = "."; -} -{ - "." (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ - { - - if (pred == null) { - return s; - } else { - return pred + s; - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String element_name() : -{Token t; String s = "";} -{ - (t = {s += t.image; }|t = < INTERPOLATION >{ s += t.image; })+ - { - return s; - } - | "*" - { return "*"; } - | "&" - { return "&"; } -} - -/** - * @exception ParseException exception during the parse - */ -String attrib(String pred) : -{ - int cases = 0; - Token att = null; - Token val = null; - String attValue = null; -} -{ - "[" ( )* att= ( )* - ( ( "=" { cases = 1; } - | { cases = 2; } - | { cases = 3; } - | { cases = 4; } - | { cases = 5; } - | { cases = 6; } ) ( )* - ( val= { attValue = val.image; } - | val= { attValue = val.image; } - ) - ( )* )? - "]" - { - String name = convertIdent(att.image); - String c; - switch (cases) { - case 0: - c = name; - break; - case 1: - c = name + "=" + attValue; - break; - case 2: - c = name + "~=" + attValue; - break; - case 3: - c = name + "|=" +attValue; - break; - case 4: - c = name + "^=" +attValue; - break; - case 5: - c = name + "$=" +attValue; - break; - case 6: - c = name + "*=" +attValue; - break; - default: - // never reached. - c = null; - } - c = "[" + c + "]"; - if (pred == null) { - return c; - } else { - return pred + c; - } - } -} - -/** - * @exception ParseException exception during the parse - */ -String pseudo(String pred) : -{Token n; -Token param; -String d; -boolean isPseudoElement = false; -} -{ - ":" (":"{isPseudoElement=true;})?( n= - { - String s = ":" + convertIdent(n.image); - if (isPseudoElement) { - if (pseudoElt != null) { - throw new CSSParseException("duplicate pseudo element definition " - + s, getLocator()); - } else { - pseudoElt = ":"+s; - return pred; - } - } else { - String c = s; - if (pred == null) { - return c; - } else { - return pred + c; - } - } - } - | ( n= ( )* d=skipStatementUntilMatchingRightParan() - { - // accept anything between function and a right parenthesis - String f = convertIdent(n.image); - String colons = isPseudoElement ? "::" : ":"; - String pseudofn = colons + f + d + ")"; - if (pred == null) { - return pseudofn; - } else { - return pred + pseudofn; - } - } - ) - ) -} - -/** - * @exception ParseException exception during the parse - */ -String hash(String pred) : -{Token n; } -{ - n= - { - String d = n.image; - if (pred == null) { - return d; - } else { - return pred + d; - } - } -} - -void variable() : -{ - String name; - LexicalUnitImpl exp = null; - boolean guarded = false; - String raw; -} -{ - try{ - name = variableName() - ":" ( )* exp=expr() ( guarded=guarded() )?(";"()*)+ - //raw=skipStatementUntilSemiColon() - { - documentHandler.variable(name, exp, guarded); - } - }catch (JumpException e) { - skipAfterExpression(); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - } else { - skipAfterExpression(); - } - } -} - -void controlDirective() : -{} -{ - ifDirective() | eachDirective() -} - -void ifContentStatement() : -{} -{ - contentDirective() | includeDirective() | media() | extendDirective() | styleRuleOrDeclarationOrNestedProperties() - | keyframes() | LOOKAHEAD(variable()) variable() | listModifyDirective() | controlDirective() | atRuleDeclaration() -} - -void ifDirective() : -{ - Token n = null; - String s = null; - String evaluator = ""; -} -{ - < IF_SYM > - ( s = booleanExpressionToken() { evaluator += s;} )+ - < LBRACE >(< S >)* - { documentHandler.startIfElseDirective(); - documentHandler.ifDirective(evaluator); - } - ( ifContentStatement() | fontFace() )* - < RBRACE >(< S >)* - (elseDirective())* - { documentHandler.endIfElseDirective(); } -} - -void elseDirective() : -{ - String evaluator = ""; - Token n = null; - String s = null; -} -{ - < ELSE_SYM >(< S >)* - ( < IF > ( s = booleanExpressionToken() { evaluator += s; } )+ )? - < LBRACE >(< S >)* - { if(!evaluator.trim().equals("")){ documentHandler.ifDirective(evaluator); } - else{ documentHandler.elseDirective(); } - } - ( ifContentStatement() | fontFace() )* - < RBRACE >(< S >)* -} - -String booleanExpressionToken() : -{ - Token n = null; - String s = null; -} -{ - ( - LOOKAHEAD(containsDirective()) - s = containsDirective() - |n = < VARIABLE > - |n = < IDENT > - |n = < NUMBER > - |n = < LPARAN > - |n = < RPARAN > - |n = < PLUS > - |n = < MINUS > - |n = < DIV > - |n = < ANY > - |n = < COMPARE > - |n = < EQ > - |n = < PRECEDES > - |n = < SUCCEEDS > - |n = < OR > - |n = < AND > - |n = < S > - |n = < NOT_EQ > -){ - if(n!=null){return n.image;} - else{return s;} - } -} - -void eachDirective() : -{ - Token var; - ArrayList list = null; - String listVariable = null; -} -{ - < EACH_SYM > - (< S >)* - var = < VARIABLE > (< S >)* < EACH_IN > (< S >)* - (list = stringList() - {documentHandler.startEachDirective(var.image, list);} - |listVariable = variableName() - {documentHandler.startEachDirective(var.image, listVariable);} - ) - < LBRACE >(< S >)* - ( ifContentStatement() )* - < RBRACE >(< S >)* - { documentHandler.endEachDirective();} -} - -ArrayList stringList(): -{ - ArrayList strings = new ArrayList(); - Token input; -} -{ - (input = < IDENT > (< S >)*) - { strings.add(input.image); } - - (< COMMA >(< S >)* input = < IDENT > { strings.add(input.image); } (< S >)*)* - { return strings; } - -} - -void mixinDirective() : -{ - String name; - ArrayList args = null; - String body; -} -{ - - ()* - (name = property() - |(name = functionName() - args = arglist()) ()*) ()* - {documentHandler.startMixinDirective(name, args);} - ( ifContentStatement() | fontFace() | page())* - ()* - {documentHandler.endMixinDirective(name, args);} -} - -ArrayList arglist() : -{ - ArrayList args = new ArrayList(); - VariableNode arg; - boolean hasNonOptionalArgument = false; -} -{ - arg=mixinArg() ( ()* { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); } - arg=mixinArg() )* - { hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); - return args; - } -} - -JAVACODE -boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) { - boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; - if(currentArgHasArguments) { - if(hasNonOptionalArguments) { throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); - } - return hasNonOptionalArguments; - }else { return true; - } -} - -VariableNode mixinArg() : -{ - String name; - Token variable = null; - LexicalUnitImpl first = null; - LexicalUnitImpl prev = null; - LexicalUnitImpl next = null; -} -{ - name=variableName() (< COLON > (< S >)* - - ( first = nonVariableTerm(null) { - prev = first; } - (LOOKAHEAD(3)(< COMMA >(< S >)*)? prev = nonVariableTerm(prev))* ) - | (variable = < VARIABLE >{ first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, variable.image);} - - ) - )? - { - VariableNode arg = new VariableNode(name, first, false); - return arg; - } -} - -ArrayList argValuelist() : -{ - ArrayList args = new ArrayList(); - LexicalUnitImpl first = null; - LexicalUnitImpl next = null; - LexicalUnitImpl prev = null; -} -{ - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - ( ()* - first = term(null) { args.add(first); prev = first;}((< COLON > (< S >)*)?next=term(prev){prev.setNextLexicalUnit(next); prev = next;})* - )* - {return args;} -} - -void includeDirective() : -{ - String name; - ArrayList args=null; -} -{ - - ()* - (name = property()|name = variableName(){ name = "$"+name;} - |(name = functionName() - args = argValuelist()) ()*) - ((";"()*)+ - {documentHandler.includeDirective(name, args);} - | ()* {documentHandler.startIncludeContentBlock(name, args);} - (styleRuleOrDeclarationOrNestedProperties() | keyframeSelector())* - ()* {documentHandler.endIncludeContentBlock();} - ) -} - -String interpolation() : -{ - Token n; -} -{ - n = < INTERPOLATION > - { - return n.image; - } -} - -void listModifyDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - Token type = null; -} -{ - //refactor, remove those 3 LOOKAHEAD(5). - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - (type = < APPEND> | type = | type= )(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - { - switch (type.kind) { - case APPEND: - documentHandler.appendDirective(variable,list,remove,separator); - break; - case REMOVE: - documentHandler.removeDirective(variable,list,remove,separator); - break; - case CONTAINS: - if(variable == null){ - variable = "$var_"+UUID.randomUUID(); - } - documentHandler.containsDirective(variable,list,remove,separator); - break; - default: - break; - } - } - (< S >)*< SEMICOLON >()* -} - - -/** - * @exception ParseException exception during the parse - */ -void appendDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - < APPEND >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { documentHandler.appendDirective(variable,list,remove,separator); } -} - -/** - * @exception ParseException exception during the parse - */ -void removeDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)* - < REMOVE >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { documentHandler.removeDirective(variable,list,remove,separator); } -} - -/** - * @exception ParseException exception during the parse - */ -String containsDirective() : -{ - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; -} -{ - (n = < VARIABLE >{ variable = n.image; }(< S >)* ":" (< S >)*)? - < CONTAINS >(< S >)* - (list = listModifyDirectiveArgs(0)) - (< RPARAN >)? < COMMA >(< S >)* - (remove = listModifyDirectiveArgs(1)) - ( < COMMA >(< S >)* n = < IDENT >{ separator = n.image; } (< S >)*)? - < RPARAN > - - { /* - *if it is not in the form like "$contains : contains($items, .v-button);" - *for example in @if, like "@if (contains(a b c, b))", then create a temp - *variable for contains(a b c, b); - */ - if(variable == null){ - variable = "$var_"+UUID.randomUUID(); - } - documentHandler.containsDirective(variable,list,remove,separator); - return variable; - } -} - -JAVACODE -String listModifyDirectiveArgs(int nest) -{ - String list = ""; - int nesting = nest; - Token t = null; - - while(true) - { - t = getToken(1); - String s = t.image; - if(t.kind == VARIABLE||t.kind == IDENT) { - list += s; - }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) { - int i = 2; - Token temp = getToken(i); - boolean isLast = true; - while(temp.kind != SEMICOLON) - { if(temp.kind != RPARAN || temp.kind != S) - { isLast = false; } - i++; - temp = getToken(i); - } - - if(isLast) { return list; - } - } else if(t.kind == STRING) { list += s.substring(1,s.length()).substring(0,s.length()-2); - - }else if(t.kind == LPARAN) { nesting++; - if(nesting > nest+1) { throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); - } - }else if(t.kind == RPARAN) { nesting--; - if(nesting == 0) { - return list; - } - } else if(t.kind == COMMA) { - if(nesting == nest) { - return list; }else { - list += ","; } - - }else if(t.kind == S) { - list += " "; } else if(t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", getLocator()); } - getNextToken(); - } -} - -Node returnDirective() : -{ - String raw; -} -{ - raw = skipStatement() - {return null;} -} - -void debuggingDirective() : -{} -{ - debugDirective() | warnDirective() -} - -void debugDirective() : -{} -{ - - { - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. - System.out.println(content); - } - ()* -} - -void warnDirective() : -{} -{ - - { - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. - System.err.println(content); - } - ()* -} - -Node forDirective() : -{ - String var; - String from; - String to; - boolean exclusive; - String body; - Token tok; -} -{ - var = variableName() - { - int[] toThrough = {TO, THROUGH}; - from = skipStatementUntil(toThrough); - } - (tok = {exclusive = true;} - | tok = {exclusive = false;}) - to = skipStatementUntilLeftBrace() - ()* - body = skipStatement() - {return documentHandler.forDirective(var, from, to, exclusive, body);} -} - -Node whileDirective() : -{ - String condition; - String body; -} -{ - condition = skipStatementUntilLeftBrace() - body = skipStatement() - { return documentHandler.whileDirective(condition, body);} -} - -void extendDirective() : -{ArrayList list;} -{ - - ()* - list = selectorList() - (";"()*)+ - {documentHandler.extendDirective(list);} -} - -void contentDirective() : -{} -{ - - ()* - (";"()*)+ - {documentHandler.contentDirective();} -} - -JAVACODE -Node importDirective(){ - return null; -} - -JAVACODE -Node charsetDirective(){ - return null; -} - -JAVACODE -Node mozDocumentDirective(){ - return null; -} - -JAVACODE -Node supportsDirective(){ - return null; -} - - -void nestedProperties(): -{String name; -LexicalUnit exp;} -{ - name=property() - ":" ( )* - ()* - { - documentHandler.startNestedProperties(name); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - - { - documentHandler.endNestedProperties(name); - } - ()* -} -/** - * @exception ParseException exception during the parse - */ -void styleRuleOrDeclarationOrNestedProperties() : -{ -} -{ - try { - // differentiate between the colon of a pseudo and the colon of nested properties and the colon of a simple property - // first check if it is a normal styleRule, if not check if it is declarationOrNestedProperties(), if still fails, most likely, it is - // is styleRule with pseudo selector with contains functions. have to do it in this way, because both the styleRule and declarationOrNestedProperties() - // have 'skipStatementUntilXXX', which cannot be LOOKAHEAD properly. - ( debuggingDirective() | LOOKAHEAD(selectorList()) styleRule() | LOOKAHEAD(3)declarationOrNestedProperties() | styleRule()) - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} -/** - * @exception ParseException exception during the parse - */ -void declarationOrNestedProperties() : -{ boolean important = false; - String name; - LexicalUnitImpl exp; - Token save; - String comment = null; -} -{ - try { - name=property() - { save = token; } - ":" ( )* - (exp=expr() ( important=prio() )? - { - Token next = getToken(1); - if(next.kind == SEMICOLON || next.kind == RBRACE){ - while(next.kind == SEMICOLON){ - skipStatement(); - next = getToken(1); - } - //only add special token kept for sprites '/**' - if(token.specialToken!=null && token.specialToken!=null && token.specialToken.image.startsWith("/**")){ - documentHandler.property(name, exp, important, token.specialToken.image); - }else{ - documentHandler.property(name, exp, important, null); - } - } - } - | ()* - { - documentHandler.startNestedProperties(name); - } - ( declaration() )? ( ";" ( )* ( declaration() )? )* - ()* - { - documentHandler.endNestedProperties(name); - } - ) - - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -void declaration() : -{ boolean important = false; - String name; - LexicalUnit exp; - Token save; -} -{ - try { - name=property() - { save = token; } - ":" ( )* exp=expr() ( important=prio() )? - { - documentHandler.property(name, exp, important); - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), - getLocator(), - e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn-1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - LocatorImpl loc = (LocatorImpl) getLocator(); - loc.column--; - reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } -} - -/** - * @exception ParseException exception during the parse - */ -boolean prio() : -{} -{ - ( )* { return true; } -} - -boolean guarded() : -{} -{ - ()* {return true;} -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl operator(LexicalUnitImpl prev) : -{Token n;} -{ -/* (comments copied from basic_arithmetics.scss) -*supports: -* 1. standard arithmetic operations (+, -, *, /, %) -* 2. / is treated as css operator, unless one of its operands is variable or there is another binary arithmetic operator -*limits: -* 1. cannot mix arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will fail -* 2. space between add and minus operator and their following operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not -* 3. parenthesis is not supported now. -*/ -n="," ( )* { return LexicalUnitImpl.createComma(n.beginLine, - n.beginColumn, - prev); } -|n="/" ( )* { return LexicalUnitImpl.createSlash(n.beginLine, - n.beginColumn, - prev); } -| n="*" ( )* { return LexicalUnitImpl.createMultiply(n.beginLine, - n.beginColumn, - prev); } -| n="%" ( )* { return LexicalUnitImpl.createModulo(n.beginLine, - n.beginColumn, - prev); } -/* -* for '+', since it can be either a binary operator or an unary operator, -* which is ambiguous. To avoid this, the binary operator '+' always has -* a space before the following term. so '2+3' is not a valid binary expression, -* but '2 + 3' is. The same for '-' operator. -*/ - -| n="+" ( )+{ return LexicalUnitImpl.createAdd(n.beginLine, - n.beginColumn, - prev); } -| n="-" ( )+{ return LexicalUnitImpl.createMinus(n.beginLine, - n.beginColumn, - prev); } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl expr() : -{ - LexicalUnitImpl first, res; - char op; -} -{ - first=term(null){ res = first; } - ( LOOKAHEAD(2) ( LOOKAHEAD(2) res=operator(res) )? res=term(res))* - { return first; } -} - -/** - * @exception ParseException exception during the parse - */ -char unaryOperator() : -{} -{ - "-" { return '-'; } -| "+" { return '+'; } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl term(LexicalUnitImpl prev) : -{ LexicalUnitImpl result = null; - Token n = null; - char op = ' '; -} -{ - (result = nonVariableTerm(prev)| result = variableTerm(prev)) - { - return result; - } -} - -LexicalUnitImpl variableTerm(LexicalUnitImpl prev) : { - LexicalUnitImpl result = null; - String varName = ""; } { - varName = variableName() - {result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, - prev, varName); return result;} } - -LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) : { LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - String varName; - String s = ""; -} -{ -( ( ( - op=unaryOperator() )? - (n= - { result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn, - prev, number(op, n, 0)); } - | n= - { result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); } - | n= - { result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); } - | n= - { result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); } - | n= - { result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); } - | n= - { - s = n.image; - int i = 0; - while (i < s.length() - && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { - i++; - } - - result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, - number(op,n,s.length()-i), - s.substring(i)); - } - | result=function(op, prev) ) ) - | ( n= - { result = - LexicalUnitImpl.createString(n.beginLine, n.beginColumn, prev, - convertStringIndex(n.image, 1, - n.image.length() -1));} - | (< DOT >{ s+="."; })?(n= | n= | n= | n=) - { s += convertIdent(n.image); - if ("inherit".equals(s)) { - result = LexicalUnitImpl.createInherit(n.beginLine, n.beginColumn, - prev); - } else { - result = LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, convertIdent(n.image)); - } - - /* / - Auto correction code used in the CSS Validator but must not - be used by a conformant CSS2 parser. - * Common error : - * H1 { - * color : black - * background : white - * } - * - Token t = getToken(1); - Token semicolon = new Token(); - semicolon.kind = SEMICOLON; - semicolon.image = ";"; - if (t.kind == COLON) { - // @@SEEME. (generate a warning?) - // @@SEEME if expression is a single ident, - generate an error ? - rejectToken(semicolon); - - result = prev; - } - / */ - } - | result=hexcolor(prev) - | result=url(prev) - | result=unicode(prev) - ) ) ( )* - { - return result; } } - -/** - * Handle all CSS2 functions. - * @exception ParseException exception during the parse - */ -LexicalUnitImpl function(char operator, LexicalUnitImpl prev) : -{Token n; - LexicalUnit params = null; -} -{ - n= ( )* - { - String fname = convertIdent(n.image); - if("alpha(".equals(fname)){ - String body = skipStatementUntilSemiColon(); - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - null, "alpha("+body); - }else if("expression(".equals(fname)){ - String body = skipStatementUntilSemiColon(); - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - null, "expression("+body); - } - } - ( params=expr() )? ")" - { - if (operator != ' ') { - throw new CSSParseException("invalid operator before a function.", - getLocator()); - } - String f = convertIdent(n.image); - LexicalUnitImpl l = (LexicalUnitImpl) params; - boolean loop = true; - if ("rgb(".equals(f)) { - // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 2: - case 4: - if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) - && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - if (loop) { - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - } - if ((i == 5) && loop && (l == null)) { - return LexicalUnitImpl.createRGBColor(n.beginLine, - n.beginColumn, - prev, params); - } else { - if (errorHandler != null) { - String errorText; - Locator loc; - if (i < 5) { - if (params == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn-1); - errorText = "not enough parameters."; - } else if (l == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn-1); - errorText = "not enough parameters: " - + params.toString(); - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "invalid parameter: " - + l.toString(); - } - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "too many parameters: " - + l.toString(); - } - errorHandler.error(new CSSParseException(errorText, loc)); - } - - throw new JumpException(); - } - } else if ("counter".equals(f)) { - int i = 0; - while (loop && l != null && i < 3) { - switch (i) { - case 0: - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 1: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if (((i == 1) || (i == 3)) && loop && (l == null)) { - return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn, - prev, params); - } - - } else if ("counters(".equals(f)) { - - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 4: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if (((i == 3) || (i == 5)) && loop && (l == null)) { - return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn, - prev, params); - } - } else if ("attr(".equals(f)) { - if ((l != null) - && (l.getNextLexicalUnit() == null) - && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { - return LexicalUnitImpl.createAttr(l.getLineNumber(), - l.getColumnNumber(), - prev, l.getStringValue()); - } - } else if ("rect(".equals(f)) { - int i = 0; - while (loop && l != null && i < 7) { - switch (i) { - case 0: - case 2: - case 4: - case 6: - switch (l.getLexicalUnitType()) { - case LexicalUnit.SAC_INTEGER: - if (l.getIntegerValue() != 0) { - loop = false; - } - break; - case LexicalUnit.SAC_IDENT: - if (!l.getStringValue().equals("auto")) { - loop = false; - } - break; - case LexicalUnit.SAC_EM: - case LexicalUnit.SAC_EX: - case LexicalUnit.SAC_PIXEL: - case LexicalUnit.SAC_CENTIMETER: - case LexicalUnit.SAC_MILLIMETER: - case LexicalUnit.SAC_INCH: - case LexicalUnit.SAC_POINT: - case LexicalUnit.SAC_PICA: - // nothing - break; - default: - loop = false; - } - break; - case 1: - case 3: - case 5: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: - throw new ParseException("implementation error"); - } - l = (LexicalUnitImpl) l.getNextLexicalUnit(); - i ++; - } - if ((i == 7) && loop && (l == null)) { - return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn, - prev, params); - } - } - return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev, - f.substring(0, - f.length() -1), - params); - } -} - -LexicalUnitImpl unicode(LexicalUnitImpl prev) : -{ Token n; -} -{ - n= - { - LexicalUnitImpl params = null; - String s = n.image.substring(2); - int index = s.indexOf('-'); - if (index == -1) { - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s, 16)); - } else { - String s1 = s.substring(0, index); - String s2 = s.substring(index); - - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s1, 16)); - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s2, 16)); - } - - return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn, - prev, params); - } -} - -LexicalUnitImpl url(LexicalUnitImpl prev) : -{ Token n; -} -{ - n= - { - String urlname = n.image.substring(4, n.image.length()-1).trim(); - return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname); - } -} - -/** - * @exception ParseException exception during the parse - */ -LexicalUnitImpl hexcolor(LexicalUnitImpl prev) : -{Token n; -} -{ - n= - { - int r; - LexicalUnitImpl first, params = null; - String s = n.image.substring(1); - - if(s.length()!=3 && s.length()!=6) { - first = null; - throw new CSSParseException("invalid hexadecimal notation for RGB: " + s, - getLocator()); - } - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, n.image); - } -} - -JAVACODE -float number(char operator, Token n, int lengthUnit) { - String image = n.image; - float f = 0; - - if (lengthUnit != 0) { - image = image.substring(0, image.length() - lengthUnit); - } - f = Float.valueOf(image).floatValue(); - return (operator == '-')? -f: f; -} - -JAVACODE -String skipStatementUntilSemiColon(){ - int[] semicolon = {SEMICOLON}; - return skipStatementUntil(semicolon); -} - -JAVACODE -String skipStatementUntilLeftBrace(){ - int[] lBrace = {LBRACE}; - return skipStatementUntil(lBrace); -} - -JAVACODE -String skipStatementUntilMatchingRightParan(){ - int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "(" - int[] rightTokens = {RPARAN}; - StringBuffer s = new StringBuffer(); - int difference = 1; - Token tok; - while(difference != 0){ - tok = getToken(1); - if(tok.kind == EOF) { - return null; - } - for(int sym : leftTokens){ - if(tok.kind == sym){ - difference++; - } - } - for(int sym : rightTokens){ - if(tok.kind == sym){ - difference--; - } - } - if(difference != 0){ - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); -} - -JAVACODE -String skipStatementUntil(int[] symbols){ - StringBuffer s = new StringBuffer(); - boolean stop = false; - Token tok; - while(!stop){ - tok = getToken(1); - if(tok.kind == EOF) { - return null; - } - for(int sym : symbols){ - if(tok.kind == sym){ - stop = true; - break; - } - } - if(!stop){ - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); -} - - -JAVACODE -String skipStatement() { - StringBuffer s = new StringBuffer(); - Token tok = getToken(0); - if (tok.image != null) { - s.append(tok.image); - } - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - getNextToken(); - s.append(skip_to_matching_brace()); - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == RBRACE) { - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == SEMICOLON) { - getNextToken(); - tok = getToken(1); - break; - } - getNextToken(); - } - - // skip white space - while (true) { - if (tok.kind != S) { - break; - } - tok = getNextToken(); - tok = getToken(1); - } - - return s.toString().trim(); -} - -JAVACODE -String skip_to_matching_brace() { - StringBuffer s = new StringBuffer(); - Token tok; - int nesting = 1; - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - break; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - nesting++; - } else if (tok.kind == RBRACE) { - nesting--; - if (nesting == 0) { - break; - } - } - getNextToken(); - } - return s.toString(); -} - -/* - * Here I handle all CSS2 unicode character stuffs. - * I convert all \XXXXXX character into a single character. - * Don't forget that the parser has recognize the token before. - * (So IDENT won't contain newline and stuffs like this). - */ -JAVACODE -String convertStringIndex(String s, int start, int len) { - StringBuffer buf = new StringBuffer(len); - int index = start; - - while (index < len) { - char c = s.charAt(index); - if (c == '\\') { - if (++index < len) { - c = s.charAt(index); - switch (c) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - buf.append('\\'); - while (index < len) { - buf.append(s.charAt(index++)); - } - break; - case '\n': - case '\f': - break; - case '\r': - if (index + 1 < len) { - if (s.charAt(index + 1) == '\n') { - index ++; - } - } - break; - default: - buf.append(c); - } - } else { - throw new CSSParseException("invalid string " + s, getLocator()); - } - } else { - buf.append(c); - } - index++; - } - - return buf.toString(); -} - -JAVACODE -String convertIdent(String s) { - return convertStringIndex(s, 0, s.length()); -} - -JAVACODE -String convertString(String s) { - return convertStringIndex(s, 0, s.length()); -} - -JAVACODE -void comments(){ - /*keeps only the multiple line comments, single line comments are skipped*/ - if (token.specialToken != null && token.specialToken.image!=null && token.specialToken.image.startsWith("/*")){ - Token tmp_t = token.specialToken; - while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; - while (tmp_t != null) { - documentHandler.comment(tmp_t.image); - tmp_t = tmp_t.next; - } - } -} - -/* - * @@HACK - * I can't insert a token into the tokens flow. - * It's jj_consume_token implementation dependant! :-( - */ -JAVACODE -void rejectToken(Token t) { - Token fakeToken = new Token(); - t.next = token; - fakeToken.next = t; - token = fakeToken; -} - -/** - * skip after an expression - */ -JAVACODE -String skipAfterExpression() { - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - - while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - - return s.toString(); -} - -/** - * The following functions are useful for a DOM CSS implementation only and are - * not part of the general CSS2 parser. - */ -// TODO required by original parser but not used by Vaadin? -void _parseRule() : -{String ret = null; -} -{ - ( )* - ( importDeclaration() | debuggingDirective() | styleRule() | media() | page() | fontFace() | ret=skipStatement() - { - if ((ret == null) || (ret.length() == 0)) { - return; - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - throw new CSSParseException("unrecognize rule: " + ret, - getLocator()); - } - } - ) -} - -void _parseImportRule() : -{ -} -{ - ( )* importDeclaration() -} - -void _parseMediaRule() : -{ -} -{ - ( )* media() -} - -void _parseDeclarationBlock() : -{ -} -{ - ( )* - ( declaration() )? ( ";" ( )* ( declaration() )? )* - } - -ArrayList _parseSelectors() : -{ ArrayList p = null; -} -{ - try { - ( )* p = selectorList() - { return p; } - } catch (ThrowedParseException e) { - throw (ParseException) e.e.fillInStackTrace(); - } -} - -/* - * Local Variables: - * compile-command: javacc Parser.jj & javac Parser.java - * End: - */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java new file mode 100644 index 0000000000..d54ab4fa7e --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/ParserTokenManager.java @@ -0,0 +1,4997 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. ParserTokenManager.java */ +package com.vaadin.sass.internal.parser; +import java.io.*; +import java.net.*; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; +import java.util.UUID; +import org.w3c.css.sac.ConditionFactory; +import org.w3c.css.sac.Condition; +import org.w3c.css.sac.SelectorFactory; +import org.w3c.css.sac.SelectorList; +import org.w3c.css.sac.Selector; +import org.w3c.css.sac.SimpleSelector; +import org.w3c.css.sac.DocumentHandler; +import org.w3c.css.sac.InputSource; +import org.w3c.css.sac.ErrorHandler; +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; +import org.w3c.css.sac.Locator; +import org.w3c.css.sac.LexicalUnit; +import org.w3c.flute.parser.selectors.SelectorFactoryImpl; +import org.w3c.flute.parser.selectors.ConditionFactoryImpl; +import org.w3c.flute.util.Encoding; +import com.vaadin.sass.internal.handler.*; +import com.vaadin.sass.internal.tree.*; + +/** Token Manager. */ +public class ParserTokenManager implements ParserConstants +{ + + /** Debug output. */ + public java.io.PrintStream debugStream = System.out; + /** Set debug output. */ + public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } +private final int jjStopStringLiteralDfa_0(int pos, long active0, long active1) +{ + switch (pos) + { + case 0: + if ((active0 & 0xffe0000000000000L) != 0L || (active1 & 0x3e0000000fL) != 0L) + return 162; + if ((active0 & 0xe000000000000L) != 0L || (active1 & 0x20L) != 0L) + { + jjmatchedKind = 72; + return 522; + } + if ((active0 & 0x80000000L) != 0L) + return 523; + if ((active0 & 0x10000000000000L) != 0L) + { + jjmatchedKind = 72; + return 29; + } + if ((active0 & 0x4000L) != 0L) + return 75; + if ((active0 & 0x2000010L) != 0L) + return 216; + if ((active0 & 0x80200L) != 0L) + return 38; + if ((active0 & 0x2000000000L) != 0L) + return 524; + return -1; + case 1: + if ((active1 & 0x2L) != 0L) + return 174; + if ((active0 & 0xffe0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 1; + return 525; + } + if ((active0 & 0x14000000000000L) != 0L) + { + jjmatchedKind = 72; + jjmatchedPos = 1; + return 522; + } + if ((active0 & 0xa000000000000L) != 0L || (active1 & 0x20L) != 0L) + return 522; + if ((active0 & 0x10L) != 0L) + return 221; + return -1; + case 2: + if ((active0 & 0xbfe0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 2; + return 525; + } + if ((active0 & 0x4000000000000000L) != 0L) + return 525; + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 2; + return 173; + } + if ((active0 & 0x14000000000000L) != 0L) + { + jjmatchedKind = 72; + jjmatchedPos = 2; + return 522; + } + return -1; + case 3: + if ((active0 & 0xb7e0000000000000L) != 0L || (active1 & 0x3e0000000dL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 3; + return 525; + } + if ((active0 & 0x800000000000000L) != 0L) + return 525; + if ((active0 & 0x4000000000000L) != 0L) + { + jjmatchedKind = 72; + jjmatchedPos = 3; + return 522; + } + if ((active0 & 0x10000000000000L) != 0L) + return 522; + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 3; + return 172; + } + return -1; + case 4: + if ((active0 & 0x9400000000000000L) != 0L || (active1 & 0x1000000000L) != 0L) + return 525; + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 4; + return 171; + } + if ((active0 & 0x4000000000000L) != 0L) + { + jjmatchedKind = 72; + jjmatchedPos = 4; + return 522; + } + if ((active0 & 0x23e0000000000000L) != 0L || (active1 & 0x2e0000000dL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 4; + return 525; + } + return -1; + case 5: + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 5; + return 170; + } + if ((active0 & 0x4000000000000L) != 0L) + { + jjmatchedKind = 72; + jjmatchedPos = 5; + return 522; + } + if ((active0 & 0x2220000000000000L) != 0L || (active1 & 0x400000000L) != 0L) + return 525; + if ((active0 & 0x1c0000000000000L) != 0L || (active1 & 0x2a0000000dL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 5; + return 525; + } + return -1; + case 6: + if ((active0 & 0x100000000000000L) != 0L || (active1 & 0x200000001L) != 0L) + return 525; + if ((active0 & 0x4000000000000L) != 0L) + return 522; + if ((active0 & 0xc0000000000000L) != 0L || (active1 & 0x280000000eL) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 6; + return 525; + } + return -1; + case 7: + if ((active0 & 0x40000000000000L) != 0L || (active1 & 0x800000008L) != 0L) + return 525; + if ((active0 & 0x80000000000000L) != 0L || (active1 & 0x2000000006L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 7; + return 525; + } + return -1; + case 8: + if ((active1 & 0x2000000002L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 8; + return 525; + } + if ((active0 & 0x80000000000000L) != 0L || (active1 & 0x4L) != 0L) + return 525; + return -1; + case 9: + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 9; + return 525; + } + if ((active1 & 0x2000000000L) != 0L) + return 525; + return -1; + case 10: + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 10; + return 525; + } + return -1; + case 11: + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 11; + return 525; + } + return -1; + case 12: + if ((active1 & 0x2L) != 0L) + { + jjmatchedKind = 103; + jjmatchedPos = 12; + return 525; + } + return -1; + default : + return -1; + } +} +private final int jjStartNfa_0(int pos, long active0, long active1) +{ + return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1); +} +private int jjStopAtPos(int pos, int kind) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + return pos + 1; +} +private int jjMoveStringLiteralDfa0_0() +{ + switch(curChar) + { + case 33: + return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L); + case 36: + return jjMoveStringLiteralDfa1_0(0x4000L, 0x0L); + case 37: + return jjStopAtPos(0, 29); + case 38: + jjmatchedKind = 30; + return jjMoveStringLiteralDfa1_0(0x1000000000L, 0x0L); + case 40: + return jjStopAtPos(0, 32); + case 41: + return jjStopAtPos(0, 33); + case 42: + jjmatchedKind = 28; + return jjMoveStringLiteralDfa1_0(0x8000L, 0x0L); + case 43: + return jjStopAtPos(0, 18); + case 44: + return jjStopAtPos(0, 20); + case 45: + jjmatchedKind = 19; + return jjMoveStringLiteralDfa1_0(0x200L, 0x0L); + case 46: + return jjStartNfaWithStates_0(0, 31, 523); + case 47: + jjmatchedKind = 25; + return jjMoveStringLiteralDfa1_0(0x10L, 0x0L); + case 58: + return jjStopAtPos(0, 38); + case 59: + return jjStopAtPos(0, 21); + case 60: + jjmatchedKind = 24; + return jjMoveStringLiteralDfa1_0(0x100L, 0x0L); + case 61: + jjmatchedKind = 17; + return jjMoveStringLiteralDfa1_0(0x400000000L, 0x0L); + case 62: + return jjStopAtPos(0, 22); + case 64: + return jjMoveStringLiteralDfa1_0(0xffe0000000000000L, 0x3e0000000fL); + case 91: + return jjStopAtPos(0, 26); + case 93: + return jjStopAtPos(0, 27); + case 94: + return jjMoveStringLiteralDfa1_0(0x2000L, 0x0L); + case 70: + case 102: + return jjMoveStringLiteralDfa1_0(0x10000000000000L, 0x0L); + case 73: + case 105: + return jjMoveStringLiteralDfa1_0(0x8000000000000L, 0x20L); + case 84: + case 116: + return jjMoveStringLiteralDfa1_0(0x6000000000000L, 0x0L); + case 123: + return jjStopAtPos(0, 10); + case 124: + return jjMoveStringLiteralDfa1_0(0x800001000L, 0x0L); + case 125: + return jjStopAtPos(0, 11); + case 126: + jjmatchedKind = 23; + return jjMoveStringLiteralDfa1_0(0x10000L, 0x0L); + default : + return jjMoveNfa_0(24, 0); + } +} +private int jjMoveStringLiteralDfa1_0(long active0, long active1) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(0, active0, active1); + return 1; + } + switch(curChar) + { + case 33: + return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L); + case 38: + if ((active0 & 0x1000000000L) != 0L) + return jjStopAtPos(1, 36); + break; + case 42: + if ((active0 & 0x10L) != 0L) + return jjStartNfaWithStates_0(1, 4, 221); + break; + case 45: + return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0x2L); + case 61: + if ((active0 & 0x1000L) != 0L) + return jjStopAtPos(1, 12); + else if ((active0 & 0x2000L) != 0L) + return jjStopAtPos(1, 13); + else if ((active0 & 0x4000L) != 0L) + return jjStopAtPos(1, 14); + else if ((active0 & 0x8000L) != 0L) + return jjStopAtPos(1, 15); + else if ((active0 & 0x10000L) != 0L) + return jjStopAtPos(1, 16); + else if ((active0 & 0x400000000L) != 0L) + return jjStopAtPos(1, 34); + else if ((active0 & 0x2000000000L) != 0L) + return jjStopAtPos(1, 37); + break; + case 67: + case 99: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x800000008L); + case 68: + case 100: + return jjMoveStringLiteralDfa2_0(active0, 0x200000000000000L, active1, 0L); + case 69: + case 101: + return jjMoveStringLiteralDfa2_0(active0, 0x9000000000000000L, active1, 0x1L); + case 70: + case 102: + if ((active1 & 0x20L) != 0L) + return jjStartNfaWithStates_0(1, 69, 522); + return jjMoveStringLiteralDfa2_0(active0, 0x880000000000000L, active1, 0x2000000000L); + case 72: + case 104: + return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L); + case 73: + case 105: + return jjMoveStringLiteralDfa2_0(active0, 0x4040000000000000L, active1, 0x200000000L); + case 77: + case 109: + return jjMoveStringLiteralDfa2_0(active0, 0x20000000000000L, active1, 0x400000000L); + case 78: + case 110: + if ((active0 & 0x8000000000000L) != 0L) + return jjStartNfaWithStates_0(1, 51, 522); + break; + case 79: + case 111: + if ((active0 & 0x2000000000000L) != 0L) + return jjStartNfaWithStates_0(1, 49, 522); + break; + case 80: + case 112: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x1000000000L); + case 82: + case 114: + return jjMoveStringLiteralDfa2_0(active0, 0x110000000000000L, active1, 0L); + case 83: + case 115: + return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x4L); + case 87: + case 119: + return jjMoveStringLiteralDfa2_0(active0, 0x2400000000000000L, active1, 0L); + case 124: + if ((active0 & 0x800000000L) != 0L) + return jjStopAtPos(1, 35); + break; + default : + break; + } + return jjStartNfa_0(0, active0, active1); +} +private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(0, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(1, active0, active1); + return 2; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa3_0(active0, 0x100L, active1, 0L); + case 62: + if ((active0 & 0x200L) != 0L) + return jjStopAtPos(2, 9); + break; + case 65: + case 97: + return jjMoveStringLiteralDfa3_0(active0, 0x1400000000000000L, active1, 0x1000000000L); + case 69: + case 101: + return jjMoveStringLiteralDfa3_0(active0, 0x300000000000000L, active1, 0x400000000L); + case 70: + case 102: + if ((active0 & 0x4000000000000000L) != 0L) + return jjStartNfaWithStates_0(2, 62, 525); + break; + case 72: + case 104: + return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000000L, active1, 0x800000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa3_0(active0, 0x20000000000000L, active1, 0L); + case 76: + case 108: + return jjMoveStringLiteralDfa3_0(active0, 0x8000000000000000L, active1, 0L); + case 77: + case 109: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x200000002L); + case 78: + case 110: + return jjMoveStringLiteralDfa3_0(active0, 0x40000000000000L, active1, 0L); + case 79: + case 111: + return jjMoveStringLiteralDfa3_0(active0, 0x810000000000000L, active1, 0x2000000008L); + case 82: + case 114: + return jjMoveStringLiteralDfa3_0(active0, 0x4000000000000L, active1, 0L); + case 85: + case 117: + return jjMoveStringLiteralDfa3_0(active0, 0x80000000000000L, active1, 0x4L); + case 88: + case 120: + return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x1L); + default : + break; + } + return jjStartNfa_0(1, active0, active1); +} +private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(1, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(2, active0, active1); + return 3; + } + switch(curChar) + { + case 45: + if ((active0 & 0x100L) != 0L) + return jjStopAtPos(3, 8); + break; + case 65: + case 97: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x800000000L); + case 66: + case 98: + return jjMoveStringLiteralDfa4_0(active0, 0x200000000000000L, active1, 0L); + case 67: + case 99: + return jjMoveStringLiteralDfa4_0(active0, 0x1040000000000000L, active1, 0L); + case 68: + case 100: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x400000000L); + case 71: + case 103: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x1000000000L); + case 73: + case 105: + return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000000L, active1, 0L); + case 77: + case 109: + if ((active0 & 0x10000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 52, 522); + break; + case 78: + case 110: + return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0x2000000008L); + case 79: + case 111: + return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L, active1, 0x2L); + case 80: + case 112: + return jjMoveStringLiteralDfa4_0(active0, 0L, active1, 0x200000004L); + case 82: + case 114: + if ((active0 & 0x800000000000000L) != 0L) + return jjStartNfaWithStates_0(3, 59, 525); + return jjMoveStringLiteralDfa4_0(active0, 0x400000000000000L, active1, 0L); + case 83: + case 115: + return jjMoveStringLiteralDfa4_0(active0, 0x8000000000000000L, active1, 0L); + case 84: + case 116: + return jjMoveStringLiteralDfa4_0(active0, 0x100000000000000L, active1, 0x1L); + case 88: + case 120: + return jjMoveStringLiteralDfa4_0(active0, 0x20000000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(2, active0, active1); +} +private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(2, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(3, active0, active1); + return 4; + } + switch(curChar) + { + case 67: + case 99: + return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L, active1, 0L); + case 69: + case 101: + if ((active0 & 0x8000000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 63, 525); + else if ((active1 & 0x1000000000L) != 0L) + return jjStartNfaWithStates_0(4, 100, 525); + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x1L); + case 72: + case 104: + if ((active0 & 0x1000000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 60, 525); + break; + case 73: + case 105: + return jjMoveStringLiteralDfa5_0(active0, 0x20000000000000L, active1, 0x400000000L); + case 76: + case 108: + return jjMoveStringLiteralDfa5_0(active0, 0x2040000000000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x400000000000000L) != 0L) + return jjStartNfaWithStates_0(4, 58, 525); + break; + case 79: + case 111: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x200000000L); + case 80: + case 112: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x4L); + case 82: + case 114: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x800000000L); + case 84: + case 116: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x2000000008L); + case 85: + case 117: + return jjMoveStringLiteralDfa5_0(active0, 0x304000000000000L, active1, 0L); + case 90: + case 122: + return jjMoveStringLiteralDfa5_0(active0, 0L, active1, 0x2L); + default : + break; + } + return jjStartNfa_0(3, active0, active1); +} +private int jjMoveStringLiteralDfa5_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(3, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(4, active0, active1); + return 5; + } + switch(curChar) + { + case 45: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x2000000002L); + case 65: + case 97: + if ((active1 & 0x400000000L) != 0L) + return jjStartNfaWithStates_0(5, 98, 525); + break; + case 69: + case 101: + if ((active0 & 0x2000000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 61, 525); + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x8L); + case 71: + case 103: + if ((active0 & 0x200000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 57, 525); + return jjMoveStringLiteralDfa6_0(active0, 0x4000000000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x20000000000000L) != 0L) + return jjStartNfaWithStates_0(5, 53, 525); + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x1L); + case 79: + case 111: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x4L); + case 82: + case 114: + return jjMoveStringLiteralDfa6_0(active0, 0x100000000000000L, active1, 0x200000000L); + case 83: + case 115: + return jjMoveStringLiteralDfa6_0(active0, 0L, active1, 0x800000000L); + case 84: + case 116: + return jjMoveStringLiteralDfa6_0(active0, 0x80000000000000L, active1, 0L); + case 85: + case 117: + return jjMoveStringLiteralDfa6_0(active0, 0x40000000000000L, active1, 0L); + default : + break; + } + return jjStartNfa_0(4, active0, active1); +} +private int jjMoveStringLiteralDfa6_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(4, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(5, active0, active1); + return 6; + } + switch(curChar) + { + case 68: + case 100: + if ((active1 & 0x1L) != 0L) + return jjStartNfaWithStates_0(6, 64, 525); + return jjMoveStringLiteralDfa7_0(active0, 0x40000000000000L, active1, 0x2L); + case 69: + case 101: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x800000000L); + case 70: + case 102: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x2000000000L); + case 72: + case 104: + if ((active0 & 0x4000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 50, 522); + break; + case 73: + case 105: + return jjMoveStringLiteralDfa7_0(active0, 0x80000000000000L, active1, 0L); + case 78: + case 110: + if ((active0 & 0x100000000000000L) != 0L) + return jjStartNfaWithStates_0(6, 56, 525); + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x8L); + case 82: + case 114: + return jjMoveStringLiteralDfa7_0(active0, 0L, active1, 0x4L); + case 84: + case 116: + if ((active1 & 0x200000000L) != 0L) + return jjStartNfaWithStates_0(6, 97, 525); + break; + default : + break; + } + return jjStartNfa_0(5, active0, active1); +} +private int jjMoveStringLiteralDfa7_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(5, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(6, active0, active1); + return 7; + } + switch(curChar) + { + case 65: + case 97: + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x2000000000L); + case 69: + case 101: + if ((active0 & 0x40000000000000L) != 0L) + return jjStartNfaWithStates_0(7, 54, 525); + break; + case 79: + case 111: + return jjMoveStringLiteralDfa8_0(active0, 0x80000000000000L, active1, 0x2L); + case 84: + case 116: + if ((active1 & 0x8L) != 0L) + return jjStartNfaWithStates_0(7, 67, 525); + else if ((active1 & 0x800000000L) != 0L) + return jjStartNfaWithStates_0(7, 99, 525); + return jjMoveStringLiteralDfa8_0(active0, 0L, active1, 0x4L); + default : + break; + } + return jjStartNfa_0(6, active0, active1); +} +private int jjMoveStringLiteralDfa8_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(6, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(7, active0, active1); + return 8; + } + switch(curChar) + { + case 67: + case 99: + return jjMoveStringLiteralDfa9_0(active0, 0L, active1, 0x2000000002L); + case 78: + case 110: + if ((active0 & 0x80000000000000L) != 0L) + return jjStartNfaWithStates_0(8, 55, 525); + break; + case 83: + case 115: + if ((active1 & 0x4L) != 0L) + return jjStartNfaWithStates_0(8, 66, 525); + break; + default : + break; + } + return jjStartNfa_0(7, active0, active1); +} +private int jjMoveStringLiteralDfa9_0(long old0, long active0, long old1, long active1) +{ + if (((active0 &= old0) | (active1 &= old1)) == 0L) + return jjStartNfa_0(7, old0, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(8, 0L, active1); + return 9; + } + switch(curChar) + { + case 69: + case 101: + if ((active1 & 0x2000000000L) != 0L) + return jjStartNfaWithStates_0(9, 101, 525); + break; + case 85: + case 117: + return jjMoveStringLiteralDfa10_0(active1, 0x2L); + default : + break; + } + return jjStartNfa_0(8, 0L, active1); +} +private int jjMoveStringLiteralDfa10_0(long old1, long active1) +{ + if (((active1 &= old1)) == 0L) + return jjStartNfa_0(8, 0L, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(9, 0L, active1); + return 10; + } + switch(curChar) + { + case 77: + case 109: + return jjMoveStringLiteralDfa11_0(active1, 0x2L); + default : + break; + } + return jjStartNfa_0(9, 0L, active1); +} +private int jjMoveStringLiteralDfa11_0(long old1, long active1) +{ + if (((active1 &= old1)) == 0L) + return jjStartNfa_0(9, 0L, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(10, 0L, active1); + return 11; + } + switch(curChar) + { + case 69: + case 101: + return jjMoveStringLiteralDfa12_0(active1, 0x2L); + default : + break; + } + return jjStartNfa_0(10, 0L, active1); +} +private int jjMoveStringLiteralDfa12_0(long old1, long active1) +{ + if (((active1 &= old1)) == 0L) + return jjStartNfa_0(10, 0L, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(11, 0L, active1); + return 12; + } + switch(curChar) + { + case 78: + case 110: + return jjMoveStringLiteralDfa13_0(active1, 0x2L); + default : + break; + } + return jjStartNfa_0(11, 0L, active1); +} +private int jjMoveStringLiteralDfa13_0(long old1, long active1) +{ + if (((active1 &= old1)) == 0L) + return jjStartNfa_0(11, 0L, old1); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(12, 0L, active1); + return 13; + } + switch(curChar) + { + case 84: + case 116: + if ((active1 & 0x2L) != 0L) + return jjStartNfaWithStates_0(13, 65, 525); + break; + default : + break; + } + return jjStartNfa_0(12, 0L, active1); +} +private int jjStartNfaWithStates_0(int pos, int kind, int state) +{ + jjmatchedKind = kind; + jjmatchedPos = pos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return pos + 1; } + return jjMoveNfa_0(state, pos + 1); +} +static final long[] jjbitVec0 = { + 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +private int jjMoveNfa_0(int startState, int curPos) +{ + int startsAt = 0; + jjnewStateCnt = 522; + int i = 1; + jjstateSet[0] = startState; + int kind = 0x7fffffff; + for (;;) + { + if (++jjround == 0x7fffffff) + ReInitRounds(); + if (curChar < 64) + { + long l = 1L << curChar; + do + { + switch(jjstateSet[--i]) + { + case 524: + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(256, 265); + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(248, 255); + break; + case 162: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 108; + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 213; + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 201; + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 185; + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 174; + break; + case 29: + if ((0x3ff200000000000L & l) != 0L) + jjCheckNAddStates(0, 3); + else if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(236, 237); + else if (curChar == 40) + { + if (kind > 118) + kind = 118; + } + if ((0x3ff200000000000L & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + break; + case 171: + if ((0x3ff200000000000L & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 170; + break; + case 523: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(4, 8); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(327, 330); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(324, 326); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(322, 323); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(319, 321); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(314, 318); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(310, 313); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(306, 309); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(303, 305); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(299, 302); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(295, 298); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(292, 294); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(289, 291); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(286, 288); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(283, 285); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(280, 282); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(277, 279); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(274, 276); + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(272, 273); + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 73) + kind = 73; + jjCheckNAdd(271); + } + break; + case 525: + case 109: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 216: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 221; + else if (curChar == 47) + { + if (kind > 2) + kind = 2; + jjCheckNAddStates(9, 11); + } + break; + case 173: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 24: + if ((0x3ff000000000000L & l) != 0L) + { + if (kind > 73) + kind = 73; + jjCheckNAddStates(12, 93); + } + else if ((0x100003600L & l) != 0L) + { + if (kind > 1) + kind = 1; + jjCheckNAdd(0); + } + else if (curChar == 46) + jjCheckNAddStates(94, 113); + else if (curChar == 45) + jjAddStates(114, 115); + else if (curChar == 33) + jjCheckNAddStates(116, 119); + else if (curChar == 47) + jjAddStates(120, 121); + else if (curChar == 35) + jjCheckNAddTwoStates(96, 97); + else if (curChar == 36) + jjCheckNAddStates(122, 125); + else if (curChar == 39) + jjCheckNAddStates(126, 129); + else if (curChar == 34) + jjCheckNAddStates(130, 133); + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 38; + else if (curChar == 35) + jjstateSet[jjnewStateCnt++] = 1; + break; + case 172: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 170: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 75: + if (curChar == 45) + jjCheckNAdd(76); + break; + case 522: + if ((0x3ff200000000000L & l) != 0L) + jjCheckNAddStates(0, 3); + else if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(236, 237); + else if (curChar == 40) + { + if (kind > 118) + kind = 118; + } + if ((0x3ff200000000000L & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + break; + case 0: + if ((0x100003600L & l) == 0L) + break; + if (kind > 1) + kind = 1; + jjCheckNAdd(0); + break; + case 2: + if (curChar == 36) + jjCheckNAddStates(134, 137); + break; + case 3: + if (curChar == 45) + jjCheckNAdd(4); + break; + case 5: + if ((0x3ff200000000000L & l) != 0L) + jjCheckNAddStates(138, 140); + break; + case 8: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(138, 140); + break; + case 9: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(141, 145); + break; + case 10: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(138, 140); + break; + case 11: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(146, 153); + break; + case 12: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(154, 157); + break; + case 13: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(158, 162); + break; + case 14: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(163, 168); + break; + case 15: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(169, 175); + break; + case 18: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(176, 180); + break; + case 19: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(181, 188); + break; + case 20: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(189, 192); + break; + case 21: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(193, 197); + break; + case 22: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(198, 203); + break; + case 23: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(204, 210); + break; + case 36: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 35; + break; + case 39: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 38; + break; + case 40: + if (curChar == 34) + jjCheckNAddStates(130, 133); + break; + case 41: + if ((0xfffffffb00000200L & l) != 0L) + jjCheckNAddStates(130, 133); + break; + case 42: + if (curChar == 34 && kind > 71) + kind = 71; + break; + case 44: + if (curChar == 12) + jjCheckNAddStates(130, 133); + break; + case 46: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(130, 133); + break; + case 47: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(211, 216); + break; + case 48: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(130, 133); + break; + case 49: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(217, 225); + break; + case 50: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(226, 230); + break; + case 51: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(231, 236); + break; + case 52: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(237, 243); + break; + case 53: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(244, 251); + break; + case 54: + if (curChar == 13) + jjCheckNAddStates(130, 133); + break; + case 55: + if (curChar == 10) + jjCheckNAddStates(130, 133); + break; + case 56: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 55; + break; + case 57: + if (curChar == 39) + jjCheckNAddStates(126, 129); + break; + case 58: + if ((0xffffff7f00000200L & l) != 0L) + jjCheckNAddStates(126, 129); + break; + case 59: + if (curChar == 39 && kind > 71) + kind = 71; + break; + case 61: + if (curChar == 12) + jjCheckNAddStates(126, 129); + break; + case 63: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(126, 129); + break; + case 64: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(252, 257); + break; + case 65: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(126, 129); + break; + case 66: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(258, 266); + break; + case 67: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(267, 271); + break; + case 68: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(272, 277); + break; + case 69: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(278, 284); + break; + case 70: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(285, 292); + break; + case 71: + if (curChar == 13) + jjCheckNAddStates(126, 129); + break; + case 72: + if (curChar == 10) + jjCheckNAddStates(126, 129); + break; + case 73: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 72; + break; + case 74: + if (curChar == 36) + jjCheckNAddStates(122, 125); + break; + case 77: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 79: + if ((0xffffffff00000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 80: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(293, 296); + break; + case 81: + if ((0x100003600L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 82: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(297, 303); + break; + case 83: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(304, 306); + break; + case 84: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(307, 310); + break; + case 85: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(311, 315); + break; + case 86: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(316, 321); + break; + case 89: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(322, 325); + break; + case 90: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(326, 332); + break; + case 91: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(333, 335); + break; + case 92: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(336, 339); + break; + case 93: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(340, 344); + break; + case 94: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(345, 350); + break; + case 95: + if (curChar == 35) + jjCheckNAddTwoStates(96, 97); + break; + case 96: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 98: + if ((0xffffffff00000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 99: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(351, 354); + break; + case 100: + if ((0x100003600L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 101: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(355, 361); + break; + case 102: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(362, 364); + break; + case 103: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(365, 368); + break; + case 104: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(369, 373); + break; + case 105: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(374, 379); + break; + case 107: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 108; + break; + case 111: + if ((0xffffffff00000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 112: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(380, 383); + break; + case 113: + if ((0x100003600L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 114: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(384, 390); + break; + case 115: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(391, 393); + break; + case 116: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(394, 397); + break; + case 117: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(398, 402); + break; + case 118: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(403, 408); + break; + case 121: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(409, 412); + break; + case 122: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(413, 419); + break; + case 123: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(420, 422); + break; + case 124: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(423, 426); + break; + case 125: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(427, 431); + break; + case 126: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(432, 437); + break; + case 128: + if ((0x100003600L & l) != 0L) + jjAddStates(438, 439); + break; + case 129: + if (curChar == 40 && kind > 115) + kind = 115; + break; + case 136: + if ((0x100003600L & l) != 0L) + jjAddStates(440, 441); + break; + case 137: + if (curChar == 40 && kind > 116) + kind = 116; + break; + case 144: + if ((0x100003600L & l) != 0L) + jjAddStates(442, 443); + break; + case 145: + if (curChar == 40 && kind > 117) + kind = 117; + break; + case 175: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 174; + break; + case 184: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 183; + break; + case 186: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 185; + break; + case 195: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 194; + break; + case 202: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 201; + break; + case 211: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 210; + break; + case 214: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 213; + break; + case 215: + if (curChar == 47) + jjAddStates(120, 121); + break; + case 217: + if ((0xffffffffffffdbffL & l) == 0L) + break; + if (kind > 2) + kind = 2; + jjCheckNAddStates(9, 11); + break; + case 218: + if ((0x2400L & l) != 0L && kind > 2) + kind = 2; + break; + case 219: + if (curChar == 10 && kind > 2) + kind = 2; + break; + case 220: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 219; + break; + case 221: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 222; + break; + case 222: + if ((0xffff7fffffffffffL & l) != 0L && kind > 3) + kind = 3; + break; + case 223: + if (curChar == 42) + jjstateSet[jjnewStateCnt++] = 221; + break; + case 225: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 227: + if ((0xffffffff00000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 228: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(444, 447); + break; + case 229: + if ((0x100003600L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 230: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(448, 454); + break; + case 231: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(455, 457); + break; + case 232: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(458, 461); + break; + case 233: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(462, 466); + break; + case 234: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(467, 472); + break; + case 235: + if ((0x3ff200000000000L & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 236: + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(236, 237); + break; + case 237: + if (curChar == 40 && kind > 118) + kind = 118; + break; + case 239: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 240: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(473, 477); + break; + case 241: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 242: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(478, 485); + break; + case 243: + case 457: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(486, 489); + break; + case 244: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(490, 494); + break; + case 245: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(495, 500); + break; + case 246: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(501, 507); + break; + case 247: + if (curChar == 33) + jjCheckNAddStates(116, 119); + break; + case 248: + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(248, 255); + break; + case 256: + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(256, 265); + break; + case 266: + if (curChar == 45) + jjAddStates(114, 115); + break; + case 270: + if (curChar == 46) + jjCheckNAddStates(94, 113); + break; + case 271: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 73) + kind = 73; + jjCheckNAdd(271); + break; + case 272: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(272, 273); + break; + case 273: + if (curChar == 37 && kind > 77) + kind = 77; + break; + case 274: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(274, 276); + break; + case 277: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(277, 279); + break; + case 280: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(280, 282); + break; + case 283: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(283, 285); + break; + case 286: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(286, 288); + break; + case 289: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(289, 291); + break; + case 292: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(292, 294); + break; + case 295: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(295, 298); + break; + case 299: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(299, 302); + break; + case 303: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(303, 305); + break; + case 306: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(306, 309); + break; + case 310: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(310, 313); + break; + case 314: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(314, 318); + break; + case 319: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(319, 321); + break; + case 322: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(322, 323); + break; + case 324: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(324, 326); + break; + case 327: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(327, 330); + break; + case 331: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(4, 8); + break; + case 332: + if (curChar == 45) + jjCheckNAdd(333); + break; + case 334: + if ((0x3ff200000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 336: + if ((0xffffffff00000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 337: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(508, 511); + break; + case 338: + if ((0x100003600L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 339: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(512, 518); + break; + case 340: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(519, 521); + break; + case 341: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(522, 525); + break; + case 342: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(526, 530); + break; + case 343: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(531, 536); + break; + case 346: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(537, 540); + break; + case 347: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(541, 547); + break; + case 348: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(548, 550); + break; + case 349: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(551, 554); + break; + case 350: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(555, 559); + break; + case 351: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(560, 565); + break; + case 353: + if (curChar == 40) + jjCheckNAddStates(566, 571); + break; + case 354: + if ((0xfffffc7a00000000L & l) != 0L) + jjCheckNAddStates(572, 575); + break; + case 355: + if ((0x100003600L & l) != 0L) + jjCheckNAddTwoStates(355, 356); + break; + case 356: + if (curChar == 41 && kind > 75) + kind = 75; + break; + case 358: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(572, 575); + break; + case 359: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(576, 580); + break; + case 360: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(572, 575); + break; + case 361: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(581, 588); + break; + case 362: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(589, 592); + break; + case 363: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(593, 597); + break; + case 364: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(598, 603); + break; + case 365: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(604, 610); + break; + case 366: + if (curChar == 39) + jjCheckNAddStates(611, 614); + break; + case 367: + if ((0xffffff7f00000200L & l) != 0L) + jjCheckNAddStates(611, 614); + break; + case 368: + if (curChar == 39) + jjCheckNAddTwoStates(355, 356); + break; + case 370: + if (curChar == 12) + jjCheckNAddStates(611, 614); + break; + case 372: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(611, 614); + break; + case 373: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(615, 620); + break; + case 374: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(611, 614); + break; + case 375: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(621, 629); + break; + case 376: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(630, 634); + break; + case 377: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(635, 640); + break; + case 378: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(641, 647); + break; + case 379: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(648, 655); + break; + case 380: + if (curChar == 13) + jjCheckNAddStates(611, 614); + break; + case 381: + if (curChar == 10) + jjCheckNAddStates(611, 614); + break; + case 382: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 381; + break; + case 383: + if (curChar == 34) + jjCheckNAddStates(656, 659); + break; + case 384: + if ((0xfffffffb00000200L & l) != 0L) + jjCheckNAddStates(656, 659); + break; + case 385: + if (curChar == 34) + jjCheckNAddTwoStates(355, 356); + break; + case 387: + if (curChar == 12) + jjCheckNAddStates(656, 659); + break; + case 389: + if ((0xffffffff00000000L & l) != 0L) + jjCheckNAddStates(656, 659); + break; + case 390: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(660, 665); + break; + case 391: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(656, 659); + break; + case 392: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(666, 674); + break; + case 393: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(675, 679); + break; + case 394: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(680, 685); + break; + case 395: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(686, 692); + break; + case 396: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(693, 700); + break; + case 397: + if (curChar == 13) + jjCheckNAddStates(656, 659); + break; + case 398: + if (curChar == 10) + jjCheckNAddStates(656, 659); + break; + case 399: + if (curChar == 13) + jjstateSet[jjnewStateCnt++] = 398; + break; + case 400: + if ((0x100003600L & l) != 0L) + jjCheckNAddStates(701, 707); + break; + case 403: + if (curChar == 43) + jjAddStates(708, 709); + break; + case 404: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 405; + break; + case 405: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(710, 713); + break; + case 406: + if (curChar == 63 && kind > 114) + kind = 114; + break; + case 407: + case 422: + case 426: + case 429: + case 432: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAdd(406); + break; + case 408: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(406, 407); + break; + case 409: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(714, 716); + break; + case 410: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjAddStates(717, 722); + break; + case 411: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 412; + break; + case 412: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 413; + break; + case 413: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAdd(414); + break; + case 414: + if ((0x3ff000000000000L & l) != 0L && kind > 114) + kind = 114; + break; + case 415: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 416; + break; + case 416: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 417; + break; + case 417: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 418; + break; + case 418: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAdd(406); + break; + case 419: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 420; + break; + case 420: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 421; + break; + case 421: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 422; + break; + case 423: + if ((0x3ff000000000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 424; + break; + case 424: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 425; + break; + case 425: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(406, 426); + break; + case 427: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 428; + break; + case 428: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(723, 725); + break; + case 430: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(406, 429); + break; + case 431: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(726, 729); + break; + case 433: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(406, 432); + break; + case 434: + if (curChar != 63) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(730, 732); + break; + case 435: + if (curChar == 43) + jjstateSet[jjnewStateCnt++] = 436; + break; + case 436: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(437, 443); + break; + case 437: + if (curChar == 45) + jjstateSet[jjnewStateCnt++] = 438; + break; + case 438: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 439; + break; + case 439: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(733, 736); + break; + case 440: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAdd(414); + break; + case 441: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(414, 440); + break; + case 442: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(737, 739); + break; + case 443: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(740, 744); + break; + case 444: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAdd(437); + break; + case 445: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(444, 437); + break; + case 446: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(745, 747); + break; + case 447: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(748, 751); + break; + case 449: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(752, 755); + break; + case 450: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(756, 762); + break; + case 451: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(763, 765); + break; + case 452: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(766, 769); + break; + case 453: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(770, 774); + break; + case 454: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(775, 780); + break; + case 455: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(781, 785); + break; + case 456: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(786, 793); + break; + case 458: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(794, 798); + break; + case 459: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(799, 804); + break; + case 460: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(805, 811); + break; + case 461: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 73) + kind = 73; + jjCheckNAddStates(12, 93); + break; + case 462: + if ((0x3ff000000000000L & l) == 0L) + break; + if (kind > 73) + kind = 73; + jjCheckNAdd(462); + break; + case 463: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(463, 464); + break; + case 464: + if (curChar == 46) + jjCheckNAdd(271); + break; + case 465: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(465, 273); + break; + case 466: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(466, 467); + break; + case 467: + if (curChar == 46) + jjCheckNAdd(272); + break; + case 468: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(468, 276); + break; + case 469: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(469, 470); + break; + case 470: + if (curChar == 46) + jjCheckNAdd(274); + break; + case 471: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(471, 279); + break; + case 472: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(472, 473); + break; + case 473: + if (curChar == 46) + jjCheckNAdd(277); + break; + case 474: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(474, 282); + break; + case 475: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(475, 476); + break; + case 476: + if (curChar == 46) + jjCheckNAdd(280); + break; + case 477: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(477, 285); + break; + case 478: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(478, 479); + break; + case 479: + if (curChar == 46) + jjCheckNAdd(283); + break; + case 480: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(480, 288); + break; + case 481: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(481, 482); + break; + case 482: + if (curChar == 46) + jjCheckNAdd(286); + break; + case 483: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(483, 291); + break; + case 484: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(484, 485); + break; + case 485: + if (curChar == 46) + jjCheckNAdd(289); + break; + case 486: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(486, 294); + break; + case 487: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(487, 488); + break; + case 488: + if (curChar == 46) + jjCheckNAdd(292); + break; + case 489: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(489, 298); + break; + case 490: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(490, 491); + break; + case 491: + if (curChar == 46) + jjCheckNAdd(295); + break; + case 492: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(492, 302); + break; + case 493: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(493, 494); + break; + case 494: + if (curChar == 46) + jjCheckNAdd(299); + break; + case 495: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(495, 305); + break; + case 496: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(496, 497); + break; + case 497: + if (curChar == 46) + jjCheckNAdd(303); + break; + case 498: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(498, 309); + break; + case 499: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(499, 500); + break; + case 500: + if (curChar == 46) + jjCheckNAdd(306); + break; + case 501: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(501, 313); + break; + case 502: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(502, 503); + break; + case 503: + if (curChar == 46) + jjCheckNAdd(310); + break; + case 504: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(504, 318); + break; + case 505: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(505, 506); + break; + case 506: + if (curChar == 46) + jjCheckNAdd(314); + break; + case 507: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(507, 321); + break; + case 508: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(508, 509); + break; + case 509: + if (curChar == 46) + jjCheckNAdd(319); + break; + case 510: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(510, 323); + break; + case 511: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(511, 512); + break; + case 512: + if (curChar == 46) + jjCheckNAdd(322); + break; + case 513: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(513, 326); + break; + case 514: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(514, 515); + break; + case 515: + if (curChar == 46) + jjCheckNAdd(324); + break; + case 516: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(516, 330); + break; + case 517: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(517, 518); + break; + case 518: + if (curChar == 46) + jjCheckNAdd(327); + break; + case 519: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddStates(812, 816); + break; + case 520: + if ((0x3ff000000000000L & l) != 0L) + jjCheckNAddTwoStates(520, 521); + break; + case 521: + if (curChar == 46) + jjCheckNAdd(331); + break; + default : break; + } + } while(i != startsAt); + } + else if (curChar < 128) + { + long l = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 524: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 264; + else if ((0x1000000010L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 254; + break; + case 162: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 121); + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 161; + break; + case 29: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(0, 3); + else if (curChar == 92) + jjCheckNAddTwoStates(227, 228); + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + else if (curChar == 92) + jjCheckNAddTwoStates(239, 240); + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 28; + break; + case 171: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + break; + case 525: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + break; + case 38: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(0, 3); + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 37; + break; + case 173: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + if ((0x8000000080000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 211; + else if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 172; + break; + case 24: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddStates(817, 822); + } + else if (curChar == 92) + jjCheckNAddStates(823, 826); + else if (curChar == 64) + jjAddStates(827, 831); + if ((0x20000000200000L & l) != 0L) + jjAddStates(832, 834); + else if ((0x800000008L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 151; + else if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 141; + else if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 133; + else if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 29; + else if (curChar == 64) + jjAddStates(835, 838); + break; + case 172: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + if ((0x400000004000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 171; + break; + case 170: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + else if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 169; + break; + case 174: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + } + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 212; + else if ((0x80000000800000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 200; + else if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 184; + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 173; + break; + case 75: + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + } + else if (curChar == 92) + jjCheckNAddTwoStates(79, 89); + break; + case 522: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(0, 3); + else if (curChar == 92) + jjCheckNAddTwoStates(227, 228); + if ((0x7fffffe87fffffeL & l) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + else if (curChar == 92) + jjCheckNAddTwoStates(239, 240); + break; + case 1: + if (curChar == 123) + jjstateSet[jjnewStateCnt++] = 2; + break; + case 4: + case 5: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(138, 140); + break; + case 6: + if (curChar == 125 && kind > 39) + kind = 39; + break; + case 7: + if (curChar == 92) + jjCheckNAddTwoStates(8, 9); + break; + case 8: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(138, 140); + break; + case 9: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(141, 145); + break; + case 11: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(146, 153); + break; + case 12: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(154, 157); + break; + case 13: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(158, 162); + break; + case 14: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(163, 168); + break; + case 15: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(169, 175); + break; + case 17: + if (curChar == 92) + jjCheckNAddTwoStates(8, 18); + break; + case 18: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(176, 180); + break; + case 19: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(181, 188); + break; + case 20: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(189, 192); + break; + case 21: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(193, 197); + break; + case 22: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(198, 203); + break; + case 23: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(204, 210); + break; + case 25: + if ((0x4000000040000L & l) != 0L && kind > 68) + kind = 68; + break; + case 26: + case 31: + if ((0x2000000020L & l) != 0L) + jjCheckNAdd(25); + break; + case 27: + if ((0x10000000100000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 26; + break; + case 28: + if ((0x100000001000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 27; + break; + case 30: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 29; + break; + case 32: + if ((0x10000000100000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 31; + break; + case 33: + if ((0x100000001000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 32; + break; + case 34: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 33; + break; + case 35: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 34; + break; + case 37: + if ((0x8000000080000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 36; + break; + case 41: + case 46: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(130, 133); + break; + case 43: + if (curChar == 92) + jjAddStates(839, 842); + break; + case 45: + if (curChar == 92) + jjAddStates(843, 844); + break; + case 47: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(211, 216); + break; + case 49: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(217, 225); + break; + case 50: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(226, 230); + break; + case 51: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(231, 236); + break; + case 52: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(237, 243); + break; + case 53: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(244, 251); + break; + case 58: + case 63: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(126, 129); + break; + case 60: + if (curChar == 92) + jjAddStates(845, 848); + break; + case 62: + if (curChar == 92) + jjAddStates(849, 850); + break; + case 64: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(252, 257); + break; + case 66: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(258, 266); + break; + case 67: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(267, 271); + break; + case 68: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(272, 277); + break; + case 69: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(278, 284); + break; + case 70: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(285, 292); + break; + case 76: + case 77: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 78: + if (curChar == 92) + jjCheckNAddTwoStates(79, 80); + break; + case 79: + if ((0x7fffffffffffffffL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 80: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(293, 296); + break; + case 82: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(297, 303); + break; + case 83: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(304, 306); + break; + case 84: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(307, 310); + break; + case 85: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(311, 315); + break; + case 86: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(316, 321); + break; + case 88: + if (curChar == 92) + jjCheckNAddTwoStates(79, 89); + break; + case 89: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(322, 325); + break; + case 90: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(326, 332); + break; + case 91: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(333, 335); + break; + case 92: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(336, 339); + break; + case 93: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(340, 344); + break; + case 94: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddStates(345, 350); + break; + case 96: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 97: + if (curChar == 92) + jjAddStates(851, 852); + break; + case 98: + if ((0x7fffffffffffffffL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 99: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(351, 354); + break; + case 101: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(355, 361); + break; + case 102: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(362, 364); + break; + case 103: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(365, 368); + break; + case 104: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(369, 373); + break; + case 105: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddStates(374, 379); + break; + case 106: + if (curChar == 64) + jjAddStates(835, 838); + break; + case 108: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 109: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 110: + if (curChar == 92) + jjCheckNAddTwoStates(111, 112); + break; + case 111: + if ((0x7fffffffffffffffL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 112: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(380, 383); + break; + case 114: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(384, 390); + break; + case 115: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(391, 393); + break; + case 116: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(394, 397); + break; + case 117: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(398, 402); + break; + case 118: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(403, 408); + break; + case 120: + if (curChar == 92) + jjCheckNAddTwoStates(111, 121); + break; + case 121: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(409, 412); + break; + case 122: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(413, 419); + break; + case 123: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(420, 422); + break; + case 124: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(423, 426); + break; + case 125: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(427, 431); + break; + case 126: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddStates(432, 437); + break; + case 127: + if ((0x2000000020L & l) != 0L) + jjAddStates(438, 439); + break; + case 130: + if ((0x40000000400000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 127; + break; + case 131: + if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 130; + break; + case 132: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 131; + break; + case 133: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 132; + break; + case 134: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 133; + break; + case 135: + if ((0x1000000010L & l) != 0L) + jjAddStates(440, 441); + break; + case 138: + if ((0x400000004000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 135; + break; + case 139: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 138; + break; + case 140: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 139; + break; + case 141: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 140; + break; + case 142: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 141; + break; + case 143: + if ((0x8000000080000L & l) != 0L) + jjAddStates(442, 443); + break; + case 146: + if ((0x400000004000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 143; + break; + case 147: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 146; + break; + case 148: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 147; + break; + case 149: + if ((0x10000000100000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 148; + break; + case 150: + if ((0x400000004000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 149; + break; + case 151: + if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 150; + break; + case 152: + if ((0x800000008L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 151; + break; + case 153: + if (curChar == 64) + jjAddStates(827, 831); + break; + case 154: + if ((0x8000000080000L & l) != 0L && kind > 102) + kind = 102; + break; + case 155: + case 163: + case 176: + case 187: + case 203: + if ((0x2000000020L & l) != 0L) + jjCheckNAdd(154); + break; + case 156: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 155; + break; + case 157: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 156; + break; + case 158: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 157; + break; + case 159: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 158; + break; + case 160: + if ((0x200000002000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 159; + break; + case 161: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 160; + break; + case 164: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 163; + break; + case 165: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 164; + break; + case 166: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 165; + break; + case 167: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 166; + break; + case 168: + if ((0x200000002000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 167; + break; + case 169: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 168; + break; + case 177: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 176; + break; + case 178: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 177; + break; + case 179: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 178; + break; + case 180: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 179; + break; + case 181: + if ((0x200000002000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 180; + break; + case 182: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 181; + break; + case 183: + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 182; + break; + case 185: + if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 184; + break; + case 188: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 187; + break; + case 189: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 188; + break; + case 190: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 189; + break; + case 191: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 190; + break; + case 192: + if ((0x200000002000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 191; + break; + case 193: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 192; + break; + case 194: + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 193; + break; + case 196: + if ((0x10000000100000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 195; + break; + case 197: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 196; + break; + case 198: + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 197; + break; + case 199: + if ((0x400000004L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 198; + break; + case 200: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 199; + break; + case 201: + if ((0x80000000800000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 200; + break; + case 204: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 203; + break; + case 205: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 204; + break; + case 206: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 205; + break; + case 207: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 206; + break; + case 208: + if ((0x200000002000000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 207; + break; + case 209: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 208; + break; + case 210: + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 209; + break; + case 212: + if ((0x8000000080000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 211; + break; + case 213: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 212; + break; + case 217: + if (kind > 2) + kind = 2; + jjAddStates(9, 11); + break; + case 222: + if (kind > 3) + kind = 3; + break; + case 225: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 226: + if (curChar == 92) + jjCheckNAddTwoStates(227, 228); + break; + case 227: + if ((0x7fffffffffffffffL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 228: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(444, 447); + break; + case 230: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(448, 454); + break; + case 231: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(455, 457); + break; + case 232: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(458, 461); + break; + case 233: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(462, 466); + break; + case 234: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(467, 472); + break; + case 235: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 238: + if (curChar == 92) + jjCheckNAddTwoStates(239, 240); + break; + case 239: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 240: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(473, 477); + break; + case 242: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(478, 485); + break; + case 243: + case 457: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(486, 489); + break; + case 244: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(490, 494); + break; + case 245: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(495, 500); + break; + case 246: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(501, 507); + break; + case 249: + if ((0x10000000100000L & l) != 0L && kind > 70) + kind = 70; + break; + case 250: + if ((0x100000001000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 249; + break; + case 251: + if ((0x20000000200000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 250; + break; + case 252: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 251; + break; + case 253: + if ((0x4000000040L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 252; + break; + case 254: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 253; + break; + case 255: + if ((0x1000000010L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 254; + break; + case 257: + if ((0x10000000100000L & l) != 0L && kind > 104) + kind = 104; + break; + case 258: + if ((0x400000004000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 257; + break; + case 259: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 258; + break; + case 260: + if ((0x10000000100000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 259; + break; + case 261: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 260; + break; + case 262: + if ((0x800000008000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 261; + break; + case 263: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 262; + break; + case 264: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 263; + break; + case 265: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 264; + break; + case 267: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 268: + if ((0x7fffffe87fffffeL & l) != 0L) + jjCheckNAddStates(0, 3); + break; + case 269: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(817, 822); + break; + case 275: + if ((0x10000000100000L & l) != 0L && kind > 78) + kind = 78; + break; + case 276: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 275; + break; + case 278: + if ((0x200000002000L & l) != 0L && kind > 79) + kind = 79; + break; + case 279: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 278; + break; + case 281: + if ((0x200000002000L & l) != 0L && kind > 80) + kind = 80; + break; + case 282: + if ((0x800000008L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 281; + break; + case 284: + if ((0x800000008L & l) != 0L && kind > 81) + kind = 81; + break; + case 285: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 284; + break; + case 287: + if ((0x400000004000L & l) != 0L && kind > 82) + kind = 82; + break; + case 288: + if ((0x20000000200L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 287; + break; + case 290: + if ((0x100000001000000L & l) != 0L && kind > 83) + kind = 83; + break; + case 291: + if ((0x1000000010000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 290; + break; + case 293: + if ((0x200000002000L & l) != 0L && kind > 84) + kind = 84; + break; + case 294: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 293; + break; + case 296: + if ((0x200000002000L & l) != 0L && kind > 85) + kind = 85; + break; + case 297: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 296; + break; + case 298: + if ((0x100000001000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 297; + break; + case 300: + if ((0x200000002000L & l) != 0L && kind > 86) + kind = 86; + break; + case 301: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 300; + break; + case 302: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 301; + break; + case 304: + if ((0x100000001000000L & l) != 0L && kind > 87) + kind = 87; + break; + case 305: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 304; + break; + case 307: + if ((0x8000000080L & l) != 0L && kind > 88) + kind = 88; + break; + case 308: + if ((0x2000000020L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 307; + break; + case 309: + if ((0x1000000010L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 308; + break; + case 311: + if ((0x1000000010L & l) != 0L && kind > 89) + kind = 89; + break; + case 312: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 311; + break; + case 313: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 312; + break; + case 315: + if ((0x1000000010L & l) != 0L && kind > 90) + kind = 90; + break; + case 316: + if ((0x200000002L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 315; + break; + case 317: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 316; + break; + case 318: + if ((0x8000000080L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 317; + break; + case 320: + if ((0x8000000080000L & l) != 0L && kind > 91) + kind = 91; + break; + case 321: + if ((0x200000002000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 320; + break; + case 323: + if ((0x8000000080000L & l) != 0L && kind > 92) + kind = 92; + break; + case 325: + if ((0x400000004000000L & l) != 0L && kind > 93) + kind = 93; + break; + case 326: + if ((0x10000000100L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 325; + break; + case 328: + if ((0x400000004000000L & l) != 0L && kind > 94) + kind = 94; + break; + case 329: + if ((0x10000000100L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 328; + break; + case 330: + if ((0x80000000800L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 329; + break; + case 333: + case 334: + if ((0x7fffffe87fffffeL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 335: + if (curChar == 92) + jjCheckNAddTwoStates(336, 337); + break; + case 336: + if ((0x7fffffffffffffffL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 337: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(508, 511); + break; + case 339: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(512, 518); + break; + case 340: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(519, 521); + break; + case 341: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(522, 525); + break; + case 342: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(526, 530); + break; + case 343: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(531, 536); + break; + case 345: + if (curChar == 92) + jjCheckNAddTwoStates(336, 346); + break; + case 346: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(537, 540); + break; + case 347: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(541, 547); + break; + case 348: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(548, 550); + break; + case 349: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(551, 554); + break; + case 350: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(555, 559); + break; + case 351: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddStates(560, 565); + break; + case 352: + if ((0x20000000200000L & l) != 0L) + jjAddStates(832, 834); + break; + case 354: + case 358: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(572, 575); + break; + case 357: + if (curChar == 92) + jjAddStates(853, 854); + break; + case 359: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(576, 580); + break; + case 361: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(581, 588); + break; + case 362: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(589, 592); + break; + case 363: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(593, 597); + break; + case 364: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(598, 603); + break; + case 365: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(604, 610); + break; + case 367: + case 372: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(611, 614); + break; + case 369: + if (curChar == 92) + jjAddStates(855, 858); + break; + case 371: + if (curChar == 92) + jjAddStates(859, 860); + break; + case 373: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(615, 620); + break; + case 375: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(621, 629); + break; + case 376: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(630, 634); + break; + case 377: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(635, 640); + break; + case 378: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(641, 647); + break; + case 379: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(648, 655); + break; + case 384: + case 389: + if ((0x7fffffffffffffffL & l) != 0L) + jjCheckNAddStates(656, 659); + break; + case 386: + if (curChar == 92) + jjAddStates(861, 864); + break; + case 388: + if (curChar == 92) + jjAddStates(865, 866); + break; + case 390: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(660, 665); + break; + case 392: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(666, 674); + break; + case 393: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(675, 679); + break; + case 394: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(680, 685); + break; + case 395: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(686, 692); + break; + case 396: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(693, 700); + break; + case 401: + if ((0x100000001000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 353; + break; + case 402: + if ((0x4000000040000L & l) != 0L) + jjstateSet[jjnewStateCnt++] = 401; + break; + case 410: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjAddStates(717, 722); + break; + case 411: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 412; + break; + case 412: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 413; + break; + case 413: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAdd(414); + break; + case 414: + if ((0x7e0000007eL & l) != 0L && kind > 114) + kind = 114; + break; + case 415: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 416; + break; + case 416: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 417; + break; + case 417: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 418; + break; + case 418: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 406; + break; + case 419: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 420; + break; + case 420: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 421; + break; + case 421: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 422; + break; + case 423: + if ((0x7e0000007eL & l) != 0L) + jjstateSet[jjnewStateCnt++] = 424; + break; + case 424: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 425; + break; + case 427: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 428; + break; + case 436: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(437, 443); + break; + case 438: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjstateSet[jjnewStateCnt++] = 439; + break; + case 439: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(733, 736); + break; + case 440: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAdd(414); + break; + case 441: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddTwoStates(414, 440); + break; + case 442: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 114) + kind = 114; + jjCheckNAddStates(737, 739); + break; + case 443: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(740, 744); + break; + case 444: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAdd(437); + break; + case 445: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddTwoStates(444, 437); + break; + case 446: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(745, 747); + break; + case 447: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(748, 751); + break; + case 448: + if (curChar == 92) + jjCheckNAddStates(823, 826); + break; + case 449: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(752, 755); + break; + case 450: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(756, 762); + break; + case 451: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(763, 765); + break; + case 452: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(766, 769); + break; + case 453: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(770, 774); + break; + case 454: + if ((0x7e0000007eL & l) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddStates(775, 780); + break; + case 455: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(781, 785); + break; + case 456: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(786, 793); + break; + case 458: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(794, 798); + break; + case 459: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(799, 804); + break; + case 460: + if ((0x7e0000007eL & l) != 0L) + jjCheckNAddStates(805, 811); + break; + default : break; + } + } while(i != startsAt); + } + else + { + int i2 = (curChar & 0xff) >> 6; + long l2 = 1L << (curChar & 077); + do + { + switch(jjstateSet[--i]) + { + case 162: + case 111: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 29: + if ((jjbitVec0[i2] & l2) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(0, 3); + break; + case 171: + case 109: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 525: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 173: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 24: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 40) + kind = 40; + jjCheckNAddStates(817, 822); + break; + case 172: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 170: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 103) + kind = 103; + jjCheckNAddTwoStates(109, 110); + break; + case 75: + case 77: + case 79: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 76) + kind = 76; + jjCheckNAddTwoStates(77, 78); + break; + case 522: + if ((jjbitVec0[i2] & l2) != 0L) + { + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + } + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(0, 3); + break; + case 5: + case 8: + case 16: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(138, 140); + break; + case 41: + case 46: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(130, 133); + break; + case 58: + case 63: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(126, 129); + break; + case 96: + case 98: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 96) + kind = 96; + jjCheckNAddTwoStates(96, 97); + break; + case 217: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 2) + kind = 2; + jjAddStates(9, 11); + break; + case 222: + if ((jjbitVec0[i2] & l2) != 0L && kind > 3) + kind = 3; + break; + case 225: + case 227: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 72) + kind = 72; + jjCheckNAddTwoStates(225, 226); + break; + case 235: + case 239: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(0, 3); + break; + case 334: + case 336: + case 344: + if ((jjbitVec0[i2] & l2) == 0L) + break; + if (kind > 95) + kind = 95; + jjCheckNAddTwoStates(334, 335); + break; + case 354: + case 358: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(572, 575); + break; + case 367: + case 372: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(611, 614); + break; + case 384: + case 389: + if ((jjbitVec0[i2] & l2) != 0L) + jjCheckNAddStates(656, 659); + break; + default : break; + } + } while(i != startsAt); + } + if (kind != 0x7fffffff) + { + jjmatchedKind = kind; + jjmatchedPos = curPos; + kind = 0x7fffffff; + } + ++curPos; + if ((i = jjnewStateCnt) == (startsAt = 522 - (jjnewStateCnt = startsAt))) + return curPos; + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { return curPos; } + } +} +private int jjMoveStringLiteralDfa0_2() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_2(0x40L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_2(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x40L) != 0L) + return jjStopAtPos(1, 6); + break; + default : + return 2; + } + return 2; +} +private int jjMoveStringLiteralDfa0_1() +{ + switch(curChar) + { + case 42: + return jjMoveStringLiteralDfa1_1(0x20L); + default : + return 1; + } +} +private int jjMoveStringLiteralDfa1_1(long active0) +{ + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + return 1; + } + switch(curChar) + { + case 47: + if ((active0 & 0x20L) != 0L) + return jjStopAtPos(1, 5); + break; + default : + return 2; + } + return 2; +} +static final int[] jjnextStates = { + 235, 236, 237, 238, 331, 332, 333, 344, 345, 217, 218, 220, 462, 463, 464, 465, + 466, 467, 273, 468, 469, 470, 276, 471, 472, 473, 279, 474, 475, 476, 282, 477, + 478, 479, 285, 480, 481, 482, 288, 483, 484, 485, 291, 486, 487, 488, 294, 489, + 490, 491, 298, 492, 493, 494, 302, 495, 496, 497, 305, 498, 499, 500, 309, 501, + 502, 503, 313, 504, 505, 506, 318, 507, 508, 509, 321, 510, 511, 512, 323, 513, + 514, 515, 326, 516, 517, 518, 330, 519, 520, 521, 332, 333, 344, 345, 271, 272, + 274, 277, 280, 283, 286, 289, 292, 295, 299, 303, 306, 310, 314, 319, 322, 324, + 327, 331, 267, 268, 248, 255, 256, 265, 216, 223, 75, 76, 87, 88, 58, 59, + 60, 62, 41, 42, 43, 45, 3, 4, 16, 17, 5, 6, 7, 5, 10, 6, + 7, 11, 5, 12, 10, 6, 7, 13, 14, 15, 5, 10, 6, 7, 5, 12, + 10, 6, 7, 5, 12, 10, 6, 7, 13, 5, 12, 10, 6, 7, 13, 14, + 10, 5, 6, 7, 19, 20, 10, 5, 6, 7, 21, 22, 23, 10, 5, 6, + 7, 20, 10, 5, 6, 7, 20, 10, 5, 6, 7, 21, 20, 10, 5, 6, + 7, 21, 22, 41, 48, 42, 43, 45, 49, 41, 50, 48, 42, 43, 45, 51, + 52, 53, 41, 48, 42, 43, 45, 41, 50, 48, 42, 43, 45, 41, 50, 48, + 42, 43, 45, 51, 41, 50, 48, 42, 43, 45, 51, 52, 58, 65, 59, 60, + 62, 66, 58, 67, 65, 59, 60, 62, 68, 69, 70, 58, 65, 59, 60, 62, + 58, 67, 65, 59, 60, 62, 58, 67, 65, 59, 60, 62, 68, 58, 67, 65, + 59, 60, 62, 68, 69, 77, 81, 78, 82, 77, 83, 81, 78, 84, 85, 86, + 77, 81, 78, 77, 83, 81, 78, 77, 83, 81, 78, 84, 77, 83, 81, 78, + 84, 85, 81, 77, 78, 90, 91, 81, 77, 78, 92, 93, 94, 81, 77, 78, + 91, 81, 77, 78, 91, 81, 77, 78, 92, 91, 81, 77, 78, 92, 93, 96, + 100, 97, 101, 96, 102, 100, 97, 103, 104, 105, 96, 100, 97, 96, 102, 100, + 97, 96, 102, 100, 97, 103, 96, 102, 100, 97, 103, 104, 109, 113, 110, 114, + 109, 115, 113, 110, 116, 117, 118, 109, 113, 110, 109, 115, 113, 110, 109, 115, + 113, 110, 116, 109, 115, 113, 110, 116, 117, 113, 109, 110, 122, 123, 113, 109, + 110, 124, 125, 126, 113, 109, 110, 123, 113, 109, 110, 123, 113, 109, 110, 124, + 123, 113, 109, 110, 124, 125, 128, 129, 136, 137, 144, 145, 225, 229, 226, 230, + 225, 231, 229, 226, 232, 233, 234, 225, 229, 226, 225, 231, 229, 226, 225, 231, + 229, 226, 232, 225, 231, 229, 226, 232, 233, 235, 237, 238, 241, 242, 235, 243, + 237, 238, 241, 244, 245, 246, 235, 237, 238, 241, 235, 243, 237, 238, 241, 235, + 243, 237, 238, 241, 244, 235, 243, 237, 238, 241, 244, 245, 334, 338, 335, 339, + 334, 340, 338, 335, 341, 342, 343, 334, 338, 335, 334, 340, 338, 335, 334, 340, + 338, 335, 341, 334, 340, 338, 335, 341, 342, 338, 334, 335, 347, 348, 338, 334, + 335, 349, 350, 351, 338, 334, 335, 348, 338, 334, 335, 348, 338, 334, 335, 349, + 348, 338, 334, 335, 349, 350, 354, 366, 383, 356, 357, 400, 354, 355, 356, 357, + 354, 356, 357, 360, 361, 354, 362, 356, 357, 360, 363, 364, 365, 354, 356, 357, + 360, 354, 362, 356, 357, 360, 354, 362, 356, 357, 360, 363, 354, 362, 356, 357, + 360, 363, 364, 367, 368, 369, 371, 367, 374, 368, 369, 371, 375, 367, 376, 374, + 368, 369, 371, 377, 378, 379, 367, 374, 368, 369, 371, 367, 376, 374, 368, 369, + 371, 367, 376, 374, 368, 369, 371, 377, 367, 376, 374, 368, 369, 371, 377, 378, + 384, 385, 386, 388, 384, 391, 385, 386, 388, 392, 384, 393, 391, 385, 386, 388, + 394, 395, 396, 384, 391, 385, 386, 388, 384, 393, 391, 385, 386, 388, 384, 393, + 391, 385, 386, 388, 394, 384, 393, 391, 385, 386, 388, 394, 395, 354, 366, 383, + 355, 356, 357, 400, 404, 410, 406, 407, 408, 409, 406, 407, 408, 411, 415, 419, + 423, 427, 431, 406, 429, 430, 406, 432, 433, 434, 406, 432, 433, 414, 440, 441, + 442, 414, 440, 441, 444, 437, 445, 446, 447, 444, 437, 445, 444, 437, 445, 446, + 229, 225, 226, 450, 451, 229, 225, 226, 452, 453, 454, 229, 225, 226, 451, 229, + 225, 226, 451, 229, 225, 226, 452, 451, 229, 225, 226, 452, 453, 235, 237, 238, + 241, 456, 457, 235, 237, 238, 241, 458, 459, 460, 457, 235, 237, 238, 241, 457, + 235, 237, 238, 241, 458, 457, 235, 237, 238, 241, 458, 459, 519, 332, 333, 344, + 345, 225, 235, 236, 237, 238, 226, 227, 449, 239, 455, 162, 175, 186, 202, 214, + 402, 403, 435, 107, 108, 119, 120, 44, 54, 56, 55, 46, 47, 61, 71, 73, + 72, 63, 64, 98, 99, 358, 359, 370, 380, 382, 381, 372, 373, 387, 397, 399, + 398, 389, 390, +}; + +/** Token literal values. */ +public static final String[] jjstrLiteralImages = { +"", null, null, null, null, null, null, null, "\74\41\55\55", "\55\55\76", +"\173", "\175", "\174\75", "\136\75", "\44\75", "\52\75", "\176\75", "\75", "\53", +"\55", "\54", "\73", "\76", "\176", "\74", "\57", "\133", "\135", "\52", "\45", +"\46", "\56", "\50", "\51", "\75\75", "\174\174", "\46\46", "\41\75", "\72", null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, null, null, null, null, +null, null, null, null, null, null, null, null, null, null, }; + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", + "IN_FORMAL_COMMENT", + "IN_MULTI_LINE_COMMENT", +}; + +/** Lex State array. */ +public static final int[] jjnewLexState = { + -1, -1, -1, 1, 2, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +}; +static final long[] jjtoToken = { + 0xfffe01ffffffff03L, 0xfc01fffffffbffL, +}; +static final long[] jjtoSkip = { + 0x64L, 0x0L, +}; +static final long[] jjtoSpecial = { + 0x24L, 0x0L, +}; +static final long[] jjtoMore = { + 0x98L, 0x0L, +}; +protected CharStream input_stream; +private final int[] jjrounds = new int[522]; +private final int[] jjstateSet = new int[1044]; +private final StringBuilder jjimage = new StringBuilder(); +private StringBuilder image = jjimage; +private int jjimageLen; +private int lengthOfMatch; +protected char curChar; +/** Constructor. */ +public ParserTokenManager(CharStream stream){ + input_stream = stream; +} + +/** Constructor. */ +public ParserTokenManager(CharStream stream, int lexState){ + this(stream); + SwitchTo(lexState); +} + +/** Reinitialise parser. */ +public void ReInit(CharStream stream) +{ + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); +} +private void ReInitRounds() +{ + int i; + jjround = 0x80000001; + for (i = 522; i-- > 0;) + jjrounds[i] = 0x80000000; +} + +/** Reinitialise parser. */ +public void ReInit(CharStream stream, int lexState) +{ + ReInit(stream); + SwitchTo(lexState); +} + +/** Switch to specified lex state. */ +public void SwitchTo(int lexState) +{ + if (lexState >= 3 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; +} + +protected Token jjFillToken() +{ + final Token t; + final String curTokenImage; + final int beginLine; + final int endLine; + final int beginColumn; + final int endColumn; + String im = jjstrLiteralImages[jjmatchedKind]; + curTokenImage = (im == null) ? input_stream.GetImage() : im; + beginLine = input_stream.getBeginLine(); + beginColumn = input_stream.getBeginColumn(); + endLine = input_stream.getEndLine(); + endColumn = input_stream.getEndColumn(); + t = Token.newToken(jjmatchedKind, curTokenImage); + + t.beginLine = beginLine; + t.endLine = endLine; + t.beginColumn = beginColumn; + t.endColumn = endColumn; + + return t; +} + +int curLexState = 0; +int defaultLexState = 0; +int jjnewStateCnt; +int jjround; +int jjmatchedPos; +int jjmatchedKind; + +/** Get the next Token. */ +public Token getNextToken() +{ + Token specialToken = null; + Token matchedToken; + int curPos = 0; + + EOFLoop : + for (;;) + { + try + { + curChar = input_stream.BeginToken(); + } + catch(java.io.IOException e) + { + jjmatchedKind = 0; + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + return matchedToken; + } + image = jjimage; + image.setLength(0); + jjimageLen = 0; + + for (;;) + { + switch(curLexState) + { + case 0: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_0(); + if (jjmatchedPos == 0 && jjmatchedKind > 119) + { + jjmatchedKind = 119; + } + break; + case 1: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_1(); + if (jjmatchedPos == 0 && jjmatchedKind > 7) + { + jjmatchedKind = 7; + } + break; + case 2: + jjmatchedKind = 0x7fffffff; + jjmatchedPos = 0; + curPos = jjMoveStringLiteralDfa0_2(); + if (jjmatchedPos == 0 && jjmatchedKind > 7) + { + jjmatchedKind = 7; + } + break; + } + if (jjmatchedKind != 0x7fffffff) + { + if (jjmatchedPos + 1 < curPos) + input_stream.backup(curPos - jjmatchedPos - 1); + if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + matchedToken.specialToken = specialToken; + TokenLexicalActions(matchedToken); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + return matchedToken; + } + else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) + { + matchedToken = jjFillToken(); + if (specialToken == null) + specialToken = matchedToken; + else + { + matchedToken.specialToken = specialToken; + specialToken = (specialToken.next = matchedToken); + } + SkipLexicalActions(matchedToken); + } + else + SkipLexicalActions(null); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + continue EOFLoop; + } + MoreLexicalActions(); + if (jjnewLexState[jjmatchedKind] != -1) + curLexState = jjnewLexState[jjmatchedKind]; + curPos = 0; + jjmatchedKind = 0x7fffffff; + try { + curChar = input_stream.readChar(); + continue; + } + catch (java.io.IOException e1) { } + } + int error_line = input_stream.getEndLine(); + int error_column = input_stream.getEndColumn(); + String error_after = null; + boolean EOFSeen = false; + try { input_stream.readChar(); input_stream.backup(1); } + catch (java.io.IOException e1) { + EOFSeen = true; + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + if (curChar == '\n' || curChar == '\r') { + error_line++; + error_column = 0; + } + else + error_column++; + } + if (!EOFSeen) { + input_stream.backup(1); + error_after = curPos <= 1 ? "" : input_stream.GetImage(); + } + throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); + } + } +} + +void SkipLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + default : + break; + } +} +void MoreLexicalActions() +{ + jjimageLen += (lengthOfMatch = jjmatchedPos + 1); + switch(jjmatchedKind) + { + case 3 : + image.append(input_stream.GetSuffix(jjimageLen)); + jjimageLen = 0; + input_stream.backup(1); + break; + default : + break; + } +} +void TokenLexicalActions(Token matchedToken) +{ + switch(jjmatchedKind) + { + case 1 : + image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1))); + image = Parser.SPACE; + break; + default : + break; + } +} +private void jjCheckNAdd(int state) +{ + if (jjrounds[state] != jjround) + { + jjstateSet[jjnewStateCnt++] = state; + jjrounds[state] = jjround; + } +} +private void jjAddStates(int start, int end) +{ + do { + jjstateSet[jjnewStateCnt++] = jjnextStates[start]; + } while (start++ != end); +} +private void jjCheckNAddTwoStates(int state1, int state2) +{ + jjCheckNAdd(state1); + jjCheckNAdd(state2); +} + +private void jjCheckNAddStates(int start, int end) +{ + do { + jjCheckNAdd(jjnextStates[start]); + } while (start++ != end); +} + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java new file mode 100644 index 0000000000..26d1121f96 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java @@ -0,0 +1,146 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ +/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ +package com.vaadin.sass.internal.parser; + +/** + * Describes the input token stream. + */ + +public class Token implements java.io.Serializable { + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /** + * An integer that describes the kind of this token. This numbering + * system is determined by JavaCCParser, and a table of these numbers is + * stored in the file ...Constants.java. + */ + public int kind; + + /** The line number of the first character of this Token. */ + public int beginLine; + /** The column number of the first character of this Token. */ + public int beginColumn; + /** The line number of the last character of this Token. */ + public int endLine; + /** The column number of the last character of this Token. */ + public int endColumn; + + /** + * The string image of the token. + */ + public String image; + + /** + * A reference to the next regular (non-special) token from the input + * stream. If this is the last token from the input stream, or if the + * token manager has not read tokens beyond this one, this field is + * set to null. This is true only if this token is also a regular + * token. Otherwise, see below for a description of the contents of + * this field. + */ + public Token next; + + /** + * This field is used to access special tokens that occur prior to this + * token, but after the immediately preceding regular (non-special) token. + * If there are no such special tokens, this field is set to null. + * When there are more than one such special token, this field refers + * to the last of these special tokens, which in turn refers to the next + * previous special token through its specialToken field, and so on + * until the first special token (whose specialToken field is null). + * The next fields of special tokens refer to other special tokens that + * immediately follow it (without an intervening regular token). If there + * is no such token, this field is null. + */ + public Token specialToken; + + /** + * An optional attribute value of the Token. + * Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or + * interpreter. This attribute value is often different from the image. + * Any subclass of Token that actually wants to return a non-null value can + * override this method as appropriate. + */ + public Object getValue() { + return null; + } + + /** + * No-argument constructor + */ + public Token() {} + + /** + * Constructs a new token for the specified Image. + */ + public Token(int kind) + { + this(kind, null); + } + + /** + * Constructs a new token for the specified Image and Kind. + */ + public Token(int kind, String image) + { + this.kind = kind; + this.image = image; + } + + /** + * Returns the image. + */ + public String toString() + { + return image; + } + + /** + * Returns a new Token object, by default. However, if you want, you + * can create and return subclass objects based on the value of ofKind. + * Simply add the cases to the switch for all those special cases. + * For example, if you have a subclass of Token called IDToken that + * you want to create if ofKind is ID, simply add something like : + * + * case MyParserConstants.ID : return new IDToken(ofKind, image); + * + * to the following switch statement. Then you can cast matchedToken + * variable to the appropriate type and use sit in your lexical actions. + */ + public static Token newToken(int ofKind, String image) + { + switch(ofKind) + { + default : return new Token(ofKind, image); + } + } + + public static Token newToken(int ofKind) + { + return newToken(ofKind, null); + } + +} +/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java new file mode 100644 index 0000000000..f093357e96 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java @@ -0,0 +1,162 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ +/* JavaCCOptions: */ +package com.vaadin.sass.internal.parser; + +/** Token Manager Error. */ +public class TokenMgrError extends Error +{ + + /** + * The version identifier for this Serializable class. + * Increment only if the serialized form of the + * class changes. + */ + private static final long serialVersionUID = 1L; + + /* + * Ordinals for various reasons why an Error of this type can be thrown. + */ + + /** + * Lexical error occurred. + */ + static final int LEXICAL_ERROR = 0; + + /** + * An attempt was made to create a second instance of a static token manager. + */ + static final int STATIC_LEXER_ERROR = 1; + + /** + * Tried to change to an invalid lexical state. + */ + static final int INVALID_LEXICAL_STATE = 2; + + /** + * Detected (and bailed out of) an infinite loop in the token manager. + */ + static final int LOOP_DETECTED = 3; + + /** + * Indicates the reason why the exception is thrown. It will have + * one of the above 4 values. + */ + int errorCode; + + /** + * Replaces unprintable characters by their escaped (or unicode escaped) + * equivalents in the given string + */ + protected static final String addEscapes(String str) { + StringBuffer retval = new StringBuffer(); + char ch; + for (int i = 0; i < str.length(); i++) { + switch (str.charAt(i)) + { + case 0 : + continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4, s.length())); + } else { + retval.append(ch); + } + continue; + } + } + return retval.toString(); + } + + /** + * Returns a detailed message for the Error when it is thrown by the + * token manager to indicate a lexical error. + * Parameters : + * EOFSeen : indicates if EOF caused the lexical error + * curLexState : lexical state in which this error occurred + * errorLine : line number when the error occurred + * errorColumn : column number when the error occurred + * errorAfter : prefix that was seen before this error occurred + * curchar : the offending character + * Note: You can customize the lexical error message by modifying this method. + */ + protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { + return("Lexical error at line " + + errorLine + ", column " + + errorColumn + ". Encountered: " + + (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); + } + + /** + * You can also modify the body of this method to customize your error messages. + * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not + * of end-users concern, so you can return something like : + * + * "Internal Error : Please file a bug report .... " + * + * from this method for such cases in the release version of your parser. + */ + public String getMessage() { + return super.getMessage(); + } + + /* + * Constructors of various flavors follow. + */ + + /** No arg constructor. */ + public TokenMgrError() { + } + + /** Constructor with message and reason. */ + public TokenMgrError(String message, int reason) { + super(message); + errorCode = reason; + } + + /** Full Constructor. */ + public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { + this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); + } +} +/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ diff --git a/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java b/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java index e70201b11a..1ed5075bd5 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/parser/ParserTest.java @@ -34,7 +34,7 @@ public class ParserTest { @Test public void testParsePropertyValue() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); LexicalUnit value = parser.parsePropertyValue(new InputSource( new StringReader("$margin/2;"))); @@ -53,7 +53,7 @@ public class ParserTest { @Test public void testCanIngoreSingleLineComment() { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); try { diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java index 32c4c37ce7..d823ccf860 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Interpolation.java @@ -36,7 +36,7 @@ public class Interpolation extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java index 9e110ecd97..6a09917d99 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Comments.java @@ -38,7 +38,7 @@ public class Comments extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java index 915bbb0f46..1e3eb09f0c 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java @@ -42,7 +42,7 @@ public class CompassImports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scssOtherDirectory) diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java index e11cb854c9..14cac4bb19 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ControlDirectives.java @@ -43,7 +43,7 @@ public class ControlDirectives extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java index 649a5777c3..b3c20b0ab6 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Extends.java @@ -37,7 +37,7 @@ public class Extends extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java index ce0875a884..5c41494ac6 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Functions.java @@ -36,7 +36,7 @@ public class Functions extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java index 128cc2fe06..aaa1a1439a 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Imports.java @@ -37,7 +37,7 @@ public class Imports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java index 0c441c7c2d..e4faee6e2a 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Mixins.java @@ -42,7 +42,7 @@ public class Mixins extends AbstractTestBase { @Test public void testParser() throws CSSException, URISyntaxException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java index 26b61a0888..9a91df04ba 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/NestedProperties.java @@ -38,7 +38,7 @@ public class NestedProperties extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java index cd213f9de4..04aca5e8d3 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Nesting.java @@ -37,7 +37,7 @@ public class Nesting extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java index 668d1e36f2..daa7dbbf07 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentImports.java @@ -37,7 +37,7 @@ public class ParentImports extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java index a6608b75d6..443d4a1086 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/ParentSelector.java @@ -35,7 +35,7 @@ public class ParentSelector extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java index 732426497f..a0727736e4 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/VariableGuarded.java @@ -19,7 +19,7 @@ public class VariableGuarded extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java index d623b00112..7f71d46f0d 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/Variables.java @@ -40,7 +40,7 @@ public class Variables extends AbstractTestBase { @Test public void testParser() throws CSSException, IOException { - Parser parser = Parser.ParserAccessor.getParser(); + Parser parser = new Parser(); SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl(); parser.setDocumentHandler(handler); parser.parseStyleSheet(getClass().getResource(scss).getPath()); -- cgit v1.2.3 From 168788959373f561b8862128fa6aedc20a5591c2 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 13 Jan 2014 17:03:01 +0200 Subject: Retain focus while changing DOM in OrderedLayout (#12967) Change-Id: Id25177a2dfecc2d0d3b8bb5803656a39bec9c5d6 --- .../com/vaadin/client/ui/orderedlayout/Slot.java | 51 +++++++++++ .../VerticalLayoutFocusWithDOMChanges.java | 63 +++++++++++++ .../VerticalLayoutFocusWithDOMChangesTest.java | 100 +++++++++++++++++++++ .../src/com/vaadin/tests/tb3/AbstractTB3Test.java | 16 ++++ 4 files changed, 230 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChanges.java create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java diff --git a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java index 49b3661431..37a97f3399 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/Slot.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/Slot.java @@ -19,9 +19,11 @@ package com.vaadin.client.ui.orderedlayout; import java.util.List; import com.google.gwt.aria.client.Roles; +import com.google.gwt.dom.client.Document; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.UIObject; import com.google.gwt.user.client.ui.Widget; @@ -456,6 +458,9 @@ public final class Slot extends SimplePanel { // Caption wrappers Widget widget = getWidget(); + final Element focusedElement = Util.getFocusedElement(); + // By default focus will not be lost + boolean focusLost = false; if (captionText != null || iconUrl != null || error != null || required) { if (caption == null) { caption = DOM.createDiv(); @@ -466,6 +471,10 @@ public final class Slot extends SimplePanel { orphan(widget); captionWrap.appendChild(widget.getElement()); adopt(widget); + + // Made changes to DOM. Focus can be lost if it was in the + // widget. + focusLost = widget.getElement().isOrHasChild(focusedElement); } } else if (caption != null) { orphan(widget); @@ -474,6 +483,9 @@ public final class Slot extends SimplePanel { captionWrap.removeFromParent(); caption = null; captionWrap = null; + + // Made changes to DOM. Focus can be lost if it was in the widget. + focusLost = widget.getElement().isOrHasChild(focusedElement); } // Caption text @@ -560,6 +572,45 @@ public final class Slot extends SimplePanel { setCaptionPosition(CaptionPosition.RIGHT); } } + + if (focusLost) { + // Find out what element is currently focused. + Element currentFocus = Util.getFocusedElement(); + if (currentFocus != null + && currentFocus.equals(Document.get().getBody())) { + // Focus has moved to BodyElement and should be moved back to + // original location. This happened because of adding or + // removing the captionWrap + focusedElement.focus(); + } else if (currentFocus != focusedElement) { + // Focus is either moved somewhere else on purpose or IE has + // lost it. Investigate further. + Timer focusTimer = new Timer() { + + @Override + public void run() { + if (Util.getFocusedElement() == null) { + // This should never become an infinite loop and + // even if it does it will be stopped once something + // is done with the browser. + schedule(25); + } else if (Util.getFocusedElement().equals( + Document.get().getBody())) { + // Focus found it's way to BodyElement. Now it can + // be restored + focusedElement.focus(); + } + } + }; + if (BrowserInfo.get().isIE8()) { + // IE8 can't fix the focus immediately. It will fail. + focusTimer.schedule(25); + } else { + // Newer IE versions can handle things immediately. + focusTimer.run(); + } + } + } } /** diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChanges.java b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChanges.java new file mode 100644 index 0000000000..1e7d817094 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChanges.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.orderedlayout; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class VerticalLayoutFocusWithDOMChanges extends AbstractTestUI implements + ValueChangeListener { + + Button dummyButton = new Button("Just a button"); + TextField listenedTextField = new TextField(); + TextField changingTextField = new TextField(); + + @Override + protected void setup(VaadinRequest request) { + VerticalLayout content = new VerticalLayout(); + setSizeFull(); + listenedTextField.addValueChangeListener(this); + listenedTextField.setImmediate(true); + changingTextField.setImmediate(true); + content.addComponent(dummyButton); + content.addComponent(listenedTextField); + content.addComponent(changingTextField); + content.setMargin(true); + content.setSpacing(true); + setContent(content); + } + + @Override + protected String getTestDescription() { + return "Check that creating or removing caption wrap doesn't lose focus"; + } + + @Override + protected Integer getTicketNumber() { + return 12967; + } + + @Override + public void valueChange(ValueChangeEvent event) { + changingTextField.setRequired(!changingTextField.isRequired()); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java new file mode 100644 index 0000000000..14c26a0e17 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/VerticalLayoutFocusWithDOMChangesTest.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.orderedlayout; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class VerticalLayoutFocusWithDOMChangesTest extends MultiBrowserTest { + + private String initialText = "Some"; + private String incrementalText = " text"; + + @Test + public void inputTextAndChangeFocus() throws InterruptedException { + openTestURL(); + List textFields = getDriver().findElements( + By.tagName("input")); + WebElement tf1 = textFields.get(0); + WebElement tf2 = textFields.get(1); + tf1.sendKeys(initialText); + new Actions(getDriver()).moveToElement(tf2).click().build().perform(); + + WebElement activeElement = getFocusedElement(); + Assert.assertEquals("input", activeElement.getTagName()); + Assert.assertEquals("", activeElement.getAttribute("value")); + + tf1.sendKeys(incrementalText); + new Actions(getDriver()) + .moveToElement( + getDriver().findElement(By.className("v-button"))) + .click().build().perform(); + activeElement = getFocusedElement(); + Assert.assertEquals("Just a button", activeElement.getText()); + + DesiredCapabilities capabilities = getDesiredCapabilities(); + if (capabilities.equals(BrowserUtil.ie(8)) + || capabilities.equals(BrowserUtil.ie(9))) { + // IE8 and IE9 insert cursor in the start of input instead of end. + Assert.assertEquals(incrementalText + initialText, + tf1.getAttribute("value")); + } else { + Assert.assertEquals(initialText + incrementalText, + tf1.getAttribute("value")); + } + } + + @Test + public void moveFocusAndChangeFieldWithValue() { + openTestURL(); + List textFields = getDriver().findElements( + By.tagName("input")); + WebElement tf1 = textFields.get(0); + WebElement tf2 = textFields.get(1); + + String firstText = "This is"; + String secondText = " default value"; + + tf2.sendKeys(firstText); + tf1.sendKeys(initialText); + new Actions(getDriver()).moveToElement(tf2).click().build().perform(); + + WebElement activeElement = getFocusedElement(); + Assert.assertEquals("input", activeElement.getTagName()); + Assert.assertEquals(firstText, activeElement.getAttribute("value")); + + new Actions(getDriver()).sendKeys(secondText).build().perform(); + DesiredCapabilities capabilities = getDesiredCapabilities(); + if (capabilities.equals(BrowserUtil.ie(8)) + || capabilities.equals(BrowserUtil.ie(9))) { + // IE8 and IE9 insert cursor in the start of input instead of end. + Assert.assertEquals(secondText + firstText, + tf2.getAttribute("value")); + } else { + Assert.assertEquals(firstText + secondText, + tf2.getAttribute("value")); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 7a214bd60c..55a2b80918 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -28,6 +28,7 @@ import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -277,6 +278,21 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { return driver.findElement(vaadinLocator(vaadinLocator)); } + /** + * Uses JavaScript to determine the currently focused element. + * + * @return Focused element or null + */ + protected WebElement getFocusedElement() { + Object focusedElement = ((JavascriptExecutor) getDriver()) + .executeScript("return document.activeElement"); + if (null != focusedElement) { + return (WebElement) focusedElement; + } else { + return null; + } + } + /** * Find a Vaadin element based on its id given using Component.setId * -- cgit v1.2.3 From f93c870fe9d7c6cd01892c97d5a9c799e079fa4e Mon Sep 17 00:00:00 2001 From: Jarno Rantala Date: Tue, 14 Jan 2014 10:02:34 +0200 Subject: Remove unselected rows from selection on client side (#13008) When server communicates the selected rows to the client side, client side datastructure of selected row keys is updated such that also the keys that has been unselected on server side are removed. This makes the test MultiSelectWithRemovedRow to pass. Change-Id: I7b6123436171972ecf345b07ddfb6d9965ca4f0c --- client/src/com/vaadin/client/ui/VScrollTable.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index bb431bf132..3c574f8f92 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -1060,6 +1060,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (uidl.hasVariable("selected")) { final Set selectedKeys = uidl .getStringArrayVariableAsSet("selected"); + removeUnselectedRowKeys(selectedKeys); + if (scrollBody != null) { Iterator iterator = scrollBody.iterator(); while (iterator.hasNext()) { @@ -1102,6 +1104,16 @@ public class VScrollTable extends FlowPanel implements HasWidgets, return keyboardSelectionOverRowFetchInProgress; } + private void removeUnselectedRowKeys(final Set selectedKeys) { + List unselectedKeys = new ArrayList(0); + for (String key : selectedRowKeys) { + if (!selectedKeys.contains(key)) { + unselectedKeys.add(key); + } + } + selectedRowKeys.removeAll(unselectedKeys); + } + /** For internal use only. May be removed or replaced in the future. */ public void updateSortingProperties(UIDL uidl) { oldSortColumn = sortColumn; -- cgit v1.2.3 From 8e2085c3465bd50510a81c3071c9589893a019a8 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 16 Jan 2014 17:44:39 +0200 Subject: Remove dead code Change-Id: I1ac813afa47e38fb508e676d25d103a29bfada6a --- .../src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java | 1 - client/src/com/vaadin/client/ApplicationConnection.java | 3 +-- client/src/com/vaadin/client/Profiler.java | 4 ---- client/src/com/vaadin/client/ui/VAccordion.java | 1 - client/src/com/vaadin/client/ui/VCalendarPanel.java | 11 ----------- client/src/com/vaadin/client/ui/VLabel.java | 8 -------- client/src/com/vaadin/client/ui/VPanel.java | 1 - client/src/com/vaadin/client/ui/VScrollTable.java | 1 - client/src/com/vaadin/client/ui/VTabsheet.java | 2 -- .../vaadin/client/ui/calendar/schedule/DateCellDayEvent.java | 8 ++++---- .../com/vaadin/client/ui/calendar/schedule/DayToolbar.java | 2 -- .../src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java | 1 - .../com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java | 1 - client/src/com/vaadin/client/ui/dd/VIsOverId.java | 3 --- client/src/com/vaadin/client/ui/dd/VItemIdIs.java | 2 -- client/src/com/vaadin/client/ui/label/LabelConnector.java | 6 ------ client/src/com/vaadin/client/ui/ui/UIConnector.java | 2 -- server/src/com/vaadin/data/fieldgroup/FieldGroup.java | 6 ------ server/src/com/vaadin/server/LegacyCommunicationManager.java | 2 -- server/src/com/vaadin/server/VaadinPortlet.java | 1 - server/src/com/vaadin/ui/AbstractComponent.java | 3 --- server/src/com/vaadin/ui/ComboBox.java | 2 -- server/src/com/vaadin/ui/Label.java | 4 ---- server/src/com/vaadin/ui/Table.java | 1 - .../tests/src/com/vaadin/data/util/TestIndexedContainer.java | 2 +- .../com/vaadin/data/util/sqlcontainer/SQLContainerTest.java | 5 ----- .../src/com/vaadin/data/util/sqlcontainer/TicketTests.java | 1 - uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java | 1 - 28 files changed, 6 insertions(+), 79 deletions(-) diff --git a/buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java b/buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java index 5c3810099a..fb7b672b21 100644 --- a/buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java +++ b/buildhelpers/src/com/vaadin/buildhelpers/FetchReleaseNotesTickets.java @@ -37,7 +37,6 @@ public class FetchReleaseNotesTickets { URLConnection connection = url.openConnection(); InputStream urlStream = connection.getInputStream(); - @SuppressWarnings("unchecked") List tickets = IOUtils.readLines(urlStream); for (String ticket : tickets) { diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index da41543894..8a3841b173 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -65,7 +65,6 @@ import com.google.gwt.user.client.Window.ClosingHandler; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration.ErrorMessage; -import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.communication.HasJavaScriptConnectorHelper; @@ -363,7 +362,7 @@ public class ApplicationConnection { * * To listen for the event add a {@link ApplicationStoppedHandler} by * invoking - * {@link ApplicationConnection#addHandler(ApplicationStoppedEvent.Type, ApplicationStoppedHandler)} + * {@link ApplicationConnection#addHandler(ApplicationConnection.ApplicationStoppedEvent.Type, ApplicationStoppedHandler)} * to the {@link ApplicationConnection} * * @since 7.1.8 diff --git a/client/src/com/vaadin/client/Profiler.java b/client/src/com/vaadin/client/Profiler.java index 083f2559b1..cfce59b08b 100644 --- a/client/src/com/vaadin/client/Profiler.java +++ b/client/src/com/vaadin/client/Profiler.java @@ -297,10 +297,6 @@ public class Profiler { if (isEnabled()) { double now = Duration.currentTimeMillis(); - StringBuilder stringBuilder = new StringBuilder( - "Time since window.performance.timing events"); - SimpleTree tree = new SimpleTree(stringBuilder.toString()); - String[] keys = new String[] { "navigationStart", "unloadEventStart", "unloadEventEnd", "redirectStart", "redirectEnd", "fetchStart", "domainLookupStart", diff --git a/client/src/com/vaadin/client/ui/VAccordion.java b/client/src/com/vaadin/client/ui/VAccordion.java index f87186fe37..ddfe9dbc2c 100644 --- a/client/src/com/vaadin/client/ui/VAccordion.java +++ b/client/src/com/vaadin/client/ui/VAccordion.java @@ -463,7 +463,6 @@ public class VAccordion extends VTabsheetBase { } @Override - @SuppressWarnings("unchecked") public Iterator getWidgetIterator() { return widgets.iterator(); } diff --git a/client/src/com/vaadin/client/ui/VCalendarPanel.java b/client/src/com/vaadin/client/ui/VCalendarPanel.java index 96678fd133..b043cd0ab7 100644 --- a/client/src/com/vaadin/client/ui/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/VCalendarPanel.java @@ -170,8 +170,6 @@ public class VCalendarPanel extends FocusableFlexTable implements private Resolution resolution = Resolution.YEAR; - private int focusedRow; - private Timer mouseTimer; private Date value; @@ -256,7 +254,6 @@ public class VCalendarPanel extends FocusableFlexTable implements if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_FOCUSED); focusedDay = curday; - focusedRow = i; return; } } @@ -741,7 +738,6 @@ public class VCalendarPanel extends FocusableFlexTable implements } if (curr.equals(focusedDate)) { focusedDay = day; - focusedRow = weekOfMonth; if (hasFocus) { day.addStyleDependentName(CN_FOCUSED); } @@ -1795,10 +1791,8 @@ public class VCalendarPanel extends FocusableFlexTable implements * Updates the valus to correspond to the values in value */ public void updateTimes() { - boolean selected = true; if (value == null) { value = new Date(); - selected = false; } if (getDateTimeService().isTwelveHourClock()) { int h = value.getHours(); @@ -1833,10 +1827,6 @@ public class VCalendarPanel extends FocusableFlexTable implements } - private int getMilliseconds() { - return DateTimeService.getMilliseconds(value); - } - private DateTimeService getDateTimeService() { if (dateTimeService == null) { dateTimeService = new DateTimeService(); @@ -2034,7 +2024,6 @@ public class VCalendarPanel extends FocusableFlexTable implements private static final String SUBPART_HOUR_SELECT = "h"; private static final String SUBPART_MINUTE_SELECT = "m"; private static final String SUBPART_SECS_SELECT = "s"; - private static final String SUBPART_MSECS_SELECT = "ms"; private static final String SUBPART_AMPM_SELECT = "ampm"; private static final String SUBPART_DAY = "day"; private static final String SUBPART_MONTH_YEAR_HEADER = "header"; diff --git a/client/src/com/vaadin/client/ui/VLabel.java b/client/src/com/vaadin/client/ui/VLabel.java index 8acd653778..35f47d540a 100644 --- a/client/src/com/vaadin/client/ui/VLabel.java +++ b/client/src/com/vaadin/client/ui/VLabel.java @@ -18,7 +18,6 @@ package com.vaadin.client.ui; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.HTML; -import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; import com.vaadin.client.Util; import com.vaadin.client.VTooltip; @@ -28,8 +27,6 @@ public class VLabel extends HTML { public static final String CLASSNAME = "v-label"; private static final String CLASSNAME_UNDEFINED_WIDTH = "v-label-undef-w"; - private ApplicationConnection connection; - public VLabel() { super(); setStyleName(CLASSNAME); @@ -71,9 +68,4 @@ public class VLabel extends HTML { super.setText(text); } } - - /** For internal use only. May be removed or replaced in the future. */ - public void setConnection(ApplicationConnection client) { - connection = client; - } } diff --git a/client/src/com/vaadin/client/ui/VPanel.java b/client/src/com/vaadin/client/ui/VPanel.java index 6b02f079d1..ffeacade46 100644 --- a/client/src/com/vaadin/client/ui/VPanel.java +++ b/client/src/com/vaadin/client/ui/VPanel.java @@ -170,7 +170,6 @@ public class VPanel extends SimplePanel implements ShortcutActionHandlerOwner, public void onBrowserEvent(Event event) { super.onBrowserEvent(event); - final Element target = DOM.eventGetTarget(event); final int type = DOM.eventGetType(event); if (type == Event.ONKEYDOWN && shortcutHandler != null) { shortcutHandler.handleKeyboardEvent(event); diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 8bd875690b..53a8ad6443 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -6037,7 +6037,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private Element getEventTargetTdOrTr(Event event) { final Element eventTarget = event.getEventTarget().cast(); Widget widget = Util.findWidget(eventTarget, null); - final Element thisTrElement = getElement(); if (widget != this) { /* diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 9ad518b85b..33ac8e27ad 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -313,11 +313,9 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private boolean closable = false; private Element closeButton; private Tab tab; - private ApplicationConnection client; TabCaption(Tab tab, ApplicationConnection client) { super(client); - this.client = client; this.tab = tab; AriaHelper.ensureHasId(getElement()); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java index 39de122694..344b5ce739 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java @@ -42,7 +42,6 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.HorizontalPanel; import com.vaadin.client.Util; -import com.vaadin.client.ui.VCalendar; import com.vaadin.shared.ui.calendar.DateConstants; /** @@ -105,7 +104,6 @@ public class DateCellDayEvent extends FocusableHTML implements eventContent.addClassName("v-calendar-event-content"); getElement().appendChild(eventContent); - VCalendar calendar = weekGrid.getCalendar(); if (weekGrid.getCalendar().isEventResizeAllowed()) { topResizeBar = DOM.createDiv(); bottomResizeBar = DOM.createDiv(); @@ -189,9 +187,11 @@ public class DateCellDayEvent extends FocusableHTML implements String escapedCaption = Util.escapeHTML(calendarEvent.getCaption()); String timeAsText = calendarEvent.getTimeAsText(); if (bigMode) { - innerHtml = "" + timeAsText + "
" + escapedCaption; + innerHtml = "" + timeAsText + "
" + + escapedCaption; } else { - innerHtml = "" + timeAsText + ": " + escapedCaption; + innerHtml = "" + timeAsText + ": " + + escapedCaption; } caption.setInnerHTML(innerHtml); eventContent.setInnerHTML(""); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java index 6233e8111e..58b5fafa7f 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/DayToolbar.java @@ -72,8 +72,6 @@ public class DayToolbar extends HorizontalPanel implements ClickHandler { setCellWidth(nextLabel, MARGINRIGHT + "px"); setCellHorizontalAlignment(nextLabel, ALIGN_RIGHT); int cellw = width / (count - 2); - int remain = width % (count - 2); - int cellw2 = cellw + 1; if (cellw > 0) { int[] cellWidths = VCalendar .distributeSize(width, count - 2, 0); diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java index df9bc42d2a..3b1c774793 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/MonthGrid.java @@ -35,7 +35,6 @@ public class MonthGrid extends FocusableGrid implements KeyDownHandler { private SimpleDayCell selectionEnd; private final VCalendar calendar; private boolean rangeSelectDisabled; - private boolean disabled; private boolean enabled = true; private final HandlerRegistration keyDownHandler; diff --git a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java index cf8006ef66..00fc1ef3ea 100644 --- a/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java +++ b/client/src/com/vaadin/client/ui/calendar/schedule/SimpleDayCell.java @@ -83,7 +83,6 @@ public class SimpleDayCell extends FocusableFlowPanel implements private Widget clickedWidget; private HandlerRegistration bottomSpacerMouseDownHandler; private boolean scrollable = false; - private boolean eventCanceled; private MonthGrid monthGrid; private HandlerRegistration keyDownHandler; diff --git a/client/src/com/vaadin/client/ui/dd/VIsOverId.java b/client/src/com/vaadin/client/ui/dd/VIsOverId.java index f8083f8b60..7e2f596a20 100644 --- a/client/src/com/vaadin/client/ui/dd/VIsOverId.java +++ b/client/src/com/vaadin/client/ui/dd/VIsOverId.java @@ -19,7 +19,6 @@ package com.vaadin.client.ui.dd; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.ConnectorMap; import com.vaadin.client.UIDL; import com.vaadin.shared.ui.dd.AcceptCriterion; import com.vaadin.ui.AbstractSelect; @@ -36,8 +35,6 @@ final public class VIsOverId extends VAcceptCriterion { .getCurrentDropHandler(); ComponentConnector dropHandlerConnector = currentDropHandler .getConnector(); - ConnectorMap paintableMap = ConnectorMap.get(currentDropHandler - .getApplicationConnection()); String pid2 = dropHandlerConnector.getConnectorId(); if (pid2.equals(pid)) { diff --git a/client/src/com/vaadin/client/ui/dd/VItemIdIs.java b/client/src/com/vaadin/client/ui/dd/VItemIdIs.java index 7d60eda4f9..b022f434f4 100644 --- a/client/src/com/vaadin/client/ui/dd/VItemIdIs.java +++ b/client/src/com/vaadin/client/ui/dd/VItemIdIs.java @@ -32,8 +32,6 @@ final public class VItemIdIs extends VAcceptCriterion { String pid = configuration.getStringAttribute("s"); ComponentConnector dragSource = drag.getTransferable() .getDragSource(); - VDropHandler currentDropHandler = VDragAndDropManager.get() - .getCurrentDropHandler(); String pid2 = dragSource.getConnectorId(); if (pid2.equals(pid)) { Object searchedId = drag.getTransferable().getData("itemId"); diff --git a/client/src/com/vaadin/client/ui/label/LabelConnector.java b/client/src/com/vaadin/client/ui/label/LabelConnector.java index 9639987e8d..6a04c91562 100644 --- a/client/src/com/vaadin/client/ui/label/LabelConnector.java +++ b/client/src/com/vaadin/client/ui/label/LabelConnector.java @@ -35,12 +35,6 @@ public class LabelConnector extends AbstractComponentConnector { return (LabelState) super.getState(); } - @Override - protected void init() { - super.init(); - getWidget().setConnection(getConnection()); - } - @Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index d0f3c8603f..17a23baad5 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -49,7 +49,6 @@ import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; -import com.vaadin.client.ConnectorMap; import com.vaadin.client.Focusable; import com.vaadin.client.Paintable; import com.vaadin.client.ServerConnector; @@ -192,7 +191,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector @Override public void updateFromUIDL(final UIDL uidl, ApplicationConnection client) { - ConnectorMap paintableMap = ConnectorMap.get(getConnection()); getWidget().id = getConnectorId(); boolean firstPaint = getWidget().connection == null; getWidget().connection = client; diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java index 23f2da53ce..7edcc9719c 100644 --- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java +++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import java.util.logging.Logger; import com.vaadin.data.Item; import com.vaadin.data.Property; @@ -55,9 +54,6 @@ import com.vaadin.util.ReflectTools; */ public class FieldGroup implements Serializable { - private static final Logger logger = Logger.getLogger(FieldGroup.class - .getName()); - private Item itemDataSource; private boolean buffered = true; @@ -1013,9 +1009,7 @@ public class FieldGroup implements Serializable { */ public Field buildAndBind(String caption, Object propertyId) throws BindException { - Class type = getPropertyType(propertyId); return buildAndBind(caption, propertyId, Field.class); - } /** diff --git a/server/src/com/vaadin/server/LegacyCommunicationManager.java b/server/src/com/vaadin/server/LegacyCommunicationManager.java index ad662cf6df..8d61968b47 100644 --- a/server/src/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/com/vaadin/server/LegacyCommunicationManager.java @@ -316,8 +316,6 @@ public class LegacyCommunicationManager implements Serializable { private final HashMap, Integer> typeToKey = new HashMap, Integer>(); private int nextTypeKey = 0; - private BootstrapHandler bootstrapHandler; - /** * @deprecated As of 7.1. Will be removed in the future. */ diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index a41f301219..6cf30e85e9 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -365,7 +365,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants, if (request instanceof RenderRequest) { return RequestType.RENDER; } else if (request instanceof ResourceRequest) { - ResourceRequest resourceRequest = (ResourceRequest) request; if (ServletPortletHelper.isUIDLRequest(vaadinRequest)) { return RequestType.UIDL; } else if (PortletUIInitHandler.isUIInitRequest(vaadinRequest)) { diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 85671922a5..33aa689a88 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -31,7 +31,6 @@ import com.vaadin.event.ConnectorActionManager; import com.vaadin.event.ShortcutListener; import com.vaadin.server.AbstractClientConnector; import com.vaadin.server.ComponentSizeValidator; -import com.vaadin.server.ErrorHandler; import com.vaadin.server.ErrorMessage; import com.vaadin.server.Resource; import com.vaadin.server.VaadinSession; @@ -86,8 +85,6 @@ public abstract class AbstractComponent extends AbstractClientConnector private static final Pattern sizePattern = Pattern .compile("^(-?\\d+(\\.\\d+)?)(%|px|em|rem|ex|in|cm|mm|pt|pc)?$"); - private ErrorHandler errorHandler = null; - /** * Keeps track of the Actions added to this component; the actual * handling/notifying is delegated, usually to the containing window. diff --git a/server/src/com/vaadin/ui/ComboBox.java b/server/src/com/vaadin/ui/ComboBox.java index 88e895df82..5fb2f81011 100644 --- a/server/src/com/vaadin/ui/ComboBox.java +++ b/server/src/com/vaadin/ui/ComboBox.java @@ -56,8 +56,6 @@ public class ComboBox extends AbstractSelect implements */ protected int pageLength = 10; - private int columns = 0; - // Current page when the user is 'paging' trough options private int currentPage = -1; diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index d7cee2a80d..3aa83de420 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -18,7 +18,6 @@ package com.vaadin.ui; import java.lang.reflect.Method; import java.util.Locale; -import java.util.logging.Logger; import com.vaadin.data.Property; import com.vaadin.data.util.AbstractProperty; @@ -56,9 +55,6 @@ public class Label extends AbstractComponent implements Property, Property.Viewer, Property.ValueChangeListener, Property.ValueChangeNotifier, Comparable

* Defines the interface to commit and discard changes to an object, supporting - * read-through and write-through modes. - *

+ * buffering. * *

- * Read-through mode means that the value read from the buffered object - * is constantly up to date with the data source. Write-through mode - * means that all changes to the object are immediately updated to the data - * source. - *

+ * In buffered mode the initial value is read from the data source and + * then buffered. Any subsequential writes or reads will be done on the buffered + * value. Calling {@link #commit()} will write the buffered value to the data + * source while calling {@link #discard()} while discard the buffered value and + * re-read the value from the data source. * *

- * Since these modes are independent, their combinations may result in some - * behaviour that may sound surprising. - *

- * - *

- * For example, if a Buffered object is in read-through mode but - * not in write-through mode, the result is an object whose value is updated - * directly from the data source only if it's not locally modified. If the value - * is locally modified, retrieving the value from the object would result in a - * value that is different than the one stored in the data source, even though - * the object is in read-through mode. - *

+ * In non-buffered mode the value is always read directly from the data + * source. Any write is done directly to the data source with no buffering in + * between. Reads are also done directly from the data source. Calling + * {@link #commit()} or {@link #discard()} in this mode is efficiently a no-op. * * @author Vaadin Ltd. * @since 3.0 @@ -77,25 +68,15 @@ public interface Buffered extends Serializable { public void discard() throws SourceException; /** - * Sets the object's buffered mode to the specified status. + * Sets the buffered mode to the specified status. *

- * When the object is in buffered mode, an internal buffer will be used to - * store changes until {@link #commit()} is called. Calling - * {@link #discard()} will revert the internal buffer to the value of the - * data source. - *

+ * When in buffered mode, an internal buffer will be used to store changes + * until {@link #commit()} is called. Calling {@link #discard()} will revert + * the internal buffer to the value of the data source. *

- * This is an easier way to use {@link #setReadThrough(boolean)} and - * {@link #setWriteThrough(boolean)} and not as error prone. Changing - * buffered mode will change both the read through and write through state - * of the object. - *

- *

- * Mixing calls to {@link #setBuffered(boolean)}/{@link #isBuffered()} and - * {@link #setReadThrough(boolean)}/{@link #isReadThrough()} or - * {@link #setWriteThrough(boolean)}/{@link #isWriteThrough()} is generally - * a bad idea. - *

+ * When in non-buffered mode both read and write operations will be done + * directly on the data source. In this mode the {@link #commit()} and + * {@link #discard()} methods serve no purpose. * * @param buffered * true if buffered mode should be turned on, false otherwise @@ -104,10 +85,7 @@ public interface Buffered extends Serializable { public void setBuffered(boolean buffered); /** - * Checks the buffered mode of this Object. - *

- * This method only returns true if both read and write buffering is used. - *

+ * Checks the buffered mode * * @return true if buffered mode is on, false otherwise * @since 7.0 -- cgit v1.2.3 From 3f09c10ec3b4982fc725d07f631015b16d8df985 Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Mon, 20 Jan 2014 20:31:13 +0200 Subject: Better-looking CSS for Vaadin API Javadocs (#13219) Change-Id: I52fd843b839830cefe330c9c9cf94b59db0928af --- all/build.xml | 3 +- all/javadoc.css | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 all/javadoc.css diff --git a/all/build.xml b/all/build.xml index 1b48721ecd..36a9499dea 100644 --- a/all/build.xml +++ b/all/build.xml @@ -43,7 +43,8 @@ - + diff --git a/all/javadoc.css b/all/javadoc.css new file mode 100644 index 0000000000..ffa7288ad4 --- /dev/null +++ b/all/javadoc.css @@ -0,0 +1,236 @@ +@charset "UTF-8"; + +/* + * stylesheet for Vaadin Javadoc when compiled with Java 6 + */ +body { + background-color: rgb(244, 244, 240); + color: rgb(70, 68, 64); + font-size: 16px; + font-family: Helvetica, Arial, sans-serif; + font-weight: lighter; + line-height: 18px; + margin: 10px 14px; +} + +body[onload] { + background-color: rgb(255, 255, 255); + margin: 8px 23px; +} + +a:link,a:visited { + color: rgb(0, 180, 240); + text-decoration: none; +} + +b { + font-weight: bolder; +} + +code,pre { + font-family: Courier, monospace; +} + +dt { + font-size: 12px; + color: rgb(120, 119, 109); + text-transform: uppercase; +} + +dd>dl>dt { + font-size: 13px; + text-transform: none; +} + +h2+dl>dt { + text-transform: none; +} + +dt>pre,pre>dt { + text-transform: initial; +} + +dd { + font-size: 14px; + margin-left: 2.5em; +} + +dd:first-child { + font-size: 13px; +} + +dd>dl>dd { + font-size: 12px; +} + +h1 { + font-size: 32px +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 16px; +} + +h1,h2,h3 { + line-height: 30px; +} + +hr { + border: 1px solid rgb(233, 233, 225); +} + +pre,h2+ul { + font-size: 12px; +} + +table { + border: none; + border-collapse: collapse; +} + +td { + padding: 0; +} + +th { + padding: 0 1ch; +} + +.TableHeadingColor,.TableSubHeadingColor { + line-height: 30px; +} + +.TableHeadingColor>th,.TableHeadingColor>th>font>b,.TableSubHeadingColor>th,.TableSubHeadingColor>th>b + { + font-weight: inherit; +} + +.TableHeadingColor>th>font { + font-size: 18px; +} + +.TableSubHeadingColor { + font-size: 14px; +} + +.TableHeadingColor,.TableSubHeadingColor { + background: rgb(233, 233, 225); +} + +.TableRowColor { + background: #FFFFFF; +} + +.TableRowColor:nth-child(odd) { + background-color: rgb(244, 244, 240); +} + +.TableRowColor>td { + font-size: 12px; + border: none; + padding: 1ex 1ch +} + +.TableRowColor>td>font { + font-size: 11px; +} + +.TableHeadingColor,.TableRowColor,.TableSubHeadingColor>th { + border: none; + border-color: transparent; +} + +table[border="1"] { + border: 2px solid rgb(233, 233, 225); +} + +.FrameTitleFont { + font-size: 18px; + font-family: Helvetica, Arial, sans-serif; + font-weight: bolder; + line-height: 30px; +} + +.FrameHeadingFont { + font-size: 12px; + font-family: Helvetica, Arial, sans-serif; + font-weight: bold; + color: rgb(120, 119, 109); + text-transform: uppercase; + display: inline-block; + margin-bottom: 4px; +} + +td>.FrameHeadingFont { + margin-top: 12px; +} + +.FrameItemFont { + font-size: 90%; + font-family: Helvetica, Arial, sans-serif; +} + +.NavBarCell1 { + background-color: rgb(245, 245, 241); + border: 2px solid rgb(245, 245, 241); +} + +.NavBarCell1+td[rowspan="3"] { + display: none; +} + +.NavBarCell1,.NavBarCell1Rev { + font-size: 0; +} + +.NavBarCell1>*,.NavBarCell1Rev>* { + font-size: 14px; +} + +.NavBarCell1 .NavBarCell1,.NavBarCell1 .NavBarCell1Rev { + padding: 3px 8px; + line-height: 1; + vertical-align: baseline; +} + +.NavBarCell1Rev { + background-color: rgb(0, 180, 240); + border-radius: 3px; +} + +.NavBarFont1 { + font-family: Helvetica, Arial, sans-serif; + color: rgb(70, 68, 64); +} + +.NavBarFont1Rev { + font-family: Helvetica, Arial, sans-serif; + color: rgb(255, 255, 255); +} + +.NavBarCell2 { + font-family: Helvetica, Arial, sans-serif; + background-color: #FFFFFF; + padding-top: 6px; +} + +.NavBarCell2:first-child { + color: transparent; +} + +.NavBarCell2>font,.NavBarCell3>font { + font-size: 11px; +} + +.NavBarCell2>font>a>b { + font-weight: normal; +} + +.NavBarCell3 { + font-family: Helvetica, Arial, sans-serif; + background-color: #FFFFFF; +} \ No newline at end of file -- cgit v1.2.3 From f0a4ea9c7241885ffd38d5faf38f25a624adac2c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 15 Nov 2013 18:49:39 +0200 Subject: Do not throw NPE for equals(null) (#8910) Change-Id: Ie9a658911c9f2722e518dedbe181c24e5ace07db --- .../src/com/vaadin/data/util/filter/Between.java | 4 ++ .../src/com/vaadin/data/util/filter/Compare.java | 3 ++ server/src/com/vaadin/data/util/filter/IsNull.java | 4 ++ server/src/com/vaadin/data/util/filter/Like.java | 4 ++ .../data/util/filter/SimpleStringFilter.java | 3 ++ .../util/sqlcontainer/filters/CompareTest.java | 44 ++++++++++++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java diff --git a/server/src/com/vaadin/data/util/filter/Between.java b/server/src/com/vaadin/data/util/filter/Between.java index 8209f7b0a2..a76821981a 100644 --- a/server/src/com/vaadin/data/util/filter/Between.java +++ b/server/src/com/vaadin/data/util/filter/Between.java @@ -67,6 +67,10 @@ public class Between implements Filter { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } + // Only objects of the same class can be equal if (!getClass().equals(obj.getClass())) { return false; diff --git a/server/src/com/vaadin/data/util/filter/Compare.java b/server/src/com/vaadin/data/util/filter/Compare.java index f9f19c6602..ac167673bd 100644 --- a/server/src/com/vaadin/data/util/filter/Compare.java +++ b/server/src/com/vaadin/data/util/filter/Compare.java @@ -307,6 +307,9 @@ public abstract class Compare implements Filter { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } // Only objects of the same class can be equal if (!getClass().equals(obj.getClass())) { diff --git a/server/src/com/vaadin/data/util/filter/IsNull.java b/server/src/com/vaadin/data/util/filter/IsNull.java index 5c5bdfc0b1..6907a016a1 100644 --- a/server/src/com/vaadin/data/util/filter/IsNull.java +++ b/server/src/com/vaadin/data/util/filter/IsNull.java @@ -62,6 +62,10 @@ public final class IsNull implements Filter { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } + // Only objects of the same class can be equal if (!getClass().equals(obj.getClass())) { return false; diff --git a/server/src/com/vaadin/data/util/filter/Like.java b/server/src/com/vaadin/data/util/filter/Like.java index 4c15564105..dc2e18363a 100644 --- a/server/src/com/vaadin/data/util/filter/Like.java +++ b/server/src/com/vaadin/data/util/filter/Like.java @@ -84,6 +84,10 @@ public class Like implements Filter { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } + // Only objects of the same class can be equal if (!getClass().equals(obj.getClass())) { return false; diff --git a/server/src/com/vaadin/data/util/filter/SimpleStringFilter.java b/server/src/com/vaadin/data/util/filter/SimpleStringFilter.java index bc58999445..a214e69846 100644 --- a/server/src/com/vaadin/data/util/filter/SimpleStringFilter.java +++ b/server/src/com/vaadin/data/util/filter/SimpleStringFilter.java @@ -82,6 +82,9 @@ public final class SimpleStringFilter implements Filter { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } // Only ones of the objects of the same class can be equal if (!(obj instanceof SimpleStringFilter)) { diff --git a/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java new file mode 100644 index 0000000000..c8faa71e66 --- /dev/null +++ b/server/tests/src/com/vaadin/data/util/sqlcontainer/filters/CompareTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.data.util.sqlcontainer.filters; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.data.util.filter.Compare; + +public class CompareTest { + + @Test + public void testEquals() { + Compare c1 = new Compare.Equal("prop1", "val1"); + Compare c2 = new Compare.Equal("prop1", "val1"); + Assert.assertTrue(c1.equals(c2)); + } + + @Test + public void testDifferentTypeEquals() { + Compare c1 = new Compare.Equal("prop1", "val1"); + Compare c2 = new Compare.Greater("prop1", "val1"); + Assert.assertFalse(c1.equals(c2)); + } + + @Test + public void testEqualsNull() { + Compare c1 = new Compare.Equal("prop1", "val1"); + Assert.assertFalse(c1.equals(null)); + } +} -- cgit v1.2.3 From 3897025e537f65e484078d4cbfbea1500ba6368b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 20 Jan 2014 20:35:41 +0200 Subject: Add deprecated expand ratio methods to FormLayout (#12876) FormLayout has never implemented expand ratios but does not tell the developer about it either. Throwing an UnsupportedOperationException would make this very clear but at the same time would break existing applications which use the methods or which handle AbstractOrderedLayouts in a generic way. Change-Id: I0208f91c3c07aff98a78153887fbbea9dbc1d3d1 --- server/src/com/vaadin/ui/FormLayout.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/src/com/vaadin/ui/FormLayout.java b/server/src/com/vaadin/ui/FormLayout.java index 9d5e637068..9dc0b24cad 100644 --- a/server/src/com/vaadin/ui/FormLayout.java +++ b/server/src/com/vaadin/ui/FormLayout.java @@ -52,4 +52,23 @@ public class FormLayout extends AbstractOrderedLayout { addComponents(children); } + /** + * @deprecated This method currently has no effect as expand ratios are not + * implemented in FormLayout + */ + @Override + @Deprecated + public void setExpandRatio(Component component, float ratio) { + super.setExpandRatio(component, ratio); + } + + /** + * @deprecated This method currently has no effect as expand ratios are not + * implemented in FormLayout + */ + @Override + @Deprecated + public float getExpandRatio(Component component) { + return super.getExpandRatio(component); + } } -- cgit v1.2.3 From 4d22f802c82f795c4fa874c3f79b9612b858717e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Jan 2014 17:44:18 +0200 Subject: Update dependencies to match GWT master (#12871) cssparser 0.9.5 -> 0.9.11 jetty 6.1.11 -> 8.1.12.v20130726 commons-codec 1.3 -> 1.8 commons-logging 1.1.1 -> 1.1.3 commons-io 2.2 -> 2.4 commons-lang 2.6 -> 3.1 Change-Id: Ie5f1b7d1c0b2e31533806640d9a5236e76787d2e --- client-compiler/ivy.xml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index f66a2e0255..6a0c26cc11 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -31,28 +31,30 @@ + rev="1.1.3" conf="build,ide -> default" /> + rev="0.9.11" conf="build,ide -> default" /> - - + + + + - + - + -- cgit v1.2.3 From 39af7639af174bd6b3d9b91bf8bf3ab1c03422ce Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Jan 2014 19:47:46 +0200 Subject: Update httpcomponents dependencies (#12871). httpclient 4.1.2 -> 4.3.1, now directly from Maven central httpcore 4.1.2 -> 4.3, now directly from Maven central httpmime 4.1.2 -> 4.3.1, now directly from Maven central Change-Id: I0056993edc1e14262da7697ed550b70cc2ed79c9 --- client-compiler/ivy.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index 6a0c26cc11..3ec72121cb 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -58,6 +58,13 @@ + + + + -- cgit v1.2.3 From 881fca3dad51eb95378c99a22dbb4d988ac24cf1 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Jan 2014 19:50:32 +0200 Subject: Update nekohtml + xalan dependencies (#12871). nekohtml 1.9.15 -> 1.9.19, now directly from Maven central xerces 2.9.1 -> 2.11.0, now directly from Maven central Change-Id: I7b9acd066f73ea546d46ce88065496c628ad5799 --- client-compiler/ivy.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index 3ec72121cb..37fec29f5a 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -65,6 +65,15 @@ + + + + + -- cgit v1.2.3 From 6cc39b3848e5dc4e678a6cf26afbd4542260827a Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 22 Jan 2014 20:08:46 +0200 Subject: Use ICU4J from Maven central (#13252) Change-Id: Id3837571a0fac020819c83e2bae17eda8ca51267 --- client-compiler/ivy.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index 37fec29f5a..eeb54af879 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -74,6 +74,9 @@ + + -- cgit v1.2.3 From a5727e440003270ebf54f9f55abf5156143a580c Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Mon, 13 Jan 2014 10:24:58 +0200 Subject: Some tests are fixed on Win (CRLF issue). Change-Id: I057bae0fd4068c6b877abdb9546ebf1490339d86 --- theme-compiler/tests/src/com/vaadin/sass/AbstractTestBase.java | 6 ++++++ .../tests/src/com/vaadin/sass/testcases/scss/CompassImports.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/theme-compiler/tests/src/com/vaadin/sass/AbstractTestBase.java b/theme-compiler/tests/src/com/vaadin/sass/AbstractTestBase.java index d867e6ccd0..01187b4502 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/AbstractTestBase.java +++ b/theme-compiler/tests/src/com/vaadin/sass/AbstractTestBase.java @@ -30,6 +30,8 @@ import com.vaadin.sass.internal.ScssStylesheet; public abstract class AbstractTestBase { + public static final String CR = "\r"; + protected ScssStylesheet stylesheet; protected String originalScss; protected String parsedScss; @@ -69,17 +71,21 @@ public abstract class AbstractTestBase { public void testParser(String file) throws CSSException, IOException, URISyntaxException { originalScss = getFileContent(file); + originalScss = originalScss.replaceAll(CR, ""); ScssStylesheet sheet = getStyleSheet(file); parsedScss = sheet.toString(); + parsedScss = parsedScss.replace(CR, ""); Assert.assertEquals("Original CSS and parsed CSS do not match", originalScss, parsedScss); } public void testCompiler(String scss, String css) throws Exception { comparisonCss = getFileContent(css); + comparisonCss = comparisonCss.replaceAll(CR, ""); ScssStylesheet sheet = getStyleSheet(scss); sheet.compile(); parsedScss = sheet.toString(); + parsedScss = parsedScss.replaceAll(CR, ""); Assert.assertEquals("Original CSS and parsed CSS do not match", comparisonCss, parsedScss); } diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java index 1e3eb09f0c..4e87eb2197 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java @@ -68,12 +68,14 @@ public class CompassImports extends AbstractTestBase { public void testCompiler(String scss, String css, String additionalPath) throws Exception { comparisonCss = getFileContent(css); + comparisonCss = comparisonCss.replaceAll(CR, ""); ScssStylesheet sheet = getStyleSheet(scss); Assert.assertNotNull(sheet); sheet.addResolver(new FilesystemResolver(additionalPath)); sheet.compile(); parsedScss = sheet.toString(); + parsedScss = parsedScss.replaceAll(CR, ""); Assert.assertEquals("Original CSS and parsed CSS do not match", comparisonCss, parsedScss); } -- cgit v1.2.3 From b89dba9889353f0f553cb9583de6a9e8cb28302b Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 28 Jan 2014 17:30:09 +0200 Subject: Exclude a possible bin directory when building (#13258) Change-Id: I34806146d737eb35668684f3edde658a7fc0beb0 --- build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/build.xml b/build.xml index bef7f7a2f3..d2e905b611 100644 --- a/build.xml +++ b/build.xml @@ -19,6 +19,7 @@ + -- cgit v1.2.3 From 32ad5f75ddb37bab46503351df5bca63ff5b6868 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 28 Jan 2014 18:25:09 +0200 Subject: Disable Opera 12 permutation (#13259) Change-Id: I7fd06de98d962df83f31bfd50657559dee5c15bf --- client/src/com/vaadin/Vaadin.gwt.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index a1dca07a1c..50600c5cbb 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -61,6 +61,6 @@ - + -- cgit v1.2.3 From 58443b4a45e6fbdfed860959a5114f13ba7f4662 Mon Sep 17 00:00:00 2001 From: Patrik Lindström Date: Wed, 22 Jan 2014 00:25:33 +0200 Subject: Implement TestBench4 features in debug window (#12694) Done: - VaadinFinderLocatorStrategy returns optimal paths for any Widget selectable by it. - TestBenchSection of the Debug Window picks and clears as expected. - Debug Window no longer presents user with a widget hierarchy - Translation from VaadinFinderLocatorStrategy query strings to ElementQuery API calls (should be done in SelectorPath.java) - Make SelectorPaths change background color when hovered Change-Id: Ie122f962a319ddf560fa9ac4f6bc57f32a120f91 --- WebContent/VAADIN/themes/base/debug/debug.scss | 8 + client/src/com/vaadin/client/ConnectorMap.java | 2 +- .../client/componentlocator/ComponentLocator.java | 16 + .../client/componentlocator/LocatorUtil.java | 76 ++ .../client/componentlocator/SelectorPredicate.java | 228 +++++ .../VaadinFinderLocatorStrategy.java | 562 ++++++------ .../vaadin/client/debug/internal/SelectorPath.java | 940 ++++----------------- .../client/debug/internal/TestBenchSection.java | 88 +- 8 files changed, 775 insertions(+), 1145 deletions(-) create mode 100644 client/src/com/vaadin/client/componentlocator/LocatorUtil.java create mode 100644 client/src/com/vaadin/client/componentlocator/SelectorPredicate.java diff --git a/WebContent/VAADIN/themes/base/debug/debug.scss b/WebContent/VAADIN/themes/base/debug/debug.scss index 0992f19bb9..b50245a7be 100644 --- a/WebContent/VAADIN/themes/base/debug/debug.scss +++ b/WebContent/VAADIN/themes/base/debug/debug.scss @@ -251,6 +251,14 @@ width: 100%; } + .v-debugwindow-selector > span.value { + width: 100%; + } + + .v-debugwindow-selector :hover { + background: rgba(255,32,32,0.5); + } + /* LOG */ .v-debugwindow-log { font-family: monospace; diff --git a/client/src/com/vaadin/client/ConnectorMap.java b/client/src/com/vaadin/client/ConnectorMap.java index 810f12824a..c2f1eda21d 100644 --- a/client/src/com/vaadin/client/ConnectorMap.java +++ b/client/src/com/vaadin/client/ConnectorMap.java @@ -116,7 +116,7 @@ public class ConnectorMap { * no connector was found */ public ComponentConnector getConnector(Widget widget) { - return getConnector(widget.getElement()); + return widget == null ? null : getConnector(widget.getElement()); } public void registerConnector(String id, ServerConnector connector) { diff --git a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java index aa841ce5b0..d2a89c00d5 100644 --- a/client/src/com/vaadin/client/componentlocator/ComponentLocator.java +++ b/client/src/com/vaadin/client/componentlocator/ComponentLocator.java @@ -201,4 +201,20 @@ public class ComponentLocator { return client; } + /** + * Check if a given selector is valid for LegacyLocatorStrategy. + * + * @param path + * Vaadin selector path + * @return true if passes path validation with LegacyLocatorStrategy + */ + public boolean isValidForLegacyLocator(String path) { + for (LocatorStrategy ls : locatorStrategies) { + if (ls instanceof LegacyLocatorStrategy) { + return ls.validatePath(path); + } + } + return false; + } + } diff --git a/client/src/com/vaadin/client/componentlocator/LocatorUtil.java b/client/src/com/vaadin/client/componentlocator/LocatorUtil.java new file mode 100644 index 0000000000..04624920a9 --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/LocatorUtil.java @@ -0,0 +1,76 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +/** + * Common String manipulator utilities used in VaadinFinderLocatorStrategy and + * SelectorPredicates. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class LocatorUtil { + + /** + * Find first occurrence of character that's not inside quotes starting from + * specified index. + * + * @param str + * Full string for searching + * @param find + * Character we want to find + * @param startingAt + * Index where we start + * @return Index of character. -1 if character not found + */ + protected static int indexOfIgnoringQuoted(String str, char find, + int startingAt) { + boolean quote = false; + String quoteChars = "'\""; + char currentQuote = '"'; + for (int i = startingAt; i < str.length(); ++i) { + char cur = str.charAt(i); + if (quote) { + if (cur == currentQuote) { + quote = !quote; + } + continue; + } else if (cur == find) { + return i; + } else { + if (quoteChars.indexOf(cur) >= 0) { + currentQuote = cur; + quote = !quote; + } + } + } + return -1; + } + + /** + * Find first occurrence of character that's not inside quotes starting from + * the beginning of string. + * + * @param str + * Full string for searching + * @param find + * Character we want to find + * @return Index of character. -1 if character not found + */ + protected static int indexOfIgnoringQuoted(String str, char find) { + return indexOfIgnoringQuoted(str, find, 0); + } +} diff --git a/client/src/com/vaadin/client/componentlocator/SelectorPredicate.java b/client/src/com/vaadin/client/componentlocator/SelectorPredicate.java new file mode 100644 index 0000000000..32b33005ed --- /dev/null +++ b/client/src/com/vaadin/client/componentlocator/SelectorPredicate.java @@ -0,0 +1,228 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.componentlocator; + +import java.util.ArrayList; +import java.util.List; + +/** + * SelectorPredicates are statements about the state of different components + * that VaadinFinderLocatorStrategy is finding. SelectorPredicates also provide + * useful information of said components to debug window by giving means to + * provide better variable naming. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class SelectorPredicate { + private String name = ""; + private String value = ""; + private boolean wildcard = false; + private int index = -1; + + public static List extractPostFilterPredicates( + String path) { + if (path.startsWith("(")) { + return extractPredicates(path.substring(path.lastIndexOf(')'))); + } + return new ArrayList(); + } + + /** + * Generate a list of predicates from a single predicate string + * + * @param str + * a comma separated string of predicates + * @return a List of Predicate objects + */ + public static List extractPredicates(String path) { + List predicates = new ArrayList(); + + String predicateStr = extractPredicateString(path); + if (null == predicateStr || predicateStr.length() == 0) { + return predicates; + } + + // Extract input strings + List input = readPredicatesFromString(predicateStr); + + // Process each predicate into proper predicate descriptor + for (String s : input) { + SelectorPredicate p = new SelectorPredicate(); + s = s.trim(); + + try { + // If we can parse out the predicate as a pure index argument, + // stop processing here. + p.index = Integer.parseInt(s); + predicates.add(p); + + continue; + } catch (Exception e) { + p.index = -1; + } + + int idx = LocatorUtil.indexOfIgnoringQuoted(s, '='); + if (idx < 0) { + continue; + } + p.name = s.substring(0, idx); + p.value = s.substring(idx + 1); + + if (p.value.equals("?")) { + p.wildcard = true; + p.value = null; + } else { + // Only unquote predicate value once we're sure it's a proper + // value... + + p.value = unquote(p.value); + } + + predicates.add(p); + } + // Move any (and all) index predicates to last place in the list. + for (int i = 0, l = predicates.size(); i < l - 1; ++i) { + if (predicates.get(i).index > -1) { + predicates.add(predicates.remove(i)); + --i; + --l; + } + } + + return predicates; + } + + /** + * Splits the predicate string to list of predicate strings. + * + * @param predicateStr + * Comma separated predicate strings + * @return List of predicate strings + */ + private static List readPredicatesFromString(String predicateStr) { + List predicates = new ArrayList(); + int prevIdx = 0; + int idx = LocatorUtil.indexOfIgnoringQuoted(predicateStr, ',', prevIdx); + + while (idx > -1) { + predicates.add(predicateStr.substring(prevIdx, idx)); + prevIdx = idx + 1; + idx = LocatorUtil.indexOfIgnoringQuoted(predicateStr, ',', prevIdx); + } + predicates.add(predicateStr.substring(prevIdx)); + + return predicates; + } + + /** + * Returns the predicate string, i.e. the string between the brackets in a + * path fragment. Examples: + * VTextField[0] => 0 + * VTextField[caption='foo'] => caption='foo' + * + * + * @param pathFragment + * The path fragment from which to extract the predicate string. + * @return The predicate string for the path fragment or empty string if not + * found. + */ + private static String extractPredicateString(String pathFragment) { + int ixOpenBracket = LocatorUtil + .indexOfIgnoringQuoted(pathFragment, '['); + if (ixOpenBracket >= 0) { + int ixCloseBracket = LocatorUtil.indexOfIgnoringQuoted( + pathFragment, ']', ixOpenBracket); + return pathFragment.substring(ixOpenBracket + 1, ixCloseBracket); + } + return ""; + } + + /** + * Removes the surrounding quotes from a string if it is quoted. + * + * @param str + * the possibly quoted string + * @return an unquoted version of str + */ + private static String unquote(String str) { + if ((str.startsWith("\"") && str.endsWith("\"")) + || (str.startsWith("'") && str.endsWith("'"))) { + return str.substring(1, str.length() - 1); + } + return str; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value + * the value to set + */ + public void setValue(String value) { + this.value = value; + } + + /** + * @return the index + */ + public int getIndex() { + return index; + } + + /** + * @param index + * the index to set + */ + public void setIndex(int index) { + this.index = index; + } + + /** + * @return the wildcard + */ + public boolean isWildcard() { + return wildcard; + } + + /** + * @param wildcard + * the wildcard to set + */ + public void setWildcard(boolean wildcard) { + this.wildcard = wildcard; + } +} diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 2bb08a52c9..49090b66db 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -19,22 +19,18 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.google.gwt.core.client.JsArrayString; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; -import com.vaadin.client.FastStringSet; import com.vaadin.client.HasComponentsConnector; import com.vaadin.client.Util; -import com.vaadin.client.metadata.NoDataException; import com.vaadin.client.metadata.Property; import com.vaadin.client.metadata.TypeDataStore; import com.vaadin.client.ui.AbstractConnector; import com.vaadin.client.ui.SubPartAware; import com.vaadin.client.ui.VNotification; -import com.vaadin.shared.AbstractComponentState; /** * The VaadinFinder locator strategy implements an XPath-like syntax for @@ -60,15 +56,11 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; /** - * Internal container/descriptor for search predicates - * - * @author Vaadin Ltd + * Internal descriptor for connector/element/widget name combinations */ - private static final class Predicate { - private String name = ""; - private String value = ""; - private boolean wildcard = false; - private int index = -1; + private static final class ConnectorPath { + private String name; + private ComponentConnector connector; } public VaadinFinderLocatorStrategy(ApplicationConnection clientConnection) { @@ -80,11 +72,176 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ @Override public String getPathForElement(Element targetElement) { - // Path generation functionality is not yet implemented as there is no - // current need for it. This might be implemented in the future if the - // need arises. Until then, all locator generation is handled by - // LegacyLocatorStrategy. - return null; + if (targetElement == null) { + return ""; + } + + List hierarchy = getConnectorHierarchyForElement(targetElement); + List path = new ArrayList(); + + // Assemble longname path components back-to-forth with useful + // predicates - first try ID, then caption. + for (int i = 0; i < hierarchy.size(); ++i) { + ConnectorPath cp = hierarchy.get(i); + String pathFragment = cp.name; + String identifier = getPropertyValue(cp.connector, "id"); + + if (identifier != null) { + pathFragment += "[id=\"" + identifier + "\"]"; + } else { + identifier = getPropertyValue(cp.connector, "caption"); + if (identifier != null) { + pathFragment += "[caption=\"" + identifier + "\"]"; + } + } + path.add(pathFragment); + } + + if (path.size() == 0) { + // If we didn't find a single element, return null.. + return null; + } + + return getBestSelector(generateQueries(path), targetElement); + } + + /** + * Search different queries for the best one. Use the fact that the lowest + * possible index is with the last selector. Last selector is the full + * search path containing the complete Component hierarchy. + * + * @param selectors + * List of selectors + * @param target + * Target element + * @return Best selector string formatted with a post filter + */ + private String getBestSelector(List selectors, Element target) { + // The last selector gives us smallest list index for target element. + String bestSelector = selectors.get(selectors.size() - 1); + int min = getElementsByPath(bestSelector).indexOf(target); + if (selectors.size() > 1 + && min == getElementsByPath(selectors.get(0)).indexOf(target)) { + // The first selector has same index as last. It's much shorter. + bestSelector = selectors.get(0); + } else if (selectors.size() > 2) { + // See if we get minimum from second last. If not then we already + // have the best one.. Second last one contains almost full + // component hierarchy. + if (getElementsByPath(selectors.get(selectors.size() - 2)).indexOf( + target) == min) { + for (int i = 1; i < selectors.size() - 2; ++i) { + // Loop through the remaining selectors and look for one + // with the same index + if (getElementsByPath(selectors.get(i)).indexOf(target) == min) { + bestSelector = selectors.get(i); + break; + } + } + + } + } + return "(" + bestSelector + ")[" + min + "]"; + + } + + /** + * Function to generate all possible search paths for given component list. + * Function strips out all the com.vaadin.ui. prefixes from elements as this + * functionality makes generating a query later on easier. + * + * @param components + * List of components + * @return List of Vaadin selectors + */ + private List generateQueries(List components) { + // Prepare to loop through all the elements. + List paths = new ArrayList(); + int compIdx = 0; + String basePath = components.get(compIdx).replace("com.vaadin.ui.", ""); + // Add a basic search for the first element (eg. //Button) + paths.add((components.size() == 1 ? "/" : "//") + basePath); + while (++compIdx < components.size()) { + // Loop through the remaining components + for (int i = components.size() - 1; i >= compIdx; --i) { + boolean recursive = false; + if (i > compIdx) { + recursive = true; + } + paths.add((i == components.size() - 1 ? "/" : "//") + + components.get(i).replace("com.vaadin.ui.", "") + + (recursive ? "//" : "/") + basePath); + } + // Add the element at index compIdx to the basePath so it is + // included in all the following searches. + basePath = components.get(compIdx).replace("com.vaadin.ui.", "") + + "/" + basePath; + } + + return paths; + } + + /** + * Helper method to get the string-form value of a named property of a + * component connector + * + * @since 7.2 + * @param c + * any ComponentConnector instance + * @param propertyName + * property name to test for + * @return a string, if the property is found, or null, if the property does + * not exist on the object (or some other error is encountered). + */ + private String getPropertyValue(ComponentConnector c, String propertyName) { + Property prop = AbstractConnector.getStateType(c).getProperty( + propertyName); + try { + return prop.getValue(c.getState()).toString(); + } catch (Exception e) { + return null; + } + } + + /** + * Generate a list representing the top-to-bottom connector hierarchy for + * any given element. ConnectorPath element provides long- and short names, + * as well as connector and widget root element references. + * + * @since 7.2 + * @param elem + * any Element that is part of a widget hierarchy + * @return a list of ConnectorPath objects, in descending order towards the + * common root container. + */ + private List getConnectorHierarchyForElement(Element elem) { + Element e = elem; + ComponentConnector c = Util.findPaintable(client, e); + List connectorHierarchy = new ArrayList(); + + while (c != null) { + + for (String id : getIDsForConnector(c)) { + ConnectorPath cp = new ConnectorPath(); + cp.name = getFullClassName(id); + cp.connector = c; + + // We want to make an exception for the UI object, since it's + // our default search context (and can't be found inside itself) + if (!cp.name.equals("com.vaadin.ui.UI")) { + connectorHierarchy.add(cp); + } + } + + e = (Element) e.getParentElement(); + if (e != null) { + c = Util.findPaintable(client, e); + e = c != null ? c.getWidget().getElement() : null; + } + + } + + return connectorHierarchy; } private boolean isNotificationExpression(String path) { @@ -118,21 +275,41 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ @Override public List getElementsByPath(String path) { + List postFilters = SelectorPredicate + .extractPostFilterPredicates(path); + if (postFilters.size() > 0) { + path = path.substring(1, path.lastIndexOf(')')); + } + List elements = new ArrayList(); if (isNotificationExpression(path)) { - List elements = new ArrayList(); for (VNotification n : findNotificationsByPath(path)) { elements.add(n.getElement()); } - return elements; + } else { + + elements.addAll(eliminateDuplicates(getElementsByPathStartingAtConnector( + path, client.getUIConnector()))); } - List elems = eliminateDuplicates(getElementsByPathStartingAtConnector( - path, client.getUIConnector())); + for (SelectorPredicate p : postFilters) { + // Post filtering supports only indexes and follows instruction + // blindly. Index that is outside of our list results into an empty + // list and multiple indexes are likely to ruin a search completely + if (p.getIndex() >= 0) { + if (p.getIndex() >= elements.size()) { + elements.clear(); + } else { + Element e = elements.get(p.getIndex()); + elements.clear(); + elements.add(e); + } + } + } - return elems; + return elements; } /** @@ -140,90 +317,56 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ @Override public Element getElementByPath(String path) { - if (isNotificationExpression(path)) { - return findNotificationsByPath(path).get(0).getElement(); + List elements = getElementsByPath(path); + if (elements.isEmpty()) { + return null; } - return getElementByPathStartingAtConnector(path, - client.getUIConnector()); + return elements.get(0); } /** - * Generate a list of predicates from a single predicate string - * - * @param str - * a comma separated string of predicates - * @return a List of Predicate objects + * {@inheritDoc} */ - private List extractPredicates(String path) { - List predicates = new ArrayList(); - - String str = extractPredicateString(path); - if (null == str || str.length() == 0) { - return predicates; - } - - // Extract input strings - List input = new ArrayList(); - { - int idx = indexOfIgnoringQuotes(str, ',', 0), p = 0; - if (idx == -1) { - input.add(str); - } else { - do { - input.add(str.substring(p, idx)); - p = idx + 1; - idx = indexOfIgnoringQuotes(str, ',', p); - } while (idx > -1); - input.add(str.substring(p)); - } + @Override + public Element getElementByPathStartingAt(String path, Element root) { + List elements = getElementsByPathStartingAt(path, root); + if (elements.isEmpty()) { + return null; } + return elements.get(0); - // Process each predicate into proper predicate descriptor - for (String s : input) { - Predicate p = new Predicate(); - s = s.trim(); - - try { - // If we can parse out the predicate as a pure index argument, - // stop processing here. - p.index = Integer.parseInt(s); - predicates.add(p); - - continue; - } catch (Exception e) { - p.index = -1; - } - - int idx = indexOfIgnoringQuotes(s, '='); - if (idx < 0) { - continue; - } - p.name = s.substring(0, idx); - p.value = s.substring(idx + 1); - - if (p.value.equals("?")) { - p.wildcard = true; - p.value = null; - } else { - // Only unquote predicate value once we're sure it's a proper - // value... - - p.value = unquote(p.value); - } + } - predicates.add(p); + /** + * {@inheritDoc} + */ + @Override + public List getElementsByPathStartingAt(String path, Element root) { + List postFilters = SelectorPredicate + .extractPostFilterPredicates(path); + if (postFilters.size() > 0) { + path = path.substring(1, path.lastIndexOf(')')); } - // Move any (and all) index predicates to last place in the list. - for (int i = 0, l = predicates.size(); i < l - 1; ++i) { - if (predicates.get(i).index > -1) { - predicates.add(predicates.remove(i)); - --i; - --l; + List elements = getElementsByPathStartingAtConnector(path, + Util.findPaintable(client, root)); + + for (SelectorPredicate p : postFilters) { + // Post filtering supports only indexes and follows instruction + // blindly. Index that is outside of our list results into an empty + // list and multiple indexes are likely to ruin a search completely + if (p.getIndex() >= 0) { + if (p.getIndex() >= elements.size()) { + elements.clear(); + } else { + Element e = elements.get(p.getIndex()); + elements.clear(); + elements.add(e); + } } } - return predicates; + return elements; } /** @@ -245,11 +388,12 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { } } - List predicates = extractPredicates(path); - for (Predicate p : predicates) { + List predicates = SelectorPredicate + .extractPredicates(path); + for (SelectorPredicate p : predicates) { - if (p.index > -1) { - VNotification n = notifications.get(p.index); + if (p.getIndex() > -1) { + VNotification n = notifications.get(p.getIndex()); notifications.clear(); if (n != null) { notifications.add(n); @@ -261,59 +405,6 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return eliminateDuplicates(notifications); } - /** - * {@inheritDoc} - */ - @Override - public Element getElementByPathStartingAt(String path, Element root) { - return getElementByPathStartingAtConnector(path, - Util.findPaintable(client, root)); - } - - /** - * {@inheritDoc} - */ - @Override - public List getElementsByPathStartingAt(String path, Element root) { - List elements = getElementsByPathStartingAtConnector(path, - Util.findPaintable(client, root)); - return elements; - } - - /** - * Finds an element by the specified path, starting traversal of the - * connector hierarchy from the specified root. - * - * @param path - * the locator path - * @param root - * the root connector - * @return the element identified by path or null if not found. - */ - private Element getElementByPathStartingAtConnector(String path, - ComponentConnector root) { - String[] pathComponents = path.split(SUBPART_SEPARATOR); - ComponentConnector connector; - if (pathComponents[0].length() > 0) { - connector = findConnectorByPath(pathComponents[0], root); - } else { - connector = root; - } - if (connector != null) { - if (pathComponents.length > 1) { - // We have subparts - if (connector.getWidget() instanceof SubPartAware) { - return ((SubPartAware) connector.getWidget()) - .getSubPartElement(pathComponents[1]); - } else { - return null; - } - } - return connector.getWidget().getElement(); - } - return null; - } - /** * Finds a list of elements by the specified path, starting traversal of the * connector hierarchy from the specified root. @@ -355,41 +446,6 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return eliminateDuplicates(output); } - /** - * Recursively finds a connector for the element identified by the provided - * path by traversing the connector hierarchy starting from the - * {@code parent} connector. - * - * @param path - * The path identifying an element. - * @param parent - * The connector to start traversing from. - * @return The connector identified by {@code path} or null if no such - * connector could be found. - */ - private ComponentConnector findConnectorByPath(String path, - ComponentConnector parent) { - boolean findRecursively = path.startsWith("//"); - // Strip away the one or two slashes from the beginning of the path - path = path.substring(findRecursively ? 2 : 1); - - String[] fragments = splitFirstFragmentFromTheRest(path); - List potentialMatches = collectPotentialMatches( - parent, fragments[0], findRecursively); - - List connectors = filterMatches(potentialMatches, - extractPredicates(fragments[0])); - - if (!connectors.isEmpty()) { - if (fragments.length > 1) { - return findConnectorByPath(fragments[1], connectors.get(0)); - } else { - return connectors.get(0); - } - } - return null; - } - /** * Recursively finds connectors for the elements identified by the provided * path by traversing the connector hierarchy starting from {@code parents} @@ -414,7 +470,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { for (ComponentConnector parent : parents) { connectors.addAll(filterMatches( collectPotentialMatches(parent, fragments[0], - findRecursively), extractPredicates(fragments[0]))); + findRecursively), SelectorPredicate + .extractPredicates(fragments[0]))); } if (!connectors.isEmpty() && fragments.length > 1) { @@ -423,28 +480,6 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return eliminateDuplicates(connectors); } - /** - * Returns the predicate string, i.e. the string between the brackets in a - * path fragment. Examples: - * VTextField[0] => 0 - * VTextField[caption='foo'] => caption='foo' - * - * - * @param pathFragment - * The path fragment from which to extract the predicate string. - * @return The predicate string for the path fragment or empty string if not - * found. - */ - private String extractPredicateString(String pathFragment) { - int ixOpenBracket = indexOfIgnoringQuotes(pathFragment, '['); - if (ixOpenBracket >= 0) { - int ixCloseBracket = indexOfIgnoringQuotes(pathFragment, ']', - ixOpenBracket); - return pathFragment.substring(ixOpenBracket + 1, ixCloseBracket); - } - return ""; - } - /** * Go through a list of potentially matching components, modifying that list * until all elements that remain in that list match the complete list of @@ -458,13 +493,13 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ private List filterMatches( List potentialMatches, - List predicates) { + List predicates) { - for (Predicate p : predicates) { + for (SelectorPredicate p : predicates) { - if (p.index > -1) { + if (p.getIndex() > -1) { try { - ComponentConnector v = potentialMatches.get(p.index); + ComponentConnector v = potentialMatches.get(p.getIndex()); potentialMatches.clear(); potentialMatches.add(v); } catch (IndexOutOfBoundsException e) { @@ -476,20 +511,11 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { for (int i = 0, l = potentialMatches.size(); i < l; ++i) { - ComponentConnector c = potentialMatches.get(i); - Property property = AbstractConnector.getStateType(c) - .getProperty(p.name); - - Object propData; - try { - propData = property.getValue(c.getState()); - } catch (NoDataException e) { - propData = null; - } + String propData = getPropertyValue(potentialMatches.get(i), + p.getName()); - if ((p.wildcard && propData == null) - || (!p.wildcard && !valueEqualsPropertyValue(p.value, - property, c.getState()))) { + if ((p.isWildcard() && propData == null) + || (!p.isWildcard() && !p.getValue().equals(propData))) { potentialMatches.remove(i); --l; --i; @@ -501,44 +527,6 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return eliminateDuplicates(potentialMatches); } - /** - * Returns true if the value matches the value of the property in the state - * object. - * - * @param value - * The value to compare against. - * @param property - * The property, whose value to check. - * @param state - * The connector, whose state object contains the property. - * @return true if the values match. - */ - private boolean valueEqualsPropertyValue(String value, Property property, - AbstractComponentState state) { - try { - return value.equals(property.getValue(state)); - } catch (Exception e) { - // The property doesn't exist in the state object, so they aren't - // equal. - return false; - } - } - - /** - * Removes the surrounding quotes from a string if it is quoted. - * - * @param str - * the possibly quoted string - * @return an unquoted version of str - */ - private String unquote(String str) { - if ((str.startsWith("\"") && str.endsWith("\"")) - || (str.startsWith("'") && str.endsWith("'"))) { - return str.substring(1, str.length() - 1); - } - return str; - } - /** * Collects all connectors that match the widget class name of the path * fragment. If the {@code collectRecursively} parameter is true, a @@ -579,6 +567,15 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return eliminateDuplicates(potentialMatches); } + private List getIDsForConnector(ComponentConnector connector) { + Class connectorClass = connector.getClass(); + List ids = new ArrayList(); + + TypeDataStore.get().findIdentifiersFor(connectorClass).addAllTo(ids); + + return ids; + } + /** * Determines whether a connector matches a path fragment. This is done by * comparing the path fragment to the name of the widget type of the @@ -593,16 +590,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { */ private boolean connectorMatchesPathFragment(ComponentConnector connector, String widgetName) { - Class connectorClass = connector.getClass(); - List ids = new ArrayList(); - FastStringSet identifiers = TypeDataStore.get().findIdentifiersFor( - connectorClass); - JsArrayString str = identifiers.dump(); - - for (int j = 0; j < str.length(); ++j) { - ids.add(str.get(j)); - } + List ids = getIDsForConnector(connector); Integer[] widgetTags = client.getConfiguration() .getTagsForServerSideClassName(getFullClassName(widgetName)); @@ -677,7 +666,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { * the path. */ private String[] splitFirstFragmentFromTheRest(String path) { - int ixOfSlash = indexOfIgnoringQuotes(path, '/'); + int ixOfSlash = LocatorUtil.indexOfIgnoringQuoted(path, '/'); if (ixOfSlash > 0) { return new String[] { path.substring(0, ixOfSlash), path.substring(ixOfSlash) }; @@ -685,33 +674,6 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { return new String[] { path }; } - private int indexOfIgnoringQuotes(String str, char find) { - return indexOfIgnoringQuotes(str, find, 0); - } - - private int indexOfIgnoringQuotes(String str, char find, int startingAt) { - boolean quote = false; - String quoteChars = "'\""; - char currentQuote = '"'; - for (int i = startingAt; i < str.length(); ++i) { - char cur = str.charAt(i); - if (quote) { - if (cur == currentQuote) { - quote = !quote; - } - continue; - } else if (cur == find) { - return i; - } else { - if (quoteChars.indexOf(cur) >= 0) { - currentQuote = cur; - quote = !quote; - } - } - } - return -1; - } - private String getSimpleClassName(String s) { String[] parts = s.split("\\."); if (s.endsWith(".class")) { diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java index 2ad77a246b..2f425ee1a7 100644 --- a/client/src/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java @@ -16,851 +16,219 @@ package com.vaadin.client.debug.internal; -import com.google.gwt.core.client.JsArrayString; -import com.google.gwt.regexp.shared.MatchResult; -import com.google.gwt.regexp.shared.RegExp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.ui.Widget; -import com.vaadin.client.ApplicationConnection; -import com.vaadin.client.ComponentConnector; -import com.vaadin.client.FastStringSet; import com.vaadin.client.ServerConnector; -import com.vaadin.client.Util; import com.vaadin.client.componentlocator.ComponentLocator; -import com.vaadin.client.componentlocator.VaadinFinderLocatorStrategy; -import com.vaadin.client.metadata.NoDataException; -import com.vaadin.client.metadata.Property; -import com.vaadin.client.metadata.TypeDataStore; -import com.vaadin.client.ui.AbstractConnector; -import com.vaadin.client.ui.SubPartAware; +import com.vaadin.client.componentlocator.SelectorPredicate; /** - * A single segment of a selector path with optional parent. - *

- * The static method {@link #findTestBenchSelector(ServerConnector, Element)} - * permits looking up a selector chain for an element (a selector and its - * parents, each selector relative to its parent). - *

- * The method {@link #findElement()} can be used to locate the element - * referenced by a {@link SelectorPath}. {@link #getJUnitSelector(String)} can - * be used to obtain the string to add to a JUnit test to refer to the element - * identified by the path. + * A single segment of a selector path pointing to an Element. *

* This class should be considered internal to the framework and may change at * any time. + *

* * @since 7.1.x */ -public abstract class SelectorPath { - private final SelectorPath parent; +public class SelectorPath { + private final String path; + private final Element element; private final ComponentLocator locator; + private static Map counter = new HashMap(); + private static Map legacyNames = new HashMap(); - private static final String SUBPART_SEPARATOR = VaadinFinderLocatorStrategy.SUBPART_SEPARATOR; - - /** - * Creates a {@link SelectorPath} from the root of the UI (without a parent) - * to identify an element. - *

- * The {@link ComponentLocator} is used to locate the corresponding - * {@link Element} in the context of a UI. If there are multiple UIs on a - * single page, the locator should correspond to the correct - * {@link ApplicationConnection}. - * - * @param locator - * {@link ComponentLocator} to use - */ - protected SelectorPath(ComponentLocator locator) { - this(null, locator); - } - - /** - * Creates a {@link SelectorPath} which is relative to another - * {@link SelectorPath}. to identify an element. - *

- * The {@link ComponentLocator} is used to locate the corresponding - * {@link Element} in the context of a UI. If there are multiple UIs on a - * single page, the locator should correspond to the correct - * {@link ApplicationConnection}. - * - * @param parent - * parent {@link SelectorPath} or null for root paths - * @param locator - * {@link ComponentLocator} to use - */ - protected SelectorPath(SelectorPath parent, ComponentLocator locator) { - this.parent = parent; - this.locator = locator; + static { + legacyNames.put("FilterSelect", "ComboBox"); + legacyNames.put("ScrollTable", "Table"); } - /** - * Returns the parent {@link SelectorPath} to which this path is relative. - * - * @return parent path - */ - public SelectorPath getParent() { - return parent; + protected SelectorPath(ServerConnector c, Element e) { + element = e; + locator = new ComponentLocator(c.getConnection()); + path = locator.getPathForElement(e); } - @Override - public String toString() { - return "SelectorPath: " + getJUnitSelector("..."); + public String getPath() { + return path; } - /** - * Returns the JUnit test fragment which can be used to refer to the element - * in a test. - * - * @param context - * the context to use (usually a variable name) or null for - * default - * @return string to add in a JUnit test - */ - public abstract String getJUnitSelector(String context); - - /** - * Returns the {@link Element} that this {@link SelectorPath} points to in - * the context of the {@link ComponentLocator} of the {@link SelectorPath}. - * - * @return Element identified by the path in the current UI - */ - public abstract Element findElement(); - - /** - * Returns the path to an element/connector, including separate intermediate - * paths and the final path segment. - * - * @param connector - * the connector to find - * @param element - * sub-element inside connector or null to use connector root - * element - * @return Vaadin locator path - */ - public static SelectorPath findTestBenchSelector(ServerConnector connector, - Element element) { - // TODO there should be a better way to locate and refer to captions - - // now using domChild in layout - SelectorPath selectorPath = null; - ApplicationConnection connection = connector.getConnection(); - if (connection != null) { - if (null == element) { - element = findConnectorRootElement(connector); - } - if (null != element) { - ComponentLocator locator = new ComponentLocator(connection); - String path = locator.getPathForElement(element); - SelectorPath parent = null; - - if (!path.isEmpty()) { - selectorPath = extractIdSelectorPath(path, locator); - if (null == selectorPath) { - // parent paths first if not rooted on an ID - if (connector.getParent() != null) { - parent = findTestBenchSelector( - connector.getParent(), null); - } - - if (parent != null) { - // update path to be relative to parent - Element parentElement = parent.findElement(); - if (null != parentElement) { - String parentPath = locator - .getPathForElement(parentElement); - if (path.startsWith(parentPath)) { - // remove path of parent to look for the - // children - path = path.substring(parentPath.length()); - } - } - } - - selectorPath = extractVaadinSelectorPath(path, parent, - locator); - } - if (null == selectorPath) { - if (path.startsWith("/V")) { - // fall-back: Vaadin - // this branch is needed for /VTabsheetPanel etc. - selectorPath = SelectorPath.vaadinPath(path, - parent, locator); - } else { - // fall-back: XPath - selectorPath = SelectorPath.xpath(path, parent, - locator); - } - } - } - } - } - return selectorPath; - } - - private static SelectorPath extractIdSelectorPath(String path, - ComponentLocator locator) { - SelectorPath selectorPath = null; - if (path.startsWith("PID_S")) { - // remove internal prefix - path = path.substring(5); - - // no parent for an ID selector - String pid = path; - String rest = null; - // split at first slash that is not in the subpart (if any) - int slashPos = path.indexOf("/"); - int subPartPos = path.indexOf(SUBPART_SEPARATOR); - if (subPartPos >= 0 && slashPos > subPartPos) { - // ignore slashes in subpart - slashPos = -1; - } else if (slashPos >= 0 && subPartPos > slashPos) { - // ignore subpart after slashes - handled as a part of rest - subPartPos = -1; - } - // split the ID part and any relative path after it - if (slashPos > 0) { - pid = path.substring(0, slashPos); - rest = path.substring(slashPos); - } - - // if there is a subpart directly after the id, need to use a Vaadin - // selector - SelectorPath pidSelector = null; - if (subPartPos > 0) { - String id = pid.substring(0, subPartPos); - // include the subpart separator - String subPart = pid.substring(subPartPos); - Element element = locator.getElementByPath("PID_S" + pid); - ComponentConnector connector = Util.findPaintable( - locator.getClient(), element); - if (null != connector && null != connector.getWidget()) { - String type = connector.getWidget().getClass() - .getSimpleName(); - pidSelector = SelectorPath.vaadinPath("//" + type - + "[id=\\\"" + id + "\\\"]" + subPart, null, - locator); - } else { - // no valid connector for the subpart - return null; - } - } else { - pidSelector = SelectorPath.id(pid, locator); - } - if (null != rest && !rest.isEmpty()) { - selectorPath = extractVaadinSelectorPath(path, pidSelector, - locator); - if (selectorPath == null) { - selectorPath = SelectorPath.xpath(rest, pidSelector, - locator); - } - } else { - selectorPath = pidSelector; - } - } - return selectorPath; + public Element getElement() { + return element; } - private static SelectorPath extractVaadinSelectorPath(String path, - SelectorPath parent, ComponentLocator locator) { - SelectorPath selectorPath = null; - - String xpathPart = null; - int xpathPos = Math.min(path.indexOf("/div"), path.indexOf("/span")); - if (xpathPos >= 0) { - xpathPart = path.substring(xpathPos); - path = path.substring(0, xpathPos); - } - - String subPartPart = null; - int subPartPos = path.indexOf("#"); - if (subPartPos >= 0) { - subPartPart = path.substring(subPartPos + 1); - path = path.substring(0, subPartPos); - } - - String domChildPart = null; - int domChildPos = path.indexOf("/domChild"); - if (domChildPos >= 0) { - // include the slash - domChildPart = path.substring(domChildPos); - path = path.substring(0, domChildPos); - } - - // is it something VaadinSelectorPath can handle? - String widgetClass = null; - // first cases in a layout slot - RegExp widgetInSlotMatcher = RegExp - .compile("^/(Slot\\[(\\d+)\\]/)([a-zA-Z]+)(\\[0\\])?$"); - MatchResult matchResult = widgetInSlotMatcher.exec(path); - if (null != matchResult) { - if (matchResult.getGroupCount() >= 3) { - widgetClass = matchResult.getGroup(3); - } - } - // handle cases without intervening slot - if (null == widgetClass) { - RegExp widgetDirectlyMatcher = RegExp - .compile("^//?([a-zA-Z]+)(\\[(\\d+)\\])?$"); - matchResult = widgetDirectlyMatcher.exec(path); - if (null != matchResult) { - if (matchResult.getGroupCount() >= 1) { - widgetClass = matchResult.getGroup(1); - } - } - } - if (null != widgetClass && !widgetClass.isEmpty()) { - selectorPath = findVaadinSelectorInParent(path, widgetClass, - parent, locator); - if (null != subPartPart - && selectorPath instanceof VaadinSelectorPath) { - ((VaadinSelectorPath) selectorPath).setSubPart(subPartPart); - } else if (null != xpathPart - && selectorPath instanceof VaadinSelectorPath) { - // try to find sub-part if supported - ComponentConnector connector = Util.findPaintable( - locator.getClient(), selectorPath.findElement()); - if (connector != null - && connector.getWidget() instanceof SubPartAware) { - // for SubPartAware, skip the XPath fall-back path - Element element = locator.getElementByPathStartingAt(path, - selectorPath.findElement()); - SubPartAware subPartAware = (SubPartAware) connector - .getWidget(); - String subPart = subPartAware.getSubPartName(element); - if (null != subPart) { - // type checked above - ((VaadinSelectorPath) selectorPath).setSubPart(subPart); - } - } else { - // fall-back to XPath for the last part of the path - selectorPath = SelectorPath.xpath(xpathPart, selectorPath, - locator); - } - } - - // the whole /domChild[i]/domChild[j]... part as a single selector - if (null != domChildPart - && selectorPath instanceof VaadinSelectorPath) { - selectorPath = SelectorPath.vaadinPath(domChildPart, - selectorPath, locator); - } - } else if (null != domChildPart) { - // cases with domChild path only (parent contains rest) - selectorPath = SelectorPath.vaadinPath(domChildPart, parent, - locator); - } - return selectorPath; + public ComponentLocator getLocator() { + return locator; } /** - * Find the zero-based index of the widget of type widgetClass identified by - * path within its parent and returns the corresponding Vaadin path (if - * any). For instance, the second button in a layout has index 1 regardless - * of non-button components in the parent. - *

- * The approach used internally is to try to find the caption of the element - * inside its parent and check whether it is sufficient to identify the - * element correctly. If not, possible indices are looped through to see if - * the component of the specified type within the specified parent - * identifies the correct element. This is inefficient but more reliable - * than some alternative approaches, and does not require special cases for - * various layouts etc. + * Generate ElementQuery code for Java. Fallback to By.vaadin(path) if + * dealing with LegacyLocator * - * @param path - * relative path for the widget of interest - * @param widgetClass - * type of the widget of interest - * @param parent - * parent component to which the path is relative - * @param locator - * ComponentLocator used to map paths to elements - * @return selector path for the element, null if none found + * @return String containing Java code for finding the element described by + * path */ - private static SelectorPath findVaadinSelectorInParent(String path, - String widgetClass, SelectorPath parent, ComponentLocator locator) { - if (null == parent) { - SelectorPath selectorPath = SelectorPath.vaadin(widgetClass, 0, - null, locator); - if (selectorPath.findElement() == locator.getElementByPath(path)) { - return selectorPath; + public String getElementQuery() { + if (locator.isValidForLegacyLocator(path)) { + return getLegacyLocatorQuery(); + } + + String[] fragments; + String tmpPath = path; + List postFilters = SelectorPredicate + .extractPostFilterPredicates(path); + if (postFilters.size() > 0) { + tmpPath = tmpPath.substring(1, tmpPath.lastIndexOf(')')); + } + + // Generate an ElementQuery + fragments = tmpPath.split("/"); + String elementQueryString; + int index = 0; + for (SelectorPredicate p : postFilters) { + if (p.getIndex() > 0) { + index = p.getIndex(); + } + } + if (index > 0) { + elementQueryString = ".get(" + index + ");"; + } else { + elementQueryString = ".fist();"; + } + for (int i = 1; i < fragments.length; ++i) { + if (fragments[i].isEmpty()) { + // Recursive search has occasional empty fragments + continue; + } + + // Get Element.class -name + String queryFragment = ""; + String elementClass = getComponentName(fragments[i]) + + "Element.class"; + for (SelectorPredicate p : SelectorPredicate + .extractPredicates(fragments[i])) { + // Add in predicates like .caption and .id + queryFragment += "." + p.getName() + "(\"" + p.getValue() + + "\")"; + } + if (i == fragments.length - 1) { + // Last element in path. + queryFragment = "$(" + elementClass + ")" + queryFragment; } else { - return null; - } - } - // This method uses an inefficient brute-force approach but its - // results should match what is used by the TestBench selectors. - Element parentElement = parent.findElement(); - String parentPathString = locator.getPathForElement(parentElement); - if (null == parentPathString) { - parentPathString = ""; - } - Element elementToFind = locator.getElementByPath(parentPathString - + path); - if (null == elementToFind) { - return null; - } - // if the connector has a caption, first try if the element can be - // located in parent with it; if that fails, use the index in parent - String caption = getCaptionForElement(elementToFind, locator); - if (null != caption) { - SelectorPath testPath = SelectorPath.vaadin(widgetClass, caption, - parent, locator); - Element testElement = testPath.findElement(); - // TODO in theory could also iterate upwards into parents, using - // "//" before the caption to find the shortest matching path that - // identifies the correct element - if (testElement == elementToFind) { - return testPath; - } - } - - // Assumes that the number of logical child elements is at most the - // number of direct children of the DOM element - e.g. layouts have a - // single component per slot. - for (int i = 0; i < parentElement.getChildCount(); ++i) { - SelectorPath testPath = SelectorPath.vaadin(widgetClass, i, parent, - locator); - Element testElement = testPath.findElement(); - if (testElement == elementToFind) { - return testPath; - } - } - return null; - } - - private static String getCaptionForElement(Element element, - ComponentLocator locator) { - String caption = null; - ComponentConnector connector = Util.findPaintable(locator.getClient(), - element); - if (null != connector) { - Property property = AbstractConnector.getStateType(connector) - .getProperty("caption"); - try { - Object value = property.getValue(connector.getState()); - if (null != value) { - caption = String.valueOf(value); + // If followed by an empty fragment search is recursive + boolean recursive = fragments[i + 1].isEmpty(); + if (recursive) { + queryFragment = ".in(" + elementClass + ")" + queryFragment; + } else { + queryFragment = ".childOf(" + elementClass + ")" + + queryFragment; } - } catch (NoDataException e) { - // skip the caption based selection and use index below } + elementQueryString = queryFragment + elementQueryString; } - return caption; - } - private static Element findConnectorRootElement(ServerConnector connector) { - Element element = null; - // try to find the root element of the connector - if (connector instanceof ComponentConnector) { - Widget widget = ((ComponentConnector) connector).getWidget(); - if (widget != null) { - element = widget.getElement(); - } - } - return element; - } - - public ComponentLocator getLocator() { - return locator; - } - - @Override - public int hashCode() { - return getJUnitSelector("context").hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SelectorPath other = (SelectorPath) obj; - if (parent == null) { - if (other.parent != null) { - return false; - } - } else if (!parent.equals(other.parent)) { - return false; - } - if (!other.getJUnitSelector("context").equals( - getJUnitSelector("context"))) { - return false; - } - return true; - } - - protected static SelectorPath xpath(String path, SelectorPath parent, - ComponentLocator locator) { - return new XPathSelectorPath(path, parent, locator); - } - - protected static SelectorPath id(String id, ComponentLocator locator) { - return new IdSelectorPath(id, locator); - } - - protected static SelectorPath vaadin(String widgetClass, - String widgetCaption, SelectorPath parent, ComponentLocator locator) { - return new VaadinSelectorPath(widgetClass, widgetCaption, 0, parent, - locator); - } - - protected static SelectorPath vaadin(String widgetClass, int widgetIndex, - SelectorPath parent, ComponentLocator locator) { - return new VaadinSelectorPath(widgetClass, null, widgetIndex, parent, - locator); - } - - protected static SelectorPath vaadinPath(String vaadinPath, - SelectorPath parent, ComponentLocator locator) { - return new ByVaadinSelectorPath(vaadinPath, parent, locator); + // Return full Java variable assignment and eQuery + return generateJavaVariable(fragments[fragments.length - 1]) + + elementQueryString; } /** - * Selector path for finding an {@link Element} based on an XPath (relative - * to the parent {@link SelectorPath}). + * @since + * @param frags + * @param i + * @return */ - private static class XPathSelectorPath extends SelectorPath { - // path segment relative to parent - private final String path; - - /** - * Creates a relative XPath based component selector path. - * - * @param path - * XPath - * @param parent - * {@link SelectorPath} to which the XPath is relative, null - * if from the root - * @param locator - * ComponentLocator to use to find the element - */ - public XPathSelectorPath(String path, SelectorPath parent, - ComponentLocator locator) { - super(parent, locator); - this.path = path; - } - - /** - * Returns the XPath relative to the parent element. - * - * @return relative path string - */ - public String getPath() { - return path; - } - - @Override - public String getJUnitSelector(String context) { - // use driver by default - String contextString = null != context ? context : "getDriver()"; - return contextString + ".findElement(By.xpath(\"" + getPath() - + "\"))"; - } - - @Override - public Element findElement() { - if (null != getParent()) { - Element parentElement = getParent().findElement(); - if (null == parentElement) { - // broken path - possibly removed parent - return null; - } - Element element = getLocator().getElementByPathStartingAt( - getPath(), parentElement); - return element; - } else { - Element element = getLocator().getElementByPath(getPath()); - return element; - } - } + protected String getComponentName(String fragment) { + return fragment.split("\\[")[0]; } /** - * Element identifier based locator path. - *

- * Identifier paths never have a parent and the identifiers should be unique - * within the context of the {@link ComponentLocator}/page. + * Generates a legacy locator for SelectorPath. + * + * @return String containing Java code for element search and assignment */ - private static class IdSelectorPath extends SelectorPath { - private final String id; - - /** - * Creates an identifier based {@link SelectorPath}. The identifier - * should not contain the old "PID_S" prefix. - * - * @param id - * @param locator - */ - public IdSelectorPath(String id, ComponentLocator locator) { - super(locator); - this.id = id; - } + private String getLegacyLocatorQuery() { + String[] frags = path.split("/"); + String name = getComponentName(frags[frags.length - 1]).substring(1); - /** - * Returns the ID in the DOM used to identify the element. - * - * @return Vaadin debug ID or equivalent - */ - public String getId() { - return id; + if (legacyNames.containsKey(name)) { + name = legacyNames.get(name); } - @Override - public String getJUnitSelector(String context) { - String contextPart = null != context ? ", " + context : ""; - return "getElementById(\"" + getId() + "\"" + contextPart + ")"; - } + name = getNameWithCount(name); - @Override - public Element findElement() { - // this also works for IDs - return getLocator().getElementByPath("PID_S" + getId()); - } + // Use direct path and elementX naming style. + return "WebElement " + name.substring(0, 1).toLowerCase() + + name.substring(1) + " = getDriver().findElement(By.vaadin(\"" + + path + "\"));"; } /** - * Common base class for Vaadin selector paths (By.vaadin(...)). + * Get variable name with counter for given component name. + * + * @param name + * Component name + * @return name followed by count */ - private static abstract class AbstractVaadinSelectorPath extends - SelectorPath { - - protected AbstractVaadinSelectorPath(SelectorPath parent, - ComponentLocator locator) { - super(parent, locator); + protected String getNameWithCount(String name) { + if (!counter.containsKey(name)) { + counter.put(name, 0); } - - /** - * Returns the {@link ComponentLocator} path of the element relative to - * the parent path. - * - * @return path of the element for By.vaadin(...) - */ - protected abstract String getPath(); - - @Override - public Element findElement() { - if (null != getParent()) { - Element parentElement = getParent().findElement(); - Element element = getLocator().getElementByPathStartingAt( - getPath(), parentElement); - return element; - } else { - return getLocator().getElementByPath(getPath()); - } - } - + counter.put(name, counter.get(name) + 1); + name += counter.get(name); + return name; } /** - * TestBench selector path for Vaadin widgets. These selectors are based on - * the widget class and either the index among the widgets of that type in - * the parent or the widget caption. + * Generate Java variable assignment from given selector fragment + * + * @param pathFragment + * Selector fragment + * @return piece of java code */ - private static class VaadinSelectorPath extends AbstractVaadinSelectorPath { - private final String widgetClass; - private final String widgetCaption; - // negative for no index - private final int widgetIndex; - private String subPart; - - /** - * Creates a Vaadin {@link SelectorPath}. The path identifies an element - * of a given type under its parent based on either its caption or its - * index (if both are given, only the caption is used). See also - * {@link ComponentLocator} for more details. - * - * @param widgetClass - * client-side widget class - * @param widgetCaption - * caption of the widget - null to use the index instead - * @param widgetIndex - * index of the widget of the type within its parent, used - * only if the caption is not given - * @param parent - * parent {@link SelectorPath} or null - * @param locator - * component locator to use to find the corresponding - * {@link Element} - */ - public VaadinSelectorPath(String widgetClass, String widgetCaption, - int widgetIndex, SelectorPath parent, ComponentLocator locator) { - super(parent, locator); - this.widgetClass = widgetClass; - this.widgetCaption = widgetCaption; - this.widgetIndex = widgetIndex; - } - - /** - * Returns the widget type used to identify the element. - * - * @return Vaadin widget class - */ - public String getWidgetClass() { - return widgetClass; - } - - /** - * Returns the widget caption to look for or null if index is used - * instead. - * - * @return widget caption to match - */ - public String getWidgetCaption() { - return widgetCaption; - } - - /** - * Returns the index of the widget of that type within its parent - only - * used if caption is null. - * - * @return widget index - */ - public int getWidgetIndex() { - return widgetIndex; - } - - /** - * Returns the sub-part string (e.g. row and column identifiers within a - * table) used to identify a part of a component. See - * {@link ComponentLocator} and especially Vaadin selectors for more - * information. - * - * @return sub-part string or null if none - */ - public String getSubPart() { - return subPart; - } - - /** - * Sets the sub-part string (e.g. row and column identifiers within a - * table) used to identify a part of a component. See - * {@link ComponentLocator} and especially Vaadin selectors for more - * information. - * - * @param subPart - * sub-part string to use or null for none - */ - public void setSubPart(String subPart) { - this.subPart = subPart; - } - - @Override - public String getJUnitSelector(String context) { - String componentClass = getComponentClass(); - String contextPart = null != context ? ", " + context : ""; - // TODO update after subpart API finished - if (null != getSubPart() || null == componentClass) { - return "getElementByPath(\"" + getPath() + "\"" + contextPart - + ")"; - } else if (null != getWidgetCaption()) { - return "getElementByCaption(" + componentClass + ".class, \"" - + getWidgetCaption() + "\"" + contextPart + ")"; - } else if (getWidgetIndex() >= 0) { - return "getElementByIndex(" + componentClass + ".class, " - + getWidgetIndex() + contextPart + ")"; - } else { - return "getElement(" + componentClass + ".class" + contextPart - + ")"; - } - } + private String generateJavaVariable(String pathFragment) { + // Get element type and predicates from fragment + List predicates = SelectorPredicate + .extractPredicates(pathFragment); + String elementType = pathFragment.split("\\[")[0]; + String name = getNameFromPredicates(predicates, elementType); - /** - * Returns the Vaadin server side component class to use for a widget - * class. - * - * @return fully qualified server side class name, null if unable to - * determine it - */ - private String getComponentClass() { - ComponentConnector connector = Util.findPaintable(getLocator() - .getClient(), findElement()); - Class connectorClass = connector - .getClass(); - FastStringSet identifiers = TypeDataStore.get().findIdentifiersFor( - connectorClass); - JsArrayString ids = identifiers.dump(); - if (ids.length() == 1) { - return ids.get(0); - } else { - return null; - } + if (name.equals(elementType)) { + name = getNameWithCount(name); } - // these are used only to locate components on the client side by path - - @Override - protected String getPath() { - return "/" + getWidgetClass() + getIndexString(false) - + getSubPartPostfix(); - } + // Replace unusable characters + name = name.replaceAll("\\W", ""); - private String getIndexString(boolean escapeQuotes) { - if (null != getWidgetCaption()) { - if (escapeQuotes) { - return "[caption=\\\"" + widgetCaption + "\\\"]"; - } else { - return "[caption=\"" + widgetCaption + "\"]"; - } - } else if (widgetIndex >= 0) { - return "[" + getWidgetIndex() + "]"; - } else { - return ""; - } - } - - private String getSubPartPostfix() { - String subPartString = ""; - if (null != getSubPart()) { - subPartString = SUBPART_SEPARATOR + getSubPart(); - } - return subPartString; - } + // Lowercase the first character of name + return elementType + "Element " + name.substring(0, 1).toLowerCase() + + name.substring(1) + " = "; } /** - * TestBench selector path for Vaadin widgets, always using a - * By.vaadin(path) rather than other convenience methods. + * Get variable name based on predicates. Fallback to elementType + * + * @param predicates + * Predicates related to element + * @param elementType + * Element type + * @return name for Variable */ - private static class ByVaadinSelectorPath extends - AbstractVaadinSelectorPath { - private final String path; - - /** - * Vaadin selector path for an exact path (including any preceding - * slash). - * - * @param path - * path of the element (normally with a leading slash), not - * null - * @param parent - * parent selector path or null if none - * @param locator - * ComponentLocator to use to find the corresponding element - */ - public ByVaadinSelectorPath(String path, SelectorPath parent, - ComponentLocator locator) { - super(parent, locator); - this.path = path; - } - - @Override - public String getJUnitSelector(String context) { - String contextPart = null != context ? ", " + context : ""; - return "getElementByPath(\"" + getPath() + "\"" + contextPart + ")"; - } - - /** - * Returns the By.vaadin(...) path relative to the parent element. - * - * @return relative path string - */ - @Override - public String getPath() { - return path; - } + private String getNameFromPredicates(List predicates, + String elementType) { + String name = elementType; + for (SelectorPredicate p : predicates) { + if ("caption".equals(p.getName())) { + // Caption + elementType is a suitable name + name = p.getValue() + elementType; + } else if ("id".equals(p.getName())) { + // Just id. This is unique, use it. + return p.getValue(); + } + } + return name; } } \ No newline at end of file diff --git a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java index 462309768f..35c0d7abe8 100644 --- a/client/src/com/vaadin/client/debug/internal/TestBenchSection.java +++ b/client/src/com/vaadin/client/debug/internal/TestBenchSection.java @@ -55,25 +55,14 @@ public class TestBenchSection implements Section { */ private static class SelectorWidget extends HTML implements MouseOverHandler, MouseOutHandler { - private static int selectorCounter = 1; + private final SelectorPath path; - final private SelectorPath path; - final private SelectorWidget parent; - final private int selectorIndex = selectorCounter++; - - public SelectorWidget(final SelectorPath path, - final SelectorWidget parent) { + public SelectorWidget(final SelectorPath path) { this.path = path; - this.parent = parent; - String parentString = (parent != null) ? ("element" + parent.selectorIndex) - : null; - String html = "

" - + Util.escapeHTML("WebElement element" + selectorIndex - + " = " + path.getJUnitSelector(parentString) + ";") - + "
"; + + Util.escapeHTML(path.getElementQuery()) + ""; setHTML(html); addMouseOverHandler(this); @@ -82,10 +71,10 @@ public class TestBenchSection implements Section { @Override public void onMouseOver(MouseOverEvent event) { - ApplicationConnection a = path.getLocator().getClient(); - Element element = path.findElement(); + Highlight.hideAll(); + + Element element = path.getElement(); if (null != element) { - Highlight.hideAll(); Highlight.show(element); } } @@ -96,13 +85,11 @@ public class TestBenchSection implements Section { } } - private final DebugButton tabButton = new DebugButton(Icon.SELECTOR, + private final DebugButton tabButton = new DebugButton(Icon.WARNING, "Pick Vaadin TestBench selectors"); private final FlowPanel content = new FlowPanel(); - private final HierarchyPanel hierarchyPanel = new HierarchyPanel(); - private final FlowPanel selectorPanel = new FlowPanel(); // map from full path to SelectorWidget to enable reuse of old selectors private Map selectorWidgets = new HashMap(); @@ -110,21 +97,14 @@ public class TestBenchSection implements Section { private final FlowPanel controls = new FlowPanel(); private final Button find = new DebugButton(Icon.HIGHLIGHT, - "Select a component on the page to inspect it"); - private final Button refreshHierarchy = new DebugButton(Icon.HIERARCHY, - "Refresh the connector hierarchy tree"); + "Pick an element and generate a query for it"); + + private final Button clear = new DebugButton(Icon.CLEAR, + "Clear current elements"); private HandlerRegistration highlightModeRegistration = null; public TestBenchSection() { - controls.add(refreshHierarchy); - refreshHierarchy.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); - refreshHierarchy.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - hierarchyPanel.update(); - } - }); controls.add(find); find.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); @@ -135,15 +115,16 @@ public class TestBenchSection implements Section { } }); - hierarchyPanel.addListener(new SelectConnectorListener() { + controls.add(clear); + clear.setStylePrimaryName(VDebugWindow.STYLENAME_BUTTON); + clear.addClickHandler(new ClickHandler() { @Override - public void select(ServerConnector connector, Element element) { - pickSelector(connector, element); + public void onClick(ClickEvent event) { + clearResults(); } }); content.setStylePrimaryName(VDebugWindow.STYLENAME + "-testbench"); - content.add(hierarchyPanel); content.add(selectorPanel); } @@ -209,33 +190,19 @@ public class TestBenchSection implements Section { highlightModeRegistration = null; find.removeStyleDependentName(VDebugWindow.STYLENAME_ACTIVE); } + Highlight.hideAll(); } private void pickSelector(ServerConnector connector, Element element) { - SelectorPath path = SelectorPath.findTestBenchSelector(connector, - element); - if (null != path) { - addSelectorWidgets(path); - } - } + SelectorPath p = new SelectorPath(connector, Util + .findPaintable(connector.getConnection(), element).getWidget() + .getElement()); + SelectorWidget w = new SelectorWidget(p); - private SelectorWidget addSelectorWidgets(SelectorPath path) { - // add selector widgets recursively from root towards children, reusing - // old ones - SelectorPath parent = path.getParent(); - SelectorWidget parentWidget = null; - if (null != parent) { - parentWidget = addSelectorWidgets(parent); - } - SelectorWidget widget = selectorWidgets.get(path); - if (null == widget) { - // the parent has already been added above - widget = new SelectorWidget(path, parentWidget); - selectorWidgets.put(path, widget); - selectorPanel.add(widget); - } - return widget; + content.add(w); + + stopFind(); } private final NativePreviewHandler highlightModeHandler = new NativePreviewHandler() { @@ -260,6 +227,7 @@ public class TestBenchSection implements Section { // make sure that not finding the highlight element only Highlight.hideAll(); + eventTarget = Util.getElementFromPoint(event.getNativeEvent() .getClientX(), event.getNativeEvent().getClientY()); ComponentConnector connector = findConnector(eventTarget); @@ -304,4 +272,8 @@ public class TestBenchSection implements Section { return null; } + private void clearResults() { + content.clear(); + } + } -- cgit v1.2.3 From 6002fd94557f1b6adc374cbc0e95060638d98c7c Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 28 Jan 2014 17:50:33 +0200 Subject: Use new client-compiler-deps (1.1.0) (#12871) Change-Id: I3036cb357a144edee56ec37870c9632b0cd90565 --- client-compiler/ivy.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index eeb54af879..ae4534303f 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -78,7 +78,7 @@ conf="build,ide -> default" /> + rev="1.1.0" conf="build,ide -> default" /> -- cgit v1.2.3 From cfaa732a771c47a53df8e36c2b2d8cdc96c777a3 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 29 Jan 2014 14:48:28 +0200 Subject: Fix a typo in SelectorPath generator Change-Id: Ic02be496a1b2b7d7728ef0e8a21209f24d971f26 --- client/src/com/vaadin/client/debug/internal/SelectorPath.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/debug/internal/SelectorPath.java b/client/src/com/vaadin/client/debug/internal/SelectorPath.java index 2f425ee1a7..f92054e016 100644 --- a/client/src/com/vaadin/client/debug/internal/SelectorPath.java +++ b/client/src/com/vaadin/client/debug/internal/SelectorPath.java @@ -96,7 +96,7 @@ public class SelectorPath { if (index > 0) { elementQueryString = ".get(" + index + ");"; } else { - elementQueryString = ".fist();"; + elementQueryString = ".first();"; } for (int i = 1; i < fragments.length; ++i) { if (fragments[i].isEmpty()) { -- cgit v1.2.3 From f8b39b3ee8d66bf287b11220f095029aa3d11793 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 20 Jan 2014 16:57:09 +0200 Subject: Upgrade to Atmosphere client 2.0.8.vaadin1 Change-Id: Icd2ebf5362976ec1d327f9a51149960d70930d45 --- push/ivy.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/push/ivy.xml b/push/ivy.xml index fd9284b782..b28c5c69d9 100644 --- a/push/ivy.xml +++ b/push/ivy.xml @@ -3,7 +3,7 @@ - + ]> Date: Wed, 29 Jan 2014 18:41:45 +0200 Subject: Exclude Jetty orbit which causes build issues (#12871) Change-Id: I06d1343dc25598e45c7a960c36fee2ef4869b651 --- client-compiler/ivy.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index ae4534303f..f0fa5a49b0 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -43,7 +43,9 @@ conf="build,ide -> default" /> + rev="8.1.12.v20130726" conf="build,ide -> default"> + + @@ -76,7 +78,7 @@ - + -- cgit v1.2.3 From 0a77f5e526da11fd066ea257a0304e883fcc0402 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 30 Jan 2014 07:56:05 +0200 Subject: Add commons-lang for now until tests are converted to lang3 (#12871) Change-Id: I14509d95dd2e042f830a7fca6925e012483bb36d --- uitest/ivy.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uitest/ivy.xml b/uitest/ivy.xml index 9c86b2b68c..0508d10b57 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -84,6 +84,10 @@ conf="build,ide -> default" /> + + + -- cgit v1.2.3 From 69983d0aa0400a3c110e960d0f9da0ca0a59a094 Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Mon, 27 Jan 2014 13:30:38 +0200 Subject: Re-adjusted the rendering order of TabSheet tabs to prevent an NPE in isClipped (#12343) Change-Id: I0705c02c12b5f0e998fda68fd7a144e45173a75e --- client/src/com/vaadin/client/ui/VTabsheet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index b65f058a46..a3d96983e8 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -841,8 +841,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable, tab = tb.addTab(); } if (selected) { - renderContent(tabUidl.getChildUIDL(0)); tb.selectTab(index); + renderContent(tabUidl.getChildUIDL(0)); } tab.updateFromUIDL(tabUidl); tab.setEnabledOnServer((!disabledTabKeys.contains(tabKeys.get(index)))); -- cgit v1.2.3 From f52c25fbb87d4c872304323d8ab42ba6d3ea0497 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Thu, 30 Jan 2014 11:38:59 +0200 Subject: Fix false-negative sasslangbroken tests (#13275). Change-Id: I184418667c1de63cbdbc26d75f2268415a8f06f9 --- theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css | 3 +++ .../sasslang/css/390-test_parent_selector_with_parent_and_subject.scss | 3 +++ .../tests/resources/sasslang/scss/350-test_interpolation.scss | 2 ++ .../sasslang/scss/390-test_parent_selector_with_parent_and_subject.css | 3 +++ .../tests/resources/sasslangbroken/css/350-test_interpolation.css | 3 --- .../css/390-test_parent_selector_with_parent_and_subject.css | 3 --- .../tests/resources/sasslangbroken/scss/350-test_interpolation.scss | 2 -- .../scss/390-test_parent_selector_with_parent_and_subject.scss | 3 --- 8 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css create mode 100644 theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss create mode 100644 theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss delete mode 100644 theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss diff --git a/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css b/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css new file mode 100644 index 0000000000..8b44646800 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/350-test_interpolation.css @@ -0,0 +1,3 @@ +ul li#foo a span.label { + foo: bar; +} diff --git a/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.scss b/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.scss new file mode 100644 index 0000000000..646238f379 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/css/390-test_parent_selector_with_parent_and_subject.scss @@ -0,0 +1,3 @@ +$subject: "!"; +foo { + bar &.baz#{$subject} .bip {c: d}} diff --git a/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss b/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss new file mode 100644 index 0000000000..bb9c9a2c8f --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/350-test_interpolation.scss @@ -0,0 +1,2 @@ +$bar : "#foo"; +ul li#{$bar} a span.label { foo: bar; } diff --git a/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.css b/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.css new file mode 100644 index 0000000000..234fea7aa5 --- /dev/null +++ b/theme-compiler/tests/resources/sasslang/scss/390-test_parent_selector_with_parent_and_subject.css @@ -0,0 +1,3 @@ +bar foo.baz! .bip { + c: d; +} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css b/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css deleted file mode 100644 index 8b44646800..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/350-test_interpolation.css +++ /dev/null @@ -1,3 +0,0 @@ -ul li#foo a span.label { - foo: bar; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css b/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css deleted file mode 100644 index 234fea7aa5..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/css/390-test_parent_selector_with_parent_and_subject.css +++ /dev/null @@ -1,3 +0,0 @@ -bar foo.baz! .bip { - c: d; -} diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss b/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss deleted file mode 100644 index bb9c9a2c8f..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/350-test_interpolation.scss +++ /dev/null @@ -1,2 +0,0 @@ -$bar : "#foo"; -ul li#{$bar} a span.label { foo: bar; } diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss b/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss deleted file mode 100644 index 646238f379..0000000000 --- a/theme-compiler/tests/resources/sasslangbroken/scss/390-test_parent_selector_with_parent_and_subject.scss +++ /dev/null @@ -1,3 +0,0 @@ -$subject: "!"; -foo { - bar &.baz#{$subject} .bip {c: d}} -- cgit v1.2.3 From e5dee6a7417e4466ad35bd9150174f86204bca3e Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 30 Jan 2014 11:39:57 +0200 Subject: Use Calendar as sender for action handlers (#13191) The sender parameter to action handlers is now the Calendar instance rather than an instance of a private RPC implementation class. This was probably broken by an earlier refactoring. Change-Id: If15cf232e7578eb55617f45db6b9304f5e80fed5 --- server/src/com/vaadin/ui/Calendar.java | 4 +- .../calendar/CalendarActionEventSource.java | 114 +++++++++++++++++++++ .../calendar/CalendarActionEventSourceTest.java | 83 +++++++++++++++ 3 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSource.java create mode 100644 uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java index 9ccc8ea2d9..b0999451c3 100644 --- a/server/src/com/vaadin/ui/Calendar.java +++ b/server/src/com/vaadin/ui/Calendar.java @@ -1824,7 +1824,7 @@ public class Calendar extends AbstractComponent implements try { Date start = formatter.parse(startDate); for (Action.Handler ah : actionHandlers) { - ah.handleAction(action, this, start); + ah.handleAction(action, Calendar.this, start); } } catch (ParseException e) { @@ -1842,7 +1842,7 @@ public class Calendar extends AbstractComponent implements DateConstants.ACTION_DATE_FORMAT_PATTERN); formatter.setTimeZone(getTimeZone()); for (Action.Handler ah : actionHandlers) { - ah.handleAction(action, this, events.get(eventIndex)); + ah.handleAction(action, Calendar.this, events.get(eventIndex)); } } } diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSource.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSource.java new file mode 100644 index 0000000000..5e81750e58 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSource.java @@ -0,0 +1,114 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.calendar; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.vaadin.event.Action; +import com.vaadin.event.Action.Handler; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Calendar; +import com.vaadin.ui.Calendar.TimeFormat; +import com.vaadin.ui.Label; +import com.vaadin.ui.components.calendar.CalendarComponentEvents.EventResizeHandler; +import com.vaadin.ui.components.calendar.event.BasicEvent; +import com.vaadin.ui.components.calendar.event.CalendarEvent; +import com.vaadin.ui.components.calendar.event.CalendarEventProvider; + +public class CalendarActionEventSource extends AbstractTestUI { + + private Calendar calendar; + + @Override + protected void setup(VaadinRequest request) { + calendar = new Calendar(new CalendarEventProvider() { + + @Override + public List getEvents( + Date startDate, Date endDate) { + + List events = new ArrayList(); + + CalendarEvent event = null; + try { + event = new BasicEvent("NAME", "TOOLTIP", + new SimpleDateFormat("yyyy-MM-dd hh:mm") + .parse("2013-01-01 07:00"), + new SimpleDateFormat("yyyy-MM-dd hh:mm") + .parse("2013-01-01 11:00")); + } catch (ParseException e) { + // Nothing to do + } + events.add(event); + + return events; + } + + }); + try { + calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2013-01-01")); + calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd") + .parse("2013-01-31")); + } catch (ParseException e) { + // Nothing to do + } + calendar.setImmediate(true); + calendar.setFirstVisibleHourOfDay(6); + calendar.setLastVisibleHourOfDay(22); + calendar.setTimeFormat(TimeFormat.Format24H); + calendar.setHandler((EventResizeHandler) null); + + setEnabled(true); + calendar.addActionHandler(new Handler() { + @Override + public void handleAction(Action action, Object sender, Object target) { + Label label1 = new Label(calendar.toString()); + label1.setId("calendarlabel"); + addComponent(label1); + + Label label2 = new Label(sender.toString()); + label2.setId("senderlabel"); + addComponent(label2); + } + + @Override + public Action[] getActions(Object target, Object sender) { + return new Action[] { new Action("ACTION") }; + } + }); + addComponent(calendar); + calendar.setSizeFull(); + setSizeFull(); + + } + + @Override + protected String getTestDescription() { + return "Calendar action event source should be the calendar itself"; + } + + @Override + protected Integer getTicketNumber() { + return 13191; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java new file mode 100644 index 0000000000..6fbe77040f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.calendar; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +/** + * Test that calendar action event source is the calendar, not a private nested + * class in it. + * + * The related code is not browser dependent so only running on a single + * browser. + * + * @author Vaadin Ltd + */ +public class CalendarActionEventSourceTest extends PrivateTB3Configuration { + @Test + public void testActionEventSourceIsCalendarForEmptyCell() throws Exception { + openTestURL(); + + // perform action on empty cell + WebElement element = getDriver().findElement( + By.className("v-calendar-spacer")); + performAction(element); + + checkEventSourceIsCalendar(); + } + + @Test + public void testActionEventSourceIsCalendarForEvent() throws Exception { + openTestURL(); + + // perform action on calendar event + WebElement element = getDriver().findElement( + By.className("v-calendar-event")); + performAction(element); + + checkEventSourceIsCalendar(); + } + + private void performAction(WebElement element) { + // right click + new Actions(getDriver()).contextClick(element).perform(); + WebElement menuItem = getDriver().findElement( + By.className("gwt-MenuItem")); + menuItem.click(); + } + + private void checkEventSourceIsCalendar() { + String calendarObject = getDriver().findElement(By.id("calendarlabel")) + .getText(); + String actionSourceObject = getDriver().findElement( + By.id("senderlabel")).getText(); + Assert.assertEquals( + "Calendar action event source must be the calendar itself", + calendarObject, actionSourceObject); + } + + @Override + protected Class getUIClass() { + return CalendarActionEventSource.class; + } + +} -- cgit v1.2.3 From 3bfd0046eaead75e6b8cac7dc7b2d1ecceb25dc9 Mon Sep 17 00:00:00 2001 From: joheriks Date: Wed, 27 Nov 2013 17:47:23 +0200 Subject: Resolved ambiguous parsing of ";" within @media block (#12923) Also infer missing semicolon before EOF (required for @debug and @warn at end of file) Change-Id: Ib4449a3b8d79ce1b35732d4a33a1a30530bfc91a --- .../com/vaadin/sass/internal/parser/Parser.java | 904 ++++++++++----------- .../src/com/vaadin/sass/internal/parser/Parser.jj | 26 +- 2 files changed, 454 insertions(+), 476 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index eee53608b5..6b4a03b038 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -4673,33 +4673,22 @@ boolean isPseudoElement = false; final public void debugDirective() throws ParseException { jj_consume_token(DEBUG_SYM); - String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE,EOF}); // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. System.out.println(content); try { + jj_consume_token(SEMICOLON); label_141: while (true) { - jj_consume_token(SEMICOLON); - label_142: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[209] = jj_gen; - break label_142; - } - jj_consume_token(S); - } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SEMICOLON: + case S: ; break; default: - jj_la1[210] = jj_gen; + jj_la1[209] = jj_gen; break label_141; } + jj_consume_token(S); } } catch (ParseException e) { acceptMissingSemicolonBeforeRbrace(e); @@ -4708,33 +4697,22 @@ boolean isPseudoElement = false; final public void warnDirective() throws ParseException { jj_consume_token(WARN_SYM); - String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE,EOF}); // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. System.err.println(content); try { - label_143: + jj_consume_token(SEMICOLON); + label_142: while (true) { - jj_consume_token(SEMICOLON); - label_144: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case S: - ; - break; - default: - jj_la1[211] = jj_gen; - break label_144; - } - jj_consume_token(S); - } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SEMICOLON: + case S: ; break; default: - jj_la1[212] = jj_gen; - break label_143; + jj_la1[210] = jj_gen; + break label_142; } + jj_consume_token(S); } } catch (ParseException e) { acceptMissingSemicolonBeforeRbrace(e); @@ -4761,20 +4739,20 @@ boolean isPseudoElement = false; exclusive = false; break; default: - jj_la1[213] = jj_gen; + jj_la1[211] = jj_gen; jj_consume_token(-1); throw new ParseException(); } to = skipStatementUntilLeftBrace(); - label_145: + label_143: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[214] = jj_gen; - break label_145; + jj_la1[212] = jj_gen; + break label_143; } jj_consume_token(S); } @@ -4795,33 +4773,33 @@ boolean isPseudoElement = false; final public void extendDirective() throws ParseException { ArrayList list; jj_consume_token(EXTEND_SYM); - label_146: + label_144: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[215] = jj_gen; - break label_146; + jj_la1[213] = jj_gen; + break label_144; } jj_consume_token(S); } list = selectorList(); documentHandler.extendDirective(list); try { - label_147: + label_145: while (true) { jj_consume_token(SEMICOLON); - label_148: + label_146: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[216] = jj_gen; - break label_148; + jj_la1[214] = jj_gen; + break label_146; } jj_consume_token(S); } @@ -4830,8 +4808,8 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[217] = jj_gen; - break label_147; + jj_la1[215] = jj_gen; + break label_145; } } } catch (ParseException e) { @@ -4841,31 +4819,31 @@ boolean isPseudoElement = false; final public void contentDirective() throws ParseException { jj_consume_token(CONTENT_SYM); - label_149: + label_147: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[218] = jj_gen; - break label_149; + jj_la1[216] = jj_gen; + break label_147; } jj_consume_token(S); } try { - label_150: + label_148: while (true) { jj_consume_token(SEMICOLON); - label_151: + label_149: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[219] = jj_gen; - break label_151; + jj_la1[217] = jj_gen; + break label_149; } jj_consume_token(S); } @@ -4874,8 +4852,8 @@ boolean isPseudoElement = false; ; break; default: - jj_la1[220] = jj_gen; - break label_150; + jj_la1[218] = jj_gen; + break label_148; } } } catch (ParseException e) { @@ -4905,28 +4883,28 @@ boolean isPseudoElement = false; LexicalUnit exp; name = property(); jj_consume_token(COLON); - label_152: + label_150: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[221] = jj_gen; - break label_152; + jj_la1[219] = jj_gen; + break label_150; } jj_consume_token(S); } jj_consume_token(LBRACE); - label_153: + label_151: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[222] = jj_gen; - break label_153; + jj_la1[220] = jj_gen; + break label_151; } jj_consume_token(S); } @@ -4937,29 +4915,29 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[223] = jj_gen; + jj_la1[221] = jj_gen; ; } - label_154: + label_152: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[224] = jj_gen; - break label_154; + jj_la1[222] = jj_gen; + break label_152; } jj_consume_token(SEMICOLON); - label_155: + label_153: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[225] = jj_gen; - break label_155; + jj_la1[223] = jj_gen; + break label_153; } jj_consume_token(S); } @@ -4969,21 +4947,21 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[226] = jj_gen; + jj_la1[224] = jj_gen; ; } } jj_consume_token(RBRACE); documentHandler.endNestedProperties(name); - label_156: + label_154: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[227] = jj_gen; - break label_156; + jj_la1[225] = jj_gen; + break label_154; } jj_consume_token(S); } @@ -5000,7 +4978,7 @@ LexicalUnit exp; debuggingDirective(); break; default: - jj_la1[228] = jj_gen; + jj_la1[226] = jj_gen; if (jj_2_6(2147483647)) { styleRule(); } else if (jj_2_7(3)) { @@ -5021,7 +4999,7 @@ LexicalUnit exp; styleRule(); break; default: - jj_la1[229] = jj_gen; + jj_la1[227] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5066,15 +5044,15 @@ LexicalUnit exp; name = property(); save = token; jj_consume_token(COLON); - label_157: + label_155: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[230] = jj_gen; - break label_157; + jj_la1[228] = jj_gen; + break label_155; } jj_consume_token(S); } @@ -5118,7 +5096,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[231] = jj_gen; + jj_la1[229] = jj_gen; ; } Token next = getToken(1); @@ -5137,15 +5115,15 @@ LexicalUnit exp; break; case LBRACE: jj_consume_token(LBRACE); - label_158: + label_156: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[232] = jj_gen; - break label_158; + jj_la1[230] = jj_gen; + break label_156; } jj_consume_token(S); } @@ -5156,29 +5134,29 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[233] = jj_gen; + jj_la1[231] = jj_gen; ; } - label_159: + label_157: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[234] = jj_gen; - break label_159; + jj_la1[232] = jj_gen; + break label_157; } jj_consume_token(SEMICOLON); - label_160: + label_158: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[235] = jj_gen; - break label_160; + jj_la1[233] = jj_gen; + break label_158; } jj_consume_token(S); } @@ -5188,27 +5166,27 @@ LexicalUnit exp; declaration(); break; default: - jj_la1[236] = jj_gen; + jj_la1[234] = jj_gen; ; } } jj_consume_token(RBRACE); - label_161: + label_159: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[237] = jj_gen; - break label_161; + jj_la1[235] = jj_gen; + break label_159; } jj_consume_token(S); } documentHandler.endNestedProperties(name); break; default: - jj_la1[238] = jj_gen; + jj_la1[236] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5258,15 +5236,15 @@ LexicalUnit exp; name = property(); save = token; jj_consume_token(COLON); - label_162: + label_160: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[239] = jj_gen; - break label_162; + jj_la1[237] = jj_gen; + break label_160; } jj_consume_token(S); } @@ -5276,7 +5254,7 @@ LexicalUnit exp; important = prio(); break; default: - jj_la1[240] = jj_gen; + jj_la1[238] = jj_gen; ; } documentHandler.property(name, exp, important); @@ -5319,15 +5297,15 @@ LexicalUnit exp; */ final public boolean prio() throws ParseException { jj_consume_token(IMPORTANT_SYM); - label_163: + label_161: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[241] = jj_gen; - break label_163; + jj_la1[239] = jj_gen; + break label_161; } jj_consume_token(S); } @@ -5337,15 +5315,15 @@ LexicalUnit exp; final public boolean guarded() throws ParseException { jj_consume_token(GUARDED_SYM); - label_164: + label_162: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[242] = jj_gen; - break label_164; + jj_la1[240] = jj_gen; + break label_162; } jj_consume_token(S); } @@ -5370,15 +5348,15 @@ LexicalUnit exp; * 3. parenthesis is not supported now. */ n = jj_consume_token(COMMA); - label_165: + label_163: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[243] = jj_gen; - break label_165; + jj_la1[241] = jj_gen; + break label_163; } jj_consume_token(S); } @@ -5388,15 +5366,15 @@ LexicalUnit exp; break; case DIV: n = jj_consume_token(DIV); - label_166: + label_164: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[244] = jj_gen; - break label_166; + jj_la1[242] = jj_gen; + break label_164; } jj_consume_token(S); } @@ -5406,15 +5384,15 @@ LexicalUnit exp; break; case ANY: n = jj_consume_token(ANY); - label_167: + label_165: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[245] = jj_gen; - break label_167; + jj_la1[243] = jj_gen; + break label_165; } jj_consume_token(S); } @@ -5424,15 +5402,15 @@ LexicalUnit exp; break; case MOD: n = jj_consume_token(MOD); - label_168: + label_166: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[246] = jj_gen; - break label_168; + jj_la1[244] = jj_gen; + break label_166; } jj_consume_token(S); } @@ -5442,7 +5420,7 @@ LexicalUnit exp; break; case PLUS: n = jj_consume_token(PLUS); - label_169: + label_167: while (true) { jj_consume_token(S); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5450,8 +5428,8 @@ LexicalUnit exp; ; break; default: - jj_la1[247] = jj_gen; - break label_169; + jj_la1[245] = jj_gen; + break label_167; } } {if (true) return LexicalUnitImpl.createAdd(n.beginLine, @@ -5460,7 +5438,7 @@ LexicalUnit exp; break; case MINUS: n = jj_consume_token(MINUS); - label_170: + label_168: while (true) { jj_consume_token(S); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5468,8 +5446,8 @@ LexicalUnit exp; ; break; default: - jj_la1[248] = jj_gen; - break label_170; + jj_la1[246] = jj_gen; + break label_168; } } {if (true) return LexicalUnitImpl.createMinus(n.beginLine, @@ -5477,7 +5455,7 @@ LexicalUnit exp; prev);} break; default: - jj_la1[249] = jj_gen; + jj_la1[247] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5492,12 +5470,12 @@ LexicalUnit exp; char op; first = term(null); res = first; - label_171: + label_169: while (true) { if (jj_2_8(2)) { ; } else { - break label_171; + break label_169; } if (jj_2_9(2)) { res = operator(res); @@ -5524,7 +5502,7 @@ LexicalUnit exp; {if (true) return '+';} break; default: - jj_la1[250] = jj_gen; + jj_la1[248] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5577,7 +5555,7 @@ LexicalUnit exp; result = variableTerm(prev); break; default: - jj_la1[251] = jj_gen; + jj_la1[249] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5630,7 +5608,7 @@ LexicalUnitImpl result = null; op = unaryOperator(); break; default: - jj_la1[252] = jj_gen; + jj_la1[250] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5746,7 +5724,7 @@ LexicalUnitImpl result = null; result = function(op, prev); break; default: - jj_la1[253] = jj_gen; + jj_la1[251] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5779,7 +5757,7 @@ LexicalUnitImpl result = null; s+="."; break; default: - jj_la1[254] = jj_gen; + jj_la1[252] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -5796,7 +5774,7 @@ LexicalUnitImpl result = null; n = jj_consume_token(FROM); break; default: - jj_la1[255] = jj_gen; + jj_la1[253] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -5843,25 +5821,25 @@ LexicalUnitImpl result = null; result = unicode(prev); break; default: - jj_la1[256] = jj_gen; + jj_la1[254] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[257] = jj_gen; + jj_la1[255] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - label_172: + label_170: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[258] = jj_gen; - break label_172; + jj_la1[256] = jj_gen; + break label_170; } jj_consume_token(S); } @@ -5877,15 +5855,15 @@ LexicalUnitImpl result = null; Token n; LexicalUnit params = null; n = jj_consume_token(FUNCTION); - label_173: + label_171: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[259] = jj_gen; - break label_173; + jj_la1[257] = jj_gen; + break label_171; } jj_consume_token(S); } @@ -5936,7 +5914,7 @@ LexicalUnitImpl result = null; params = expr(); break; default: - jj_la1[260] = jj_gen; + jj_la1[258] = jj_gen; ; } jj_consume_token(RPARAN); @@ -6213,27 +6191,27 @@ LexicalUnitImpl result = null; String skipStatementUntil(int[] symbols) throws ParseException { StringBuffer s = new StringBuffer(); - boolean stop = false; + boolean found = false; Token tok; - while(!stop){ + while(!found){ tok = getToken(1); - if(tok.kind == EOF) { - return null; - } for(int sym : symbols){ if(tok.kind == sym){ - stop = true; + found = true; break; } } - if(!stop){ + if(tok.kind == EOF) { + break; + } + if(!found){ if (tok.image != null) { s.append(tok.image); } getNextToken(); } } - return s.toString().trim(); + return found ? s.toString().trim() : null; } String skipStatement() throws ParseException { @@ -6393,15 +6371,15 @@ LexicalUnitImpl result = null; // TODO required by original parser but not used by Vaadin? final public void _parseRule() throws ParseException { String ret = null; - label_174: + label_172: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[261] = jj_gen; - break label_174; + jj_la1[259] = jj_gen; + break label_172; } jj_consume_token(S); } @@ -6436,7 +6414,7 @@ LexicalUnitImpl result = null; fontFace(); break; default: - jj_la1[262] = jj_gen; + jj_la1[260] = jj_gen; ret = skipStatement(); if ((ret == null) || (ret.length() == 0)) { {if (true) return;} @@ -6451,15 +6429,15 @@ LexicalUnitImpl result = null; } final public void _parseImportRule() throws ParseException { - label_175: + label_173: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[263] = jj_gen; - break label_175; + jj_la1[261] = jj_gen; + break label_173; } jj_consume_token(S); } @@ -6467,15 +6445,15 @@ LexicalUnitImpl result = null; } final public void _parseMediaRule() throws ParseException { - label_176: + label_174: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[264] = jj_gen; - break label_176; + jj_la1[262] = jj_gen; + break label_174; } jj_consume_token(S); } @@ -6483,15 +6461,15 @@ LexicalUnitImpl result = null; } final public void _parseDeclarationBlock() throws ParseException { - label_177: + label_175: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[265] = jj_gen; - break label_177; + jj_la1[263] = jj_gen; + break label_175; } jj_consume_token(S); } @@ -6501,29 +6479,29 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[266] = jj_gen; + jj_la1[264] = jj_gen; ; } - label_178: + label_176: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: ; break; default: - jj_la1[267] = jj_gen; - break label_178; + jj_la1[265] = jj_gen; + break label_176; } jj_consume_token(SEMICOLON); - label_179: + label_177: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[268] = jj_gen; - break label_179; + jj_la1[266] = jj_gen; + break label_177; } jj_consume_token(S); } @@ -6533,7 +6511,7 @@ LexicalUnitImpl result = null; declaration(); break; default: - jj_la1[269] = jj_gen; + jj_la1[267] = jj_gen; ; } } @@ -6542,15 +6520,15 @@ LexicalUnitImpl result = null; final public ArrayList _parseSelectors() throws ParseException { ArrayList p = null; try { - label_180: + label_178: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case S: ; break; default: - jj_la1[270] = jj_gen; - break label_180; + jj_la1[268] = jj_gen; + break label_178; } jj_consume_token(S); } @@ -6564,7 +6542,7 @@ LexicalUnitImpl result = null; void acceptMissingSemicolonBeforeRbrace(ParseException parseException) throws ParseException { Token next = getToken(1); - if (next.kind != RBRACE) { + if (next.kind != RBRACE && next.kind!=EOF) { throw parseException; } } @@ -6632,7 +6610,7 @@ LexicalUnitImpl result = null; finally { jj_save(8, xla); } } - private boolean jj_3R_202() { + private boolean jj_3R_200() { if (jj_scan_token(VARIABLE)) return true; Token xsp; while (true) { @@ -6647,15 +6625,15 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_220() { - if (jj_3R_219()) return true; + private boolean jj_3R_218() { + if (jj_3R_217()) return true; return false; } - private boolean jj_3R_184() { + private boolean jj_3R_182() { Token xsp; xsp = jj_scanpos; - if (jj_3R_202()) jj_scanpos = xsp; + if (jj_3R_200()) jj_scanpos = xsp; if (jj_scan_token(CONTAINS)) return true; while (true) { xsp = jj_scanpos; @@ -6665,7 +6643,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_219() { + private boolean jj_3R_217() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(18)) { @@ -6682,59 +6660,59 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_181() { - if (jj_3R_191()) return true; + private boolean jj_3R_179() { + if (jj_3R_189()) return true; if (jj_scan_token(COLON)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } - if (jj_3R_192()) return true; + if (jj_3R_190()) return true; xsp = jj_scanpos; - if (jj_3R_193()) jj_scanpos = xsp; - if (jj_3R_194()) return true; + if (jj_3R_191()) jj_scanpos = xsp; + if (jj_3R_192()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_194()) { jj_scanpos = xsp; break; } + if (jj_3R_192()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_196() { + private boolean jj_3R_194() { if (jj_scan_token(S)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_220()) jj_scanpos = xsp; + if (jj_3R_218()) jj_scanpos = xsp; return false; } - private boolean jj_3R_195() { - if (jj_3R_219()) return true; + private boolean jj_3R_193() { + if (jj_3R_217()) return true; return false; } - private boolean jj_3R_182() { + private boolean jj_3R_180() { Token xsp; xsp = jj_scanpos; - if (jj_3R_195()) { + if (jj_3R_193()) { jj_scanpos = xsp; - if (jj_3R_196()) return true; + if (jj_3R_194()) return true; } return false; } - private boolean jj_3R_222() { + private boolean jj_3R_220() { if (jj_scan_token(HASH)) return true; return false; } - private boolean jj_3R_292() { + private boolean jj_3R_290() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_293() { + private boolean jj_3R_291() { if (jj_scan_token(FUNCTION)) return true; Token xsp; while (true) { @@ -6746,46 +6724,46 @@ LexicalUnitImpl result = null; } private boolean jj_3_7() { - if (jj_3R_188()) return true; + if (jj_3R_186()) return true; return false; } - private boolean jj_3R_291() { + private boolean jj_3R_289() { if (jj_scan_token(COLON)) return true; return false; } - private boolean jj_3R_209() { + private boolean jj_3R_207() { if (jj_scan_token(LBRACE)) return true; return false; } - private boolean jj_3R_224() { + private boolean jj_3R_222() { if (jj_scan_token(COLON)) return true; Token xsp; xsp = jj_scanpos; - if (jj_3R_291()) jj_scanpos = xsp; + if (jj_3R_289()) jj_scanpos = xsp; xsp = jj_scanpos; - if (jj_3R_292()) { + if (jj_3R_290()) { jj_scanpos = xsp; - if (jj_3R_293()) return true; + if (jj_3R_291()) return true; } return false; } - private boolean jj_3R_208() { - if (jj_3R_192()) return true; + private boolean jj_3R_206() { + if (jj_3R_190()) return true; return false; } private boolean jj_3_6() { - if (jj_3R_187()) return true; + if (jj_3R_185()) return true; if (jj_scan_token(LBRACE)) return true; return false; } - private boolean jj_3R_188() { - if (jj_3R_207()) return true; + private boolean jj_3R_186() { + if (jj_3R_205()) return true; if (jj_scan_token(COLON)) return true; Token xsp; while (true) { @@ -6793,24 +6771,24 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_208()) { + if (jj_3R_206()) { jj_scanpos = xsp; - if (jj_3R_209()) return true; + if (jj_3R_207()) return true; } return false; } - private boolean jj_3R_271() { - if (jj_3R_192()) return true; + private boolean jj_3R_269() { + if (jj_3R_190()) return true; return false; } - private boolean jj_3R_312() { + private boolean jj_3R_310() { if (jj_scan_token(STRING)) return true; return false; } - private boolean jj_3R_261() { + private boolean jj_3R_259() { if (jj_scan_token(FUNCTION)) return true; Token xsp; while (true) { @@ -6818,65 +6796,65 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_271()) jj_scanpos = xsp; + if (jj_3R_269()) jj_scanpos = xsp; if (jj_scan_token(RPARAN)) return true; return false; } - private boolean jj_3R_310() { + private boolean jj_3R_308() { if (jj_scan_token(STARMATCH)) return true; return false; } - private boolean jj_3R_311() { + private boolean jj_3R_309() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_309() { + private boolean jj_3R_307() { if (jj_scan_token(DOLLARMATCH)) return true; return false; } - private boolean jj_3R_308() { + private boolean jj_3R_306() { if (jj_scan_token(CARETMATCH)) return true; return false; } - private boolean jj_3R_307() { + private boolean jj_3R_305() { if (jj_scan_token(DASHMATCH)) return true; return false; } - private boolean jj_3R_306() { + private boolean jj_3R_304() { if (jj_scan_token(INCLUDES)) return true; return false; } - private boolean jj_3R_273() { + private boolean jj_3R_271() { if (jj_scan_token(INTERPOLATION)) return true; return false; } - private boolean jj_3R_305() { + private boolean jj_3R_303() { if (jj_scan_token(EQ)) return true; return false; } - private boolean jj_3R_298() { + private boolean jj_3R_296() { Token xsp; xsp = jj_scanpos; + if (jj_3R_303()) { + jj_scanpos = xsp; + if (jj_3R_304()) { + jj_scanpos = xsp; if (jj_3R_305()) { jj_scanpos = xsp; if (jj_3R_306()) { jj_scanpos = xsp; if (jj_3R_307()) { jj_scanpos = xsp; - if (jj_3R_308()) { - jj_scanpos = xsp; - if (jj_3R_309()) { - jj_scanpos = xsp; - if (jj_3R_310()) return true; + if (jj_3R_308()) return true; } } } @@ -6887,9 +6865,9 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_311()) { + if (jj_3R_309()) { jj_scanpos = xsp; - if (jj_3R_312()) return true; + if (jj_3R_310()) return true; } while (true) { xsp = jj_scanpos; @@ -6898,22 +6876,22 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_252() { - if (jj_3R_265()) return true; + private boolean jj_3R_250() { + if (jj_3R_263()) return true; return false; } - private boolean jj_3R_251() { - if (jj_3R_264()) return true; + private boolean jj_3R_249() { + if (jj_3R_262()) return true; return false; } - private boolean jj_3R_250() { - if (jj_3R_263()) return true; + private boolean jj_3R_248() { + if (jj_3R_261()) return true; return false; } - private boolean jj_3R_225() { + private boolean jj_3R_223() { if (jj_scan_token(LBRACKET)) return true; Token xsp; while (true) { @@ -6926,65 +6904,65 @@ LexicalUnitImpl result = null; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } xsp = jj_scanpos; - if (jj_3R_298()) jj_scanpos = xsp; + if (jj_3R_296()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } - private boolean jj_3R_304() { + private boolean jj_3R_302() { if (jj_scan_token(INTERPOLATION)) return true; return false; } - private boolean jj_3R_259() { + private boolean jj_3R_257() { if (jj_scan_token(PARENT)) return true; return false; } - private boolean jj_3R_258() { + private boolean jj_3R_256() { if (jj_scan_token(ANY)) return true; return false; } - private boolean jj_3R_268() { + private boolean jj_3R_266() { Token xsp; xsp = jj_scanpos; - if (jj_3R_272()) { + if (jj_3R_270()) { jj_scanpos = xsp; - if (jj_3R_273()) return true; + if (jj_3R_271()) return true; } return false; } - private boolean jj_3R_272() { + private boolean jj_3R_270() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_221() { + private boolean jj_3R_219() { Token xsp; xsp = jj_scanpos; - if (jj_3R_257()) { + if (jj_3R_255()) { jj_scanpos = xsp; - if (jj_3R_258()) { + if (jj_3R_256()) { jj_scanpos = xsp; - if (jj_3R_259()) return true; + if (jj_3R_257()) return true; } } return false; } - private boolean jj_3R_257() { + private boolean jj_3R_255() { Token xsp; - if (jj_3R_268()) return true; + if (jj_3R_266()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_268()) { jj_scanpos = xsp; break; } + if (jj_3R_266()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_185() { + private boolean jj_3R_183() { if (jj_scan_token(COMMA)) return true; Token xsp; while (true) { @@ -6994,30 +6972,30 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_303() { + private boolean jj_3R_301() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_286() { + private boolean jj_3R_284() { Token xsp; xsp = jj_scanpos; - if (jj_3R_303()) { + if (jj_3R_301()) { jj_scanpos = xsp; - if (jj_3R_304()) return true; + if (jj_3R_302()) return true; } return false; } - private boolean jj_3R_262() { + private boolean jj_3R_260() { if (jj_scan_token(DOT)) return true; return false; } - private boolean jj_3R_249() { + private boolean jj_3R_247() { Token xsp; xsp = jj_scanpos; - if (jj_3R_262()) jj_scanpos = xsp; + if (jj_3R_260()) jj_scanpos = xsp; xsp = jj_scanpos; if (jj_scan_token(72)) { jj_scanpos = xsp; @@ -7035,49 +7013,49 @@ LexicalUnitImpl result = null; private boolean jj_3_5() { Token xsp; xsp = jj_scanpos; - if (jj_3R_185()) jj_scanpos = xsp; - if (jj_3R_186()) return true; + if (jj_3R_183()) jj_scanpos = xsp; + if (jj_3R_184()) return true; return false; } - private boolean jj_3R_302() { - if (jj_3R_224()) return true; + private boolean jj_3R_300() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_248() { + private boolean jj_3R_246() { if (jj_scan_token(STRING)) return true; return false; } - private boolean jj_3R_223() { + private boolean jj_3R_221() { if (jj_scan_token(DOT)) return true; Token xsp; - if (jj_3R_286()) return true; + if (jj_3R_284()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_286()) { jj_scanpos = xsp; break; } + if (jj_3R_284()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_247() { - if (jj_3R_261()) return true; + private boolean jj_3R_245() { + if (jj_3R_259()) return true; return false; } - private boolean jj_3R_204() { + private boolean jj_3R_202() { Token xsp; xsp = jj_scanpos; - if (jj_3R_248()) { + if (jj_3R_246()) { jj_scanpos = xsp; - if (jj_3R_249()) { + if (jj_3R_247()) { jj_scanpos = xsp; - if (jj_3R_250()) { + if (jj_3R_248()) { jj_scanpos = xsp; - if (jj_3R_251()) { + if (jj_3R_249()) { jj_scanpos = xsp; - if (jj_3R_252()) return true; + if (jj_3R_250()) return true; } } } @@ -7085,305 +7063,305 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_300() { - if (jj_3R_223()) return true; + private boolean jj_3R_298() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_295() { - if (jj_3R_223()) return true; + private boolean jj_3R_293() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_297() { - if (jj_3R_224()) return true; + private boolean jj_3R_295() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_285() { - if (jj_3R_224()) return true; + private boolean jj_3R_283() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_288() { - if (jj_3R_223()) return true; + private boolean jj_3R_286() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_290() { - if (jj_3R_224()) return true; + private boolean jj_3R_288() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_246() { + private boolean jj_3R_244() { if (jj_scan_token(DIMEN)) return true; return false; } - private boolean jj_3R_245() { + private boolean jj_3R_243() { if (jj_scan_token(KHZ)) return true; return false; } - private boolean jj_3R_301() { - if (jj_3R_225()) return true; + private boolean jj_3R_299() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_244() { + private boolean jj_3R_242() { if (jj_scan_token(HZ)) return true; return false; } - private boolean jj_3R_278() { + private boolean jj_3R_276() { Token xsp; xsp = jj_scanpos; - if (jj_3R_299()) { + if (jj_3R_297()) { jj_scanpos = xsp; - if (jj_3R_300()) { + if (jj_3R_298()) { jj_scanpos = xsp; - if (jj_3R_301()) { + if (jj_3R_299()) { jj_scanpos = xsp; - if (jj_3R_302()) return true; + if (jj_3R_300()) return true; } } } return false; } - private boolean jj_3R_299() { - if (jj_3R_222()) return true; + private boolean jj_3R_297() { + if (jj_3R_220()) return true; return false; } - private boolean jj_3R_277() { + private boolean jj_3R_275() { Token xsp; xsp = jj_scanpos; - if (jj_3R_294()) { + if (jj_3R_292()) { jj_scanpos = xsp; - if (jj_3R_295()) { + if (jj_3R_293()) { jj_scanpos = xsp; - if (jj_3R_296()) { + if (jj_3R_294()) { jj_scanpos = xsp; - if (jj_3R_297()) return true; + if (jj_3R_295()) return true; } } } return false; } - private boolean jj_3R_294() { - if (jj_3R_222()) return true; + private boolean jj_3R_292() { + if (jj_3R_220()) return true; return false; } - private boolean jj_3R_243() { + private boolean jj_3R_241() { if (jj_scan_token(MS)) return true; return false; } - private boolean jj_3R_282() { - if (jj_3R_224()) return true; + private boolean jj_3R_280() { + if (jj_3R_222()) return true; return false; } - private boolean jj_3R_276() { + private boolean jj_3R_274() { Token xsp; xsp = jj_scanpos; - if (jj_3R_287()) { + if (jj_3R_285()) { jj_scanpos = xsp; - if (jj_3R_288()) { + if (jj_3R_286()) { jj_scanpos = xsp; - if (jj_3R_289()) { + if (jj_3R_287()) { jj_scanpos = xsp; - if (jj_3R_290()) return true; + if (jj_3R_288()) return true; } } } return false; } - private boolean jj_3R_287() { - if (jj_3R_222()) return true; + private boolean jj_3R_285() { + if (jj_3R_220()) return true; return false; } - private boolean jj_3R_296() { - if (jj_3R_225()) return true; + private boolean jj_3R_294() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_284() { - if (jj_3R_225()) return true; + private boolean jj_3R_282() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_242() { + private boolean jj_3R_240() { if (jj_scan_token(SECOND)) return true; return false; } - private boolean jj_3R_289() { - if (jj_3R_225()) return true; + private boolean jj_3R_287() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_275() { + private boolean jj_3R_273() { Token xsp; xsp = jj_scanpos; - if (jj_3R_283()) { + if (jj_3R_281()) { jj_scanpos = xsp; - if (jj_3R_284()) { + if (jj_3R_282()) { jj_scanpos = xsp; - if (jj_3R_285()) return true; + if (jj_3R_283()) return true; } } return false; } - private boolean jj_3R_280() { - if (jj_3R_223()) return true; + private boolean jj_3R_278() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_283() { - if (jj_3R_223()) return true; + private boolean jj_3R_281() { + if (jj_3R_221()) return true; return false; } - private boolean jj_3R_241() { + private boolean jj_3R_239() { if (jj_scan_token(GRAD)) return true; return false; } - private boolean jj_3R_240() { + private boolean jj_3R_238() { if (jj_scan_token(RAD)) return true; return false; } - private boolean jj_3R_239() { + private boolean jj_3R_237() { if (jj_scan_token(DEG)) return true; return false; } - private boolean jj_3R_238() { + private boolean jj_3R_236() { if (jj_scan_token(EXS)) return true; return false; } - private boolean jj_3R_201() { - if (jj_3R_225()) return true; + private boolean jj_3R_199() { + if (jj_3R_223()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_278()) { jj_scanpos = xsp; break; } + if (jj_3R_276()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_237() { + private boolean jj_3R_235() { if (jj_scan_token(REM)) return true; return false; } - private boolean jj_3R_200() { - if (jj_3R_224()) return true; + private boolean jj_3R_198() { + if (jj_3R_222()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_277()) { jj_scanpos = xsp; break; } + if (jj_3R_275()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_281() { - if (jj_3R_225()) return true; + private boolean jj_3R_279() { + if (jj_3R_223()) return true; return false; } - private boolean jj_3R_236() { + private boolean jj_3R_234() { if (jj_scan_token(LEM)) return true; return false; } - private boolean jj_3R_199() { - if (jj_3R_223()) return true; + private boolean jj_3R_197() { + if (jj_3R_221()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_276()) { jj_scanpos = xsp; break; } + if (jj_3R_274()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_198() { - if (jj_3R_222()) return true; + private boolean jj_3R_196() { + if (jj_3R_220()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_275()) { jj_scanpos = xsp; break; } + if (jj_3R_273()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_274() { + private boolean jj_3R_272() { Token xsp; xsp = jj_scanpos; - if (jj_3R_279()) { + if (jj_3R_277()) { jj_scanpos = xsp; - if (jj_3R_280()) { + if (jj_3R_278()) { jj_scanpos = xsp; - if (jj_3R_281()) { + if (jj_3R_279()) { jj_scanpos = xsp; - if (jj_3R_282()) return true; + if (jj_3R_280()) return true; } } } return false; } - private boolean jj_3R_279() { - if (jj_3R_222()) return true; + private boolean jj_3R_277() { + if (jj_3R_220()) return true; return false; } - private boolean jj_3R_235() { + private boolean jj_3R_233() { if (jj_scan_token(EMS)) return true; return false; } - private boolean jj_3R_234() { + private boolean jj_3R_232() { if (jj_scan_token(PX)) return true; return false; } - private boolean jj_3R_197() { - if (jj_3R_221()) return true; + private boolean jj_3R_195() { + if (jj_3R_219()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_274()) { jj_scanpos = xsp; break; } + if (jj_3R_272()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_233() { + private boolean jj_3R_231() { if (jj_scan_token(IN)) return true; return false; } - private boolean jj_3R_183() { + private boolean jj_3R_181() { Token xsp; xsp = jj_scanpos; - if (jj_3R_197()) { + if (jj_3R_195()) { jj_scanpos = xsp; - if (jj_3R_198()) { + if (jj_3R_196()) { jj_scanpos = xsp; - if (jj_3R_199()) { + if (jj_3R_197()) { jj_scanpos = xsp; - if (jj_3R_200()) { + if (jj_3R_198()) { jj_scanpos = xsp; - if (jj_3R_201()) return true; + if (jj_3R_199()) return true; } } } @@ -7391,57 +7369,61 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_232() { + private boolean jj_3R_230() { if (jj_scan_token(PC)) return true; return false; } - private boolean jj_3R_254() { - if (jj_3R_219()) return true; - if (jj_3R_183()) return true; + private boolean jj_3R_252() { + if (jj_3R_217()) return true; + if (jj_3R_181()) return true; return false; } - private boolean jj_3R_231() { + private boolean jj_3R_229() { if (jj_scan_token(MM)) return true; return false; } - private boolean jj_3R_230() { + private boolean jj_3R_228() { if (jj_scan_token(CM)) return true; return false; } - private boolean jj_3R_229() { + private boolean jj_3R_227() { if (jj_scan_token(PT)) return true; return false; } - private boolean jj_3R_228() { + private boolean jj_3R_226() { if (jj_scan_token(PERCENTAGE)) return true; return false; } - private boolean jj_3R_211() { - if (jj_3R_256()) return true; + private boolean jj_3R_209() { + if (jj_3R_254()) return true; return false; } - private boolean jj_3R_227() { + private boolean jj_3R_225() { if (jj_scan_token(NUMBER)) return true; return false; } - private boolean jj_3R_226() { - if (jj_3R_260()) return true; + private boolean jj_3R_224() { + if (jj_3R_258()) return true; return false; } - private boolean jj_3R_203() { + private boolean jj_3R_201() { Token xsp; xsp = jj_scanpos; - if (jj_3R_226()) jj_scanpos = xsp; + if (jj_3R_224()) jj_scanpos = xsp; xsp = jj_scanpos; + if (jj_3R_225()) { + jj_scanpos = xsp; + if (jj_3R_226()) { + jj_scanpos = xsp; if (jj_3R_227()) { jj_scanpos = xsp; if (jj_3R_228()) { @@ -7478,11 +7460,7 @@ LexicalUnitImpl result = null; jj_scanpos = xsp; if (jj_3R_244()) { jj_scanpos = xsp; - if (jj_3R_245()) { - jj_scanpos = xsp; - if (jj_3R_246()) { - jj_scanpos = xsp; - if (jj_3R_247()) return true; + if (jj_3R_245()) return true; } } } @@ -7506,12 +7484,12 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_186() { + private boolean jj_3R_184() { Token xsp; xsp = jj_scanpos; - if (jj_3R_203()) { + if (jj_3R_201()) { jj_scanpos = xsp; - if (jj_3R_204()) return true; + if (jj_3R_202()) return true; } while (true) { xsp = jj_scanpos; @@ -7520,49 +7498,49 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_263() { + private boolean jj_3R_261() { if (jj_scan_token(HASH)) return true; return false; } private boolean jj_3_2() { - if (jj_3R_182()) return true; - if (jj_3R_183()) return true; + if (jj_3R_180()) return true; + if (jj_3R_181()) return true; return false; } - private boolean jj_3R_256() { - if (jj_3R_191()) return true; + private boolean jj_3R_254() { + if (jj_3R_189()) return true; return false; } - private boolean jj_3R_264() { + private boolean jj_3R_262() { if (jj_scan_token(URL)) return true; return false; } - private boolean jj_3R_206() { + private boolean jj_3R_204() { if (jj_scan_token(COMMA)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_scan_token(1)) { jj_scanpos = xsp; break; } } - if (jj_3R_205()) return true; + if (jj_3R_203()) return true; return false; } - private boolean jj_3R_253() { - if (jj_3R_183()) return true; + private boolean jj_3R_251() { + if (jj_3R_181()) return true; return false; } - private boolean jj_3R_205() { + private boolean jj_3R_203() { Token xsp; xsp = jj_scanpos; - if (jj_3R_253()) { + if (jj_3R_251()) { jj_scanpos = xsp; - if (jj_3R_254()) return true; + if (jj_3R_252()) return true; } while (true) { xsp = jj_scanpos; @@ -7575,62 +7553,62 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_210() { - if (jj_3R_186()) return true; + private boolean jj_3R_208() { + if (jj_3R_184()) return true; return false; } - private boolean jj_3R_189() { + private boolean jj_3R_187() { Token xsp; xsp = jj_scanpos; - if (jj_3R_210()) { + if (jj_3R_208()) { jj_scanpos = xsp; - if (jj_3R_211()) return true; + if (jj_3R_209()) return true; } return false; } private boolean jj_3_9() { - if (jj_3R_190()) return true; + if (jj_3R_188()) return true; return false; } - private boolean jj_3R_270() { + private boolean jj_3R_268() { if (jj_scan_token(PLUS)) return true; return false; } - private boolean jj_3R_260() { + private boolean jj_3R_258() { Token xsp; xsp = jj_scanpos; - if (jj_3R_269()) { + if (jj_3R_267()) { jj_scanpos = xsp; - if (jj_3R_270()) return true; + if (jj_3R_268()) return true; } return false; } - private boolean jj_3R_269() { + private boolean jj_3R_267() { if (jj_scan_token(MINUS)) return true; return false; } private boolean jj_3_1() { - if (jj_3R_181()) return true; + if (jj_3R_179()) return true; return false; } - private boolean jj_3R_187() { - if (jj_3R_205()) return true; + private boolean jj_3R_185() { + if (jj_3R_203()) return true; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_206()) { jj_scanpos = xsp; break; } + if (jj_3R_204()) { jj_scanpos = xsp; break; } } return false; } - private boolean jj_3R_265() { + private boolean jj_3R_263() { if (jj_scan_token(UNICODERANGE)) return true; return false; } @@ -7639,17 +7617,17 @@ LexicalUnitImpl result = null; Token xsp; xsp = jj_scanpos; if (jj_3_9()) jj_scanpos = xsp; - if (jj_3R_189()) return true; + if (jj_3R_187()) return true; return false; } private boolean jj_3_4() { - if (jj_3R_184()) return true; + if (jj_3R_182()) return true; return false; } - private boolean jj_3R_192() { - if (jj_3R_189()) return true; + private boolean jj_3R_190() { + if (jj_3R_187()) return true; Token xsp; while (true) { xsp = jj_scanpos; @@ -7658,7 +7636,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_217() { + private boolean jj_3R_215() { if (jj_scan_token(MINUS)) return true; Token xsp; if (jj_scan_token(1)) return true; @@ -7669,7 +7647,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_216() { + private boolean jj_3R_214() { if (jj_scan_token(PLUS)) return true; Token xsp; if (jj_scan_token(1)) return true; @@ -7680,17 +7658,17 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_267() { + private boolean jj_3R_265() { if (jj_scan_token(INTERPOLATION)) return true; return false; } private boolean jj_3_3() { - if (jj_3R_181()) return true; + if (jj_3R_179()) return true; return false; } - private boolean jj_3R_215() { + private boolean jj_3R_213() { if (jj_scan_token(MOD)) return true; Token xsp; while (true) { @@ -7700,7 +7678,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_214() { + private boolean jj_3R_212() { if (jj_scan_token(ANY)) return true; Token xsp; while (true) { @@ -7710,7 +7688,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_213() { + private boolean jj_3R_211() { if (jj_scan_token(DIV)) return true; Token xsp; while (true) { @@ -7720,7 +7698,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_194() { + private boolean jj_3R_192() { if (jj_scan_token(SEMICOLON)) return true; Token xsp; while (true) { @@ -7730,7 +7708,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_212() { + private boolean jj_3R_210() { if (jj_scan_token(COMMA)) return true; Token xsp; while (true) { @@ -7740,20 +7718,20 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_190() { + private boolean jj_3R_188() { Token xsp; xsp = jj_scanpos; + if (jj_3R_210()) { + jj_scanpos = xsp; + if (jj_3R_211()) { + jj_scanpos = xsp; if (jj_3R_212()) { jj_scanpos = xsp; if (jj_3R_213()) { jj_scanpos = xsp; if (jj_3R_214()) { jj_scanpos = xsp; - if (jj_3R_215()) { - jj_scanpos = xsp; - if (jj_3R_216()) { - jj_scanpos = xsp; - if (jj_3R_217()) return true; + if (jj_3R_215()) return true; } } } @@ -7762,7 +7740,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_191() { + private boolean jj_3R_189() { if (jj_scan_token(VARIABLE)) return true; Token xsp; while (true) { @@ -7772,27 +7750,27 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_255() { + private boolean jj_3R_253() { Token xsp; xsp = jj_scanpos; - if (jj_3R_266()) { + if (jj_3R_264()) { jj_scanpos = xsp; - if (jj_3R_267()) return true; + if (jj_3R_265()) return true; } return false; } - private boolean jj_3R_266() { + private boolean jj_3R_264() { if (jj_scan_token(IDENT)) return true; return false; } - private boolean jj_3R_207() { + private boolean jj_3R_205() { Token xsp; - if (jj_3R_255()) return true; + if (jj_3R_253()) return true; while (true) { xsp = jj_scanpos; - if (jj_3R_255()) { jj_scanpos = xsp; break; } + if (jj_3R_253()) { jj_scanpos = xsp; break; } } while (true) { xsp = jj_scanpos; @@ -7801,7 +7779,7 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_218() { + private boolean jj_3R_216() { if (jj_scan_token(GUARDED_SYM)) return true; Token xsp; while (true) { @@ -7811,8 +7789,8 @@ LexicalUnitImpl result = null; return false; } - private boolean jj_3R_193() { - if (jj_3R_218()) return true; + private boolean jj_3R_191() { + if (jj_3R_216()) return true; return false; } @@ -7826,7 +7804,7 @@ LexicalUnitImpl result = null; private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; - final private int[] jj_la1 = new int[271]; + final private int[] jj_la1 = new int[269]; static private int[] jj_la1_0; static private int[] jj_la1_1; static private int[] jj_la1_2; @@ -7838,16 +7816,16 @@ LexicalUnitImpl result = null; jj_la1_init_3(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x0,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x800c0000,0x2,0x2,0x0,0x200400,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x200000,0x2,0x200000,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; + jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0xd4fd1500,0x2,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x0,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x800c0000,0x2,0x2,0x0,0x200400,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x2,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; } private static void jj_la1_init_1() { - jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x160000,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x60001c0,0x0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x160000,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; } private static void jj_la1_init_2() { - jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0xfffffb80,0x0,0x0,0x1100,0x0,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; + jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b80,0x2b80,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0xfffffb80,0x0,0x0,0x1100,0x0,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; } private static void jj_la1_init_3() { - jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x440001,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x440001,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[9]; private boolean jj_rescan = false; @@ -7859,7 +7837,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 271; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7869,7 +7847,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 271; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7879,7 +7857,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 271; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -7889,7 +7867,7 @@ LexicalUnitImpl result = null; token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 271; i++) jj_la1[i] = -1; + for (int i = 0; i < 269; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -8006,7 +7984,7 @@ LexicalUnitImpl result = null; la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 271; i++) { + for (int i = 0; i < 269; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1< { - String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE,EOF}); // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. System.out.println(content); } try { - (";"()*)+ + ";" ()* } catch (ParseException e) { acceptMissingSemicolonBeforeRbrace(e); @@ -2009,12 +2009,12 @@ void warnDirective() : { { - String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE}); + String content = skipStatementUntil(new int[] {SEMICOLON,RBRACE,EOF}); // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. System.err.println(content); } try { - (";"()*)+ + ";" ()* } catch (ParseException e) { acceptMissingSemicolonBeforeRbrace(e); @@ -2831,27 +2831,27 @@ String skipStatementUntilRightParan(){ JAVACODE String skipStatementUntil(int[] symbols){ StringBuffer s = new StringBuffer(); - boolean stop = false; + boolean found = false; Token tok; - while(!stop){ + while(!found){ tok = getToken(1); - if(tok.kind == EOF) { - return null; - } for(int sym : symbols){ if(tok.kind == sym){ - stop = true; + found = true; break; } } - if(!stop){ + if(tok.kind == EOF) { + break; + } + if(!found){ if (tok.image != null) { s.append(tok.image); } getNextToken(); } } - return s.toString().trim(); + return found ? s.toString().trim() : null; } @@ -3089,7 +3089,7 @@ ArrayList _parseSelectors() : JAVACODE void acceptMissingSemicolonBeforeRbrace( ParseException parseException ) { Token next = getToken(1); - if (next.kind != RBRACE) { + if (next.kind != RBRACE && next.kind!=EOF) { throw parseException; } } -- cgit v1.2.3 From 3c5644c4a3e0484b7e65a2852d9cedeeab167419 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Wed, 22 Jan 2014 15:29:25 +0200 Subject: Refactor PushConnection handling (#13223) UIs now always have a PushConnection object if push is enabled, and push reconnections do not create and set a new instance. PushConnection.push can always be called; it internally handles deferring the push until (re)connection if it is currently disconnected. This is very desirable when using long polling, as it reconnects after each push. Change-Id: I478748cc940da86f34a5f55266f6b325682d4585 --- .../communication/AtmospherePushConnection.java | 146 ++++++++++++--------- .../server/communication/PushConnection.java | 14 +- .../vaadin/server/communication/PushHandler.java | 34 ++--- server/src/com/vaadin/ui/PushConfiguration.java | 42 +++--- server/src/com/vaadin/ui/UI.java | 83 ++++++------ 5 files changed, 176 insertions(+), 143 deletions(-) diff --git a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java index 6a515abc29..56dd576403 100644 --- a/server/src/com/vaadin/server/communication/AtmospherePushConnection.java +++ b/server/src/com/vaadin/server/communication/AtmospherePushConnection.java @@ -22,22 +22,16 @@ import java.io.Serializable; import java.io.StringReader; import java.io.StringWriter; import java.io.Writer; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.logging.Level; -import java.util.logging.Logger; import org.atmosphere.cpr.AtmosphereResource; import org.atmosphere.cpr.AtmosphereResource.TRANSPORT; -import org.json.JSONException; import com.vaadin.shared.communication.PushConstants; import com.vaadin.ui.UI; /** - * {@link PushConnection} implementation using the Atmosphere push support that - * is by default included in Vaadin. + * A {@link PushConnection} implementation using the Atmosphere push support + * that is by default included in Vaadin. * * @author Vaadin Ltd * @since 7.1 @@ -92,55 +86,84 @@ public class AtmospherePushConnection implements PushConnection { } } + protected enum State { + /** + * Not connected. Trying to push will set the connection state to + * PUSH_PENDING or RESPONSE_PENDING and defer sending the message until + * a connection is established. + */ + DISCONNECTED, + + /** + * Not connected. An asynchronous push is pending the opening of the + * connection. + */ + PUSH_PENDING, + + /** + * Not connected. A response to a client request is pending the opening + * of the connection. + */ + RESPONSE_PENDING, + + /** + * Connected. Messages can be sent through the connection. + */ + CONNECTED; + } + + private State state = State.DISCONNECTED; private UI ui; private AtmosphereResource resource; - private Future outgoingMessage; private FragmentedMessage incomingMessage; - public AtmospherePushConnection(UI ui, AtmosphereResource resource) { + public AtmospherePushConnection(UI ui) { this.ui = ui; - this.resource = resource; } @Override public void push() { - assert isConnected(); - try { - push(true); - } catch (IOException e) { - // TODO Error handling - throw new RuntimeException("Push failed", e); - } + push(true); } /** - * Pushes pending state changes and client RPC calls to the client. + * Pushes pending state changes and client RPC calls to the client. If + * {@code isConnected()} is false, defers the push until a connection is + * established. * * @param async * True if this push asynchronously originates from the server, * false if it is a response to a client request. - * @throws IOException */ - protected void push(boolean async) throws IOException { - Writer writer = new StringWriter(); - try { - new UidlWriter().write(getUI(), writer, false, async); - } catch (JSONException e) { - throw new IOException("Error writing UIDL", e); + public void push(boolean async) { + if (!isConnected()) { + if (async && state != State.RESPONSE_PENDING) { + state = State.PUSH_PENDING; + } else { + state = State.RESPONSE_PENDING; + } + } else { + try { + Writer writer = new StringWriter(); + new UidlWriter().write(getUI(), writer, false, async); + sendMessage("for(;;);[{" + writer.toString() + "}]"); + } catch (Exception e) { + throw new RuntimeException("Push failed", e); + } } - sendMessage("for(;;);[{" + writer.toString() + "}]"); } /** - * Sends the given message to the current client. + * Sends the given message to the current client. Cannot be called if + * {@isConnected()} is false. * * @param message * The message to send */ void sendMessage(String message) { + assert (isConnected()); // "Broadcast" the changes to the single client only - outgoingMessage = getResource().getBroadcaster().broadcast(message, - getResource()); + getResource().getBroadcaster().broadcast(message, getResource()); } /** @@ -157,7 +180,7 @@ public class AtmospherePushConnection implements PushConnection { */ protected Reader receiveMessage(Reader reader) throws IOException { - if (resource.transport() != TRANSPORT.WEBSOCKET) { + if (resource == null || resource.transport() != TRANSPORT.WEBSOCKET) { return reader; } @@ -179,9 +202,37 @@ public class AtmospherePushConnection implements PushConnection { @Override public boolean isConnected() { - return resource != null - && resource.getBroadcaster().getAtmosphereResources() - .contains(resource); + assert (state == State.CONNECTED) ^ (resource == null); + return state == State.CONNECTED; + } + + /** + * Associates this {@code AtmospherePushConnection} with the given + * {@AtmosphereResource} representing an established + * push connection. If already connected, calls {@link #disconnect()} first. + * If there is a deferred push, carries it out via the new connection. + * + * @since 7.2 + */ + public void connect(AtmosphereResource resource) { + + assert resource != null; + assert resource != this.resource; + + if (isConnected()) { + disconnect(); + } + + this.resource = resource; + State oldState = state; + state = State.CONNECTED; + + if (oldState == State.PUSH_PENDING + || oldState == State.RESPONSE_PENDING) { + // Sending a "response" message (async=false) also takes care of a + // pending push, but not vice versa + push(oldState == State.PUSH_PENDING); + } } /** @@ -202,33 +253,8 @@ public class AtmospherePushConnection implements PushConnection { @Override public void disconnect() { assert isConnected(); - - if (outgoingMessage != null) { - // Wait for the last message to be sent before closing the - // connection (assumes that futures are completed in order) - try { - outgoingMessage.get(1000, TimeUnit.MILLISECONDS); - } catch (TimeoutException e) { - getLogger() - .log(Level.INFO, - "Timeout waiting for messages to be sent to client before disconnect"); - } catch (Exception e) { - getLogger() - .log(Level.INFO, - "Error waiting for messages to be sent to client before disconnect"); - } - outgoingMessage = null; - } - resource.resume(); resource = null; - } - - /** - * @since - * @return - */ - private static Logger getLogger() { - return Logger.getLogger(AtmospherePushConnection.class.getName()); + state = State.DISCONNECTED; } } diff --git a/server/src/com/vaadin/server/communication/PushConnection.java b/server/src/com/vaadin/server/communication/PushConnection.java index 7f78d1d48e..cab3c94824 100644 --- a/server/src/com/vaadin/server/communication/PushConnection.java +++ b/server/src/com/vaadin/server/communication/PushConnection.java @@ -20,7 +20,12 @@ import com.vaadin.ui.UI; /** * Represents a bidirectional ("push") connection between a single UI and its - * client-side. + * client-side. A single {@code PushConnection} instance is bound to a UI as + * long as push is enabled in that UI, even if the actual connection is + * momentarily dropped either due to a network failure or as a normal part of + * the transport mechanism. + *

+ * This interface is an internal API, only meant to be used by the framework. * * @author Vaadin Ltd * @since 7.1 @@ -28,9 +33,10 @@ import com.vaadin.ui.UI; public interface PushConnection { /** - * Pushes pending state changes and client RPC calls to the client. Cannot - * be called if {@link #isConnected()} is false. It is NOT safe to invoke - * this method if not holding the session lock. + * Pushes pending state changes and client RPC calls to the client. Can be + * called even if {@link #isConnected()} is false; the push will be deferred + * until a connection is available. It is NOT safe to invoke this method if + * not holding the session lock. *

* This is internal API; please use {@link UI#push()} instead. */ diff --git a/server/src/com/vaadin/server/communication/PushHandler.java b/server/src/com/vaadin/server/communication/PushHandler.java index eaa0de6027..99aff3780f 100644 --- a/server/src/com/vaadin/server/communication/PushHandler.java +++ b/server/src/com/vaadin/server/communication/PushHandler.java @@ -73,8 +73,8 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter @Override public void run(AtmosphereResource resource, UI ui) throws IOException { getLogger().log(Level.FINER, - "New push connection with transport {0}", - resource.transport()); + "New push connection for resource {0} with transport {1}", + new Object[] { resource.uuid(), resource.transport() }); resource.addEventListener(PushHandler.this); @@ -105,10 +105,9 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter resource.suspend(); - AtmospherePushConnection connection = new AtmospherePushConnection( - ui, resource); - - ui.setPushConnection(connection); + AtmospherePushConnection connection = getConnectionForUI(ui); + assert (connection != null); + connection.connect(resource); } }; @@ -172,11 +171,11 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter @Override public void run(AtmosphereResource resource, UI ui) throws IOException { PushMode pushMode = ui.getPushConfiguration().getPushMode(); - AtmospherePushConnection pushConnection = getConnectionForUI(ui); + AtmospherePushConnection connection = getConnectionForUI(ui); String id = resource.uuid(); - if (pushConnection == null) { + if (connection == null) { getLogger() .log(Level.WARNING, "Could not find push connection to close: {0} with transport {1}", @@ -199,7 +198,7 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter "Connection unexpectedly closed for resource {0} with transport {1}", new Object[] { id, resource.transport() }); } - ui.setPushConnection(null); + connection.disconnect(); } } }; @@ -333,10 +332,10 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter private static AtmospherePushConnection getConnectionForUI(UI ui) { PushConnection pushConnection = ui.getPushConnection(); if (pushConnection instanceof AtmospherePushConnection) { - assert pushConnection.isConnected(); return (AtmospherePushConnection) pushConnection; + } else { + return null; } - return null; } @Override @@ -373,7 +372,7 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter break; case JSONP: case LONG_POLLING: - resource.resume(); + disconnect(event); break; default: getLogger().log(Level.SEVERE, "Unknown transport {0}", @@ -396,13 +395,6 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter disconnect(event); } - @Override - public void onResume(AtmosphereResourceEvent event) { - // Log event on trace level - super.onResume(event); - disconnect(event); - } - @Override public void destroy() { } @@ -426,8 +418,8 @@ public class PushHandler extends AtmosphereResourceEventListenerAdapter */ private static void sendRefreshAndDisconnect(AtmosphereResource resource) throws IOException { - AtmospherePushConnection connection = new AtmospherePushConnection( - null, resource); + AtmospherePushConnection connection = new AtmospherePushConnection(null); + connection.connect(resource); try { connection.sendMessage(VaadinService .createCriticalNotificationJSON(null, null, null, null)); diff --git a/server/src/com/vaadin/ui/PushConfiguration.java b/server/src/com/vaadin/ui/PushConfiguration.java index a592b39bef..49738c5aff 100644 --- a/server/src/com/vaadin/ui/PushConfiguration.java +++ b/server/src/com/vaadin/ui/PushConfiguration.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import com.vaadin.server.VaadinSession; +import com.vaadin.server.communication.AtmospherePushConnection; import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.ui.Transport; import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; @@ -170,20 +171,32 @@ class PushConfigurationImpl implements PushConfiguration { throw new IllegalArgumentException("Push mode cannot be null"); } - if (pushMode.isEnabled()) { - VaadinSession session = ui.getSession(); - if (session != null && !session.getService().ensurePushAvailable()) { - throw new IllegalStateException( - "Push is not available. See previous log messages for more information."); - } + VaadinSession session = ui.getSession(); + + if (session == null) { + throw new UIDetachedException( + "Cannot set the push mode for a detached UI"); + } + + assert session.hasLock(); + + if (pushMode.isEnabled() && !session.getService().ensurePushAvailable()) { + throw new IllegalStateException( + "Push is not available. See previous log messages for more information."); } - /* - * Client-side will open a new connection or disconnect the old - * connection, so there's nothing more to do on the server at this - * point. - */ - getState().mode = pushMode; + PushMode oldMode = getState().mode; + if (oldMode != pushMode) { + getState().mode = pushMode; + + if (!oldMode.isEnabled() && pushMode.isEnabled()) { + // The push connection is initially in a disconnected state; + // the client will establish the connection + ui.setPushConnection(new AtmospherePushConnection(ui)); + } + // Nothing to do here if disabling push; + // the client will close the connection + } } /* @@ -274,9 +287,8 @@ class PushConfigurationImpl implements PushConfiguration { @Override public Collection getParameterNames() { - return Collections - .unmodifiableCollection(ui.getState(false).pushConfiguration.parameters - .keySet()); + return Collections.unmodifiableCollection(getState(false).parameters + .keySet()); } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index a292e6b829..e688c06061 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -55,6 +55,7 @@ import com.vaadin.server.communication.PushConnection; import com.vaadin.shared.Connector; import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; +import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.ui.ui.DebugWindowClientRpc; import com.vaadin.shared.ui.ui.DebugWindowServerRpc; import com.vaadin.shared.ui.ui.ScrollClientRpc; @@ -422,8 +423,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements } else { if (session == null) { detach(); - // Close the push connection when UI is detached. Otherwise the + // Disable push when the UI is detached. Otherwise the // push connection and possibly VaadinSession will live on. + getPushConfiguration().setPushMode(PushMode.DISABLED); setPushConnection(null); } this.session = session; @@ -550,8 +552,6 @@ public abstract class UI extends AbstractSingleComponentContainer implements private transient PushConnection pushConnection = null; - private boolean hasPendingPush = false; - private LocaleService localeService = new LocaleService(this, getState(false).localeServiceState); @@ -1368,6 +1368,9 @@ public abstract class UI extends AbstractSingleComponentContainer implements * Pushes the pending changes and client RPC invocations of this UI to the * client-side. *

+ * If push is enabled, but the push connection is not currently open, the + * push will be done when the connection is established. + *

* As with all UI methods, the session must be locked when calling this * method. It is also recommended that {@link UI#getCurrent()} is set up to * return this UI since writing the response may invoke logic in any @@ -1385,79 +1388,73 @@ public abstract class UI extends AbstractSingleComponentContainer implements */ public void push() { VaadinSession session = getSession(); - if (session != null) { - assert session.hasLock(); - - /* - * Purge the pending access queue as it might mark a connector as - * dirty when the push would otherwise be ignored because there are - * no changes to push. - */ - session.getService().runPendingAccessTasks(session); - - if (!getConnectorTracker().hasDirtyConnectors()) { - // Do not push if there is nothing to push - return; - } - if (!getPushConfiguration().getPushMode().isEnabled()) { - throw new IllegalStateException("Push not enabled"); - } + if (session == null) { + throw new UIDetachedException("Cannot push a detached UI"); + } + assert session.hasLock(); - if (pushConnection == null) { - hasPendingPush = true; - } else { - pushConnection.push(); - } - } else { - throw new UIDetachedException("Trying to push a detached UI"); + if (!getPushConfiguration().getPushMode().isEnabled()) { + throw new IllegalStateException("Push not enabled"); + } + assert pushConnection != null; + + /* + * Purge the pending access queue as it might mark a connector as dirty + * when the push would otherwise be ignored because there are no changes + * to push. + */ + session.getService().runPendingAccessTasks(session); + + if (!getConnectorTracker().hasDirtyConnectors()) { + // Do not push if there is nothing to push + return; } + + pushConnection.push(); } /** * Returns the internal push connection object used by this UI. This method - * should only be called by the framework. If the returned PushConnection is - * not null, it is guaranteed to have {@code isConnected() == true}. + * should only be called by the framework. *

* This method is not intended to be overridden. If it is overridden, care * should be taken since this method might be called in situations where * {@link UI#getCurrent()} does not return this UI. * - * @return the push connection used by this UI, null if there - * is no active push connection. + * @return the push connection used by this UI, or {@code null} if push is + * not available. */ public PushConnection getPushConnection() { - assert (pushConnection == null || pushConnection.isConnected()); + assert !(getPushConfiguration().getPushMode().isEnabled() && pushConnection == null); return pushConnection; } /** * Sets the internal push connection object used by this UI. This method - * should only be called by the framework. If {@pushConnection} is not null, - * its {@code isConnected()} must be true. + * should only be called by the framework. + *

+ * The {@code pushConnection} argument must be non-null if and only if + * {@code getPushConfiguration().getPushMode().isEnabled()}. * * @param pushConnection * the push connection to use for this UI */ public void setPushConnection(PushConnection pushConnection) { - // If pushMode is disabled then there should never be a pushConnection - assert (pushConnection == null || getPushConfiguration().getPushMode() - .isEnabled()); - assert (pushConnection == null || pushConnection.isConnected()); + // If pushMode is disabled then there should never be a pushConnection; + // if enabled there should always be + assert (pushConnection == null) + ^ getPushConfiguration().getPushMode().isEnabled(); if (pushConnection == this.pushConnection) { return; } - if (this.pushConnection != null) { + if (this.pushConnection != null && this.pushConnection.isConnected()) { this.pushConnection.disconnect(); } this.pushConnection = pushConnection; - if (pushConnection != null && hasPendingPush) { - hasPendingPush = false; - pushConnection.push(); - } } /** -- cgit v1.2.3 From efd8f211612fa55a2b35d1c72a9913f2011bfe7a Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Wed, 22 Jan 2014 17:48:19 +0200 Subject: Implement long polling support for push (#13011) * The Transport enum has a new LONG_POLLING constant * AbstractTestUI supports the ?transport=long-polling GET parameter Change-Id: Ic2f5abfbd4aa3c875f5c83932ce5ee6f31c366ad --- shared/src/com/vaadin/shared/ui/ui/Transport.java | 6 ++- .../vaadin/tests/components/AbstractTestUI.java | 30 +++++------ .../vaadin/tests/push/BasicPushLongPolling.java | 34 ++++++++++++ .../tests/push/BasicPushLongPollingTest.java | 19 +++++++ .../tests/push/LongPollingReconnectTest.java | 25 +++++++++ .../tests/push/PushLargeDataLongPolling.java | 32 ++++++++++++ .../tests/push/PushLargeDataLongPollingTest.java | 61 ++++++++++++++++++++++ 7 files changed, 191 insertions(+), 16 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java create mode 100644 uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java create mode 100644 uitest/src/com/vaadin/tests/push/LongPollingReconnectTest.java create mode 100644 uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java create mode 100644 uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java diff --git a/shared/src/com/vaadin/shared/ui/ui/Transport.java b/shared/src/com/vaadin/shared/ui/ui/Transport.java index ea641c0a3c..ebc0ba3aea 100644 --- a/shared/src/com/vaadin/shared/ui/ui/Transport.java +++ b/shared/src/com/vaadin/shared/ui/ui/Transport.java @@ -30,7 +30,11 @@ public enum Transport { /** * HTTP streaming */ - STREAMING("streaming"); + STREAMING("streaming"), + /** + * HTTP long polling + */ + LONG_POLLING("long-polling"); private String identifier; diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 8f92ff3118..cbca4bcf7f 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -113,27 +113,27 @@ public abstract class AbstractTestUI extends UI { protected void setTransport(VaadinRequest request) { String transport = request.getParameter("transport"); PushConfiguration config = getPushConfiguration(); - PushMode mode = config.getPushMode(); if ("xhr".equals(transport)) { config.setPushMode(PushMode.DISABLED); } else if ("websocket".equals(transport)) { - if (!mode.isEnabled()) { - config.setPushMode(PushMode.AUTOMATIC); - } - config.setTransport(Transport.WEBSOCKET); - // Ensure no fallback is used - getPushConfiguration().setParameter( - PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + enablePush(Transport.WEBSOCKET); } else if ("streaming".equals(transport)) { - if (!mode.isEnabled()) { - config.setPushMode(PushMode.AUTOMATIC); - } - config.setTransport(Transport.STREAMING); - // Ensure no fallback is used - getPushConfiguration().setParameter( - PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + enablePush(Transport.STREAMING); + } else if ("long-polling".equals(transport)) { + enablePush(Transport.LONG_POLLING); + } + } + + protected void enablePush(Transport transport) { + PushConfiguration config = getPushConfiguration(); + if (!config.getPushMode().isEnabled()) { + config.setPushMode(PushMode.AUTOMATIC); } + config.setTransport(transport); + // Ensure no fallback is used + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); } private VerticalLayout layout; diff --git a/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java b/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java new file mode 100644 index 0000000000..bbb7895f20 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushLongPolling.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class BasicPushLongPolling extends BasicPush { + + @Override + public void init(VaadinRequest request) { + super.init(request); + // Don't use fallback so we can easier detect if long polling fails + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } + +} diff --git a/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java b/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java new file mode 100644 index 0000000000..b526a11d38 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/BasicPushLongPollingTest.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +public class BasicPushLongPollingTest extends BasicPushTest { +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/LongPollingReconnectTest.java b/uitest/src/com/vaadin/tests/push/LongPollingReconnectTest.java new file mode 100644 index 0000000000..81c974e1e5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/LongPollingReconnectTest.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +public class LongPollingReconnectTest extends PushReconnectTest { + + @Override + protected Class getUIClass() { + return BasicPushLongPolling.class; + } + +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java new file mode 100644 index 0000000000..52a647115a --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPolling.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import com.vaadin.annotations.Push; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; + +@Push(transport = Transport.LONG_POLLING) +public class PushLargeDataLongPolling extends PushLargeData { + + @Override + protected void setup(VaadinRequest request) { + super.setup(request); + getPushConfiguration().setParameter( + PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none"); + } +} diff --git a/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java new file mode 100644 index 0000000000..624310f1b5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/push/PushLargeDataLongPollingTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.push; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class PushLargeDataLongPollingTest extends MultiBrowserTest { + + @Test + public void testLongPollingLargeData() { + openTestURL(); + + // Without this there is a large chance that we will wait for all pushes + // to complete before moving on + testBench(driver).disableWaitForVaadin(); + + push(); + // Push complete. Browser will reconnect now as > 10MB has been sent + // Push again to ensure push still works + push(); + + } + + private void push() { + // Wait for startButton to be present + waitForElementToBePresent(vaadinLocatorById("startButton")); + + String logRow0Id = "Log_row_0"; + By logRow0 = vaadinLocatorById(logRow0Id); + + vaadinElementById("startButton").click(); + // Wait for push to start + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Package ")); + + // Wait for until push should be done + sleep(PushLargeData.DEFAULT_DURATION_MS); + + // Wait until push is actually done + waitUntil(ExpectedConditions.textToBePresentInElement(logRow0, + "Push complete")); + } + +} -- cgit v1.2.3 From fb597c1a4cb823a74e1738f612f2416b9b85b27d Mon Sep 17 00:00:00 2001 From: Juho Nurminen Date: Fri, 24 Jan 2014 16:40:19 +0200 Subject: Fixed TabSheet tab focusing (#13206) Change-Id: Ice0988a281504be3b304be3be6c09e2e2c5be4ba --- client/src/com/vaadin/client/ui/VTabsheet.java | 11 +--- .../tabsheet/TabSheetFocusedTabTest.java | 71 ++++++++++++++++++++++ 2 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 33ac8e27ad..81786f2647 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -486,6 +486,9 @@ public class VTabsheet extends VTabsheetBase implements Focusable, int index = getWidgetIndex(caption.getParent()); + navigateTab(getTabsheet().focusedTabIndex, index); + getTabsheet().focusedTabIndex = index; + getTabsheet().focusedTab = getTab(index); getTabsheet().focus(); getTabsheet().loadTabSheet(index); } @@ -700,15 +703,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, if (activeTabIndex != tabIndex && canSelectTab(tabIndex)) { tb.selectTab(tabIndex); - // If this TabSheet already has focus, set the new selected tab - // as focused. - if (focusedTab != null) { - focusedTab = tb.getTab(tabIndex); - focusedTab.focus(); - } - activeTabIndex = tabIndex; - focusedTabIndex = tabIndex; addStyleDependentName("loading"); // Hide the current contents so a loading indicator can be shown diff --git a/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java new file mode 100644 index 0000000000..81648c1b52 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/tabsheet/TabSheetFocusedTabTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.tabsheet; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TabSheetFocusedTabTest extends MultiBrowserTest { + + @Override + protected Class getUIClass() { + return TabsheetScrolling.class; + } + + @Test + public void clickingChangesFocusedTab() throws Exception { + openTestURL(); + + getTab(1).click(); + + assertTrue(isFocused(getTab(1))); + + new Actions(getDriver()).sendKeys(Keys.RIGHT).perform(); + + assertFalse(isFocused(getTab(1))); + assertTrue(isFocused(getTab(3))); + + getTab(5).click(); + + assertFalse(isFocused(getTab(3))); + assertTrue(isFocused(getTab(5))); + + getTab(1).click(); + + assertFalse(isFocused(getTab(5))); + assertTrue(isFocused(getTab(1))); + } + + private WebElement getTab(int index) { + return getDriver() + .findElement( + By.xpath("(//table[contains(@class, 'v-tabsheet-tabs')])[1]/tbody/tr/td[" + + (index + 1) + "]/div")); + } + + private boolean isFocused(WebElement tab) { + return tab.getAttribute("class").contains("v-tabsheet-tabitem-focus"); + } + +} -- cgit v1.2.3 From 16e079fcaed8cf531187475527ae52e7cf2d2504 Mon Sep 17 00:00:00 2001 From: Jarno Rantala Date: Fri, 17 Jan 2014 17:28:08 +0200 Subject: Prevent setting firstRowInViewPort to negative value (#13008) This should fix MultiSelectWithRemovedRow test in IE. Change-Id: I54f4ba1cc5c1efeea1582cc0314cfb9a4a859279 --- client/src/com/vaadin/client/ui/VScrollTable.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 3c574f8f92..e800e7fe79 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -6965,8 +6965,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } firstRowInViewPort = calcFirstRowInViewPort(); - if (firstRowInViewPort > totalRows - pageLength) { - firstRowInViewPort = totalRows - pageLength; + int maxFirstRow = totalRows - pageLength; + if (firstRowInViewPort > maxFirstRow && maxFirstRow >= 0) { + firstRowInViewPort = maxFirstRow; } int postLimit = (int) (firstRowInViewPort + (pageLength - 1) + pageLength -- cgit v1.2.3 From 691580e36b1b5a04e1f18004783b28ca9892fa31 Mon Sep 17 00:00:00 2001 From: Jonatan Kronqvist Date: Fri, 31 Jan 2014 13:06:42 +0200 Subject: Update TestBench dependency to 3.1.2 TestBench 3.1.2 is deployed to the testing grid, but the vaadin project still depended on 3.1.1 until this fix. Change-Id: Idecf0c772bd59d144a2caf3454d7749e352fef8a --- uitest/ivy.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uitest/ivy.xml b/uitest/ivy.xml index 9c86b2b68c..352cd89f2e 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -83,7 +83,7 @@ + rev="3.1.2" conf="build-provided,ide -> default" /> -- cgit v1.2.3 From 2c1f8e67a71ad1163dd5b87f070987a05dfe35c5 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 3 Feb 2014 11:31:06 +0200 Subject: Add SuggestionPopup to ComboBox SubParts. (#13286) Change-Id: Ibee44bb9b568fc188ac9e05fb67ce94a9846b5bc --- client/src/com/vaadin/client/ui/VFilterSelect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 9b14fbbb37..63c8d3dbf9 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -1983,6 +1983,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, return tb.getElement(); } else if ("button".equals(subPart)) { return popupOpener.getElement(); + } else if ("popup".equals(subPart) && suggestionPopup.isAttached()) { + return suggestionPopup.getElement(); } return null; } @@ -1993,6 +1995,8 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, return "textbox"; } else if (popupOpener.getElement().isOrHasChild(subElement)) { return "button"; + } else if (suggestionPopup.getElement().isOrHasChild(subElement)) { + return "popup"; } return null; } -- cgit v1.2.3 From eca905f8d6b527d7af41416eb96cf4d328167047 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Fri, 31 Jan 2014 10:46:55 +0200 Subject: Parser recognizes @content directive inside @media (#13279). Change-Id: I7fd8868233e9378aaf3725bb202d4b34f3f27713 --- .../vaadin/sass/internal/parser/CharStream.java | 2 +- .../com/vaadin/sass/internal/parser/Parser.java | 15342 +++++++++---------- .../src/com/vaadin/sass/internal/parser/Parser.jj | 10 +- .../src/com/vaadin/sass/internal/parser/Token.java | 2 +- .../vaadin/sass/internal/parser/TokenMgrError.java | 2 +- .../tests/resources/automatic/css/media.css | 11 + .../tests/resources/automatic/scss/media.scss | 21 + .../src/com/vaadin/sass/testcases/css/Media.java | 1 + 8 files changed, 7297 insertions(+), 8094 deletions(-) diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java index c22f19451b..e43320453c 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/CharStream.java @@ -127,4 +127,4 @@ interface CharStream { void Done(); } -/* JavaCC - OriginalChecksum=deb80d024b50bdc8bfaadaf528157233 (do not edit this line) */ +/* JavaCC - OriginalChecksum=18aae0a549695f0fec96a11297b442bb (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java index 53d1ee78ca..2615ef322f 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.java @@ -16,38 +16,39 @@ /* Generated By:JavaCC: Do not edit this line. Parser.java */ package com.vaadin.sass.internal.parser; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.URL; +import java.io.*; +import java.net.*; import java.util.ArrayList; import java.util.Locale; +import java.util.Map; import java.util.UUID; -import org.w3c.css.sac.CSSException; -import org.w3c.css.sac.CSSParseException; import org.w3c.css.sac.ConditionFactory; +import org.w3c.css.sac.Condition; +import org.w3c.css.sac.SelectorFactory; +import org.w3c.css.sac.SelectorList; +import org.w3c.css.sac.Selector; +import org.w3c.css.sac.SimpleSelector; import org.w3c.css.sac.DocumentHandler; -import org.w3c.css.sac.ErrorHandler; import org.w3c.css.sac.InputSource; -import org.w3c.css.sac.LexicalUnit; +import org.w3c.css.sac.ErrorHandler; +import org.w3c.css.sac.CSSException; +import org.w3c.css.sac.CSSParseException; import org.w3c.css.sac.Locator; -import org.w3c.css.sac.SelectorFactory; -import org.w3c.css.sac.SelectorList; -import org.w3c.flute.parser.selectors.ConditionFactoryImpl; +import org.w3c.css.sac.LexicalUnit; + import org.w3c.flute.parser.selectors.SelectorFactoryImpl; +import org.w3c.flute.parser.selectors.ConditionFactoryImpl; + import org.w3c.flute.util.Encoding; -import com.vaadin.sass.internal.handler.SCSSDocumentHandlerImpl; -import com.vaadin.sass.internal.tree.Node; -import com.vaadin.sass.internal.tree.VariableNode; +import com.vaadin.sass.internal.handler.*; + +import com.vaadin.sass.internal.tree.*; /** * A CSS2 parser - * + * * @author Philippe Le H�garet * @version $Revision: 1.15 $ */ @@ -78,32 +79,27 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * @@TODO - * @exception CSSException - * Not yet implemented + * @exception CSSException Not yet implemented */ - @Override public void setLocale(Locale locale) throws CSSException { throw new CSSException(CSSException.SAC_NOT_SUPPORTED_ERR); } - public InputSource getInputSource() { + public InputSource getInputSource(){ return source; } /** * Set the document handler for this parser */ - @Override public void setDocumentHandler(DocumentHandler handler) { - documentHandler = (SCSSDocumentHandlerImpl) handler; + this.documentHandler = (SCSSDocumentHandlerImpl) handler; } - @Override public void setSelectorFactory(SelectorFactory selectorFactory) { this.selectorFactory = selectorFactory; } - @Override public void setConditionFactory(ConditionFactory conditionFactory) { this.conditionFactory = conditionFactory; } @@ -111,24 +107,19 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * Set the error handler for this parser */ - @Override public void setErrorHandler(ErrorHandler error) { - errorHandler = error; + this.errorHandler = error; } /** * Main parse methods - * - * @param source - * the source of the style sheet. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. + * + * @param source the source of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. */ - @Override - public void parseStyleSheet(InputSource source) throws CSSException, - IOException { + public void parseStyleSheet(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); if (selectorFactory == null) { @@ -143,34 +134,26 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * Convenient method for URIs. - * - * @param systemId - * the fully resolved URI of the style sheet. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. + * + * @param systemId the fully resolved URI of the style sheet. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. */ - @Override - public void parseStyleSheet(String systemId) throws CSSException, - IOException { + public void parseStyleSheet(String systemId) + throws CSSException, IOException { parseStyleSheet(new InputSource(systemId)); } /** - * This method parses only one rule (style rule or at-rule, except - * @charset). - * - * @param source - * the source of the rule. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. + * This method parses only one rule (style rule or at-rule, except @charset). + * + * @param source the source of the rule. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. */ // TODO required by original parser but not used by Vaadin? - @Override - public void parseRule(InputSource source) throws CSSException, IOException { + public void parseRule(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); @@ -186,17 +169,13 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * This method parses a style declaration (including the surrounding curly * braces). - * - * @param source - * the source of the style declaration. - * @exception IOException - * the source can't be parsed. - * @exception CSSException - * the source is not CSS valid. + * + * @param source the source of the style declaration. + * @exception IOException the source can't be parsed. + * @exception CSSException the source is not CSS valid. */ - @Override - public void parseStyleDeclaration(InputSource source) throws CSSException, - IOException { + public void parseStyleDeclaration(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); @@ -211,10 +190,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * This methods returns "http://www.w3.org/TR/REC-CSS2". - * * @return the string "http://www.w3.org/TR/REC-CSS2". */ - @Override public String getParserVersion() { return "http://www.w3.org/TR/REC-CSS2"; } @@ -222,8 +199,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { /** * Parse methods used by DOM Level 2 implementation. */ - public void parseImportRule(InputSource source) throws CSSException, - IOException { + public void parseImportRule(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); @@ -236,8 +213,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { _parseImportRule(); } - public void parseMediaRule(InputSource source) throws CSSException, - IOException { + public void parseMediaRule(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); @@ -250,16 +227,14 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { _parseMediaRule(); } - @Override - public SelectorList parseSelectors(InputSource source) throws CSSException, - IOException { + public SelectorList parseSelectors(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); return null; } - @Override public LexicalUnit parsePropertyValue(InputSource source) throws CSSException, IOException { this.source = source; @@ -268,9 +243,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return expr(); } - @Override - public boolean parsePriority(InputSource source) throws CSSException, - IOException { + public boolean parsePriority(InputSource source) + throws CSSException, IOException { this.source = source; ReInit(getCharStreamWithLurk(source)); @@ -278,8 +252,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } /** - * Convert the source into a Reader. Used only by DOM Level 2 parser - * methods. + * Convert the source into a Reader. Used only by DOM Level 2 parser methods. */ private Reader getReader(InputSource source) throws IOException { if (source.getCharacterStream() != null) { @@ -291,7 +264,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { return new InputStreamReader(source.getByteStream(), "ASCII"); } else { return new InputStreamReader(source.getByteStream(), - source.getEncoding()); + source.getEncoding()); } } else { // systemId @@ -301,10 +274,11 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } /** - * Convert the source into a CharStream with encoding informations. The - * encoding can be found in the InputSource or in the CSS document. Since - * this method marks the reader and make a reset after looking for the - * charset declaration, you'll find the charset declaration into the stream. + * Convert the source into a CharStream with encoding informations. + * The encoding can be found in the InputSource or in the CSS document. + * Since this method marks the reader and make a reset after looking for + * the charset declaration, you'll find the charset declaration into the + * stream. */ private CharStream getCharStreamWithLurk(InputSource source) throws CSSException, IOException { @@ -324,7 +298,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } } } - // use UTF-8 as the default encoding. + //use UTF-8 as the default encoding. String encoding = source.getEncoding(); InputStream input = source.getByteStream(); if (!input.markSupported()) { @@ -334,7 +308,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } // Mark either the original stream or the wrapped stream input.mark(100); - if (encoding == null) { + if(encoding == null){ encoding = "ASCII"; char c = ' '; @@ -343,15 +317,14 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { if (c == '@') { // hum, is it a charset ? - int size = 100; + int size = 100; byte[] buf = new byte[size]; input.read(buf, 0, 7); String keyword = new String(buf, 0, 7); if (keyword.equals("charset")) { // Yes, this is the charset declaration ! - // here I don't use the right declaration : white space are - // ' '. + // here I don't use the right declaration : white space are ' '. while ((c = (char) input.read()) == ' ') { // find the first quote } @@ -378,17 +351,15 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { if (c != ';') { // no semi colon at the end ? throw new CSSException("invalid charset declaration: " - + "missing semi colon"); + + "missing semi colon"); } encoding = new String(buf, 0, i); if (source.getEncoding() != null) { // compare the two encoding informations. - // For example, I don't accept to have ASCII and after - // UTF-8. + // For example, I don't accept to have ASCII and after UTF-8. // Is it really good ? That is the question. if (!encoding.equals(source.getEncoding())) { - throw new CSSException( - "invalid encoding information."); + throw new CSSException("invalid encoding information."); } } } // else no charset declaration available @@ -398,7 +369,7 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { source.setEncoding(encoding); // set the real reader of this source. source.setCharacterStream(new InputStreamReader(source.getByteStream(), - Encoding.getJavaEncoding(encoding))); + Encoding.getJavaEncoding(encoding))); // reset the stream (leave the charset declaration in the stream). input.reset(); @@ -406,7 +377,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } private LocatorImpl currentLocator; - private Locator getLocator() { if (currentLocator == null) { currentLocator = new LocatorImpl(this); @@ -414,7 +384,6 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } return currentLocator.reInit(this); } - private LocatorImpl getLocator(Token save) { if (currentLocator == null) { currentLocator = new LocatorImpl(this, save); @@ -431,8 +400,8 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { if (pe.specialConstructor) { StringBuffer errorM = new StringBuffer(); if (pe.currentToken != null) { - errorM.append("encountered \u005c"").append( - pe.currentToken.next); + errorM.append("encountered \u005c"") + .append(pe.currentToken.next); } errorM.append('"'); if (pe.expectedTokenSequences.length != 0) { @@ -448,10 +417,10 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } } errorHandler.error(new CSSParseException(errorM.toString(), - l, e)); + l, e)); } else { - errorHandler.error(new CSSParseException(e.getMessage(), l, - e)); + errorHandler.error(new CSSParseException(e.getMessage(), + l, e)); } } else if (e == null) { errorHandler.error(new CSSParseException("error", l, null)); @@ -462,8162 +431,7357 @@ public class Parser implements org.w3c.css.sac.Parser, ParserConstants { } private void reportWarningSkipText(Locator l, String text) { - if (errorHandler != null && text != null) { + if (errorHandler != null && text != null) { errorHandler.warning(new CSSParseException("Skipping: " + text, l)); } } - /* - * The grammar of CSS2 - */ +/* + * The grammar of CSS2 + */ - /** - * The main entry for the parser. - * - * @exception ParseException - * exception during the parse - */ - final public void parserUnit() throws ParseException { - try { - documentHandler.startDocument(source); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CHARSET_SYM: - charset(); - break; - default: - jj_la1[0] = jj_gen; - ; - } - label_1: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[1] = jj_gen; - break label_1; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - jj_consume_token(S); - comments(); - break; - case CDO: - case CDC: - case ATKEYWORD: - ignoreStatement(); - break; - default: - jj_la1[2] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - label_2: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT_SYM: - ; - break; - default: - jj_la1[3] = jj_gen; - break label_2; - } - importDeclaration(); - label_3: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[4] = jj_gen; - break label_3; - } - ignoreStatement(); - label_4: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[5] = jj_gen; - break label_4; - } - jj_consume_token(S); - } - } - } - afterImportDeclaration(); - jj_consume_token(0); - } finally { - documentHandler.endDocument(source); +/** + * The main entry for the parser. + * + * @exception ParseException exception during the parse + */ + final public void parserUnit() throws ParseException { + try { + documentHandler.startDocument(source); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CHARSET_SYM: + charset(); + break; + default: + jj_la1[0] = jj_gen; + ; + } + label_1: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case CDO: + case CDC: + case ATKEYWORD: + ; + break; + default: + jj_la1[1] = jj_gen; + break label_1; } - } - - final public void charset() throws ParseException { - Token n; - try { - jj_consume_token(CHARSET_SYM); - label_5: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[6] = jj_gen; - break label_5; - } - jj_consume_token(S); - } - n = jj_consume_token(STRING); - label_6: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[7] = jj_gen; - break label_6; - } - jj_consume_token(S); - } - jj_consume_token(SEMICOLON); - } catch (ParseException e) { - reportError(getLocator(e.currentToken.next), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (Exception e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + jj_consume_token(S); + comments(); + break; + case CDO: + case CDC: + case ATKEYWORD: + ignoreStatement(); + break; + default: + jj_la1[2] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORT_SYM: + ; + break; + default: + jj_la1[3] = jj_gen; + break label_2; } - } - - final public void afterImportDeclaration() throws ParseException { - String ret; - Locator l; - label_7: while (true) { + importDeclaration(); + label_3: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: + case CDC: + case ATKEYWORD: ; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case MIXIN_SYM: - mixinDirective(); - break; - case EACH_SYM: - case IF_SYM: - controlDirective(); - break; - case INCLUDE_SYM: - includeDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case MEDIA_SYM: - media(); - break; - case PAGE_SYM: - page(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - case KEY_FRAME_SYM: - keyframes(); - break; + break; + default: + jj_la1[4] = jj_gen; + break label_3; + } + ignoreStatement(); + label_4: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; default: - jj_la1[8] = jj_gen; - if (jj_2_1(2147483647)) { - variable(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - listModifyDirective(); - break; - default: - jj_la1[9] = jj_gen; - l = getLocator(); - ret = skipStatement(); - if ((ret == null) || (ret.length() == 0)) { - { - if (true) { - return; - } - } - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(l, ret); - } - } - } - } - label_8: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case CDC: - case ATKEYWORD: - ; - break; - default: - jj_la1[10] = jj_gen; - break label_8; - } - ignoreStatement(); - label_9: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[11] = jj_gen; - break label_9; - } - jj_consume_token(S); - } + jj_la1[5] = jj_gen; + break label_4; } - } - } - - final public void ignoreStatement() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - jj_consume_token(CDO); + jj_consume_token(S); + } + } + } + afterImportDeclaration(); + jj_consume_token(0); + } finally { + documentHandler.endDocument(source); + } + } + + final public void charset() throws ParseException { + Token n; + try { + jj_consume_token(CHARSET_SYM); + label_5: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[6] = jj_gen; + break label_5; + } + jj_consume_token(S); + } + n = jj_consume_token(STRING); + label_6: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[7] = jj_gen; + break label_6; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + } catch (ParseException e) { + reportError(getLocator(e.currentToken.next), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } catch (Exception e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } + } + + final public void afterImportDeclaration() throws ParseException { + String ret; + Locator l; + label_7: + while (true) { + ; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case MIXIN_SYM: + mixinDirective(); + break; + case EACH_SYM: + case IF_SYM: + controlDirective(); + break; + case INCLUDE_SYM: + includeDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case MEDIA_SYM: + media(); + break; + case PAGE_SYM: + page(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + case KEY_FRAME_SYM: + keyframes(); + break; + default: + jj_la1[8] = jj_gen; + if (jj_2_1(2147483647)) { + variable(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VARIABLE: + listModifyDirective(); break; + default: + jj_la1[9] = jj_gen; + l = getLocator(); + ret = skipStatement(); + if ((ret == null) || (ret.length() == 0)) { + {if (true) return;} + } + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(l, ret); + } + } + } + } + label_8: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: case CDC: - jj_consume_token(CDC); - break; case ATKEYWORD: - atRuleDeclaration(); - break; + ; + break; default: - jj_la1[12] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); + jj_la1[10] = jj_gen; + break label_8; } - } - - /** - * The import statement - * - * @exception ParseException - * exception during the parse - */ - final public void importDeclaration() throws ParseException { - Token n; - String uri; - MediaListImpl ml = new MediaListImpl(); - boolean isURL = false; - try { - jj_consume_token(IMPORT_SYM); - label_10: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[13] = jj_gen; - break label_10; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STRING: - n = jj_consume_token(STRING); - uri = convertStringIndex(n.image, 1, n.image.length() - 1); - break; - case URL: - n = jj_consume_token(URL); - isURL = true; - uri = n.image.substring(4, n.image.length() - 1).trim(); - if ((uri.charAt(0) == '"') || (uri.charAt(0) == '\u005c'')) { - uri = uri.substring(1, uri.length() - 1); - } - break; - default: - jj_la1[14] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_11: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[15] = jj_gen; - break label_11; - } - jj_consume_token(S); - } - mediaStatement(ml); - jj_consume_token(SEMICOLON); - label_12: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[16] = jj_gen; - break label_12; - } - jj_consume_token(S); - } - if (ml.getLength() == 0) { - // see section 6.3 of the CSS2 recommandation. - ml.addItem("all"); - } - documentHandler.importStyle(uri, ml, isURL); - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); + ignoreStatement(); + label_9: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[11] = jj_gen; + break label_9; + } + jj_consume_token(S); + } + } + } + } + + final public void ignoreStatement() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: + jj_consume_token(CDO); + break; + case CDC: + jj_consume_token(CDC); + break; + case ATKEYWORD: + atRuleDeclaration(); + break; + default: + jj_la1[12] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } +/** + * The import statement + * + * @exception ParseException exception during the parse + */ + final public void importDeclaration() throws ParseException { + Token n; + String uri; + MediaListImpl ml = new MediaListImpl(); + boolean isURL = false; + try { + jj_consume_token(IMPORT_SYM); + label_10: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[13] = jj_gen; + break label_10; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + uri = convertStringIndex(n.image, 1, + n.image.length() -1); + break; + case URL: + n = jj_consume_token(URL); + isURL=true; + uri = n.image.substring(4, n.image.length()-1).trim(); + if ((uri.charAt(0) == '"') + || (uri.charAt(0) == '\u005c'')) { + uri = uri.substring(1, uri.length()-1); + } + break; + default: + jj_la1[14] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_11: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[15] = jj_gen; + break label_11; + } + jj_consume_token(S); + } + mediaStatement(ml); + jj_consume_token(SEMICOLON); + label_12: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[16] = jj_gen; + break label_12; } - } + jj_consume_token(S); + } + if (ml.getLength() == 0) { + // see section 6.3 of the CSS2 recommandation. + ml.addItem("all"); + } + documentHandler.importStyle(uri, ml, isURL); + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); - /** - * @exception ParseException - * exception during the parse - */ - final public void keyframes() throws ParseException { - Token n; - boolean start = false; - String keyframeName = null; - String animationname = ""; - try { - n = jj_consume_token(KEY_FRAME_SYM); - label_13: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[17] = jj_gen; - break label_13; - } - jj_consume_token(S); - } - keyframeName = n.image; - label_14: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - animationname += n.image; - break; - case INTERPOLATION: - n = jj_consume_token(INTERPOLATION); - animationname += n.image; - break; - default: - jj_la1[18] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[19] = jj_gen; - break label_14; - } - } - label_15: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[20] = jj_gen; - break label_15; - } - jj_consume_token(S); - } - start = true; - documentHandler.startKeyFrames(keyframeName, animationname); - jj_consume_token(LBRACE); - label_16: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[21] = jj_gen; - break label_16; - } - jj_consume_token(S); - } - label_17: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - case FROM: - case CONTENT_SYM: - case PERCENTAGE: - ; - break; - default: - jj_la1[22] = jj_gen; - break label_17; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - case FROM: - case PERCENTAGE: - keyframeSelector(); - break; - case CONTENT_SYM: - contentDirective(); - break; - default: - jj_la1[23] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_18: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[24] = jj_gen; - break label_18; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - } finally { - if (start) { - documentHandler.endKeyFrames(); - } - } } + } - final public void keyframeSelector() throws ParseException { - Token n; - String selector = ""; - boolean start = false; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FROM: - n = jj_consume_token(FROM); - break; - case TO: - n = jj_consume_token(TO); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - default: - jj_la1[25] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - selector += n.image; - label_19: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[26] = jj_gen; - break label_19; - } - jj_consume_token(S); - } - label_20: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[27] = jj_gen; - break label_20; - } - jj_consume_token(COMMA); - label_21: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[28] = jj_gen; - break label_21; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case FROM: - n = jj_consume_token(FROM); - break; - case TO: - n = jj_consume_token(TO); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - default: - jj_la1[29] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - selector += (", " + n.image); - label_22: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[30] = jj_gen; - break label_22; - } - jj_consume_token(S); - } - } - jj_consume_token(LBRACE); - label_23: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[31] = jj_gen; - break label_23; - } - jj_consume_token(S); - } - start = true; - documentHandler.startKeyframeSelector(selector); - label_24: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case MICROSOFT_RULE: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[32] = jj_gen; - break label_24; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case MICROSOFT_RULE: - microsoftExtension(); - break; - default: - jj_la1[33] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_25: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[34] = jj_gen; - break label_25; - } - jj_consume_token(S); - } - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn - 1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endKeyframeSelector(); - } +/** + * @exception ParseException exception during the parse + */ + final public void keyframes() throws ParseException { + Token n; + boolean start = false; + String keyframeName = null; + String animationname = ""; + try { + n = jj_consume_token(KEY_FRAME_SYM); + label_13: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[17] = jj_gen; + break label_13; + } + jj_consume_token(S); + } + keyframeName = n.image; + label_14: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + animationname += n.image; + break; + case INTERPOLATION: + n = jj_consume_token(INTERPOLATION); + animationname += n.image; + break; + default: + jj_la1[18] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - } - - /** - * @exception ParseException - * exception during the parse - */ - /* see http://www.w3.org/TR/css3-mediaqueries/ */ - final public void media() throws ParseException { - boolean start = false; - String ret; - MediaListImpl ml = new MediaListImpl(); - try { - jj_consume_token(MEDIA_SYM); - label_26: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[35] = jj_gen; - break label_26; - } - jj_consume_token(S); - } - mediaStatement(ml); - start = true; - documentHandler.startMedia(ml); - jj_consume_token(LBRACE); - label_27: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[36] = jj_gen; - break label_27; - } - jj_consume_token(S); - } - label_28: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CDO: - case LBRACE: - case DASHMATCH: - case INCLUDES: - case PLUS: - case MINUS: - case COMMA: - case SEMICOLON: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case NONASCII: - case DEBUG_SYM: - case WARN_SYM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case PERCENTAGE: - case HASH: - case IMPORT_SYM: - case MEDIA_SYM: - case CHARSET_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case ATKEYWORD: - case IMPORTANT_SYM: - case UNICODERANGE: - case FUNCTION: - case UNKNOWN: - ; - break; - default: - jj_la1[37] = jj_gen; - break label_28; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case CDO: - case LBRACE: - case DASHMATCH: - case INCLUDES: - case MINUS: - case COMMA: - case SEMICOLON: - case NONASCII: - case STRING: - case NUMBER: - case URL: - case PERCENTAGE: - case IMPORT_SYM: - case MEDIA_SYM: - case CHARSET_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case ATKEYWORD: - case IMPORTANT_SYM: - case UNICODERANGE: - case FUNCTION: - case UNKNOWN: - skipUnknownRule(); - break; - default: - jj_la1[38] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_29: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[39] = jj_gen; - break label_29; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } finally { - if (start) { - documentHandler.endMedia(ml); - } - } - } - - final public void mediaStatement(MediaListImpl ml) throws ParseException { - Token t; - t = getToken(1); - // loop over comma separated parts, add each to ml - while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) - && (t.kind != SEMICOLON)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - if (t.kind == COMMA) { - // skip the comma and the token before it that is still the - // active token - getNextToken(); - getNextToken(); - t = getToken(1); - } - String str = s.toString().trim(); - if (str.length() > 0) { - ml.addItem(str); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String medium() throws ParseException { - Token n; - n = jj_consume_token(IDENT); - { - if (true) { - return convertIdent(n.image); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void page() throws ParseException { - boolean start = false; - Token n = null; - String page = null; - String pseudo = null; - try { - jj_consume_token(PAGE_SYM); - label_30: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[40] = jj_gen; - break label_30; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - label_31: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[41] = jj_gen; - break label_31; - } - jj_consume_token(S); - } - break; - default: - jj_la1[42] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - pseudo = pseudo_page(); - break; - default: - jj_la1[43] = jj_gen; - ; - } - if (n != null) { - page = convertIdent(n.image); - } - jj_consume_token(LBRACE); - label_32: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[44] = jj_gen; - break label_32; - } - jj_consume_token(S); - } - start = true; - documentHandler.startPage(page, pseudo); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[45] = jj_gen; - ; - } - label_33: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[46] = jj_gen; - break label_33; - } - jj_consume_token(SEMICOLON); - label_34: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[47] = jj_gen; - break label_34; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[48] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_35: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[49] = jj_gen; - break label_35; - } - jj_consume_token(S); - } - } catch (ParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - skipStatement(); - // reportWarningSkipText(li, skipStatement()); - } else { - skipStatement(); - } - } finally { - if (start) { - documentHandler.endPage(page, pseudo); - } - } - } - - final public String pseudo_page() throws ParseException { - Token n; - jj_consume_token(COLON); - n = jj_consume_token(IDENT); - label_36: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[50] = jj_gen; - break label_36; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image); - } - } - throw new Error("Missing return statement in function"); - } - - final public void fontFace() throws ParseException { - boolean start = false; - try { - jj_consume_token(FONT_FACE_SYM); - label_37: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[51] = jj_gen; - break label_37; - } - jj_consume_token(S); - } - jj_consume_token(LBRACE); - label_38: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[52] = jj_gen; - break label_38; - } - jj_consume_token(S); - } - start = true; - documentHandler.startFontFace(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[53] = jj_gen; - ; - } - label_39: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[54] = jj_gen; - break label_39; - } - jj_consume_token(SEMICOLON); - label_40: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[55] = jj_gen; - break label_40; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[56] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_41: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[57] = jj_gen; - break label_41; - } - jj_consume_token(S); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } finally { - if (start) { - documentHandler.endFontFace(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void atRuleDeclaration() throws ParseException { - Token n; - String ret; - n = jj_consume_token(ATKEYWORD); - ret = skipStatement(); - if ((ret != null) && (ret.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(getLocator(), ret); - } - } - - final public void skipUnknownRule() throws ParseException { - Token n; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ATKEYWORD: - n = jj_consume_token(ATKEYWORD); - break; - case CDO: - n = jj_consume_token(CDO); - break; - case CHARSET_SYM: - n = jj_consume_token(CHARSET_SYM); - break; - case COMMA: - n = jj_consume_token(COMMA); - break; - case DASHMATCH: - n = jj_consume_token(DASHMATCH); - break; - case FONT_FACE_SYM: - n = jj_consume_token(FONT_FACE_SYM); - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - break; - case IMPORTANT_SYM: - n = jj_consume_token(IMPORTANT_SYM); - break; - case IMPORT_SYM: - n = jj_consume_token(IMPORT_SYM); - break; - case INCLUDES: - n = jj_consume_token(INCLUDES); - break; - case LBRACE: - n = jj_consume_token(LBRACE); - break; - case MEDIA_SYM: - n = jj_consume_token(MEDIA_SYM); - break; - case NONASCII: - n = jj_consume_token(NONASCII); - break; - case NUMBER: - n = jj_consume_token(NUMBER); - break; - case PAGE_SYM: - n = jj_consume_token(PAGE_SYM); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - break; - case STRING: - n = jj_consume_token(STRING); - break; - case UNICODERANGE: - n = jj_consume_token(UNICODERANGE); - break; - case URL: - n = jj_consume_token(URL); - break; - case SEMICOLON: - n = jj_consume_token(SEMICOLON); - break; - case MINUS: - n = jj_consume_token(MINUS); - break; - case UNKNOWN: - n = jj_consume_token(UNKNOWN); - break; - default: - jj_la1[58] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - String ret; - Locator loc = getLocator(); - ret = skipStatement(); - if ((ret != null) && (n.image.charAt(0) == '@')) { - documentHandler.unrecognizedRule(ret); - } else { - reportWarningSkipText(loc, ret); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public char combinator() throws ParseException { - char connector = ' '; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - connector = combinatorChar(); - break; - case S: - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - connector = combinatorChar(); - break; - default: - jj_la1[59] = jj_gen; - ; - } - break; - default: - jj_la1[60] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - { - if (true) { - return connector; - } - } - throw new Error("Missing return statement in function"); - } - - /** to refactor combinator and reuse in selector(). */ - final public char combinatorChar() throws ParseException { - Token t; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - t = jj_consume_token(PLUS); - break; - case PRECEDES: - t = jj_consume_token(PRECEDES); - break; - case SIBLING: - t = jj_consume_token(SIBLING); - break; - default: - jj_la1[61] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_42: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[62] = jj_gen; - break label_42; - } - jj_consume_token(S); - } - { - if (true) { - return t.image.charAt(0); - } - } - throw new Error("Missing return statement in function"); - } - - final public void microsoftExtension() throws ParseException { - Token n; - String name = ""; - String value = ""; - // This is not really taking the syntax of filter rules into account - n = jj_consume_token(MICROSOFT_RULE); - label_43: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[63] = jj_gen; - break label_43; - } - jj_consume_token(S); - } - name = n.image; - jj_consume_token(COLON); - label_44: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - value += n.image; - break; - case NUMBER: - n = jj_consume_token(NUMBER); - value += n.image; - break; - case STRING: - n = jj_consume_token(STRING); - value += n.image; - break; - case COMMA: - n = jj_consume_token(COMMA); - value += n.image; - break; - case INTERPOLATION: - n = jj_consume_token(INTERPOLATION); - value += n.image; - break; - case COLON: - n = jj_consume_token(COLON); - value += n.image; - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - value += n.image; - break; - case RPARAN: - n = jj_consume_token(RPARAN); - value += n.image; - break; - case EQ: - n = jj_consume_token(EQ); - value += n.image; - break; - case DOT: - n = jj_consume_token(DOT); - value += n.image; - break; - case S: - n = jj_consume_token(S); - if (value.lastIndexOf(' ') != value.length() - 1) { - value += n.image; - } - break; - default: - jj_la1[64] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case COMMA: - case DOT: - case RPARAN: - case COLON: - case INTERPOLATION: - case STRING: - case IDENT: - case NUMBER: - case FUNCTION: - ; - break; - default: - jj_la1[65] = jj_gen; - break label_44; - } - } - jj_consume_token(SEMICOLON); - label_45: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[66] = jj_gen; - break label_45; - } - jj_consume_token(S); - } - documentHandler.microsoftDirective(name, value); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String property() throws ParseException { - Token t; - String s = ""; - label_46: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[67] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[68] = jj_gen; - break label_46; - } - } - label_47: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[69] = jj_gen; - break label_47; - } - jj_consume_token(S); - } - { - if (true) { - return s; - } - } - throw new Error("Missing return statement in function"); - } - - final public String variableName() throws ParseException { - Token n; - n = jj_consume_token(VARIABLE); - label_48: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[70] = jj_gen; - break label_48; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image.substring(1)); - } - } - throw new Error("Missing return statement in function"); - } - - final public String functionName() throws ParseException { - Token n; - n = jj_consume_token(FUNCTION); - label_49: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[71] = jj_gen; - break label_49; - } - jj_consume_token(S); - } - { - if (true) { - return convertIdent(n.image.substring(0, n.image.length() - 1)); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void styleRule() throws ParseException { - boolean start = false; - ArrayList l = null; - Token save; - Locator loc; - try { - l = selectorList(); - save = token; - jj_consume_token(LBRACE); - label_50: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[72] = jj_gen; - break label_50; - } - jj_consume_token(S); - } - start = true; - documentHandler.startSelector(l); - label_51: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case MICROSOFT_RULE: - case IDENT: - case VARIABLE: - case HASH: - case IMPORT_SYM: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[73] = jj_gen; - break label_51; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case MICROSOFT_RULE: - microsoftExtension(); - break; - case IMPORT_SYM: - importDeclaration(); - break; - default: - jj_la1[74] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_52: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[75] = jj_gen; - break label_52; - } - jj_consume_token(S); - } - } catch (ThrowedParseException e) { - if (errorHandler != null) { - LocatorImpl li = new LocatorImpl(this, - e.e.currentToken.next.beginLine, - e.e.currentToken.next.beginColumn - 1); - reportError(li, e.e); - } - } catch (ParseException e) { - reportError(getLocator(), e); - skipStatement(); - // reportWarningSkipText(getLocator(), skipStatement()); - - } catch (TokenMgrError e) { - reportWarningSkipText(getLocator(), skipStatement()); - } finally { - if (start) { - documentHandler.endSelector(); - } - } - } - - final public ArrayList selectorList() throws ParseException { - ArrayList selectors = new ArrayList(); - String selector; - selector = selector(); - label_53: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[76] = jj_gen; - break label_53; - } - jj_consume_token(COMMA); - label_54: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[77] = jj_gen; - break label_54; - } - jj_consume_token(S); - } - selectors.add(selector); - selector = selector(); - } - selectors.add(selector); - { - if (true) { - return selectors; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String selector() throws ParseException { - String selector = null; - char comb; - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - selector = simple_selector(null, ' '); - break; - case PLUS: - case PRECEDES: - case SIBLING: - comb = combinatorChar(); - selector = simple_selector(selector, comb); - break; - default: - jj_la1[78] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_55: while (true) { - if (jj_2_2(2)) { - ; - } else { - break label_55; - } - comb = combinator(); - selector = simple_selector(selector, comb); - } - label_56: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[79] = jj_gen; - break label_56; - } - jj_consume_token(S); - } - { - if (true) { - return selector; - } - } - } catch (ParseException e) { - /* - * Token t = getToken(1); StringBuffer s = new StringBuffer(); - * s.append(getToken(0).image); while ((t.kind != COMMA) && (t.kind - * != SEMICOLON) && (t.kind != LBRACE) && (t.kind != EOF)) { - * s.append(t.image); getNextToken(); t = getToken(1); } - * reportWarningSkipText(getLocator(), s.toString()); - */ - Token t = getToken(1); - while ((t.kind != COMMA) && (t.kind != SEMICOLON) - && (t.kind != LBRACE) && (t.kind != EOF)) { - getNextToken(); - t = getToken(1); - } - - { - if (true) { - throw new ThrowedParseException(e); - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String simple_selector(String selector, char comb) - throws ParseException { - String simple_current = null; - String cond = null; - - pseudoElt = null; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ANY: - case PARENT: - case INTERPOLATION: - case IDENT: - simple_current = element_name(); - label_57: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case DOT: - case COLON: - case HASH: - ; - break; - default: - jj_la1[80] = jj_gen; - break label_57; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case HASH: - cond = hash(cond); - break; - case DOT: - cond = _class(cond); - break; - case LBRACKET: - cond = attrib(cond); - break; - case COLON: - cond = pseudo(cond); - break; - default: - jj_la1[81] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - break; - case LBRACKET: - case DOT: - case COLON: - case HASH: - label_58: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case HASH: - cond = hash(cond); - break; - case DOT: - cond = _class(cond); - break; - case LBRACKET: - cond = attrib(cond); - break; - case COLON: - cond = pseudo(cond); - break; - default: - jj_la1[82] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case LBRACKET: - case DOT: - case COLON: - case HASH: - ; - break; - default: - jj_la1[83] = jj_gen; - break label_58; - } - } - break; - default: - jj_la1[84] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - if (simple_current == null) { - simple_current = ""; - } - if (cond != null) { - simple_current = simple_current + cond; - } - StringBuilder builder = new StringBuilder(); - switch (comb) { - case ' ': - if (selector != null) { - builder.append(selector).append(" "); - } - break; - case '+': - case '>': - case '~': - if (selector != null) { - builder.append(selector).append(" "); - } - builder.append(comb).append(" "); - break; - default: { - if (true) { - throw new ParseException("invalid state. send a bug report"); - } - } - } - builder.append(simple_current); - selector = builder.toString(); - - if (pseudoElt != null) { - selector = selector + pseudoElt; - } - { - if (true) { - return selector; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String _class(String pred) throws ParseException { - Token t; - String s = "."; - jj_consume_token(DOT); - label_59: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[85] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[86] = jj_gen; - break label_59; - } - } - if (pred == null) { - { - if (true) { - return s; - } - } - } else { - { - if (true) { - return pred + s; - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String element_name() throws ParseException { - Token t; - String s = ""; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - label_60: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - t = jj_consume_token(IDENT); - s += t.image; - break; - case INTERPOLATION: - t = jj_consume_token(INTERPOLATION); - s += t.image; - break; - default: - jj_la1[87] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - ; - break; - default: - jj_la1[88] = jj_gen; - break label_60; - } - } - { - if (true) { - return s; - } - } - break; - case ANY: - jj_consume_token(ANY); - { - if (true) { - return "*"; - } - } - break; - case PARENT: - jj_consume_token(PARENT); - { - if (true) { - return "&"; - } - } - break; - default: - jj_la1[89] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String attrib(String pred) throws ParseException { - int cases = 0; - Token att = null; - Token val = null; - String attValue = null; - jj_consume_token(LBRACKET); - label_61: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[90] = jj_gen; - break label_61; - } - jj_consume_token(S); - } - att = jj_consume_token(IDENT); - label_62: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[91] = jj_gen; - break label_62; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DASHMATCH: - case CARETMATCH: - case DOLLARMATCH: - case STARMATCH: - case INCLUDES: - case EQ: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case EQ: - jj_consume_token(EQ); - cases = 1; - break; - case INCLUDES: - jj_consume_token(INCLUDES); - cases = 2; - break; - case DASHMATCH: - jj_consume_token(DASHMATCH); - cases = 3; - break; - case CARETMATCH: - jj_consume_token(CARETMATCH); - cases = 4; - break; - case DOLLARMATCH: - jj_consume_token(DOLLARMATCH); - cases = 5; - break; - case STARMATCH: - jj_consume_token(STARMATCH); - cases = 6; - break; - default: - jj_la1[92] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_63: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[93] = jj_gen; - break label_63; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - val = jj_consume_token(IDENT); - attValue = val.image; - break; - case STRING: - val = jj_consume_token(STRING); - attValue = val.image; - break; - default: - jj_la1[94] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_64: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[95] = jj_gen; - break label_64; - } - jj_consume_token(S); - } - break; - default: - jj_la1[96] = jj_gen; - ; - } - jj_consume_token(RBRACKET); - String name = convertIdent(att.image); - String c; - switch (cases) { - case 0: - c = name; - break; - case 1: - c = name + "=" + attValue; - break; - case 2: - c = name + "~=" + attValue; - break; - case 3: - c = name + "|=" + attValue; - break; - case 4: - c = name + "^=" + attValue; - break; - case 5: - c = name + "$=" + attValue; - break; - case 6: - c = name + "*=" + attValue; - break; - default: - // never reached. - c = null; - } - c = "[" + c + "]"; - if (pred == null) { - { - if (true) { - return c; - } - } - } else { - { - if (true) { - return pred + c; - } - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String pseudo(String pred) throws ParseException { - Token n; - Token param; - String d; - boolean isPseudoElement = false; - jj_consume_token(COLON); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - isPseudoElement = true; - break; - default: - jj_la1[97] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - String s = ":" + convertIdent(n.image); - if (isPseudoElement) { - if (pseudoElt != null) { - { - if (true) { - throw new CSSParseException( - "duplicate pseudo element definition " + s, - getLocator()); - } - } - } else { - pseudoElt = ":" + s; - { - if (true) { - return pred; - } - } - } - } else { - String c = s; - if (pred == null) { - { - if (true) { - return c; - } - } - } else { - { - if (true) { - return pred + c; - } - } - } - } - break; - case FUNCTION: - n = jj_consume_token(FUNCTION); - label_65: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[98] = jj_gen; - break label_65; - } - jj_consume_token(S); - } - d = skipStatementUntilMatchingRightParan(); - jj_consume_token(RPARAN); - // accept anything between function and a right parenthesis - String f = convertIdent(n.image); - String colons = isPseudoElement ? "::" : ":"; - String pseudofn = colons + f + d + ")"; - if (pred == null) { - { - if (true) { - return pseudofn; - } - } - } else { - { - if (true) { - return pred + pseudofn; - } - } - } - break; - default: - jj_la1[99] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String hash(String pred) throws ParseException { - Token n; - n = jj_consume_token(HASH); - String d = n.image; - if (pred == null) { - { - if (true) { - return d; - } - } - } else { - { - if (true) { - return pred + d; - } - } - } - throw new Error("Missing return statement in function"); - } - - final public void variable() throws ParseException { - String name; - LexicalUnitImpl exp = null; - boolean guarded = false; - String raw; - try { - name = variableName(); - jj_consume_token(COLON); - label_66: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[100] = jj_gen; - break label_66; - } - jj_consume_token(S); - } - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case GUARDED_SYM: - guarded = guarded(); - break; - default: - jj_la1[101] = jj_gen; - ; - } - label_67: while (true) { - jj_consume_token(SEMICOLON); - label_68: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[102] = jj_gen; - break label_68; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[103] = jj_gen; - break label_67; - } - } - documentHandler.variable(name, exp, guarded); - } catch (JumpException e) { - skipAfterExpression(); - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - } else { - skipAfterExpression(); - } - } - } - - final public void controlDirective() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IF_SYM: - ifDirective(); - break; - case EACH_SYM: - eachDirective(); - break; - default: - jj_la1[104] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public void ifContentStatement() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case CONTENT_SYM: - contentDirective(); - break; - case INCLUDE_SYM: - includeDirective(); - break; - case MEDIA_SYM: - media(); - break; - case EXTEND_SYM: - extendDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case HASH: - styleRuleOrDeclarationOrNestedProperties(); - break; - case KEY_FRAME_SYM: - keyframes(); - break; - default: - jj_la1[105] = jj_gen; - if (jj_2_3(2147483647)) { - variable(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - listModifyDirective(); - break; - case EACH_SYM: - case IF_SYM: - controlDirective(); - break; - case ATKEYWORD: - atRuleDeclaration(); - break; - default: - jj_la1[106] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } - - final public void ifDirective() throws ParseException { - Token n = null; - String s = null; - String evaluator = ""; - jj_consume_token(IF_SYM); - label_69: while (true) { - s = booleanExpressionToken(); - evaluator += s; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case PLUS: - case MINUS: - case PRECEDES: - case SUCCEEDS: - case DIV: - case ANY: - case LPARAN: - case RPARAN: - case COMPARE: - case OR: - case AND: - case NOT_EQ: - case IDENT: - case NUMBER: - case VARIABLE: - case CONTAINS: - ; - break; - default: - jj_la1[107] = jj_gen; - break label_69; - } - } - jj_consume_token(LBRACE); - label_70: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[108] = jj_gen; - break label_70; - } - jj_consume_token(S); - } - documentHandler.startIfElseDirective(); - documentHandler.ifDirective(evaluator); - label_71: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[109] = jj_gen; - break label_71; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[110] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_72: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[111] = jj_gen; - break label_72; - } - jj_consume_token(S); - } - label_73: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case ELSE_SYM: - ; - break; - default: - jj_la1[112] = jj_gen; - break label_73; - } - elseDirective(); - } - documentHandler.endIfElseDirective(); - } - - final public void elseDirective() throws ParseException { - String evaluator = ""; - Token n = null; - String s = null; - jj_consume_token(ELSE_SYM); - label_74: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[113] = jj_gen; - break label_74; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IF: - jj_consume_token(IF); - label_75: while (true) { - s = booleanExpressionToken(); - evaluator += s; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - case EQ: - case PLUS: - case MINUS: - case PRECEDES: - case SUCCEEDS: - case DIV: - case ANY: - case LPARAN: - case RPARAN: - case COMPARE: - case OR: - case AND: - case NOT_EQ: - case IDENT: - case NUMBER: - case VARIABLE: - case CONTAINS: - ; - break; - default: - jj_la1[114] = jj_gen; - break label_75; - } - } - break; - default: - jj_la1[115] = jj_gen; - ; - } - jj_consume_token(LBRACE); - label_76: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[116] = jj_gen; - break label_76; - } - jj_consume_token(S); - } - if (!evaluator.trim().equals("")) { - documentHandler.ifDirective(evaluator); - } else { - documentHandler.elseDirective(); - } - label_77: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[117] = jj_gen; - break label_77; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[118] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_78: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[119] = jj_gen; - break label_78; - } - jj_consume_token(S); - } - } - - final public String booleanExpressionToken() throws ParseException { - Token n = null; - String s = null; - if (jj_2_4(2147483647)) { - s = containsDirective(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - n = jj_consume_token(VARIABLE); - break; - case IDENT: - n = jj_consume_token(IDENT); - break; - case NUMBER: - n = jj_consume_token(NUMBER); - break; - case LPARAN: - n = jj_consume_token(LPARAN); - break; - case RPARAN: - n = jj_consume_token(RPARAN); - break; - case PLUS: - n = jj_consume_token(PLUS); - break; - case MINUS: - n = jj_consume_token(MINUS); - break; - case DIV: - n = jj_consume_token(DIV); - break; - case ANY: - n = jj_consume_token(ANY); - break; - case COMPARE: - n = jj_consume_token(COMPARE); - break; - case EQ: - n = jj_consume_token(EQ); - break; - case PRECEDES: - n = jj_consume_token(PRECEDES); - break; - case SUCCEEDS: - n = jj_consume_token(SUCCEEDS); - break; - case OR: - n = jj_consume_token(OR); - break; - case AND: - n = jj_consume_token(AND); - break; - case S: - n = jj_consume_token(S); - break; - case NOT_EQ: - n = jj_consume_token(NOT_EQ); - break; - default: - jj_la1[120] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - if (n != null) { - { - if (true) { - return n.image; - } - } - } else { - { - if (true) { - return s; - } - } - } - throw new Error("Missing return statement in function"); - } - - final public void eachDirective() throws ParseException { - Token var; - ArrayList list = null; - String listVariable = null; - jj_consume_token(EACH_SYM); - label_79: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[121] = jj_gen; - break label_79; - } - jj_consume_token(S); - } - var = jj_consume_token(VARIABLE); - label_80: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[122] = jj_gen; - break label_80; - } - jj_consume_token(S); - } - jj_consume_token(EACH_IN); - label_81: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[123] = jj_gen; - break label_81; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - list = stringList(); - documentHandler.startEachDirective(var.image, list); - break; - case VARIABLE: - listVariable = variableName(); - documentHandler.startEachDirective(var.image, listVariable); - break; - default: - jj_la1[124] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(LBRACE); - label_82: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[125] = jj_gen; - break label_82; - } - jj_consume_token(S); - } - label_83: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[126] = jj_gen; - break label_83; - } - ifContentStatement(); - } - jj_consume_token(RBRACE); - label_84: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[127] = jj_gen; - break label_84; - } - jj_consume_token(S); - } - documentHandler.endEachDirective(); - } - - final public ArrayList stringList() throws ParseException { - ArrayList strings = new ArrayList(); - Token input; - input = jj_consume_token(IDENT); - label_85: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[128] = jj_gen; - break label_85; - } - jj_consume_token(S); - } - strings.add(input.image); - label_86: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[129] = jj_gen; - break label_86; - } - jj_consume_token(COMMA); - label_87: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[130] = jj_gen; - break label_87; - } - jj_consume_token(S); - } - input = jj_consume_token(IDENT); - strings.add(input.image); - label_88: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[131] = jj_gen; - break label_88; - } - jj_consume_token(S); - } - } - { - if (true) { - return strings; - } - } - throw new Error("Missing return statement in function"); - } - - final public void mixinDirective() throws ParseException { - String name; - ArrayList args = null; - String body; - jj_consume_token(MIXIN_SYM); - label_89: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[132] = jj_gen; - break label_89; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - name = property(); - break; - case FUNCTION: - name = functionName(); - args = arglist(); - jj_consume_token(RPARAN); - label_90: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[133] = jj_gen; - break label_90; - } - jj_consume_token(S); - } - break; - default: - jj_la1[134] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(LBRACE); - label_91: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[135] = jj_gen; - break label_91; - } - jj_consume_token(S); - } - documentHandler.startMixinDirective(name, args); - label_92: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case PAGE_SYM: - case FONT_FACE_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ; - break; - default: - jj_la1[136] = jj_gen; - break label_92; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case INCLUDE_SYM: - case DEBUG_SYM: - case WARN_SYM: - case EACH_SYM: - case IF_SYM: - case EXTEND_SYM: - case CONTENT_SYM: - case IDENT: - case VARIABLE: - case HASH: - case MEDIA_SYM: - case KEY_FRAME_SYM: - case ATKEYWORD: - ifContentStatement(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - case PAGE_SYM: - page(); - break; - default: - jj_la1[137] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_93: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[138] = jj_gen; - break label_93; - } - jj_consume_token(S); - } - documentHandler.endMixinDirective(name, args); - } - - final public ArrayList arglist() throws ParseException { - ArrayList args = new ArrayList(); - VariableNode arg; - boolean hasNonOptionalArgument = false; - arg = mixinArg(); - label_94: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[139] = jj_gen; - break label_94; - } - jj_consume_token(COMMA); - label_95: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[140] = jj_gen; - break label_95; - } - jj_consume_token(S); - } - hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, - hasNonOptionalArgument); - args.add(arg); - arg = mixinArg(); - } - hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, - hasNonOptionalArgument); - args.add(arg); - { - if (true) { - return args; - } - } - throw new Error("Missing return statement in function"); - } - - boolean checkMixinForNonOptionalArguments(VariableNode arg, - boolean hasNonOptionalArguments) throws ParseException { - boolean currentArgHasArguments = arg.getExpr() != null - && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE - && arg.getExpr().getNextLexicalUnit() != null; - - if (currentArgHasArguments) { - if (hasNonOptionalArguments) { - throw new ParseException("Sass Error: Required argument $" - + arg.getName() - + " must come before any optional arguments."); - } - return hasNonOptionalArguments; - } else { - return true; - } - } - - final public VariableNode mixinArg() throws ParseException { - String name; - Token variable = null; - LexicalUnitImpl first = null; - LexicalUnitImpl prev = null; - LexicalUnitImpl next = null; - name = variableName(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - case VARIABLE: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_96: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[141] = jj_gen; - break label_96; - } - jj_consume_token(S); - } - first = nonVariableTerm(null); - prev = first; - label_97: while (true) { - if (jj_2_5(3)) { - ; - } else { - break label_97; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_98: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[142] = jj_gen; - break label_98; - } - jj_consume_token(S); - } - break; - default: - jj_la1[143] = jj_gen; - ; - } - prev = nonVariableTerm(prev); - } - break; - case VARIABLE: - variable = jj_consume_token(VARIABLE); - first = LexicalUnitImpl.createVariable(token.beginLine, - token.beginColumn, prev, variable.image); - break; - default: - jj_la1[144] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[145] = jj_gen; - ; - } - VariableNode arg = new VariableNode(name, first, false); - { - if (true) { - return arg; - } - } - throw new Error("Missing return statement in function"); - } - - final public ArrayList argValuelist() - throws ParseException { - ArrayList args = new ArrayList(); - LexicalUnitImpl first = null; - LexicalUnitImpl next = null; - LexicalUnitImpl prev = null; - first = term(null); - args.add(first); - prev = first; - label_99: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case COLON: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - ; - break; - default: - jj_la1[146] = jj_gen; - break label_99; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_100: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[147] = jj_gen; - break label_100; - } - jj_consume_token(S); - } - break; - default: - jj_la1[148] = jj_gen; - ; - } - next = term(prev); - prev.setNextLexicalUnit(next); - prev = next; - } - label_101: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - ; - break; - default: - jj_la1[149] = jj_gen; - break label_101; - } - jj_consume_token(COMMA); - label_102: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[150] = jj_gen; - break label_102; - } - jj_consume_token(S); - } - first = term(null); - args.add(first); - prev = first; - label_103: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case COLON: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - ; - break; - default: - jj_la1[151] = jj_gen; - break label_103; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COLON: - jj_consume_token(COLON); - label_104: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[152] = jj_gen; - break label_104; - } - jj_consume_token(S); - } - break; - default: - jj_la1[153] = jj_gen; - ; - } - next = term(prev); - prev.setNextLexicalUnit(next); - prev = next; - } - } - { - if (true) { - return args; - } - } - throw new Error("Missing return statement in function"); - } - - final public void includeDirective() throws ParseException { - String name; - ArrayList args = null; - jj_consume_token(INCLUDE_SYM); - label_105: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[154] = jj_gen; - break label_105; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - name = property(); - break; - case VARIABLE: - name = variableName(); - name = "$" + name; - break; - case FUNCTION: - name = functionName(); - args = argValuelist(); - jj_consume_token(RPARAN); - label_106: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[155] = jj_gen; - break label_106; - } - jj_consume_token(S); - } - break; - default: - jj_la1[156] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - label_107: while (true) { - jj_consume_token(SEMICOLON); - label_108: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[157] = jj_gen; - break label_108; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[158] = jj_gen; - break label_107; - } - } - documentHandler.includeDirective(name, args); - break; - case LBRACE: - jj_consume_token(LBRACE); - label_109: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[159] = jj_gen; - break label_109; - } - jj_consume_token(S); - } - documentHandler.startIncludeContentBlock(name, args); - label_110: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case TO: - case FROM: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case PERCENTAGE: - case HASH: - ; - break; - default: - jj_la1[160] = jj_gen; - break label_110; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case DEBUG_SYM: - case WARN_SYM: - case IDENT: - case HASH: - styleRuleOrDeclarationOrNestedProperties(); - break; - case TO: - case FROM: - case PERCENTAGE: - keyframeSelector(); - break; - default: - jj_la1[161] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - jj_consume_token(RBRACE); - label_111: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[162] = jj_gen; - break label_111; - } - jj_consume_token(S); - } - documentHandler.endIncludeContentBlock(); - break; - default: - jj_la1[163] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public String interpolation() throws ParseException { - Token n; - n = jj_consume_token(INTERPOLATION); - { - if (true) { - return n.image; - } - } - throw new Error("Missing return statement in function"); - } - - final public void listModifyDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - Token type = null; - // refactor, remove those 3 LOOKAHEAD(5). - n = jj_consume_token(VARIABLE); - variable = n.image; - label_112: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[164] = jj_gen; - break label_112; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_113: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[165] = jj_gen; - break label_113; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case APPEND: - type = jj_consume_token(APPEND); - break; - case REMOVE: - type = jj_consume_token(REMOVE); - break; - case CONTAINS: - type = jj_consume_token(CONTAINS); - break; - default: - jj_la1[166] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_114: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[167] = jj_gen; - break label_114; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[168] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_115: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[169] = jj_gen; - break label_115; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_116: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[170] = jj_gen; - break label_116; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_117: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[171] = jj_gen; - break label_117; - } - jj_consume_token(S); - } - break; - default: - jj_la1[172] = jj_gen; - ; - } - jj_consume_token(RPARAN); - switch (type.kind) { - case APPEND: - documentHandler.appendDirective(variable, list, remove, separator); - break; - case REMOVE: - documentHandler.removeDirective(variable, list, remove, separator); - break; - case CONTAINS: - if (variable == null) { - variable = "$var_" + UUID.randomUUID(); - } - documentHandler - .containsDirective(variable, list, remove, separator); - break; - default: - break; - } - label_118: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[173] = jj_gen; - break label_118; - } - jj_consume_token(S); - } - jj_consume_token(SEMICOLON); - label_119: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[174] = jj_gen; - break label_119; - } - jj_consume_token(S); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void appendDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - n = jj_consume_token(VARIABLE); - variable = n.image; - label_120: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[175] = jj_gen; - break label_120; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_121: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[176] = jj_gen; - break label_121; - } - jj_consume_token(S); - } - jj_consume_token(APPEND); - label_122: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[177] = jj_gen; - break label_122; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[178] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_123: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[179] = jj_gen; - break label_123; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_124: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[180] = jj_gen; - break label_124; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_125: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[181] = jj_gen; - break label_125; - } - jj_consume_token(S); - } - break; - default: - jj_la1[182] = jj_gen; - ; - } - jj_consume_token(RPARAN); - documentHandler.appendDirective(variable, list, remove, separator); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void removeDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - n = jj_consume_token(VARIABLE); - variable = n.image; - label_126: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[183] = jj_gen; - break label_126; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_127: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[184] = jj_gen; - break label_127; - } - jj_consume_token(S); - } - jj_consume_token(REMOVE); - label_128: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[185] = jj_gen; - break label_128; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[186] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_129: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[187] = jj_gen; - break label_129; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_130: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[188] = jj_gen; - break label_130; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_131: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[189] = jj_gen; - break label_131; - } - jj_consume_token(S); - } - break; - default: - jj_la1[190] = jj_gen; - ; - } - jj_consume_token(RPARAN); - documentHandler.removeDirective(variable, list, remove, separator); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public String containsDirective() throws ParseException { - String list = null; - String remove = null; - String separator = null; - String variable = null; - Token n = null; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case VARIABLE: - n = jj_consume_token(VARIABLE); - variable = n.image; - label_132: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[191] = jj_gen; - break label_132; - } - jj_consume_token(S); - } - jj_consume_token(COLON); - label_133: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[192] = jj_gen; - break label_133; - } - jj_consume_token(S); - } - break; - default: - jj_la1[193] = jj_gen; - ; - } - jj_consume_token(CONTAINS); - label_134: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[194] = jj_gen; - break label_134; - } - jj_consume_token(S); - } - list = listModifyDirectiveArgs(0); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case RPARAN: - jj_consume_token(RPARAN); - break; - default: - jj_la1[195] = jj_gen; - ; - } - jj_consume_token(COMMA); - label_135: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[196] = jj_gen; - break label_135; - } - jj_consume_token(S); - } - remove = listModifyDirectiveArgs(1); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - jj_consume_token(COMMA); - label_136: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[197] = jj_gen; - break label_136; - } - jj_consume_token(S); - } - n = jj_consume_token(IDENT); - separator = n.image; - label_137: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[198] = jj_gen; - break label_137; - } - jj_consume_token(S); - } - break; - default: - jj_la1[199] = jj_gen; - ; - } - jj_consume_token(RPARAN); - /* - * if it is not in the form like - * "$contains : contains($items, .v-button);"for example in @if, like - * "@if (contains(a b c, b))", then create a tempvariable for contains(a - * b c, b); - */ - if (variable == null) { - variable = "$var_" + UUID.randomUUID(); - } - documentHandler.containsDirective(variable, list, remove, separator); - { - if (true) { - return variable; - } - } - throw new Error("Missing return statement in function"); - } - - String listModifyDirectiveArgs(int nest) throws ParseException { - String list = ""; - int nesting = nest; - Token t = null; - - while (true) { - t = getToken(1); - String s = t.image; - if (t.kind == VARIABLE || t.kind == IDENT) { - list += s; - } else if (s.toLowerCase().equals("auto") - || s.toLowerCase().equals("space") - || s.toLowerCase().equals("comma")) { - int i = 2; - Token temp = getToken(i); - boolean isLast = true; - while (temp.kind != SEMICOLON) { - if (temp.kind != RPARAN || temp.kind != S) { - isLast = false; - } - i++; - temp = getToken(i); - } - - if (isLast) { - return list; - } - } else if (t.kind == STRING) { - list += s.substring(1, s.length()).substring(0, s.length() - 2); - - } else if (t.kind == LPARAN) { - nesting++; - if (nesting > nest + 1) { - throw new CSSParseException( - "Only one ( ) pair per parameter allowed", - getLocator()); - } - } else if (t.kind == RPARAN) { - nesting--; - if (nesting == 0) { - return list; - } - } else if (t.kind == COMMA) { - if (nesting == nest) { - return list; - } else { - list += ","; - } - - } else if (t.kind == S) { - list += " "; - } else if (t.kind == LBRACE) { - throw new CSSParseException("Invalid token,'{' found", - getLocator()); - } - - getNextToken(); - } - } - - final public Node returnDirective() throws ParseException { - String raw; - raw = skipStatement(); - { - if (true) { - return null; - } - } - throw new Error("Missing return statement in function"); - } - - final public void debuggingDirective() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - debugDirective(); - break; - case WARN_SYM: - warnDirective(); - break; - default: - jj_la1[200] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public void debugDirective() throws ParseException { - jj_consume_token(DEBUG_SYM); - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call - // documentHandler.debugDirective() etc. - System.out.println(content); - label_138: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[201] = jj_gen; - break label_138; - } - jj_consume_token(S); - } - } - - final public void warnDirective() throws ParseException { - jj_consume_token(WARN_SYM); - String content = skipStatementUntilSemiColon(); - // TODO should evaluate the content expression, call - // documentHandler.warnDirective() etc. - System.err.println(content); - label_139: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[202] = jj_gen; - break label_139; - } - jj_consume_token(S); - } - } - - final public Node forDirective() throws ParseException { - String var; - String from; - String to; - boolean exclusive; - String body; - Token tok; - var = variableName(); - int[] toThrough = { TO, THROUGH }; - from = skipStatementUntil(toThrough); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case TO: - tok = jj_consume_token(TO); - exclusive = true; - break; - case THROUGH: - tok = jj_consume_token(THROUGH); - exclusive = false; - break; - default: - jj_la1[203] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - to = skipStatementUntilLeftBrace(); - label_140: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[204] = jj_gen; - break label_140; - } - jj_consume_token(S); - } - body = skipStatement(); - { - if (true) { - return documentHandler.forDirective(var, from, to, exclusive, - body); - } - } - throw new Error("Missing return statement in function"); - } - - final public Node whileDirective() throws ParseException { - String condition; - String body; - condition = skipStatementUntilLeftBrace(); - body = skipStatement(); - { - if (true) { - return documentHandler.whileDirective(condition, body); - } - } - throw new Error("Missing return statement in function"); - } - - final public void extendDirective() throws ParseException { - ArrayList list; - jj_consume_token(EXTEND_SYM); - label_141: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[205] = jj_gen; - break label_141; - } - jj_consume_token(S); - } - list = selectorList(); - label_142: while (true) { - jj_consume_token(SEMICOLON); - label_143: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[206] = jj_gen; - break label_143; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[207] = jj_gen; - break label_142; - } - } - documentHandler.extendDirective(list); - } - - final public void contentDirective() throws ParseException { - jj_consume_token(CONTENT_SYM); - label_144: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[208] = jj_gen; - break label_144; - } - jj_consume_token(S); - } - label_145: while (true) { - jj_consume_token(SEMICOLON); - label_146: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[209] = jj_gen; - break label_146; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[210] = jj_gen; - break label_145; - } - } - documentHandler.contentDirective(); - } - - Node importDirective() throws ParseException { - return null; - } - - Node charsetDirective() throws ParseException { - return null; - } - - Node mozDocumentDirective() throws ParseException { - return null; - } - - Node supportsDirective() throws ParseException { - return null; - } - - final public void nestedProperties() throws ParseException { - String name; - LexicalUnit exp; - name = property(); - jj_consume_token(COLON); - label_147: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[211] = jj_gen; - break label_147; - } - jj_consume_token(S); - } - jj_consume_token(LBRACE); - label_148: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[212] = jj_gen; - break label_148; - } - jj_consume_token(S); - } - documentHandler.startNestedProperties(name); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[213] = jj_gen; - ; - } - label_149: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[214] = jj_gen; - break label_149; - } - jj_consume_token(SEMICOLON); - label_150: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[215] = jj_gen; - break label_150; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[216] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - documentHandler.endNestedProperties(name); - label_151: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[217] = jj_gen; - break label_151; - } - jj_consume_token(S); - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void styleRuleOrDeclarationOrNestedProperties() - throws ParseException { - try { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - default: - jj_la1[218] = jj_gen; - if (jj_2_6(2147483647)) { - styleRule(); - } else if (jj_2_7(3)) { - declarationOrNestedProperties(); - } else { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - default: - jj_la1[219] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void declarationOrNestedProperties() throws ParseException { - boolean important = false; - String name; - LexicalUnitImpl exp; - Token save; - String comment = null; - try { - name = property(); - save = token; - jj_consume_token(COLON); - label_152: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[220] = jj_gen; - break label_152; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORTANT_SYM: - important = prio(); - break; - default: - jj_la1[221] = jj_gen; - ; - } - Token next = getToken(1); - if (next.kind == SEMICOLON || next.kind == RBRACE) { - while (next.kind == SEMICOLON) { - skipStatement(); - next = getToken(1); - } - // only add special token kept for sprites '/**' - if (token.specialToken != null - && token.specialToken != null - && token.specialToken.image.startsWith("/**")) { - documentHandler.property(name, exp, important, - token.specialToken.image); - } else { - documentHandler.property(name, exp, important, null); - } - } - break; - case LBRACE: - jj_consume_token(LBRACE); - label_153: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[222] = jj_gen; - break label_153; - } - jj_consume_token(S); - } - documentHandler.startNestedProperties(name); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[223] = jj_gen; - ; - } - label_154: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[224] = jj_gen; - break label_154; - } - jj_consume_token(SEMICOLON); - label_155: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[225] = jj_gen; - break label_155; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[226] = jj_gen; - ; - } - } - jj_consume_token(RBRACE); - label_156: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[227] = jj_gen; - break label_156; - } - jj_consume_token(S); - } - documentHandler.endNestedProperties(name); - break; - default: - jj_la1[228] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public void declaration() throws ParseException { - boolean important = false; - String name; - LexicalUnit exp; - Token save; - try { - name = property(); - save = token; - jj_consume_token(COLON); - label_157: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[229] = jj_gen; - break label_157; - } - jj_consume_token(S); - } - exp = expr(); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORTANT_SYM: - important = prio(); - break; - default: - jj_la1[230] = jj_gen; - ; - } - documentHandler.property(name, exp, important); - } catch (JumpException e) { - skipAfterExpression(); - // reportWarningSkipText(getLocator(), skipAfterExpression()); - - } catch (NumberFormatException e) { - if (errorHandler != null) { - errorHandler.error(new CSSParseException("Invalid number " - + e.getMessage(), getLocator(), e)); - } - reportWarningSkipText(getLocator(), skipAfterExpression()); - } catch (ParseException e) { - if (errorHandler != null) { - if (e.currentToken != null) { - LocatorImpl li = new LocatorImpl(this, - e.currentToken.next.beginLine, - e.currentToken.next.beginColumn - 1); - reportError(li, e); - } else { - reportError(getLocator(), e); - } - skipAfterExpression(); - /* - * LocatorImpl loc = (LocatorImpl) getLocator(); loc.column--; - * reportWarningSkipText(loc, skipAfterExpression()); - */ - } else { - skipAfterExpression(); - } - } - } - - /** - * @exception ParseException - * exception during the parse - */ - final public boolean prio() throws ParseException { - jj_consume_token(IMPORTANT_SYM); - label_158: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[231] = jj_gen; - break label_158; - } - jj_consume_token(S); - } - { - if (true) { - return true; - } - } - throw new Error("Missing return statement in function"); - } - - final public boolean guarded() throws ParseException { - jj_consume_token(GUARDED_SYM); - label_159: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[232] = jj_gen; - break label_159; - } - jj_consume_token(S); - } - { - if (true) { - return true; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl operator(LexicalUnitImpl prev) - throws ParseException { - Token n; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case COMMA: - /* - * (comments copied from basic_arithmetics.scss)supports: 1. - * standard arithmetic operations (+, -, *, /, %) 2. / is treated as - * css operator, unless one of its operands is variable or there is - * another binary arithmetic operatorlimits: 1. cannot mix - * arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will - * fail 2. space between add and minus operator and their following - * operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not 3. - * parenthesis is not supported now. - */ - n = jj_consume_token(COMMA); - label_160: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[233] = jj_gen; - break label_160; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createComma(n.beginLine, - n.beginColumn, prev); - } - } - break; - case DIV: - n = jj_consume_token(DIV); - label_161: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[234] = jj_gen; - break label_161; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createSlash(n.beginLine, - n.beginColumn, prev); - } - } - break; - case ANY: - n = jj_consume_token(ANY); - label_162: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[235] = jj_gen; - break label_162; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createMultiply(n.beginLine, - n.beginColumn, prev); - } - } - break; - case MOD: - n = jj_consume_token(MOD); - label_163: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[236] = jj_gen; - break label_163; - } - jj_consume_token(S); - } - { - if (true) { - return LexicalUnitImpl.createModulo(n.beginLine, - n.beginColumn, prev); - } - } - break; - case PLUS: - n = jj_consume_token(PLUS); - label_164: while (true) { - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[237] = jj_gen; - break label_164; - } - } - { - if (true) { - return LexicalUnitImpl.createAdd(n.beginLine, - n.beginColumn, prev); - } - } - break; - case MINUS: - n = jj_consume_token(MINUS); - label_165: while (true) { - jj_consume_token(S); - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[238] = jj_gen; - break label_165; - } - } - { - if (true) { - return LexicalUnitImpl.createMinus(n.beginLine, - n.beginColumn, prev); - } - } - break; - default: - jj_la1[239] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl expr() throws ParseException { - LexicalUnitImpl first, res; - char op; - first = term(null); - res = first; - label_166: while (true) { - if (jj_2_8(2)) { - ; - } else { - break label_166; - } - if (jj_2_9(2)) { - res = operator(res); - } else { - ; - } - res = term(res); - } - { - if (true) { - return first; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public char unaryOperator() throws ParseException { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case MINUS: - jj_consume_token(MINUS); - { - if (true) { - return '-'; - } - } - break; - case PLUS: - jj_consume_token(PLUS); - { - if (true) { - return '+'; - } - } - break; - default: - jj_la1[240] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl term(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - result = nonVariableTerm(prev); - break; - case VARIABLE: - result = variableTerm(prev); - break; - default: - jj_la1[241] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl variableTerm(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - String varName = ""; - varName = variableName(); - result = LexicalUnitImpl.createVariable(token.beginLine, - token.beginColumn, prev, varName); - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) - throws ParseException { - LexicalUnitImpl result = null; - Token n = null; - char op = ' '; - String varName; - String s = ""; - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case NUMBER: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case FUNCTION: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - op = unaryOperator(); - break; - default: - jj_la1[242] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case NUMBER: - n = jj_consume_token(NUMBER); - result = LexicalUnitImpl.createNumber(n.beginLine, - n.beginColumn, prev, number(op, n, 0)); - break; - case PERCENTAGE: - n = jj_consume_token(PERCENTAGE); - result = LexicalUnitImpl.createPercentage(n.beginLine, - n.beginColumn, prev, number(op, n, 1)); - break; - case PT: - n = jj_consume_token(PT); - result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case CM: - n = jj_consume_token(CM); - result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case MM: - n = jj_consume_token(MM); - result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case PC: - n = jj_consume_token(PC); - result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case IN: - n = jj_consume_token(IN); - result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case PX: - n = jj_consume_token(PX); - result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case EMS: - n = jj_consume_token(EMS); - result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case LEM: - n = jj_consume_token(LEM); - result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case REM: - n = jj_consume_token(REM); - result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case EXS: - n = jj_consume_token(EXS); - result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case DEG: - n = jj_consume_token(DEG); - result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case RAD: - n = jj_consume_token(RAD); - result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case GRAD: - n = jj_consume_token(GRAD); - result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case SECOND: - n = jj_consume_token(SECOND); - result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, - prev, number(op, n, 1)); - break; - case MS: - n = jj_consume_token(MS); - result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case HZ: - n = jj_consume_token(HZ); - result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 2)); - break; - case KHZ: - n = jj_consume_token(KHZ); - result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, - prev, number(op, n, 3)); - break; - case DIMEN: - n = jj_consume_token(DIMEN); - s = n.image; - int i = 0; - while (i < s.length() - && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { - i++; - } - - result = LexicalUnitImpl.createDimen(n.beginLine, - n.beginColumn, prev, number(op, n, s.length() - i), - s.substring(i)); - break; - case FUNCTION: - result = function(op, prev); - break; - default: - jj_la1[243] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case URL: - case HASH: - case UNICODERANGE: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case STRING: - n = jj_consume_token(STRING); - result = LexicalUnitImpl.createString(n.beginLine, - n.beginColumn, prev, - convertStringIndex(n.image, 1, n.image.length() - 1)); - break; - case DOT: - case TO: - case THROUGH: - case FROM: - case IDENT: - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case DOT: - jj_consume_token(DOT); - s += "."; - break; - default: - jj_la1[244] = jj_gen; - ; - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IDENT: - n = jj_consume_token(IDENT); - break; - case TO: - n = jj_consume_token(TO); - break; - case THROUGH: - n = jj_consume_token(THROUGH); - break; - case FROM: - n = jj_consume_token(FROM); - break; - default: - jj_la1[245] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - s += convertIdent(n.image); - if ("inherit".equals(s)) { - result = LexicalUnitImpl.createInherit(n.beginLine, - n.beginColumn, prev); - } else { - result = LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, prev, convertIdent(n.image)); - } - - /* - * / Auto correction code used in the CSS Validator but must not - * be used by a conformant CSS2 parser. Common error : H1 { - * color : black background : white } - * - * Token t = getToken(1); Token semicolon = new Token(); - * semicolon.kind = SEMICOLON; semicolon.image = ";"; if (t.kind - * == COLON) { // @@SEEME. (generate a warning?) // @@SEEME if - * expression is a single ident, generate an error ? - * rejectToken(semicolon); - * - * result = prev; } / - */ - - break; - case HASH: - result = hexcolor(prev); - break; - case URL: - result = url(prev); - break; - case UNICODERANGE: - result = unicode(prev); - break; - default: - jj_la1[246] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - default: - jj_la1[247] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - label_167: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[248] = jj_gen; - break label_167; - } - jj_consume_token(S); - } - { - if (true) { - return result; - } - } - throw new Error("Missing return statement in function"); - } - - /** - * Handle all CSS2 functions. - * - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) - throws ParseException { - Token n; - LexicalUnit params = null; - n = jj_consume_token(FUNCTION); - label_168: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[249] = jj_gen; - break label_168; - } - jj_consume_token(S); - } - String fname = convertIdent(n.image); - if ("alpha(".equals(fname)) { - String body = skipStatementUntilSemiColon(); - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, null, "alpha(" + body); - } - } - } else if ("expression(".equals(fname)) { - String body = skipStatementUntilSemiColon(); - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, - n.beginColumn, null, "expression(" + body); - } - } - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case PLUS: - case MINUS: - case DOT: - case TO: - case THROUGH: - case FROM: - case STRING: - case IDENT: - case NUMBER: - case URL: - case VARIABLE: - case PERCENTAGE: - case PT: - case MM: - case CM: - case PC: - case IN: - case PX: - case EMS: - case LEM: - case REM: - case EXS: - case DEG: - case RAD: - case GRAD: - case MS: - case SECOND: - case HZ: - case KHZ: - case DIMEN: - case HASH: - case UNICODERANGE: - case FUNCTION: - params = expr(); - break; - default: - jj_la1[250] = jj_gen; - ; - } - jj_consume_token(RPARAN); - if (operator != ' ') { - { - if (true) { - throw new CSSParseException( - "invalid operator before a function.", getLocator()); - } - } - } - String f = convertIdent(n.image); - LexicalUnitImpl l = (LexicalUnitImpl) params; - boolean loop = true; - if ("rgb(".equals(f)) { - // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 2: - case 4: - if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) - && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - if (loop) { - l = l.getNextLexicalUnit(); - i++; - } - } - if ((i == 5) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createRGBColor(n.beginLine, - n.beginColumn, prev, params); - } - } - } else { - if (errorHandler != null) { - String errorText; - Locator loc; - if (i < 5) { - if (params == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn - 1); - errorText = "not enough parameters."; - } else if (l == null) { - loc = new LocatorImpl(this, n.beginLine, - n.beginColumn - 1); - errorText = "not enough parameters: " - + params.toString(); - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "invalid parameter: " + l.toString(); - } - } else { - loc = new LocatorImpl(this, l.getLineNumber(), - l.getColumnNumber()); - errorText = "too many parameters: " + l.toString(); - } - errorHandler.error(new CSSParseException(errorText, loc)); - } - - { - if (true) { - throw new JumpException(); - } - } - } - } else if ("counter".equals(f)) { - int i = 0; - while (loop && l != null && i < 3) { - switch (i) { - case 0: - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 1: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if (((i == 1) || (i == 3)) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createCounter(n.beginLine, - n.beginColumn, prev, params); - } - } - } - - } else if ("counters(".equals(f)) { - - int i = 0; - while (loop && l != null && i < 5) { - switch (i) { - case 0: - case 4: - if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { - loop = false; - } - break; - case 2: - if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { - loop = false; - } - break; - case 1: - case 3: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if (((i == 3) || (i == 5)) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createCounters(n.beginLine, - n.beginColumn, prev, params); - } - } - } - } else if ("attr(".equals(f)) { - if ((l != null) && (l.getNextLexicalUnit() == null) - && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { - { - if (true) { - return LexicalUnitImpl.createAttr(l.getLineNumber(), - l.getColumnNumber(), prev, l.getStringValue()); - } - } - } - } else if ("rect(".equals(f)) { - int i = 0; - while (loop && l != null && i < 7) { - switch (i) { - case 0: - case 2: - case 4: - case 6: - switch (l.getLexicalUnitType()) { - case LexicalUnit.SAC_INTEGER: - if (l.getIntegerValue() != 0) { - loop = false; - } - break; - case LexicalUnit.SAC_IDENT: - if (!l.getStringValue().equals("auto")) { - loop = false; - } - break; - case LexicalUnit.SAC_EM: - case LexicalUnit.SAC_EX: - case LexicalUnit.SAC_PIXEL: - case LexicalUnit.SAC_CENTIMETER: - case LexicalUnit.SAC_MILLIMETER: - case LexicalUnit.SAC_INCH: - case LexicalUnit.SAC_POINT: - case LexicalUnit.SAC_PICA: - // nothing - break; - default: - loop = false; - } - break; - case 1: - case 3: - case 5: - if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { - loop = false; - } - break; - default: { - if (true) { - throw new ParseException("implementation error"); - } - } - } - l = l.getNextLexicalUnit(); - i++; - } - if ((i == 7) && loop && (l == null)) { - { - if (true) { - return LexicalUnitImpl.createRect(n.beginLine, - n.beginColumn, prev, params); - } - } - } - } - { - if (true) { - return LexicalUnitImpl.createFunction(n.beginLine, - n.beginColumn, prev, f.substring(0, f.length() - 1), - params); - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl unicode(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(UNICODERANGE); - LexicalUnitImpl params = null; - String s = n.image.substring(2); - int index = s.indexOf('-'); - if (index == -1) { - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s, 16)); - } else { - String s1 = s.substring(0, index); - String s2 = s.substring(index); - - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s1, 16)); - params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, - params, Integer.parseInt(s2, 16)); - } - - { - if (true) { - return LexicalUnitImpl.createUnicodeRange(n.beginLine, - n.beginColumn, prev, params); - } - } - throw new Error("Missing return statement in function"); - } - - final public LexicalUnitImpl url(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(URL); - String urlname = n.image.substring(4, n.image.length() - 1).trim(); - { - if (true) { - return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, - prev, urlname); - } - } - throw new Error("Missing return statement in function"); - } - - /** - * @exception ParseException - * exception during the parse - */ - final public LexicalUnitImpl hexcolor(LexicalUnitImpl prev) - throws ParseException { - Token n; - n = jj_consume_token(HASH); - int r; - LexicalUnitImpl first, params = null; - String s = n.image.substring(1); - - if (s.length() != 3 && s.length() != 6) { - first = null; - { - if (true) { - throw new CSSParseException( - "invalid hexadecimal notation for RGB: " + s, - getLocator()); - } - } - } - { - if (true) { - return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, - prev, n.image); - } - } - throw new Error("Missing return statement in function"); - } - - float number(char operator, Token n, int lengthUnit) throws ParseException { - String image = n.image; - float f = 0; - - if (lengthUnit != 0) { - image = image.substring(0, image.length() - lengthUnit); - } - f = Float.valueOf(image).floatValue(); - return (operator == '-') ? -f : f; - } - - String skipStatementUntilSemiColon() throws ParseException { - int[] semicolon = { SEMICOLON }; - return skipStatementUntil(semicolon); - } - - String skipStatementUntilLeftBrace() throws ParseException { - int[] lBrace = { LBRACE }; - return skipStatementUntil(lBrace); - } - - String skipStatementUntilMatchingRightParan() throws ParseException { - int[] leftTokens = { LPARAN, FUNCTION }; // a FUNCTION also contains "(" - int[] rightTokens = { RPARAN }; - StringBuffer s = new StringBuffer(); - int difference = 1; - Token tok; - while (difference != 0) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - for (int sym : leftTokens) { - if (tok.kind == sym) { - difference++; - } - } - for (int sym : rightTokens) { - if (tok.kind == sym) { - difference--; - } - } - if (difference != 0) { - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); - } - - String skipStatementUntil(int[] symbols) throws ParseException { - StringBuffer s = new StringBuffer(); - boolean stop = false; - Token tok; - while (!stop) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - for (int sym : symbols) { - if (tok.kind == sym) { - stop = true; - break; - } - } - if (!stop) { - if (tok.image != null) { - s.append(tok.image); - } - getNextToken(); - } - } - return s.toString().trim(); - } - - String skipStatement() throws ParseException { - StringBuffer s = new StringBuffer(); - Token tok = getToken(0); - if (tok.image != null) { - s.append(tok.image); - } - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - return null; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - getNextToken(); - s.append(skip_to_matching_brace()); - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == RBRACE) { - getNextToken(); - tok = getToken(1); - break; - } else if (tok.kind == SEMICOLON) { - getNextToken(); - tok = getToken(1); - break; - } - getNextToken(); - } - - // skip white space - while (true) { - if (tok.kind != S) { - break; - } - tok = getNextToken(); - tok = getToken(1); - } - - return s.toString().trim(); - } - - String skip_to_matching_brace() throws ParseException { - StringBuffer s = new StringBuffer(); - Token tok; - int nesting = 1; - while (true) { - tok = getToken(1); - if (tok.kind == EOF) { - break; - } - s.append(tok.image); - if (tok.kind == LBRACE) { - nesting++; - } else if (tok.kind == RBRACE) { - nesting--; - if (nesting == 0) { - break; - } - } - getNextToken(); - } - return s.toString(); - } - - String convertStringIndex(String s, int start, int len) - throws ParseException { - StringBuffer buf = new StringBuffer(len); - int index = start; - - while (index < len) { - char c = s.charAt(index); - if (c == '\u005c\u005c') { - if (++index < len) { - c = s.charAt(index); - switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - buf.append('\u005c\u005c'); - while (index < len) { - buf.append(s.charAt(index++)); - } - break; - case '\u005cn': - case '\u005cf': - break; - case '\u005cr': - if (index + 1 < len) { - if (s.charAt(index + 1) == '\u005cn') { - index++; - } - } - break; - default: - buf.append(c); - } - } else { - throw new CSSParseException("invalid string " + s, - getLocator()); - } - } else { - buf.append(c); - } - index++; - } - - return buf.toString(); - } - - String convertIdent(String s) throws ParseException { - return convertStringIndex(s, 0, s.length()); - } - - String convertString(String s) throws ParseException { - return convertStringIndex(s, 0, s.length()); - } - - void comments() throws ParseException { - /* - * keeps only the multiple line comments, single line comments are - * skipped - */ - if (token.specialToken != null && token.specialToken.image != null - && token.specialToken.image.startsWith("/*")) { - Token tmp_t = token.specialToken; - while (tmp_t.specialToken != null) { - tmp_t = tmp_t.specialToken; - } - while (tmp_t != null) { - documentHandler.comment(tmp_t.image); - tmp_t = tmp_t.next; - } - } - } - - void rejectToken(Token t) throws ParseException { - Token fakeToken = new Token(); - t.next = token; - fakeToken.next = t; - token = fakeToken; - } - - String skipAfterExpression() throws ParseException { - Token t = getToken(1); - StringBuffer s = new StringBuffer(); - s.append(getToken(0).image); - - while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { - s.append(t.image); - getNextToken(); - t = getToken(1); - } - - return s.toString(); - } - - /** - * The following functions are useful for a DOM CSS implementation only and - * are not part of the general CSS2 parser. - */ - // TODO required by original parser but not used by Vaadin? - final public void _parseRule() throws ParseException { - String ret = null; - label_169: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[251] = jj_gen; - break label_169; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case IMPORT_SYM: - importDeclaration(); - break; - case DEBUG_SYM: - case WARN_SYM: - debuggingDirective(); - break; - case PLUS: - case PRECEDES: - case SIBLING: - case LBRACKET: - case ANY: - case PARENT: - case DOT: - case COLON: - case INTERPOLATION: - case IDENT: - case HASH: - styleRule(); - break; - case MEDIA_SYM: - media(); - break; - case PAGE_SYM: - page(); - break; - case FONT_FACE_SYM: - fontFace(); - break; - default: - jj_la1[252] = jj_gen; - ret = skipStatement(); - if ((ret == null) || (ret.length() == 0)) { - { - if (true) { - return; - } - } - } - if (ret.charAt(0) == '@') { - documentHandler.unrecognizedRule(ret); - } else { - { - if (true) { - throw new CSSParseException("unrecognize rule: " + ret, - getLocator()); - } - } - } - } - } - - final public void _parseImportRule() throws ParseException { - label_170: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[253] = jj_gen; - break label_170; - } - jj_consume_token(S); - } - importDeclaration(); - } - - final public void _parseMediaRule() throws ParseException { - label_171: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[254] = jj_gen; - break label_171; - } - jj_consume_token(S); - } - media(); - } - - final public void _parseDeclarationBlock() throws ParseException { - label_172: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[255] = jj_gen; - break label_172; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[256] = jj_gen; - ; - } - label_173: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case SEMICOLON: - ; - break; - default: - jj_la1[257] = jj_gen; - break label_173; - } - jj_consume_token(SEMICOLON); - label_174: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[258] = jj_gen; - break label_174; - } - jj_consume_token(S); - } - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case INTERPOLATION: - case IDENT: - declaration(); - break; - default: - jj_la1[259] = jj_gen; - ; - } - } - } - - final public ArrayList _parseSelectors() throws ParseException { - ArrayList p = null; - try { - label_175: while (true) { - switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { - case S: - ; - break; - default: - jj_la1[260] = jj_gen; - break label_175; - } - jj_consume_token(S); - } - p = selectorList(); - { - if (true) { - return p; - } - } - } catch (ThrowedParseException e) { - { - if (true) { - throw (ParseException) e.e.fillInStackTrace(); - } - } - } - throw new Error("Missing return statement in function"); - } - - private boolean jj_2_1(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_1(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(0, xla); - } - } - - private boolean jj_2_2(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_2(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(1, xla); - } - } - - private boolean jj_2_3(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_3(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(2, xla); - } - } - - private boolean jj_2_4(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_4(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(3, xla); - } - } - - private boolean jj_2_5(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_5(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(4, xla); - } - } - - private boolean jj_2_6(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_6(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(5, xla); - } - } - - private boolean jj_2_7(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_7(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(6, xla); - } - } - - private boolean jj_2_8(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_8(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(7, xla); - } - } - - private boolean jj_2_9(int xla) { - jj_la = xla; - jj_lastpos = jj_scanpos = token; - try { - return !jj_3_9(); - } catch (LookaheadSuccess ls) { - return true; - } finally { - jj_save(8, xla); - } - } - - private boolean jj_3R_209() { - if (jj_scan_token(MINUS)) { - return true; - } - Token xsp; - if (jj_scan_token(1)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_188() { - if (jj_3R_210()) { - return true; - } - return false; - } - - private boolean jj_3R_208() { - if (jj_scan_token(PLUS)) { - return true; - } - Token xsp; - if (jj_scan_token(1)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_207() { - if (jj_scan_token(MOD)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_206() { - if (jj_scan_token(ANY)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_205() { - if (jj_scan_token(DIV)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_204() { - if (jj_scan_token(COMMA)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_185() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_204()) { - jj_scanpos = xsp; - if (jj_3R_205()) { - jj_scanpos = xsp; - if (jj_3R_206()) { - jj_scanpos = xsp; - if (jj_3R_207()) { - jj_scanpos = xsp; - if (jj_3R_208()) { - jj_scanpos = xsp; - if (jj_3R_209()) { - return true; - } - } - } - } - } - } - return false; - } - - private boolean jj_3R_212() { - if (jj_3R_211()) { - return true; - } - return false; - } - - private boolean jj_3R_211() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(18)) { - jj_scanpos = xsp; - if (jj_scan_token(22)) { - jj_scanpos = xsp; - if (jj_scan_token(23)) { - return true; - } - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_191() { - if (jj_scan_token(S)) { - return true; - } - Token xsp; - xsp = jj_scanpos; - if (jj_3R_212()) { - jj_scanpos = xsp; - } - return false; - } - - private boolean jj_3R_210() { - if (jj_scan_token(GUARDED_SYM)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_176() { - if (jj_3R_186()) { - return true; - } - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_3R_187()) { - return true; - } - xsp = jj_scanpos; - if (jj_3R_188()) { - jj_scanpos = xsp; - } - if (jj_3R_189()) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_3R_189()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_190() { - if (jj_3R_211()) { - return true; - } - return false; - } - - private boolean jj_3R_177() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_190()) { - jj_scanpos = xsp; - if (jj_3R_191()) { - return true; - } - } - return false; - } - - private boolean jj_3R_194() { - if (jj_scan_token(VARIABLE)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(COLON)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_179() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_194()) { - jj_scanpos = xsp; - } - if (jj_scan_token(CONTAINS)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (true) { - jj_la = 0; - jj_scanpos = jj_lastpos; - return false; - } - return false; - } - - private boolean jj_3R_262() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } - - private boolean jj_3R_279() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_280() { - if (jj_scan_token(FUNCTION)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (true) { - jj_la = 0; - jj_scanpos = jj_lastpos; - return false; - } - return false; - } - - private boolean jj_3R_278() { - if (jj_scan_token(COLON)) { - return true; - } - return false; - } - - private boolean jj_3R_265() { - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - xsp = jj_scanpos; - if (jj_3R_278()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_3R_279()) { - jj_scanpos = xsp; - if (jj_3R_280()) { - return true; - } - } - return false; - } - - private boolean jj_3_7() { - if (jj_3R_183()) { - return true; - } - return false; - } - - private boolean jj_3R_201() { - if (jj_scan_token(LBRACE)) { - return true; - } - return false; - } - - private boolean jj_3R_290() { - if (jj_scan_token(STRING)) { - return true; - } - return false; - } - - private boolean jj_3R_288() { - if (jj_scan_token(STARMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_287() { - if (jj_scan_token(DOLLARMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_289() { - if (jj_scan_token(IDENT)) { - return true; - } - return false; - } - - private boolean jj_3R_286() { - if (jj_scan_token(CARETMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_285() { - if (jj_scan_token(DASHMATCH)) { - return true; - } - return false; - } - - private boolean jj_3R_284() { - if (jj_scan_token(INCLUDES)) { - return true; - } - return false; - } - - private boolean jj_3R_270() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } - - private boolean jj_3R_283() { - if (jj_scan_token(EQ)) { - return true; - } - return false; - } - - private boolean jj_3R_200() { - if (jj_3R_187()) { - return true; - } - return false; - } - - private boolean jj_3R_277() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_283()) { - jj_scanpos = xsp; - if (jj_3R_284()) { - jj_scanpos = xsp; - if (jj_3R_285()) { - jj_scanpos = xsp; - if (jj_3R_286()) { - jj_scanpos = xsp; - if (jj_3R_287()) { - jj_scanpos = xsp; - if (jj_3R_288()) { - return true; - } - } - } - } - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_289()) { - jj_scanpos = xsp; - if (jj_3R_290()) { - return true; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3_6() { - if (jj_3R_182()) { - return true; - } - if (jj_scan_token(LBRACE)) { - return true; - } - return false; - } - - private boolean jj_3R_264() { - if (jj_scan_token(LBRACKET)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - if (jj_scan_token(IDENT)) { - return true; - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_277()) { - jj_scanpos = xsp; - } - if (jj_scan_token(RBRACKET)) { - return true; - } - return false; - } - - private boolean jj_3R_183() { - if (jj_3R_199()) { - return true; - } - if (jj_scan_token(COLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_200()) { - jj_scanpos = xsp; - if (jj_3R_201()) { - return true; - } - } - return false; - } - - private boolean jj_3R_282() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } - - private boolean jj_3R_268() { - if (jj_3R_187()) { - return true; - } - return false; - } - - private boolean jj_3R_248() { - if (jj_scan_token(PARENT)) { - return true; - } - return false; - } - - private boolean jj_3R_247() { - if (jj_scan_token(ANY)) { - return true; - } - return false; - } - - private boolean jj_3R_261() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_269()) { - jj_scanpos = xsp; - if (jj_3R_270()) { - return true; - } - } - return false; - } - - private boolean jj_3R_269() { - if (jj_scan_token(IDENT)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[19] = jj_gen; + break label_14; } - return false; - } - - private boolean jj_3R_213() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_246()) { - jj_scanpos = xsp; - if (jj_3R_247()) { - jj_scanpos = xsp; - if (jj_3R_248()) { - return true; - } - } + } + label_15: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[20] = jj_gen; + break label_15; + } + jj_consume_token(S); + } + start = true; documentHandler.startKeyFrames(keyframeName, animationname); + jj_consume_token(LBRACE); + label_16: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[21] = jj_gen; + break label_16; + } + jj_consume_token(S); + } + label_17: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case TO: + case FROM: + case CONTENT_SYM: + case PERCENTAGE: + ; + break; + default: + jj_la1[22] = jj_gen; + break label_17; } - return false; - } - - private boolean jj_3R_246() { - Token xsp; - if (jj_3R_261()) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case TO: + case FROM: + case PERCENTAGE: + keyframeSelector(); + break; + case CONTENT_SYM: + contentDirective(); + break; + default: + jj_la1[23] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_18: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[24] = jj_gen; + break label_18; + } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + } finally { + if (start) { + documentHandler.endKeyFrames(); + } + } + } + + final public void keyframeSelector() throws ParseException { + Token n; + String selector = ""; + boolean start = false; + try { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case FROM: + n = jj_consume_token(FROM); + break; + case TO: + n = jj_consume_token(TO); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + default: + jj_la1[25] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + selector += n.image; + label_19: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[26] = jj_gen; + break label_19; + } + jj_consume_token(S); + } + label_20: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[27] = jj_gen; + break label_20; } + jj_consume_token(COMMA); + label_21: while (true) { - xsp = jj_scanpos; - if (jj_3R_261()) { - jj_scanpos = xsp; - break; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[28] = jj_gen; + break label_21; + } + jj_consume_token(S); } - return false; - } - - private boolean jj_3R_254() { - if (jj_scan_token(FUNCTION)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case FROM: + n = jj_consume_token(FROM); + break; + case TO: + n = jj_consume_token(TO); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + default: + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - Token xsp; + selector += (", " + n.image); + label_22: while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - xsp = jj_scanpos; - if (jj_3R_268()) { - jj_scanpos = xsp; - } - if (jj_scan_token(RPARAN)) { - return true; - } - return false; - } - - private boolean jj_3R_180() { - if (jj_scan_token(COMMA)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[30] = jj_gen; + break label_22; + } + jj_consume_token(S); + } + } + jj_consume_token(LBRACE); + label_23: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[31] = jj_gen; + break label_23; + } + jj_consume_token(S); + } + start = true; + documentHandler.startKeyframeSelector(selector); + label_24: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case MICROSOFT_RULE: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[32] = jj_gen; + break label_24; } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case MICROSOFT_RULE: + microsoftExtension(); + break; + default: + jj_la1[33] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_25: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[34] = jj_gen; + break label_25; } - return false; - } - - private boolean jj_3R_241() { - if (jj_3R_258()) { - return true; + jj_consume_token(S); + } + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); } - return false; - } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); - private boolean jj_3R_276() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_281()) { - jj_scanpos = xsp; - if (jj_3R_282()) { - return true; - } + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endKeyframeSelector(); } - return false; } + } - private boolean jj_3R_281() { - if (jj_scan_token(IDENT)) { - return true; +/** + * @exception ParseException exception during the parse + */ +/* see http://www.w3.org/TR/css3-mediaqueries/ */ + final public void media() throws ParseException { + boolean start = false; + String ret; + MediaListImpl ml = new MediaListImpl(); + try { + jj_consume_token(MEDIA_SYM); + label_26: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[35] = jj_gen; + break label_26; + } + jj_consume_token(S); + } + mediaStatement(ml); + start = true; documentHandler.startMedia(ml); + jj_consume_token(LBRACE); + label_27: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[36] = jj_gen; + break label_27; + } + jj_consume_token(S); + } + label_28: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CDO: + case LBRACE: + case DASHMATCH: + case INCLUDES: + case PLUS: + case MINUS: + case COMMA: + case SEMICOLON: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case NONASCII: + case DEBUG_SYM: + case WARN_SYM: + case CONTENT_SYM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case PERCENTAGE: + case HASH: + case IMPORT_SYM: + case MEDIA_SYM: + case CHARSET_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case ATKEYWORD: + case IMPORTANT_SYM: + case UNICODERANGE: + case FUNCTION: + case UNKNOWN: + ; + break; + default: + jj_la1[37] = jj_gen; + break label_28; + } + mediaDirective(); + } + jj_consume_token(RBRACE); + label_29: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[38] = jj_gen; + break label_29; + } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } finally { + if (start) { + documentHandler.endMedia(ml); + } + } + } + + final public void mediaDirective() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case CDO: + case LBRACE: + case DASHMATCH: + case INCLUDES: + case MINUS: + case COMMA: + case SEMICOLON: + case NONASCII: + case STRING: + case NUMBER: + case URL: + case PERCENTAGE: + case IMPORT_SYM: + case MEDIA_SYM: + case CHARSET_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case ATKEYWORD: + case IMPORTANT_SYM: + case UNICODERANGE: + case FUNCTION: + case UNKNOWN: + skipUnknownRule(); + break; + case CONTENT_SYM: + contentDirective(); + break; + default: + jj_la1[39] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void mediaStatement(MediaListImpl ml) throws ParseException { + Token t; + t = getToken(1); + // loop over comma separated parts, add each to ml + while ((t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != LBRACE) && (t.kind != EOF) && (t.kind != SEMICOLON)) { + s.append(t.image); + getNextToken(); + t = getToken(1); } - return false; - } - - private boolean jj_3R_240() { - if (jj_3R_257()) { - return true; + if (t.kind == COMMA) { + // skip the comma and the token before it that is still the active token + getNextToken(); + getNextToken(); + t = getToken(1); } - return false; - } - - private boolean jj_3R_239() { - if (jj_3R_256()) { - return true; + String str = s.toString().trim(); + if (str.length() > 0) { + ml.addItem(str); } - return false; - } + } + } - private boolean jj_3_5() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_180()) { - jj_scanpos = xsp; - } - if (jj_3R_181()) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String medium() throws ParseException { + Token n; + n = jj_consume_token(IDENT); + {if (true) return convertIdent(n.image);} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_263() { - if (jj_scan_token(DOT)) { - return true; - } - Token xsp; - if (jj_3R_276()) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void page() throws ParseException { + boolean start = false; + Token n = null; + String page = null; + String pseudo = null; + try { + jj_consume_token(PAGE_SYM); + label_30: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[40] = jj_gen; + break label_30; } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + label_31: while (true) { - xsp = jj_scanpos; - if (jj_3R_276()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_252() { - if (jj_3R_265()) { - return true; - } - return false; - } - - private boolean jj_3R_275() { - if (jj_3R_265()) { - return true; - } - return false; - } - - private boolean jj_3R_273() { - if (jj_3R_263()) { - return true; - } - return false; - } - - private boolean jj_3R_250() { - if (jj_3R_263()) { - return true; - } - return false; - } - - private boolean jj_3R_251() { - if (jj_3R_264()) { - return true; - } - return false; - } - - private boolean jj_3R_274() { - if (jj_3R_264()) { - return true; - } - return false; - } - - private boolean jj_3R_255() { - if (jj_scan_token(DOT)) { - return true; - } - return false; - } - - private boolean jj_3R_271() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_272()) { - jj_scanpos = xsp; - if (jj_3R_273()) { - jj_scanpos = xsp; - if (jj_3R_274()) { - jj_scanpos = xsp; - if (jj_3R_275()) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_272() { - if (jj_3R_262()) { - return true; - } - return false; - } - - private boolean jj_3R_238() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_255()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_scan_token(72)) { - jj_scanpos = xsp; - if (jj_scan_token(49)) { - jj_scanpos = xsp; - if (jj_scan_token(50)) { - jj_scanpos = xsp; - if (jj_scan_token(52)) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_237() { - if (jj_scan_token(STRING)) { - return true; - } - return false; - } - - private boolean jj_3R_214() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_249()) { - jj_scanpos = xsp; - if (jj_3R_250()) { - jj_scanpos = xsp; - if (jj_3R_251()) { - jj_scanpos = xsp; - if (jj_3R_252()) { - return true; - } - } - } - } - return false; - } - - private boolean jj_3R_249() { - if (jj_3R_262()) { - return true; - } - return false; - } - - private boolean jj_3R_236() { - if (jj_3R_254()) { - return true; - } - return false; - } - - private boolean jj_3R_196() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_237()) { - jj_scanpos = xsp; - if (jj_3R_238()) { - jj_scanpos = xsp; - if (jj_3R_239()) { - jj_scanpos = xsp; - if (jj_3R_240()) { - jj_scanpos = xsp; - if (jj_3R_241()) { - return true; - } - } - } - } - } - return false; - } - - private boolean jj_3R_193() { - Token xsp; - if (jj_3R_214()) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[41] = jj_gen; + break label_31; + } + jj_consume_token(S); + } + break; + default: + jj_la1[42] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + pseudo = pseudo_page(); + break; + default: + jj_la1[43] = jj_gen; + ; + } + if (n != null) { + page = convertIdent(n.image); + } + jj_consume_token(LBRACE); + label_32: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[44] = jj_gen; + break label_32; + } + jj_consume_token(S); + } + start = true; + documentHandler.startPage(page, pseudo); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[45] = jj_gen; + ; + } + label_33: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[46] = jj_gen; + break label_33; } + jj_consume_token(SEMICOLON); + label_34: while (true) { - xsp = jj_scanpos; - if (jj_3R_214()) { - jj_scanpos = xsp; - break; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[47] = jj_gen; + break label_34; + } + jj_consume_token(S); } - return false; - } - - private boolean jj_3R_192() { - if (jj_3R_213()) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[48] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + label_35: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[49] = jj_gen; + break label_35; + } + jj_consume_token(S); + } + } catch (ParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + skipStatement(); + // reportWarningSkipText(li, skipStatement()); + } else { + skipStatement(); + } + } finally { + if (start) { + documentHandler.endPage(page, pseudo); + } + } + } + + final public String pseudo_page() throws ParseException { + Token n; + jj_consume_token(COLON); + n = jj_consume_token(IDENT); + label_36: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[50] = jj_gen; + break label_36; + } + jj_consume_token(S); + } + {if (true) return convertIdent(n.image);} + throw new Error("Missing return statement in function"); + } + + final public void fontFace() throws ParseException { + boolean start = false; + try { + jj_consume_token(FONT_FACE_SYM); + label_37: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[51] = jj_gen; + break label_37; + } + jj_consume_token(S); + } + jj_consume_token(LBRACE); + label_38: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[52] = jj_gen; + break label_38; + } + jj_consume_token(S); + } + start = true; documentHandler.startFontFace(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[53] = jj_gen; + ; + } + label_39: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[54] = jj_gen; + break label_39; } - Token xsp; + jj_consume_token(SEMICOLON); + label_40: while (true) { - xsp = jj_scanpos; - if (jj_3R_271()) { - jj_scanpos = xsp; - break; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[55] = jj_gen; + break label_40; + } + jj_consume_token(S); } - return false; - } - - private boolean jj_3R_178() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_192()) { - jj_scanpos = xsp; - if (jj_3R_193()) { - return true; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[56] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + label_41: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[57] = jj_gen; + break label_41; } - return false; - } + jj_consume_token(S); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); - private boolean jj_3R_243() { - if (jj_3R_211()) { - return true; - } - if (jj_3R_178()) { - return true; - } - return false; + } finally { + if (start) { + documentHandler.endFontFace(); + } } + } - private boolean jj_3R_235() { - if (jj_scan_token(DIMEN)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void atRuleDeclaration() throws ParseException { + Token n; + String ret; + n = jj_consume_token(ATKEYWORD); + ret=skipStatement(); + if ((ret != null) && (ret.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(getLocator(), ret); } - return false; - } + } + + final public void skipUnknownRule() throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ATKEYWORD: + n = jj_consume_token(ATKEYWORD); + break; + case CDO: + n = jj_consume_token(CDO); + break; + case CHARSET_SYM: + n = jj_consume_token(CHARSET_SYM); + break; + case COMMA: + n = jj_consume_token(COMMA); + break; + case DASHMATCH: + n = jj_consume_token(DASHMATCH); + break; + case FONT_FACE_SYM: + n = jj_consume_token(FONT_FACE_SYM); + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + break; + case IMPORTANT_SYM: + n = jj_consume_token(IMPORTANT_SYM); + break; + case IMPORT_SYM: + n = jj_consume_token(IMPORT_SYM); + break; + case INCLUDES: + n = jj_consume_token(INCLUDES); + break; + case LBRACE: + n = jj_consume_token(LBRACE); + break; + case MEDIA_SYM: + n = jj_consume_token(MEDIA_SYM); + break; + case NONASCII: + n = jj_consume_token(NONASCII); + break; + case NUMBER: + n = jj_consume_token(NUMBER); + break; + case PAGE_SYM: + n = jj_consume_token(PAGE_SYM); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + break; + case STRING: + n = jj_consume_token(STRING); + break; + case UNICODERANGE: + n = jj_consume_token(UNICODERANGE); + break; + case URL: + n = jj_consume_token(URL); + break; + case SEMICOLON: + n = jj_consume_token(SEMICOLON); + break; + case MINUS: + n = jj_consume_token(MINUS); + break; + case UNKNOWN: + n = jj_consume_token(UNKNOWN); + break; + default: + jj_la1[58] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + String ret; + Locator loc = getLocator(); + ret=skipStatement(); + if ((ret != null) && (n.image.charAt(0) == '@')) { + documentHandler.unrecognizedRule(ret); + } else { + reportWarningSkipText(loc, ret); + } + } - private boolean jj_3R_234() { - if (jj_scan_token(KHZ)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public char combinator() throws ParseException { +char connector = ' '; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + connector = combinatorChar(); + break; + case S: + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + connector = combinatorChar(); + break; + default: + jj_la1[59] = jj_gen; + ; + } + break; + default: + jj_la1[60] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return connector;} + throw new Error("Missing return statement in function"); + } + +/**to refactor combinator and reuse in selector().*/ + final public char combinatorChar() throws ParseException { + Token t; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + t = jj_consume_token(PLUS); + break; + case PRECEDES: + t = jj_consume_token(PRECEDES); + break; + case SIBLING: + t = jj_consume_token(SIBLING); + break; + default: + jj_la1[61] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_42: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[62] = jj_gen; + break label_42; + } + jj_consume_token(S); + } + {if (true) return t.image.charAt(0);} + throw new Error("Missing return statement in function"); + } + + final public void microsoftExtension() throws ParseException { + Token n; + String name = ""; + String value = ""; + // This is not really taking the syntax of filter rules into account + n = jj_consume_token(MICROSOFT_RULE); + label_43: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[63] = jj_gen; + break label_43; + } + jj_consume_token(S); + } + name = n.image; + jj_consume_token(COLON); + label_44: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + value += n.image; + break; + case NUMBER: + n = jj_consume_token(NUMBER); + value += n.image; + break; + case STRING: + n = jj_consume_token(STRING); + value += n.image; + break; + case COMMA: + n = jj_consume_token(COMMA); + value += n.image; + break; + case INTERPOLATION: + n = jj_consume_token(INTERPOLATION); + value += n.image; + break; + case COLON: + n = jj_consume_token(COLON); + value += n.image; + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + value += n.image; + break; + case RPARAN: + n = jj_consume_token(RPARAN); + value += n.image; + break; + case EQ: + n = jj_consume_token(EQ); + value += n.image; + break; + case DOT: + n = jj_consume_token(DOT); + value += n.image; + break; + case S: + n = jj_consume_token(S); + if(value.lastIndexOf(' ') != value.length()-1) + { value += n.image; } + break; + default: + jj_la1[64] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case EQ: + case COMMA: + case DOT: + case RPARAN: + case COLON: + case INTERPOLATION: + case STRING: + case IDENT: + case NUMBER: + case FUNCTION: + ; + break; + default: + jj_la1[65] = jj_gen; + break label_44; + } + } + jj_consume_token(SEMICOLON); + label_45: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[66] = jj_gen; + break label_45; + } + jj_consume_token(S); + } + documentHandler.microsoftDirective(name, value); + } - private boolean jj_3R_233() { - if (jj_scan_token(HZ)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String property() throws ParseException { + Token t;String s = ""; + label_46: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[67] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[68] = jj_gen; + break label_46; + } + } + label_47: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[69] = jj_gen; + break label_47; + } + jj_consume_token(S); + } + {if (true) return s;} + throw new Error("Missing return statement in function"); + } + + final public String variableName() throws ParseException { + Token n; + n = jj_consume_token(VARIABLE); + label_48: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[70] = jj_gen; + break label_48; + } + jj_consume_token(S); + } + {if (true) return convertIdent(n.image.substring(1));} + throw new Error("Missing return statement in function"); + } + + final public String functionName() throws ParseException { + Token n; + n = jj_consume_token(FUNCTION); + label_49: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[71] = jj_gen; + break label_49; + } + jj_consume_token(S); + } + {if (true) return convertIdent(n.image.substring(0, n.image.length()-1));} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_232() { - if (jj_scan_token(MS)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void styleRule() throws ParseException { + boolean start = false; + ArrayList l = null; + Token save; + Locator loc; + try { + l = selectorList(); + save = token; + jj_consume_token(LBRACE); + label_50: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[72] = jj_gen; + break label_50; + } + jj_consume_token(S); + } + start = true; + documentHandler.startSelector(l); + label_51: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case MICROSOFT_RULE: + case IDENT: + case VARIABLE: + case HASH: + case IMPORT_SYM: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[73] = jj_gen; + break label_51; } - return false; - } - - private boolean jj_3R_231() { - if (jj_scan_token(SECOND)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case MICROSOFT_RULE: + microsoftExtension(); + break; + case IMPORT_SYM: + importDeclaration(); + break; + default: + jj_la1[74] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_52: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[75] = jj_gen; + break label_52; + } + jj_consume_token(S); + } + } catch (ThrowedParseException e) { + if (errorHandler != null) { + LocatorImpl li = new LocatorImpl(this, + e.e.currentToken.next.beginLine, + e.e.currentToken.next.beginColumn-1); + reportError(li, e.e); + } + } catch (ParseException e) { + reportError(getLocator(), e); + skipStatement(); + // reportWarningSkipText(getLocator(), skipStatement()); + + } catch (TokenMgrError e) { + reportWarningSkipText(getLocator(), skipStatement()); + } finally { + if (start) { + documentHandler.endSelector(); + } + } + } + + final public ArrayList selectorList() throws ParseException { + ArrayList selectors = new ArrayList(); + String selector; + selector = selector(); + label_53: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[76] = jj_gen; + break label_53; + } + jj_consume_token(COMMA); + label_54: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[77] = jj_gen; + break label_54; } - return false; + jj_consume_token(S); + } + selectors.add(selector); + selector = selector(); } + selectors.add(selector); + {if (true) return selectors;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_230() { - if (jj_scan_token(GRAD)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String selector() throws ParseException { + String selector = null; + char comb; + try { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + selector = simple_selector(null, ' '); + break; + case PLUS: + case PRECEDES: + case SIBLING: + comb = combinatorChar(); + selector = simple_selector(selector, comb); + break; + default: + jj_la1[78] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_55: + while (true) { + if (jj_2_2(2)) { + ; + } else { + break label_55; + } + comb = combinator(); + selector = simple_selector(selector, comb); + } + label_56: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[79] = jj_gen; + break label_56; + } + jj_consume_token(S); + } + {if (true) return selector;} + } catch (ParseException e) { + /* + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); + } + reportWarningSkipText(getLocator(), s.toString()); + */ + Token t = getToken(1); + while ((t.kind != COMMA) && (t.kind != SEMICOLON) + && (t.kind != LBRACE) && (t.kind != EOF)) { + getNextToken(); + t = getToken(1); + } - private boolean jj_3R_229() { - if (jj_scan_token(RAD)) { - return true; - } - return false; + {if (true) throw new ThrowedParseException(e);} } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_228() { - if (jj_scan_token(DEG)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public String simple_selector(String selector, char comb) throws ParseException { + String simple_current = null; + String cond = null; + + pseudoElt = null; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ANY: + case PARENT: + case INTERPOLATION: + case IDENT: + simple_current = element_name(); + label_57: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + case DOT: + case COLON: + case HASH: + ; + break; + default: + jj_la1[80] = jj_gen; + break label_57; } - return false; - } - - private boolean jj_3R_227() { - if (jj_scan_token(EXS)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASH: + cond = hash(cond); + break; + case DOT: + cond = _class(cond); + break; + case LBRACKET: + cond = attrib(cond); + break; + case COLON: + cond = pseudo(cond); + break; + default: + jj_la1[81] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + break; + case LBRACKET: + case DOT: + case COLON: + case HASH: + label_58: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case HASH: + cond = hash(cond); + break; + case DOT: + cond = _class(cond); + break; + case LBRACKET: + cond = attrib(cond); + break; + case COLON: + cond = pseudo(cond); + break; + default: + jj_la1[82] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - return false; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LBRACKET: + case DOT: + case COLON: + case HASH: + ; + break; + default: + jj_la1[83] = jj_gen; + break label_58; + } + } + break; + default: + jj_la1[84] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + if (simple_current == null) { + simple_current = ""; + } + if (cond != null) { + simple_current = simple_current + cond; + } + StringBuilder builder = new StringBuilder(); + switch (comb) { + case ' ': + if(selector!=null){ + builder.append(selector).append(" "); + } + break; + case '+': + case '>': + case '~': + if(selector!=null){ + builder.append(selector).append(" "); + } + builder.append(comb).append(" "); + break; + default: + {if (true) throw new ParseException("invalid state. send a bug report");} + } + builder.append(simple_current); + selector = builder.toString(); - private boolean jj_3R_226() { - if (jj_scan_token(REM)) { - return true; - } - return false; - } + if (pseudoElt != null) { + selector = selector + pseudoElt; + } + {if (true) return selector;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3_2() { - if (jj_3R_177()) { - return true; - } - if (jj_3R_178()) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String _class(String pred) throws ParseException { + Token t; +String s = "."; + jj_consume_token(DOT); + label_59: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[85] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[86] = jj_gen; + break label_59; + } + } + if (pred == null) { + {if (true) return s;} + } else { + {if (true) return pred + s;} + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_225() { - if (jj_scan_token(LEM)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public String element_name() throws ParseException { + Token t; String s = ""; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + label_60: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + t = jj_consume_token(IDENT); + s += t.image; + break; + case INTERPOLATION: + t = jj_consume_token(INTERPOLATION); + s += t.image; + break; + default: + jj_la1[87] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } - return false; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + ; + break; + default: + jj_la1[88] = jj_gen; + break label_60; + } + } + {if (true) return s;} + break; + case ANY: + jj_consume_token(ANY); + {if (true) return "*";} + break; + case PARENT: + jj_consume_token(PARENT); + {if (true) return "&";} + break; + default: + jj_la1[89] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_224() { - if (jj_scan_token(EMS)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String attrib(String pred) throws ParseException { + int cases = 0; + Token att = null; + Token val = null; + String attValue = null; + jj_consume_token(LBRACKET); + label_61: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[90] = jj_gen; + break label_61; + } + jj_consume_token(S); + } + att = jj_consume_token(IDENT); + label_62: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[91] = jj_gen; + break label_62; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DASHMATCH: + case CARETMATCH: + case DOLLARMATCH: + case STARMATCH: + case INCLUDES: + case EQ: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case EQ: + jj_consume_token(EQ); + cases = 1; + break; + case INCLUDES: + jj_consume_token(INCLUDES); + cases = 2; + break; + case DASHMATCH: + jj_consume_token(DASHMATCH); + cases = 3; + break; + case CARETMATCH: + jj_consume_token(CARETMATCH); + cases = 4; + break; + case DOLLARMATCH: + jj_consume_token(DOLLARMATCH); + cases = 5; + break; + case STARMATCH: + jj_consume_token(STARMATCH); + cases = 6; + break; + default: + jj_la1[92] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_63: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[93] = jj_gen; + break label_63; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + val = jj_consume_token(IDENT); + attValue = val.image; + break; + case STRING: + val = jj_consume_token(STRING); + attValue = val.image; + break; + default: + jj_la1[94] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_64: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[95] = jj_gen; + break label_64; + } + jj_consume_token(S); + } + break; + default: + jj_la1[96] = jj_gen; + ; + } + jj_consume_token(RBRACKET); + String name = convertIdent(att.image); + String c; + switch (cases) { + case 0: + c = name; + break; + case 1: + c = name + "=" + attValue; + break; + case 2: + c = name + "~=" + attValue; + break; + case 3: + c = name + "|=" +attValue; + break; + case 4: + c = name + "^=" +attValue; + break; + case 5: + c = name + "$=" +attValue; + break; + case 6: + c = name + "*=" +attValue; + break; + default: + // never reached. + c = null; + } + c = "[" + c + "]"; + if (pred == null) { + {if (true) return c;} + } else { + {if (true) return pred + c;} + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_198() { - if (jj_scan_token(COMMA)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; +/** + * @exception ParseException exception during the parse + */ + final public String pseudo(String pred) throws ParseException { + Token n; +Token param; +String d; +boolean isPseudoElement = false; + jj_consume_token(COLON); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + isPseudoElement=true; + break; + default: + jj_la1[97] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + String s = ":" + convertIdent(n.image); + if (isPseudoElement) { + if (pseudoElt != null) { + {if (true) throw new CSSParseException("duplicate pseudo element definition " + + s, getLocator());} + } else { + pseudoElt = ":"+s; + {if (true) return pred;} + } + } else { + String c = s; + if (pred == null) { + {if (true) return c;} + } else { + {if (true) return pred + c;} + } } - } - if (jj_3R_197()) { - return true; - } - return false; - } + break; + case FUNCTION: + n = jj_consume_token(FUNCTION); + label_65: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[98] = jj_gen; + break label_65; + } + jj_consume_token(S); + } + d = skipStatementUntilMatchingRightParan(); + jj_consume_token(RPARAN); + // accept anything between function and a right parenthesis + String f = convertIdent(n.image); + String colons = isPseudoElement ? "::" : ":"; + String pseudofn = colons + f + d + ")"; + if (pred == null) { + {if (true) return pseudofn;} + } else { + {if (true) return pred + pseudofn;} + } + break; + default: + jj_la1[99] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_242() { - if (jj_3R_178()) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public String hash(String pred) throws ParseException { + Token n; + n = jj_consume_token(HASH); + String d = n.image; + if (pred == null) { + {if (true) return d;} + } else { + {if (true) return pred + d;} + } + throw new Error("Missing return statement in function"); + } + + final public void variable() throws ParseException { + String name; + LexicalUnitImpl exp = null; + boolean guarded = false; + String raw; + try { + name = variableName(); + jj_consume_token(COLON); + label_66: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[100] = jj_gen; + break label_66; + } + jj_consume_token(S); + } + exp = expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case GUARDED_SYM: + guarded = guarded(); + break; + default: + jj_la1[101] = jj_gen; + ; + } + label_67: + while (true) { + jj_consume_token(SEMICOLON); + label_68: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[102] = jj_gen; + break label_68; + } + jj_consume_token(S); } - return false; - } - - private boolean jj_3R_223() { - if (jj_scan_token(PX)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[103] = jj_gen; + break label_67; } - return false; + } + documentHandler.variable(name, exp, guarded); + } catch (JumpException e) { + skipAfterExpression(); + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + } else { + skipAfterExpression(); + } } - - private boolean jj_3R_222() { - if (jj_scan_token(IN)) { - return true; + } + + final public void controlDirective() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IF_SYM: + ifDirective(); + break; + case EACH_SYM: + eachDirective(); + break; + default: + jj_la1[104] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void ifContentStatement() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case CONTENT_SYM: + contentDirective(); + break; + case INCLUDE_SYM: + includeDirective(); + break; + case MEDIA_SYM: + media(); + break; + case EXTEND_SYM: + extendDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case HASH: + styleRuleOrDeclarationOrNestedProperties(); + break; + case KEY_FRAME_SYM: + keyframes(); + break; + default: + jj_la1[105] = jj_gen; + if (jj_2_3(2147483647)) { + variable(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VARIABLE: + listModifyDirective(); + break; + case EACH_SYM: + case IF_SYM: + controlDirective(); + break; + case ATKEYWORD: + atRuleDeclaration(); + break; + default: + jj_la1[106] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } + + final public void ifDirective() throws ParseException { + Token n = null; + String s = null; + String evaluator = ""; + jj_consume_token(IF_SYM); + label_69: + while (true) { + s = booleanExpressionToken(); + evaluator += s; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case EQ: + case PLUS: + case MINUS: + case PRECEDES: + case SUCCEEDS: + case DIV: + case ANY: + case LPARAN: + case RPARAN: + case COMPARE: + case OR: + case AND: + case NOT_EQ: + case IDENT: + case NUMBER: + case VARIABLE: + case CONTAINS: + ; + break; + default: + jj_la1[107] = jj_gen; + break label_69; + } + } + jj_consume_token(LBRACE); + label_70: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[108] = jj_gen; + break label_70; + } + jj_consume_token(S); + } + documentHandler.startIfElseDirective(); + documentHandler.ifDirective(evaluator); + label_71: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[109] = jj_gen; + break label_71; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[110] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_72: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[111] = jj_gen; + break label_72; + } + jj_consume_token(S); + } + label_73: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ELSE_SYM: + ; + break; + default: + jj_la1[112] = jj_gen; + break label_73; + } + elseDirective(); + } + documentHandler.endIfElseDirective(); + } + + final public void elseDirective() throws ParseException { + String evaluator = ""; + Token n = null; + String s = null; + jj_consume_token(ELSE_SYM); + label_74: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[113] = jj_gen; + break label_74; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IF: + jj_consume_token(IF); + label_75: + while (true) { + s = booleanExpressionToken(); + evaluator += s; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + case EQ: + case PLUS: + case MINUS: + case PRECEDES: + case SUCCEEDS: + case DIV: + case ANY: + case LPARAN: + case RPARAN: + case COMPARE: + case OR: + case AND: + case NOT_EQ: + case IDENT: + case NUMBER: + case VARIABLE: + case CONTAINS: + ; + break; + default: + jj_la1[114] = jj_gen; + break label_75; + } + } + break; + default: + jj_la1[115] = jj_gen; + ; + } + jj_consume_token(LBRACE); + label_76: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[116] = jj_gen; + break label_76; + } + jj_consume_token(S); + } + if(!evaluator.trim().equals("")){ documentHandler.ifDirective(evaluator); } + else{ documentHandler.elseDirective(); } + label_77: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[117] = jj_gen; + break label_77; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[118] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_78: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[119] = jj_gen; + break label_78; + } + jj_consume_token(S); + } + } + + final public String booleanExpressionToken() throws ParseException { + Token n = null; + String s = null; + if (jj_2_4(2147483647)) { + s = containsDirective(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VARIABLE: + n = jj_consume_token(VARIABLE); + break; + case IDENT: + n = jj_consume_token(IDENT); + break; + case NUMBER: + n = jj_consume_token(NUMBER); + break; + case LPARAN: + n = jj_consume_token(LPARAN); + break; + case RPARAN: + n = jj_consume_token(RPARAN); + break; + case PLUS: + n = jj_consume_token(PLUS); + break; + case MINUS: + n = jj_consume_token(MINUS); + break; + case DIV: + n = jj_consume_token(DIV); + break; + case ANY: + n = jj_consume_token(ANY); + break; + case COMPARE: + n = jj_consume_token(COMPARE); + break; + case EQ: + n = jj_consume_token(EQ); + break; + case PRECEDES: + n = jj_consume_token(PRECEDES); + break; + case SUCCEEDS: + n = jj_consume_token(SUCCEEDS); + break; + case OR: + n = jj_consume_token(OR); + break; + case AND: + n = jj_consume_token(AND); + break; + case S: + n = jj_consume_token(S); + break; + case NOT_EQ: + n = jj_consume_token(NOT_EQ); + break; + default: + jj_la1[120] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + if(n!=null){{if (true) return n.image;}} + else{{if (true) return s;}} + throw new Error("Missing return statement in function"); + } + + final public void eachDirective() throws ParseException { + Token var; + ArrayList list = null; + String listVariable = null; + jj_consume_token(EACH_SYM); + label_79: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[121] = jj_gen; + break label_79; + } + jj_consume_token(S); + } + var = jj_consume_token(VARIABLE); + label_80: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[122] = jj_gen; + break label_80; + } + jj_consume_token(S); + } + jj_consume_token(EACH_IN); + label_81: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[123] = jj_gen; + break label_81; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + list = stringList(); + documentHandler.startEachDirective(var.image, list); + break; + case VARIABLE: + listVariable = variableName(); + documentHandler.startEachDirective(var.image, listVariable); + break; + default: + jj_la1[124] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(LBRACE); + label_82: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[125] = jj_gen; + break label_82; + } + jj_consume_token(S); + } + label_83: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[126] = jj_gen; + break label_83; + } + ifContentStatement(); + } + jj_consume_token(RBRACE); + label_84: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[127] = jj_gen; + break label_84; + } + jj_consume_token(S); + } + documentHandler.endEachDirective(); + } + + final public ArrayList stringList() throws ParseException { + ArrayList strings = new ArrayList(); + Token input; + input = jj_consume_token(IDENT); + label_85: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[128] = jj_gen; + break label_85; + } + jj_consume_token(S); + } + strings.add(input.image); + label_86: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[129] = jj_gen; + break label_86; + } + jj_consume_token(COMMA); + label_87: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[130] = jj_gen; + break label_87; + } + jj_consume_token(S); + } + input = jj_consume_token(IDENT); + strings.add(input.image); + label_88: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[131] = jj_gen; + break label_88; + } + jj_consume_token(S); + } + } + {if (true) return strings;} + throw new Error("Missing return statement in function"); + } + + final public void mixinDirective() throws ParseException { + String name; + ArrayList args = null; + String body; + jj_consume_token(MIXIN_SYM); + label_89: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[132] = jj_gen; + break label_89; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + name = property(); + break; + case FUNCTION: + name = functionName(); + args = arglist(); + jj_consume_token(RPARAN); + label_90: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[133] = jj_gen; + break label_90; + } + jj_consume_token(S); + } + break; + default: + jj_la1[134] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(LBRACE); + label_91: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[135] = jj_gen; + break label_91; + } + jj_consume_token(S); + } + documentHandler.startMixinDirective(name, args); + label_92: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case PAGE_SYM: + case FONT_FACE_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ; + break; + default: + jj_la1[136] = jj_gen; + break label_92; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case INCLUDE_SYM: + case DEBUG_SYM: + case WARN_SYM: + case EACH_SYM: + case IF_SYM: + case EXTEND_SYM: + case CONTENT_SYM: + case IDENT: + case VARIABLE: + case HASH: + case MEDIA_SYM: + case KEY_FRAME_SYM: + case ATKEYWORD: + ifContentStatement(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + case PAGE_SYM: + page(); + break; + default: + jj_la1[137] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_93: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[138] = jj_gen; + break label_93; + } + jj_consume_token(S); + } + documentHandler.endMixinDirective(name, args); + } + + final public ArrayList arglist() throws ParseException { + ArrayList args = new ArrayList(); + VariableNode arg; + boolean hasNonOptionalArgument = false; + arg = mixinArg(); + label_94: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[139] = jj_gen; + break label_94; + } + jj_consume_token(COMMA); + label_95: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[140] = jj_gen; + break label_95; } - return false; + jj_consume_token(S); + } + hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + arg = mixinArg(); } + hasNonOptionalArgument = checkMixinForNonOptionalArguments(arg, hasNonOptionalArgument); args.add(arg); + {if (true) return args;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_197() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_242()) { - jj_scanpos = xsp; - if (jj_3R_243()) { - return true; - } - } + boolean checkMixinForNonOptionalArguments(VariableNode arg, boolean hasNonOptionalArguments) throws ParseException { + boolean currentArgHasArguments = arg.getExpr() != null && arg.getExpr().getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && arg.getExpr().getNextLexicalUnit() != null; + + if(currentArgHasArguments) + { + if(hasNonOptionalArguments) + { + throw new ParseException("Sass Error: Required argument $"+ arg.getName() +" must come before any optional arguments."); + } + return hasNonOptionalArguments; + }else + { + return true; + } + } + + final public VariableNode mixinArg() throws ParseException { + String name; + Token variable = null; + LexicalUnitImpl first = null; + LexicalUnitImpl prev = null; + LexicalUnitImpl next = null; + name = variableName(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + case VARIABLE: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_96: while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { - jj_scanpos = xsp; - break; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[141] = jj_gen; + break label_96; + } + jj_consume_token(S); } + first = nonVariableTerm(null); + prev = first; + label_97: while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; + if (jj_2_5(3)) { + ; + } else { + break label_97; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_98: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; break; + default: + jj_la1[142] = jj_gen; + break label_98; + } + jj_consume_token(S); } - } - return false; + break; + default: + jj_la1[143] = jj_gen; + ; + } + prev = nonVariableTerm(prev); + } + break; + case VARIABLE: + variable = jj_consume_token(VARIABLE); + first = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, variable.image); + break; + default: + jj_la1[144] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[145] = jj_gen; + ; } - - private boolean jj_3R_221() { - if (jj_scan_token(PC)) { - return true; + VariableNode arg = new VariableNode(name, first, false); + {if (true) return arg;} + throw new Error("Missing return statement in function"); + } + + final public ArrayList argValuelist() throws ParseException { + ArrayList args = new ArrayList(); + LexicalUnitImpl first = null; + LexicalUnitImpl next = null; + LexicalUnitImpl prev = null; + first = term(null); + args.add(first); prev = first; + label_99: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case COLON: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[146] = jj_gen; + break label_99; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_100: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[147] = jj_gen; + break label_100; + } + jj_consume_token(S); + } + break; + default: + jj_la1[148] = jj_gen; + ; + } + next = term(prev); + prev.setNextLexicalUnit(next); prev = next; + } + label_101: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + ; + break; + default: + jj_la1[149] = jj_gen; + break label_101; + } + jj_consume_token(COMMA); + label_102: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[150] = jj_gen; + break label_102; + } + jj_consume_token(S); + } + first = term(null); + args.add(first); prev = first; + label_103: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case COLON: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + ; + break; + default: + jj_la1[151] = jj_gen; + break label_103; } - return false; - } - - private boolean jj_3R_220() { - if (jj_scan_token(MM)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COLON: + jj_consume_token(COLON); + label_104: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[152] = jj_gen; + break label_104; + } + jj_consume_token(S); + } + break; + default: + jj_la1[153] = jj_gen; + ; + } + next = term(prev); + prev.setNextLexicalUnit(next); prev = next; + } + } + {if (true) return args;} + throw new Error("Missing return statement in function"); + } + + final public void includeDirective() throws ParseException { + String name; + ArrayList args=null; + jj_consume_token(INCLUDE_SYM); + label_105: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[154] = jj_gen; + break label_105; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + name = property(); + break; + case VARIABLE: + name = variableName(); + name = "$"+name; + break; + case FUNCTION: + name = functionName(); + args = argValuelist(); + jj_consume_token(RPARAN); + label_106: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[155] = jj_gen; + break label_106; + } + jj_consume_token(S); + } + break; + default: + jj_la1[156] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + label_107: + while (true) { + jj_consume_token(SEMICOLON); + label_108: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[157] = jj_gen; + break label_108; + } + jj_consume_token(S); } - return false; - } - - private boolean jj_3R_219() { - if (jj_scan_token(CM)) { - return true; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[158] = jj_gen; + break label_107; } - return false; - } - - private boolean jj_3R_218() { - if (jj_scan_token(PT)) { - return true; + } + documentHandler.includeDirective(name, args); + break; + case LBRACE: + jj_consume_token(LBRACE); + label_109: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[159] = jj_gen; + break label_109; + } + jj_consume_token(S); + } + documentHandler.startIncludeContentBlock(name, args); + label_110: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case TO: + case FROM: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case PERCENTAGE: + case HASH: + ; + break; + default: + jj_la1[160] = jj_gen; + break label_110; } - return false; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case DEBUG_SYM: + case WARN_SYM: + case IDENT: + case HASH: + styleRuleOrDeclarationOrNestedProperties(); + break; + case TO: + case FROM: + case PERCENTAGE: + keyframeSelector(); + break; + default: + jj_la1[161] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + jj_consume_token(RBRACE); + label_111: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[162] = jj_gen; + break label_111; + } + jj_consume_token(S); + } + documentHandler.endIncludeContentBlock(); + break; + default: + jj_la1[163] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public String interpolation() throws ParseException { + Token n; + n = jj_consume_token(INTERPOLATION); + {if (true) return n.image;} + throw new Error("Missing return statement in function"); + } + + final public void listModifyDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + Token type = null; + //refactor, remove those 3 LOOKAHEAD(5). + n = jj_consume_token(VARIABLE); + variable = n.image; + label_112: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[164] = jj_gen; + break label_112; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_113: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[165] = jj_gen; + break label_113; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case APPEND: + type = jj_consume_token(APPEND); + break; + case REMOVE: + type = jj_consume_token(REMOVE); + break; + case CONTAINS: + type = jj_consume_token(CONTAINS); + break; + default: + jj_la1[166] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_114: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[167] = jj_gen; + break label_114; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[168] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_115: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[169] = jj_gen; + break label_115; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_116: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[170] = jj_gen; + break label_116; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_117: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[171] = jj_gen; + break label_117; + } + jj_consume_token(S); + } + break; + default: + jj_la1[172] = jj_gen; + ; + } + jj_consume_token(RPARAN); + switch (type.kind) { + case APPEND: + documentHandler.appendDirective(variable,list,remove,separator); + break; + case REMOVE: + documentHandler.removeDirective(variable,list,remove,separator); + break; + case CONTAINS: + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + break; + default: + break; + } + label_118: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[173] = jj_gen; + break label_118; + } + jj_consume_token(S); + } + jj_consume_token(SEMICOLON); + label_119: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[174] = jj_gen; + break label_119; + } + jj_consume_token(S); + } + } - private boolean jj_3R_217() { - if (jj_scan_token(PERCENTAGE)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void appendDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + n = jj_consume_token(VARIABLE); + variable = n.image; + label_120: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[175] = jj_gen; + break label_120; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_121: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[176] = jj_gen; + break label_121; + } + jj_consume_token(S); + } + jj_consume_token(APPEND); + label_122: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[177] = jj_gen; + break label_122; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[178] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_123: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[179] = jj_gen; + break label_123; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_124: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[180] = jj_gen; + break label_124; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_125: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[181] = jj_gen; + break label_125; } - return false; + jj_consume_token(S); + } + break; + default: + jj_la1[182] = jj_gen; + ; } + jj_consume_token(RPARAN); + documentHandler.appendDirective(variable,list,remove,separator); + } - private boolean jj_3R_203() { - if (jj_3R_245()) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void removeDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + n = jj_consume_token(VARIABLE); + variable = n.image; + label_126: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[183] = jj_gen; + break label_126; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_127: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[184] = jj_gen; + break label_127; + } + jj_consume_token(S); + } + jj_consume_token(REMOVE); + label_128: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[185] = jj_gen; + break label_128; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[186] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_129: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[187] = jj_gen; + break label_129; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_130: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[188] = jj_gen; + break label_130; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_131: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[189] = jj_gen; + break label_131; } - return false; + jj_consume_token(S); + } + break; + default: + jj_la1[190] = jj_gen; + ; } + jj_consume_token(RPARAN); + documentHandler.removeDirective(variable,list,remove,separator); + } - private boolean jj_3_1() { - if (jj_3R_176()) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public String containsDirective() throws ParseException { + String list = null; + String remove = null; + String separator = null; + String variable = null; + Token n = null; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case VARIABLE: + n = jj_consume_token(VARIABLE); + variable = n.image; + label_132: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[191] = jj_gen; + break label_132; + } + jj_consume_token(S); + } + jj_consume_token(COLON); + label_133: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[192] = jj_gen; + break label_133; + } + jj_consume_token(S); + } + break; + default: + jj_la1[193] = jj_gen; + ; + } + jj_consume_token(CONTAINS); + label_134: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[194] = jj_gen; + break label_134; + } + jj_consume_token(S); + } + list = listModifyDirectiveArgs(0); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case RPARAN: + jj_consume_token(RPARAN); + break; + default: + jj_la1[195] = jj_gen; + ; + } + jj_consume_token(COMMA); + label_135: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[196] = jj_gen; + break label_135; + } + jj_consume_token(S); + } + remove = listModifyDirectiveArgs(1); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + jj_consume_token(COMMA); + label_136: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[197] = jj_gen; + break label_136; + } + jj_consume_token(S); + } + n = jj_consume_token(IDENT); + separator = n.image; + label_137: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[198] = jj_gen; + break label_137; + } + jj_consume_token(S); + } + break; + default: + jj_la1[199] = jj_gen; + ; + } + jj_consume_token(RPARAN); + /* + *if it is not in the form like "$contains : contains($items, .v-button);" + *for example in @if, like "@if (contains(a b c, b))", then create a temp + *variable for contains(a b c, b); + */ + if(variable == null){ + variable = "$var_"+UUID.randomUUID(); + } + documentHandler.containsDirective(variable,list,remove,separator); + {if (true) return variable;} + throw new Error("Missing return statement in function"); + } + + String listModifyDirectiveArgs(int nest) throws ParseException { + String list = ""; + int nesting = nest; + Token t = null; - private boolean jj_3R_182() { - if (jj_3R_197()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_198()) { - jj_scanpos = xsp; - break; - } - } - return false; - } - - private boolean jj_3R_216() { - if (jj_scan_token(NUMBER)) { - return true; - } - return false; - } - - private boolean jj_3R_215() { - if (jj_3R_253()) { - return true; - } - return false; - } - - private boolean jj_3R_195() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_215()) { - jj_scanpos = xsp; - } - xsp = jj_scanpos; - if (jj_3R_216()) { - jj_scanpos = xsp; - if (jj_3R_217()) { - jj_scanpos = xsp; - if (jj_3R_218()) { - jj_scanpos = xsp; - if (jj_3R_219()) { - jj_scanpos = xsp; - if (jj_3R_220()) { - jj_scanpos = xsp; - if (jj_3R_221()) { - jj_scanpos = xsp; - if (jj_3R_222()) { - jj_scanpos = xsp; - if (jj_3R_223()) { - jj_scanpos = xsp; - if (jj_3R_224()) { - jj_scanpos = xsp; - if (jj_3R_225()) { - jj_scanpos = xsp; - if (jj_3R_226()) { - jj_scanpos = xsp; - if (jj_3R_227()) { - jj_scanpos = xsp; - if (jj_3R_228()) { - jj_scanpos = xsp; - if (jj_3R_229()) { - jj_scanpos = xsp; - if (jj_3R_230()) { - jj_scanpos = xsp; - if (jj_3R_231()) { - jj_scanpos = xsp; - if (jj_3R_232()) { - jj_scanpos = xsp; - if (jj_3R_233()) { - jj_scanpos = xsp; - if (jj_3R_234()) { - jj_scanpos = xsp; - if (jj_3R_235()) { - jj_scanpos = xsp; - if (jj_3R_236()) { - return true; - } - } - } - } - } - } - } - } - } - } - } - } - } - } + while(true) + { + t = getToken(1); + String s = t.image; + if(t.kind == VARIABLE||t.kind == IDENT) + { + list += s; + }else if(s.toLowerCase().equals("auto")||s.toLowerCase().equals("space")||s.toLowerCase().equals("comma")) + { + int i = 2; + Token temp = getToken(i); + boolean isLast = true; + while(temp.kind != SEMICOLON) + { + if(temp.kind != RPARAN || temp.kind != S) + { + isLast = false; } - } + i++; + temp = getToken(i); + } + + if(isLast) + { + return list; } - } } - } - } - return false; - } + else if(t.kind == STRING) + { + list += s.substring(1,s.length()).substring(0,s.length()-2); - private boolean jj_3R_181() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_195()) { - jj_scanpos = xsp; - if (jj_3R_196()) { - return true; - } - } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; - } - } - return false; - } + }else if(t.kind == LPARAN) + { + nesting++; + if(nesting > nest+1) + { + throw new CSSParseException("Only one ( ) pair per parameter allowed", getLocator()); + } + }else if(t.kind == RPARAN) + { + nesting--; + if(nesting == 0) + { + return list; + } + } else if(t.kind == COMMA) + { + if(nesting == nest) + { + return list; + }else + { + list += ","; + } - private boolean jj_3R_256() { - if (jj_scan_token(HASH)) { - return true; - } - return false; - } + }else if(t.kind == S) + { + list += " "; + } else if(t.kind == LBRACE) + { + throw new CSSParseException("Invalid token,'{' found", getLocator()); + } - private boolean jj_3_4() { - if (jj_3R_179()) { - return true; + getNextToken(); } - return false; - } + } + + final public Node returnDirective() throws ParseException { + String raw; + raw = skipStatement(); + {if (true) return null;} + throw new Error("Missing return statement in function"); + } + + final public void debuggingDirective() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DEBUG_SYM: + debugDirective(); + break; + case WARN_SYM: + warnDirective(); + break; + default: + jj_la1[200] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void debugDirective() throws ParseException { + jj_consume_token(DEBUG_SYM); + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.debugDirective() etc. + System.out.println(content); + label_138: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[201] = jj_gen; + break label_138; + } + jj_consume_token(S); + } + } + + final public void warnDirective() throws ParseException { + jj_consume_token(WARN_SYM); + String content = skipStatementUntilSemiColon(); + // TODO should evaluate the content expression, call documentHandler.warnDirective() etc. + System.err.println(content); + label_139: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[202] = jj_gen; + break label_139; + } + jj_consume_token(S); + } + } + + final public Node forDirective() throws ParseException { + String var; + String from; + String to; + boolean exclusive; + String body; + Token tok; + var = variableName(); + int[] toThrough = {TO, THROUGH}; + from = skipStatementUntil(toThrough); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case TO: + tok = jj_consume_token(TO); + exclusive = true; + break; + case THROUGH: + tok = jj_consume_token(THROUGH); + exclusive = false; + break; + default: + jj_la1[203] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + to = skipStatementUntilLeftBrace(); + label_140: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[204] = jj_gen; + break label_140; + } + jj_consume_token(S); + } + body = skipStatement(); + {if (true) return documentHandler.forDirective(var, from, to, exclusive, body);} + throw new Error("Missing return statement in function"); + } + + final public Node whileDirective() throws ParseException { + String condition; + String body; + condition = skipStatementUntilLeftBrace(); + body = skipStatement(); + {if (true) return documentHandler.whileDirective(condition, body);} + throw new Error("Missing return statement in function"); + } + + final public void extendDirective() throws ParseException { + ArrayList list; + jj_consume_token(EXTEND_SYM); + label_141: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[205] = jj_gen; + break label_141; + } + jj_consume_token(S); + } + list = selectorList(); + label_142: + while (true) { + jj_consume_token(SEMICOLON); + label_143: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[206] = jj_gen; + break label_143; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[207] = jj_gen; + break label_142; + } + } + documentHandler.extendDirective(list); + } + + final public void contentDirective() throws ParseException { + jj_consume_token(CONTENT_SYM); + label_144: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[208] = jj_gen; + break label_144; + } + jj_consume_token(S); + } + label_145: + while (true) { + jj_consume_token(SEMICOLON); + label_146: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[209] = jj_gen; + break label_146; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[210] = jj_gen; + break label_145; + } + } + documentHandler.contentDirective(); + } + + Node importDirective() throws ParseException { + return null; + } + + Node charsetDirective() throws ParseException { + return null; + } + + Node mozDocumentDirective() throws ParseException { + return null; + } + + Node supportsDirective() throws ParseException { + return null; + } + + final public void nestedProperties() throws ParseException { + String name; +LexicalUnit exp; + name = property(); + jj_consume_token(COLON); + label_147: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[211] = jj_gen; + break label_147; + } + jj_consume_token(S); + } + jj_consume_token(LBRACE); + label_148: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[212] = jj_gen; + break label_148; + } + jj_consume_token(S); + } + documentHandler.startNestedProperties(name); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[213] = jj_gen; + ; + } + label_149: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[214] = jj_gen; + break label_149; + } + jj_consume_token(SEMICOLON); + label_150: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[215] = jj_gen; + break label_150; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[216] = jj_gen; + ; + } + } + jj_consume_token(RBRACE); + documentHandler.endNestedProperties(name); + label_151: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[217] = jj_gen; + break label_151; + } + jj_consume_token(S); + } + } - private boolean jj_3R_245() { - if (jj_3R_186()) { - return true; - } - return false; +/** + * @exception ParseException exception during the parse + */ + final public void styleRuleOrDeclarationOrNestedProperties() throws ParseException { + try { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + default: + jj_la1[218] = jj_gen; + if (jj_2_6(2147483647)) { + styleRule(); + } else if (jj_2_7(3)) { + declarationOrNestedProperties(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + default: + jj_la1[219] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } } + } - private boolean jj_3R_257() { - if (jj_scan_token(URL)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public void declarationOrNestedProperties() throws ParseException { + boolean important = false; + String name; + LexicalUnitImpl exp; + Token save; + String comment = null; + try { + name = property(); + save = token; + jj_consume_token(COLON); + label_152: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[220] = jj_gen; + break label_152; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + exp = expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[221] = jj_gen; + ; + } + Token next = getToken(1); + if(next.kind == SEMICOLON || next.kind == RBRACE){ + while(next.kind == SEMICOLON){ + skipStatement(); + next = getToken(1); + } + //only add special token kept for sprites '/**' + if(token.specialToken!=null && token.specialToken!=null && token.specialToken.image.startsWith("/**")){ + documentHandler.property(name, exp, important, token.specialToken.image); + }else{ + documentHandler.property(name, exp, important, null); + } + } + break; + case LBRACE: + jj_consume_token(LBRACE); + label_153: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[222] = jj_gen; + break label_153; + } + jj_consume_token(S); + } + documentHandler.startNestedProperties(name); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[223] = jj_gen; + ; } - return false; - } - - private boolean jj_3R_202() { - if (jj_3R_181()) { - return true; + label_154: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[224] = jj_gen; + break label_154; + } + jj_consume_token(SEMICOLON); + label_155: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[225] = jj_gen; + break label_155; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[226] = jj_gen; + ; + } } - return false; + jj_consume_token(RBRACE); + label_156: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[227] = jj_gen; + break label_156; + } + jj_consume_token(S); + } + documentHandler.endNestedProperties(name); + break; + default: + jj_la1[228] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } } + } - private boolean jj_3R_260() { - if (jj_scan_token(INTERPOLATION)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public void declaration() throws ParseException { + boolean important = false; + String name; + LexicalUnit exp; + Token save; + try { + name = property(); + save = token; + jj_consume_token(COLON); + label_157: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[229] = jj_gen; + break label_157; + } + jj_consume_token(S); + } + exp = expr(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORTANT_SYM: + important = prio(); + break; + default: + jj_la1[230] = jj_gen; + ; + } + documentHandler.property(name, exp, important); + } catch (JumpException e) { + skipAfterExpression(); + // reportWarningSkipText(getLocator(), skipAfterExpression()); + + } catch (NumberFormatException e) { + if (errorHandler != null) { + errorHandler.error(new CSSParseException("Invalid number " + + e.getMessage(), + getLocator(), + e)); + } + reportWarningSkipText(getLocator(), skipAfterExpression()); + } catch (ParseException e) { + if (errorHandler != null) { + if (e.currentToken != null) { + LocatorImpl li = new LocatorImpl(this, + e.currentToken.next.beginLine, + e.currentToken.next.beginColumn-1); + reportError(li, e); + } else { + reportError(getLocator(), e); + } + skipAfterExpression(); + /* + LocatorImpl loc = (LocatorImpl) getLocator(); + loc.column--; + reportWarningSkipText(loc, skipAfterExpression()); + */ + } else { + skipAfterExpression(); + } + } + } - private boolean jj_3R_184() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_202()) { - jj_scanpos = xsp; - if (jj_3R_203()) { - return true; - } - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public boolean prio() throws ParseException { + jj_consume_token(IMPORTANT_SYM); + label_158: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[231] = jj_gen; + break label_158; + } + jj_consume_token(S); + } + {if (true) return true;} + throw new Error("Missing return statement in function"); + } + + final public boolean guarded() throws ParseException { + jj_consume_token(GUARDED_SYM); + label_159: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[232] = jj_gen; + break label_159; + } + jj_consume_token(S); + } + {if (true) return true;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3_9() { - if (jj_3R_185()) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public LexicalUnitImpl operator(LexicalUnitImpl prev) throws ParseException { + Token n; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case COMMA: + /* (comments copied from basic_arithmetics.scss) + *supports: + * 1. standard arithmetic operations (+, -, *, /, %) + * 2. / is treated as css operator, unless one of its operands is variable or there is another binary arithmetic operator + *limits: + * 1. cannot mix arithmetic and css operations, e.g. "margin: 1px + 3px 2px" will fail + * 2. space between add and minus operator and their following operand is mandatory. e.g. "1 + 2" is valid, "1+2" is not + * 3. parenthesis is not supported now. + */ + n = jj_consume_token(COMMA); + label_160: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[233] = jj_gen; + break label_160; + } + jj_consume_token(S); + } + {if (true) return LexicalUnitImpl.createComma(n.beginLine, + n.beginColumn, + prev);} + break; + case DIV: + n = jj_consume_token(DIV); + label_161: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[234] = jj_gen; + break label_161; + } + jj_consume_token(S); + } + {if (true) return LexicalUnitImpl.createSlash(n.beginLine, + n.beginColumn, + prev);} + break; + case ANY: + n = jj_consume_token(ANY); + label_162: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[235] = jj_gen; + break label_162; + } + jj_consume_token(S); + } + {if (true) return LexicalUnitImpl.createMultiply(n.beginLine, + n.beginColumn, + prev);} + break; + case MOD: + n = jj_consume_token(MOD); + label_163: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[236] = jj_gen; + break label_163; + } + jj_consume_token(S); + } + {if (true) return LexicalUnitImpl.createModulo(n.beginLine, + n.beginColumn, + prev);} + break; + case PLUS: + n = jj_consume_token(PLUS); + label_164: + while (true) { + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[237] = jj_gen; + break label_164; + } + } + {if (true) return LexicalUnitImpl.createAdd(n.beginLine, + n.beginColumn, + prev);} + break; + case MINUS: + n = jj_consume_token(MINUS); + label_165: + while (true) { + jj_consume_token(S); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[238] = jj_gen; + break label_165; + } + } + {if (true) return LexicalUnitImpl.createMinus(n.beginLine, + n.beginColumn, + prev);} + break; + default: + jj_la1[239] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3_3() { - if (jj_3R_176()) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public LexicalUnitImpl expr() throws ParseException { + LexicalUnitImpl first, res; + char op; + first = term(null); + res = first; + label_166: + while (true) { + if (jj_2_8(2)) { + ; + } else { + break label_166; + } + if (jj_2_9(2)) { + res = operator(res); + } else { + ; + } + res = term(res); + } + {if (true) return first;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_267() { - if (jj_scan_token(PLUS)) { - return true; - } - return false; - } +/** + * @exception ParseException exception during the parse + */ + final public char unaryOperator() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case MINUS: + jj_consume_token(MINUS); + {if (true) return '-';} + break; + case PLUS: + jj_consume_token(PLUS); + {if (true) return '+';} + break; + default: + jj_la1[240] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_253() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_266()) { - jj_scanpos = xsp; - if (jj_3R_267()) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public LexicalUnitImpl term(LexicalUnitImpl prev) throws ParseException { + LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + result = nonVariableTerm(prev); + break; + case VARIABLE: + result = variableTerm(prev); + break; + default: + jj_la1[241] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return result;} + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl variableTerm(LexicalUnitImpl prev) throws ParseException { + LexicalUnitImpl result = null; + String varName = ""; + varName = variableName(); + result = LexicalUnitImpl.createVariable(token.beginLine, token.beginColumn, + prev, varName); {if (true) return result;} + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl nonVariableTerm(LexicalUnitImpl prev) throws ParseException { +LexicalUnitImpl result = null; + Token n = null; + char op = ' '; + String varName; + String s = ""; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case NUMBER: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case FUNCTION: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + op = unaryOperator(); + break; + default: + jj_la1[242] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NUMBER: + n = jj_consume_token(NUMBER); + result = LexicalUnitImpl.createNumber(n.beginLine, n.beginColumn, + prev, number(op, n, 0)); + break; + case PERCENTAGE: + n = jj_consume_token(PERCENTAGE); + result = LexicalUnitImpl.createPercentage(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); + break; + case PT: + n = jj_consume_token(PT); + result = LexicalUnitImpl.createPT(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case CM: + n = jj_consume_token(CM); + result = LexicalUnitImpl.createCM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case MM: + n = jj_consume_token(MM); + result = LexicalUnitImpl.createMM(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case PC: + n = jj_consume_token(PC); + result = LexicalUnitImpl.createPC(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case IN: + n = jj_consume_token(IN); + result = LexicalUnitImpl.createIN(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case PX: + n = jj_consume_token(PX); + result = LexicalUnitImpl.createPX(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case EMS: + n = jj_consume_token(EMS); + result = LexicalUnitImpl.createEMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case LEM: + n = jj_consume_token(LEM); + result = LexicalUnitImpl.createLEM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case REM: + n = jj_consume_token(REM); + result = LexicalUnitImpl.createREM(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case EXS: + n = jj_consume_token(EXS); + result = LexicalUnitImpl.createEXS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case DEG: + n = jj_consume_token(DEG); + result = LexicalUnitImpl.createDEG(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case RAD: + n = jj_consume_token(RAD); + result = LexicalUnitImpl.createRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case GRAD: + n = jj_consume_token(GRAD); + result = LexicalUnitImpl.createGRAD(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case SECOND: + n = jj_consume_token(SECOND); + result = LexicalUnitImpl.createS(n.beginLine, n.beginColumn, + prev, number(op, n, 1)); + break; + case MS: + n = jj_consume_token(MS); + result = LexicalUnitImpl.createMS(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case HZ: + n = jj_consume_token(HZ); + result = LexicalUnitImpl.createHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 2)); + break; + case KHZ: + n = jj_consume_token(KHZ); + result = LexicalUnitImpl.createKHZ(n.beginLine, n.beginColumn, + prev, number(op, n, 3)); + break; + case DIMEN: + n = jj_consume_token(DIMEN); + s = n.image; + int i = 0; + while (i < s.length() + && (Character.isDigit(s.charAt(i)) || (s.charAt(i) == '.'))) { + i++; } - } - return false; - } - - private boolean jj_3R_266() { - if (jj_scan_token(MINUS)) { - return true; - } - return false; - } - private boolean jj_3R_258() { - if (jj_scan_token(UNICODERANGE)) { - return true; + result = LexicalUnitImpl.createDimen(n.beginLine, n.beginColumn, prev, + number(op,n,s.length()-i), + s.substring(i)); + break; + case FUNCTION: + result = function(op, prev); + break; + default: + jj_la1[243] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case URL: + case HASH: + case UNICODERANGE: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + n = jj_consume_token(STRING); + result = + LexicalUnitImpl.createString(n.beginLine, n.beginColumn, prev, + convertStringIndex(n.image, 1, + n.image.length() -1)); + break; + case DOT: + case TO: + case THROUGH: + case FROM: + case IDENT: + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case DOT: + jj_consume_token(DOT); + s+="."; + break; + default: + jj_la1[244] = jj_gen; + ; } - return false; - } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IDENT: + n = jj_consume_token(IDENT); + break; + case TO: + n = jj_consume_token(TO); + break; + case THROUGH: + n = jj_consume_token(THROUGH); + break; + case FROM: + n = jj_consume_token(FROM); + break; + default: + jj_la1[245] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + s += convertIdent(n.image); + if ("inherit".equals(s)) { + result = LexicalUnitImpl.createInherit(n.beginLine, n.beginColumn, + prev); + } else { + result = LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, convertIdent(n.image)); + } + + /* / + Auto correction code used in the CSS Validator but must not + be used by a conformant CSS2 parser. + * Common error : + * H1 { + * color : black + * background : white + * } + * + Token t = getToken(1); + Token semicolon = new Token(); + semicolon.kind = SEMICOLON; + semicolon.image = ";"; + if (t.kind == COLON) { + // @@SEEME. (generate a warning?) + // @@SEEME if expression is a single ident, + generate an error ? + rejectToken(semicolon); + + result = prev; + } + / */ + + break; + case HASH: + result = hexcolor(prev); + break; + case URL: + result = url(prev); + break; + case UNICODERANGE: + result = unicode(prev); + break; + default: + jj_la1[246] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + default: + jj_la1[247] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + label_167: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[248] = jj_gen; + break label_167; + } + jj_consume_token(S); + } + {if (true) return result;} + throw new Error("Missing return statement in function"); + } - private boolean jj_3_8() { - Token xsp; - xsp = jj_scanpos; - if (jj_3_9()) { - jj_scanpos = xsp; - } - if (jj_3R_184()) { - return true; - } - return false; +/** + * Handle all CSS2 functions. + * @exception ParseException exception during the parse + */ + final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) throws ParseException { + Token n; + LexicalUnit params = null; + n = jj_consume_token(FUNCTION); + label_168: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[249] = jj_gen; + break label_168; + } + jj_consume_token(S); } - - private boolean jj_3R_186() { - if (jj_scan_token(VARIABLE)) { - return true; + String fname = convertIdent(n.image); + if("alpha(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + {if (true) return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "alpha("+body);} + }else if("expression(".equals(fname)){ + String body = skipStatementUntilSemiColon(); + {if (true) return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + null, "expression("+body);} + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PLUS: + case MINUS: + case DOT: + case TO: + case THROUGH: + case FROM: + case STRING: + case IDENT: + case NUMBER: + case URL: + case VARIABLE: + case PERCENTAGE: + case PT: + case MM: + case CM: + case PC: + case IN: + case PX: + case EMS: + case LEM: + case REM: + case EXS: + case DEG: + case RAD: + case GRAD: + case MS: + case SECOND: + case HZ: + case KHZ: + case DIMEN: + case HASH: + case UNICODERANGE: + case FUNCTION: + params = expr(); + break; + default: + jj_la1[250] = jj_gen; + ; + } + jj_consume_token(RPARAN); + if (operator != ' ') { + {if (true) throw new CSSParseException("invalid operator before a function.", + getLocator());} } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; + String f = convertIdent(n.image); + LexicalUnitImpl l = (LexicalUnitImpl) params; + boolean loop = true; + if ("rgb(".equals(f)) { + // this is a RGB declaration (e.g. rgb(255, 50%, 0) ) + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 2: + case 4: + if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER) + && (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + {if (true) throw new ParseException("implementation error");} + } + if (loop) { + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } } - } - return false; - } + if ((i == 5) && loop && (l == null)) { + {if (true) return LexicalUnitImpl.createRGBColor(n.beginLine, + n.beginColumn, + prev, params);} + } else { + if (errorHandler != null) { + String errorText; + Locator loc; + if (i < 5) { + if (params == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters."; + } else if (l == null) { + loc = new LocatorImpl(this, n.beginLine, + n.beginColumn-1); + errorText = "not enough parameters: " + + params.toString(); + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "invalid parameter: " + + l.toString(); + } + } else { + loc = new LocatorImpl(this, l.getLineNumber(), + l.getColumnNumber()); + errorText = "too many parameters: " + + l.toString(); + } + errorHandler.error(new CSSParseException(errorText, loc)); + } - private boolean jj_3R_189() { - if (jj_scan_token(SEMICOLON)) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; + {if (true) throw new JumpException();} } - } - return false; - } - - private boolean jj_3R_187() { - if (jj_3R_184()) { - return true; - } - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_8()) { - jj_scanpos = xsp; - break; + } else if ("counter".equals(f)) { + int i = 0; + while (loop && l != null && i < 3) { + switch (i) { + case 0: + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 1: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + {if (true) throw new ParseException("implementation error");} + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if (((i == 1) || (i == 3)) && loop && (l == null)) { + {if (true) return LexicalUnitImpl.createCounter(n.beginLine, n.beginColumn, + prev, params);} } - } - return false; - } - private boolean jj_3R_244() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_259()) { - jj_scanpos = xsp; - if (jj_3R_260()) { - return true; + } else if ("counters(".equals(f)) { + + int i = 0; + while (loop && l != null && i < 5) { + switch (i) { + case 0: + case 4: + if (l.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { + loop = false; + } + break; + case 2: + if (l.getLexicalUnitType() != LexicalUnit.SAC_STRING_VALUE) { + loop = false; + } + break; + case 1: + case 3: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + {if (true) throw new ParseException("implementation error");} + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; } - } - return false; - } + if (((i == 3) || (i == 5)) && loop && (l == null)) { + {if (true) return LexicalUnitImpl.createCounters(n.beginLine, n.beginColumn, + prev, params);} + } + } else if ("attr(".equals(f)) { + if ((l != null) + && (l.getNextLexicalUnit() == null) + && (l.getLexicalUnitType() == LexicalUnit.SAC_IDENT)) { + {if (true) return LexicalUnitImpl.createAttr(l.getLineNumber(), + l.getColumnNumber(), + prev, l.getStringValue());} + } + } else if ("rect(".equals(f)) { + int i = 0; + while (loop && l != null && i < 7) { + switch (i) { + case 0: + case 2: + case 4: + case 6: + switch (l.getLexicalUnitType()) { + case LexicalUnit.SAC_INTEGER: + if (l.getIntegerValue() != 0) { + loop = false; + } + break; + case LexicalUnit.SAC_IDENT: + if (!l.getStringValue().equals("auto")) { + loop = false; + } + break; + case LexicalUnit.SAC_EM: + case LexicalUnit.SAC_EX: + case LexicalUnit.SAC_PIXEL: + case LexicalUnit.SAC_CENTIMETER: + case LexicalUnit.SAC_MILLIMETER: + case LexicalUnit.SAC_INCH: + case LexicalUnit.SAC_POINT: + case LexicalUnit.SAC_PICA: + // nothing + break; + default: + loop = false; + } + break; + case 1: + case 3: + case 5: + if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { + loop = false; + } + break; + default: + {if (true) throw new ParseException("implementation error");} + } + l = (LexicalUnitImpl) l.getNextLexicalUnit(); + i ++; + } + if ((i == 7) && loop && (l == null)) { + {if (true) return LexicalUnitImpl.createRect(n.beginLine, n.beginColumn, + prev, params);} + } + } + {if (true) return LexicalUnitImpl.createFunction(n.beginLine, n.beginColumn, prev, + f.substring(0, + f.length() -1), + params);} + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl unicode(LexicalUnitImpl prev) throws ParseException { + Token n; + n = jj_consume_token(UNICODERANGE); + LexicalUnitImpl params = null; + String s = n.image.substring(2); + int index = s.indexOf('-'); + if (index == -1) { + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s, 16)); + } else { + String s1 = s.substring(0, index); + String s2 = s.substring(index); + + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s1, 16)); + params = LexicalUnitImpl.createInteger(n.beginLine, n.beginColumn, + params, Integer.parseInt(s2, 16)); + } + + {if (true) return LexicalUnitImpl.createUnicodeRange(n.beginLine, n.beginColumn, + prev, params);} + throw new Error("Missing return statement in function"); + } + + final public LexicalUnitImpl url(LexicalUnitImpl prev) throws ParseException { + Token n; + n = jj_consume_token(URL); + String urlname = n.image.substring(4, n.image.length()-1).trim(); + {if (true) return LexicalUnitImpl.createURL(n.beginLine, n.beginColumn, prev, urlname);} + throw new Error("Missing return statement in function"); + } - private boolean jj_3R_259() { - if (jj_scan_token(IDENT)) { - return true; +/** + * @exception ParseException exception during the parse + */ + final public LexicalUnitImpl hexcolor(LexicalUnitImpl prev) throws ParseException { + Token n; + n = jj_consume_token(HASH); + int r; + LexicalUnitImpl first, params = null; + String s = n.image.substring(1); + + if(s.length()!=3 && s.length()!=6) { + first = null; + {if (true) throw new CSSParseException("invalid hexadecimal notation for RGB: " + s, + getLocator());} + } + {if (true) return LexicalUnitImpl.createIdent(n.beginLine, n.beginColumn, + prev, n.image);} + throw new Error("Missing return statement in function"); + } + + float number(char operator, Token n, int lengthUnit) throws ParseException { + String image = n.image; + float f = 0; + + if (lengthUnit != 0) { + image = image.substring(0, image.length() - lengthUnit); + } + f = Float.valueOf(image).floatValue(); + return (operator == '-')? -f: f; + } + + String skipStatementUntilSemiColon() throws ParseException { + int[] semicolon = {SEMICOLON}; + return skipStatementUntil(semicolon); + } + + String skipStatementUntilLeftBrace() throws ParseException { + int[] lBrace = {LBRACE}; + return skipStatementUntil(lBrace); + } + + String skipStatementUntilMatchingRightParan() throws ParseException { + int[] leftTokens = {LPARAN, FUNCTION}; // a FUNCTION also contains "(" + int[] rightTokens = {RPARAN}; + StringBuffer s = new StringBuffer(); + int difference = 1; + Token tok; + while(difference != 0){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; + } + for(int sym : leftTokens){ + if(tok.kind == sym){ + difference++; + } + } + for(int sym : rightTokens){ + if(tok.kind == sym){ + difference--; + } + } + if(difference != 0){ + if (tok.image != null) { + s.append(tok.image); + } + getNextToken(); } - return false; } + return s.toString().trim(); + } - private boolean jj_3R_199() { - Token xsp; - if (jj_3R_244()) { - return true; + String skipStatementUntil(int[] symbols) throws ParseException { + StringBuffer s = new StringBuffer(); + boolean stop = false; + Token tok; + while(!stop){ + tok = getToken(1); + if(tok.kind == EOF) { + return null; } - while (true) { - xsp = jj_scanpos; - if (jj_3R_244()) { - jj_scanpos = xsp; + for(int sym : symbols){ + if(tok.kind == sym){ + stop = true; break; } } - while (true) { - xsp = jj_scanpos; - if (jj_scan_token(1)) { - jj_scanpos = xsp; - break; + if(!stop){ + if (tok.image != null) { + s.append(tok.image); } - } - return false; - } - - /** Generated Token Manager. */ - public ParserTokenManager token_source; - /** Current token. */ - public Token token; - /** Next token. */ - public Token jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - private int jj_gen; - final private int[] jj_la1 = new int[261]; - static private int[] jj_la1_0; - static private int[] jj_la1_1; - static private int[] jj_la1_2; - static private int[] jj_la1_3; - static { - jj_la1_init_0(); - jj_la1_init_1(); - jj_la1_init_2(); - jj_la1_init_3(); - } - - private static void jj_la1_init_0() { - jj_la1_0 = new int[] { 0x0, 0x302, 0x302, 0x0, 0x300, 0x2, 0x2, 0x2, - 0xd4c40000, 0x0, 0x300, 0x2, 0x300, 0x2, 0x0, 0x2, 0x2, 0x2, - 0x0, 0x0, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, 0x2, 0x100000, 0x2, - 0x0, 0x2, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x2, 0x2, - 0xd4fd1500, 0xd4fd1500, 0x2, 0x2, 0x2, 0x0, 0x0, 0x2, 0x0, - 0x200000, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, - 0x0, 0x2, 0x391500, 0xc40000, 0xc40002, 0xc40000, 0x2, 0x2, - 0x80120002, 0x80120002, 0x2, 0x0, 0x0, 0x2, 0x2, 0x2, 0x2, - 0xd4c40000, 0xd4c40000, 0x2, 0x100000, 0x2, 0xd4c40000, 0x2, - 0x84000000, 0x84000000, 0x84000000, 0x84000000, 0xd4000000, - 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x2, 0x2, 0x3f000, 0x2, 0x0, - 0x2, 0x3f000, 0x0, 0x2, 0x0, 0x2, 0x0, 0x2, 0x200000, 0x0, - 0xd4c40000, 0x0, 0x134e0002, 0x2, 0xd4c40000, 0xd4c40000, 0x2, - 0x0, 0x2, 0x134e0002, 0x0, 0x2, 0xd4c40000, 0xd4c40000, 0x2, - 0x134e0002, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0x2, 0x2, - 0x100000, 0x2, 0x2, 0x2, 0x2, 0x0, 0x2, 0xd4c40000, 0xd4c40000, - 0x2, 0x100000, 0x2, 0x2, 0x2, 0x100000, 0x0, 0x0, 0x800c0000, - 0x2, 0x0, 0x100000, 0x2, 0x800c0000, 0x2, 0x0, 0x2, 0x2, 0x0, - 0x2, 0x200000, 0x2, 0xd4c40000, 0xd4c40000, 0x2, 0x200400, 0x2, - 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, - 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x2, 0x0, - 0x2, 0x2, 0x2, 0x100000, 0x2, 0x2, 0x0, 0x2, 0x0, 0x2, 0x2, - 0x2, 0x100000, 0x0, 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x200000, - 0x2, 0x2, 0x200000, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, - 0x0, 0xd4c40000, 0x2, 0x0, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, - 0x800c0400, 0x2, 0x0, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, 0x2, - 0x321c0000, 0xc0000, 0x800c0000, 0xc0000, 0x0, 0x80000000, 0x0, - 0x80000000, 0x800c0000, 0x2, 0x2, 0x800c0000, 0x2, 0xd4c40000, - 0x2, 0x2, 0x2, 0x0, 0x200000, 0x2, 0x0, 0x2, }; - } - - private static void jj_la1_init_1() { - jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x566000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, - 0x80, 0x0, 0x0, 0x120000, 0x120000, 0x0, 0x120000, 0x0, 0x0, - 0x0, 0x120000, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, - 0x60001c0, 0x60001c0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x80, 0x0, - 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, - 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc2, 0xc2, 0x0, 0x80, 0x80, - 0x0, 0x0, 0x0, 0x0, 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, - 0xc0, 0x0, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x50000000, 0x64000c0, 0x50000000, 0x3f, - 0x0, 0x564000c0, 0x564000c0, 0x0, 0x80000000, 0x0, 0x3f, 0x0, - 0x0, 0x564000c0, 0x564000c0, 0x0, 0x3f, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, - 0x564000c0, 0x564000c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, - 0x40, 0x160040, 0x0, 0x40, 0x0, 0x0, 0x160040, 0x0, 0x40, 0x0, - 0x0, 0x80, 0x0, 0x0, 0x0, 0x61200c0, 0x61200c0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, - 0x6000000, 0x0, 0x0, 0x60000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x6000000, 0xc0, 0x0, - 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x160000, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x160000, 0x0, - 0x0, 0x0, 0x160000, 0x160000, 0x160000, 0x0, 0x0, 0x160000, - 0x0, 0x60000c0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 0x0, }; - } - - private static void jj_la1_init_2() { - jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, - 0x1000, 0x0, 0x0, 0x0, 0x0, 0x880, 0x0, 0x0, 0x0, 0x100, 0x100, - 0x0, 0x0, 0x2008, 0x2008, 0x0, 0x2000, 0x0, 0x0, 0x0, 0x2000, - 0x0, 0x0, 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x2b80, 0x2b80, 0x0, - 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, - 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x2a80, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x380, 0x380, 0x0, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, - 0x1119, 0x1119, 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x0, 0x0, 0x0, 0x0, - 0x180, 0x0, 0x0, 0x0, 0x0, 0x100, 0x0, 0x40, 0x0, 0x0, 0x0, - 0x109, 0x1000, 0x1300, 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, - 0x1300, 0x20, 0x0, 0x1109, 0x1109, 0x0, 0x1300, 0x0, 0x0, 0x0, - 0x1100, 0x0, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x100, - 0x0, 0x1109, 0x1109, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1000, - 0x1000, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0x0, - 0x0, 0x0, 0x1100, 0x0, 0x0, 0x0, 0x2100, 0x2100, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x1000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0x100, - 0x0, 0x0, 0x100, 0x0, 0xfffffb80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfffffb80, 0x0, 0xffffe200, 0x0, - 0x100, 0x980, 0xffffeb80, 0x0, 0x0, 0xfffffb80, 0x0, 0x100, - 0x0, 0x0, 0x0, 0x100, 0x0, 0x0, 0x100, 0x0, }; - } - - private static void jj_la1_init_3() { - jj_la1_3 = new int[] { 0x8, 0x80, 0x80, 0x2, 0x80, 0x0, 0x0, 0x0, 0x75, - 0x0, 0x80, 0x0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, - 0xc5, 0x0, 0x0, 0x0, 0xc401bf, 0xc401bf, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xc401be, 0x0, 0x0, 0x0, 0x0, 0x0, 0x400000, - 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc7, 0xc7, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x400000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x80, 0x200000, 0x0, - 0xe5, 0xe5, 0x0, 0x0, 0x0, 0x200000, 0x0, 0x0, 0xe5, 0xe5, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x400000, 0x0, 0xf5, 0xf5, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x440001, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, - 0x0, 0x0, 0x0, 0x400000, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, - 0x0, 0x0, 0x380000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x100, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x100, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x440001, 0x0, 0x400000, - 0x0, 0x0, 0x40001, 0x440001, 0x0, 0x0, 0x440001, 0x0, 0x37, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, }; - } - - final private JJCalls[] jj_2_rtns = new JJCalls[9]; - private boolean jj_rescan = false; - private int jj_gc = 0; - - /** Constructor with user supplied CharStream. */ - public Parser(CharStream stream) { - token_source = new ParserTokenManager(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); + getNextToken(); } } + return s.toString().trim(); + } - /** Reinitialise. */ - public void ReInit(CharStream stream) { - token_source.ReInit(stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); - } + String skipStatement() throws ParseException { + StringBuffer s = new StringBuffer(); + Token tok = getToken(0); + if (tok.image != null) { + s.append(tok.image); } - - /** Constructor with generated Token Manager. */ - public Parser(ParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + return null; } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); + s.append(tok.image); + if (tok.kind == LBRACE) { + getNextToken(); + s.append(skip_to_matching_brace()); + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == RBRACE) { + getNextToken(); + tok = getToken(1); + break; + } else if (tok.kind == SEMICOLON) { + getNextToken(); + tok = getToken(1); + break; } + getNextToken(); } - /** Reinitialise. */ - public void ReInit(ParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 261; i++) { - jj_la1[i] = -1; - } - for (int i = 0; i < jj_2_rtns.length; i++) { - jj_2_rtns[i] = new JJCalls(); + // skip white space + while (true) { + if (tok.kind != S) { + break; } + tok = getNextToken(); + tok = getToken(1); } - private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) { - token = token.next; - } else { - token = token.next = token_source.getNextToken(); - } - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - if (++jj_gc > 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) { - c.first = null; + return s.toString().trim(); + } + + String skip_to_matching_brace() throws ParseException { + StringBuffer s = new StringBuffer(); + Token tok; + int nesting = 1; + while (true) { + tok = getToken(1); + if (tok.kind == EOF) { + break; + } + s.append(tok.image); + if (tok.kind == LBRACE) { + nesting++; + } else if (tok.kind == RBRACE) { + nesting--; + if (nesting == 0) { + break; + } + } + getNextToken(); + } + return s.toString(); + } + + String convertStringIndex(String s, int start, int len) throws ParseException { + StringBuffer buf = new StringBuffer(len); + int index = start; + + while (index < len) { + char c = s.charAt(index); + if (c == '\u005c\u005c') { + if (++index < len) { + c = s.charAt(index); + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + buf.append('\u005c\u005c'); + while (index < len) { + buf.append(s.charAt(index++)); + } + break; + case '\u005cn': + case '\u005cf': + break; + case '\u005cr': + if (index + 1 < len) { + if (s.charAt(index + 1) == '\u005cn') { + index ++; } - c = c.next; } + break; + default: + buf.append(c); } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - static private final class LookaheadSuccess extends java.lang.Error { - } - - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - - private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source - .getNextToken(); } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; + throw new CSSParseException("invalid string " + s, getLocator()); } } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; - Token tok = token; - while (tok != null && tok != jj_scanpos) { - i++; - tok = tok.next; - } - if (tok != null) { - jj_add_error_token(kind, i); - } + buf.append(c); } - if (jj_scanpos.kind != kind) { - return true; - } - if (jj_la == 0 && jj_scanpos == jj_lastpos) { - throw jj_ls; - } - return false; + index++; } - /** Get the next Token. */ - final public Token getNextToken() { - if (token.next != null) { - token = token.next; - } else { - token = token.next = token_source.getNextToken(); - } - jj_ntk = -1; - jj_gen++; - return token; - } + return buf.toString(); + } - /** Get the specific Token. */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) { - t = t.next; - } else { - t = t.next = token_source.getNextToken(); - } - } - return t; - } + String convertIdent(String s) throws ParseException { + return convertStringIndex(s, 0, s.length()); + } - private int jj_ntk() { - if ((jj_nt = token.next) == null) { - return (jj_ntk = (token.next = token_source.getNextToken()).kind); - } else { - return (jj_ntk = jj_nt.kind); + String convertString(String s) throws ParseException { + return convertStringIndex(s, 0, s.length()); + } + + void comments() throws ParseException { + /*keeps only the multiple line comments, single line comments are skipped*/ + if (token.specialToken != null && token.specialToken.image!=null && token.specialToken.image.startsWith("/*")){ + Token tmp_t = token.specialToken; + while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; + while (tmp_t != null) { + documentHandler.comment(tmp_t.image); + tmp_t = tmp_t.next; } } + } - private java.util.List jj_expentries = new java.util.ArrayList(); - private int[] jj_expentry; - private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; - private int jj_endpos; + void rejectToken(Token t) throws ParseException { + Token fakeToken = new Token(); + t.next = token; + fakeToken.next = t; + token = fakeToken; + } - private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) { - return; - } - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - jj_entries_loop: for (java.util.Iterator it = jj_expentries - .iterator(); it.hasNext();) { - int[] oldentry = (int[]) (it.next()); - if (oldentry.length == jj_expentry.length) { - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - continue jj_entries_loop; - } - } - jj_expentries.add(jj_expentry); - break jj_entries_loop; - } - } - if (pos != 0) { - jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } + String skipAfterExpression() throws ParseException { + Token t = getToken(1); + StringBuffer s = new StringBuffer(); + s.append(getToken(0).image); + + while ((t.kind != RBRACE) && (t.kind != SEMICOLON) && (t.kind != EOF)) { + s.append(t.image); + getNextToken(); + t = getToken(1); } - /** Generate ParseException. */ - public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[120]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 261; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1 << j)) != 0) { - la1tokens[j] = true; - } - if ((jj_la1_1[i] & (1 << j)) != 0) { - la1tokens[32 + j] = true; - } - if ((jj_la1_2[i] & (1 << j)) != 0) { - la1tokens[64 + j] = true; + return s.toString(); + } + +/** + * The following functions are useful for a DOM CSS implementation only and are + * not part of the general CSS2 parser. + */ +// TODO required by original parser but not used by Vaadin? + final public void _parseRule() throws ParseException { + String ret = null; + label_169: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[251] = jj_gen; + break label_169; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case IMPORT_SYM: + importDeclaration(); + break; + case DEBUG_SYM: + case WARN_SYM: + debuggingDirective(); + break; + case PLUS: + case PRECEDES: + case SIBLING: + case LBRACKET: + case ANY: + case PARENT: + case DOT: + case COLON: + case INTERPOLATION: + case IDENT: + case HASH: + styleRule(); + break; + case MEDIA_SYM: + media(); + break; + case PAGE_SYM: + page(); + break; + case FONT_FACE_SYM: + fontFace(); + break; + default: + jj_la1[252] = jj_gen; + ret = skipStatement(); + if ((ret == null) || (ret.length() == 0)) { + {if (true) return;} } - if ((jj_la1_3[i] & (1 << j)) != 0) { - la1tokens[96 + j] = true; + if (ret.charAt(0) == '@') { + documentHandler.unrecognizedRule(ret); + } else { + {if (true) throw new CSSParseException("unrecognize rule: " + ret, + getLocator());} } - } - } - } - for (int i = 0; i < 120; i++) { - if (la1tokens[i]) { - jj_expentry = new int[1]; - jj_expentry[0] = i; - jj_expentries.add(jj_expentry); - } - } - jj_endpos = 0; - jj_rescan_token(); - jj_add_error_token(0, 0); - int[][] exptokseq = new int[jj_expentries.size()][]; - for (int i = 0; i < jj_expentries.size(); i++) { - exptokseq[i] = jj_expentries.get(i); - } - return new ParseException(token, exptokseq, tokenImage); } + } + + final public void _parseImportRule() throws ParseException { + label_170: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[253] = jj_gen; + break label_170; + } + jj_consume_token(S); + } + importDeclaration(); + } + + final public void _parseMediaRule() throws ParseException { + label_171: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[254] = jj_gen; + break label_171; + } + jj_consume_token(S); + } + media(); + } + + final public void _parseDeclarationBlock() throws ParseException { + label_172: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[255] = jj_gen; + break label_172; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[256] = jj_gen; + ; + } + label_173: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case SEMICOLON: + ; + break; + default: + jj_la1[257] = jj_gen; + break label_173; + } + jj_consume_token(SEMICOLON); + label_174: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[258] = jj_gen; + break label_174; + } + jj_consume_token(S); + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case INTERPOLATION: + case IDENT: + declaration(); + break; + default: + jj_la1[259] = jj_gen; + ; + } + } + } + + final public ArrayList _parseSelectors() throws ParseException { + ArrayList p = null; + try { + label_175: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case S: + ; + break; + default: + jj_la1[260] = jj_gen; + break label_175; + } + jj_consume_token(S); + } + p = selectorList(); + {if (true) return p;} + } catch (ThrowedParseException e) { + {if (true) throw (ParseException) e.e.fillInStackTrace();} + } + throw new Error("Missing return statement in function"); + } + + private boolean jj_2_1(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_1(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(0, xla); } + } + + private boolean jj_2_2(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_2(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(1, xla); } + } + + private boolean jj_2_3(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_3(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(2, xla); } + } + + private boolean jj_2_4(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_4(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(3, xla); } + } + + private boolean jj_2_5(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_5(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(4, xla); } + } + + private boolean jj_2_6(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_6(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(5, xla); } + } + + private boolean jj_2_7(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_7(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(6, xla); } + } + + private boolean jj_2_8(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_8(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(7, xla); } + } + + private boolean jj_2_9(int xla) { + jj_la = xla; jj_lastpos = jj_scanpos = token; + try { return !jj_3_9(); } + catch(LookaheadSuccess ls) { return true; } + finally { jj_save(8, xla); } + } + + private boolean jj_3R_207() { + if (jj_scan_token(MOD)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_206() { + if (jj_scan_token(ANY)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_205() { + if (jj_scan_token(DIV)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_204() { + if (jj_scan_token(COMMA)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_185() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_204()) { + jj_scanpos = xsp; + if (jj_3R_205()) { + jj_scanpos = xsp; + if (jj_3R_206()) { + jj_scanpos = xsp; + if (jj_3R_207()) { + jj_scanpos = xsp; + if (jj_3R_208()) { + jj_scanpos = xsp; + if (jj_3R_209()) return true; + } + } + } + } + } + return false; + } + + private boolean jj_3R_212() { + if (jj_3R_211()) return true; + return false; + } + + private boolean jj_3R_211() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(18)) { + jj_scanpos = xsp; + if (jj_scan_token(22)) { + jj_scanpos = xsp; + if (jj_scan_token(23)) return true; + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_191() { + if (jj_scan_token(S)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_212()) jj_scanpos = xsp; + return false; + } + + private boolean jj_3R_210() { + if (jj_scan_token(GUARDED_SYM)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_176() { + if (jj_3R_186()) return true; + if (jj_scan_token(COLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (jj_3R_187()) return true; + xsp = jj_scanpos; + if (jj_3R_188()) jj_scanpos = xsp; + if (jj_3R_189()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_189()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_190() { + if (jj_3R_211()) return true; + return false; + } + + private boolean jj_3R_177() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_190()) { + jj_scanpos = xsp; + if (jj_3R_191()) return true; + } + return false; + } + + private boolean jj_3R_194() { + if (jj_scan_token(VARIABLE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(COLON)) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_179() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_194()) jj_scanpos = xsp; + if (jj_scan_token(CONTAINS)) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (true) { jj_la = 0; jj_scanpos = jj_lastpos; return false;} + return false; + } + + private boolean jj_3R_262() { + if (jj_scan_token(HASH)) return true; + return false; + } + + private boolean jj_3R_279() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_280() { + if (jj_scan_token(FUNCTION)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (true) { jj_la = 0; jj_scanpos = jj_lastpos; return false;} + return false; + } + + private boolean jj_3R_278() { + if (jj_scan_token(COLON)) return true; + return false; + } + + private boolean jj_3R_265() { + if (jj_scan_token(COLON)) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_278()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_279()) { + jj_scanpos = xsp; + if (jj_3R_280()) return true; + } + return false; + } + + private boolean jj_3_7() { + if (jj_3R_183()) return true; + return false; + } + + private boolean jj_3R_201() { + if (jj_scan_token(LBRACE)) return true; + return false; + } + + private boolean jj_3R_290() { + if (jj_scan_token(STRING)) return true; + return false; + } + + private boolean jj_3R_288() { + if (jj_scan_token(STARMATCH)) return true; + return false; + } + + private boolean jj_3R_287() { + if (jj_scan_token(DOLLARMATCH)) return true; + return false; + } + + private boolean jj_3R_289() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_286() { + if (jj_scan_token(CARETMATCH)) return true; + return false; + } + + private boolean jj_3R_285() { + if (jj_scan_token(DASHMATCH)) return true; + return false; + } + + private boolean jj_3R_284() { + if (jj_scan_token(INCLUDES)) return true; + return false; + } + + private boolean jj_3R_270() { + if (jj_scan_token(INTERPOLATION)) return true; + return false; + } + + private boolean jj_3R_283() { + if (jj_scan_token(EQ)) return true; + return false; + } + + private boolean jj_3R_200() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_277() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_283()) { + jj_scanpos = xsp; + if (jj_3R_284()) { + jj_scanpos = xsp; + if (jj_3R_285()) { + jj_scanpos = xsp; + if (jj_3R_286()) { + jj_scanpos = xsp; + if (jj_3R_287()) { + jj_scanpos = xsp; + if (jj_3R_288()) return true; + } + } + } + } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_289()) { + jj_scanpos = xsp; + if (jj_3R_290()) return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3_6() { + if (jj_3R_182()) return true; + if (jj_scan_token(LBRACE)) return true; + return false; + } + + private boolean jj_3R_264() { + if (jj_scan_token(LBRACKET)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (jj_scan_token(IDENT)) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_277()) jj_scanpos = xsp; + if (jj_scan_token(RBRACKET)) return true; + return false; + } + + private boolean jj_3R_183() { + if (jj_3R_199()) return true; + if (jj_scan_token(COLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_200()) { + jj_scanpos = xsp; + if (jj_3R_201()) return true; + } + return false; + } + + private boolean jj_3R_282() { + if (jj_scan_token(INTERPOLATION)) return true; + return false; + } + + private boolean jj_3R_268() { + if (jj_3R_187()) return true; + return false; + } + + private boolean jj_3R_248() { + if (jj_scan_token(PARENT)) return true; + return false; + } + + private boolean jj_3R_247() { + if (jj_scan_token(ANY)) return true; + return false; + } + + private boolean jj_3R_261() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_269()) { + jj_scanpos = xsp; + if (jj_3R_270()) return true; + } + return false; + } + + private boolean jj_3R_269() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_213() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_246()) { + jj_scanpos = xsp; + if (jj_3R_247()) { + jj_scanpos = xsp; + if (jj_3R_248()) return true; + } + } + return false; + } + + private boolean jj_3R_246() { + Token xsp; + if (jj_3R_261()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_261()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_254() { + if (jj_scan_token(FUNCTION)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + xsp = jj_scanpos; + if (jj_3R_268()) jj_scanpos = xsp; + if (jj_scan_token(RPARAN)) return true; + return false; + } + + private boolean jj_3R_180() { + if (jj_scan_token(COMMA)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_241() { + if (jj_3R_258()) return true; + return false; + } + + private boolean jj_3R_276() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_281()) { + jj_scanpos = xsp; + if (jj_3R_282()) return true; + } + return false; + } + + private boolean jj_3R_281() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_240() { + if (jj_3R_257()) return true; + return false; + } + + private boolean jj_3R_239() { + if (jj_3R_256()) return true; + return false; + } + + private boolean jj_3_5() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_180()) jj_scanpos = xsp; + if (jj_3R_181()) return true; + return false; + } + + private boolean jj_3R_263() { + if (jj_scan_token(DOT)) return true; + Token xsp; + if (jj_3R_276()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_276()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_252() { + if (jj_3R_265()) return true; + return false; + } + + private boolean jj_3R_275() { + if (jj_3R_265()) return true; + return false; + } + + private boolean jj_3R_273() { + if (jj_3R_263()) return true; + return false; + } + + private boolean jj_3R_250() { + if (jj_3R_263()) return true; + return false; + } + + private boolean jj_3R_251() { + if (jj_3R_264()) return true; + return false; + } + + private boolean jj_3R_274() { + if (jj_3R_264()) return true; + return false; + } + + private boolean jj_3R_255() { + if (jj_scan_token(DOT)) return true; + return false; + } + + private boolean jj_3R_271() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_272()) { + jj_scanpos = xsp; + if (jj_3R_273()) { + jj_scanpos = xsp; + if (jj_3R_274()) { + jj_scanpos = xsp; + if (jj_3R_275()) return true; + } + } + } + return false; + } + + private boolean jj_3R_272() { + if (jj_3R_262()) return true; + return false; + } + + private boolean jj_3R_238() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_255()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_scan_token(72)) { + jj_scanpos = xsp; + if (jj_scan_token(49)) { + jj_scanpos = xsp; + if (jj_scan_token(50)) { + jj_scanpos = xsp; + if (jj_scan_token(52)) return true; + } + } + } + return false; + } + + private boolean jj_3R_237() { + if (jj_scan_token(STRING)) return true; + return false; + } + + private boolean jj_3R_214() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_249()) { + jj_scanpos = xsp; + if (jj_3R_250()) { + jj_scanpos = xsp; + if (jj_3R_251()) { + jj_scanpos = xsp; + if (jj_3R_252()) return true; + } + } + } + return false; + } + + private boolean jj_3R_249() { + if (jj_3R_262()) return true; + return false; + } + + private boolean jj_3R_236() { + if (jj_3R_254()) return true; + return false; + } + + private boolean jj_3R_196() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_237()) { + jj_scanpos = xsp; + if (jj_3R_238()) { + jj_scanpos = xsp; + if (jj_3R_239()) { + jj_scanpos = xsp; + if (jj_3R_240()) { + jj_scanpos = xsp; + if (jj_3R_241()) return true; + } + } + } + } + return false; + } + + private boolean jj_3R_193() { + Token xsp; + if (jj_3R_214()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_214()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_192() { + if (jj_3R_213()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_271()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_178() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_192()) { + jj_scanpos = xsp; + if (jj_3R_193()) return true; + } + return false; + } + + private boolean jj_3R_243() { + if (jj_3R_211()) return true; + if (jj_3R_178()) return true; + return false; + } + + private boolean jj_3R_235() { + if (jj_scan_token(DIMEN)) return true; + return false; + } + + private boolean jj_3R_234() { + if (jj_scan_token(KHZ)) return true; + return false; + } + + private boolean jj_3R_233() { + if (jj_scan_token(HZ)) return true; + return false; + } + + private boolean jj_3R_232() { + if (jj_scan_token(MS)) return true; + return false; + } + + private boolean jj_3R_231() { + if (jj_scan_token(SECOND)) return true; + return false; + } + + private boolean jj_3R_230() { + if (jj_scan_token(GRAD)) return true; + return false; + } + + private boolean jj_3R_229() { + if (jj_scan_token(RAD)) return true; + return false; + } + + private boolean jj_3R_228() { + if (jj_scan_token(DEG)) return true; + return false; + } + + private boolean jj_3R_227() { + if (jj_scan_token(EXS)) return true; + return false; + } + + private boolean jj_3R_226() { + if (jj_scan_token(REM)) return true; + return false; + } + + private boolean jj_3_2() { + if (jj_3R_177()) return true; + if (jj_3R_178()) return true; + return false; + } + + private boolean jj_3R_225() { + if (jj_scan_token(LEM)) return true; + return false; + } + + private boolean jj_3R_224() { + if (jj_scan_token(EMS)) return true; + return false; + } + + private boolean jj_3R_198() { + if (jj_scan_token(COMMA)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + if (jj_3R_197()) return true; + return false; + } + + private boolean jj_3R_242() { + if (jj_3R_178()) return true; + return false; + } + + private boolean jj_3R_223() { + if (jj_scan_token(PX)) return true; + return false; + } + + private boolean jj_3R_222() { + if (jj_scan_token(IN)) return true; + return false; + } + + private boolean jj_3R_197() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_242()) { + jj_scanpos = xsp; + if (jj_3R_243()) return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_221() { + if (jj_scan_token(PC)) return true; + return false; + } + + private boolean jj_3R_220() { + if (jj_scan_token(MM)) return true; + return false; + } + + private boolean jj_3R_219() { + if (jj_scan_token(CM)) return true; + return false; + } + + private boolean jj_3R_218() { + if (jj_scan_token(PT)) return true; + return false; + } + + private boolean jj_3R_217() { + if (jj_scan_token(PERCENTAGE)) return true; + return false; + } + + private boolean jj_3R_203() { + if (jj_3R_245()) return true; + return false; + } + + private boolean jj_3R_182() { + if (jj_3R_197()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_198()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_216() { + if (jj_scan_token(NUMBER)) return true; + return false; + } + + private boolean jj_3R_215() { + if (jj_3R_253()) return true; + return false; + } + + private boolean jj_3R_195() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_215()) jj_scanpos = xsp; + xsp = jj_scanpos; + if (jj_3R_216()) { + jj_scanpos = xsp; + if (jj_3R_217()) { + jj_scanpos = xsp; + if (jj_3R_218()) { + jj_scanpos = xsp; + if (jj_3R_219()) { + jj_scanpos = xsp; + if (jj_3R_220()) { + jj_scanpos = xsp; + if (jj_3R_221()) { + jj_scanpos = xsp; + if (jj_3R_222()) { + jj_scanpos = xsp; + if (jj_3R_223()) { + jj_scanpos = xsp; + if (jj_3R_224()) { + jj_scanpos = xsp; + if (jj_3R_225()) { + jj_scanpos = xsp; + if (jj_3R_226()) { + jj_scanpos = xsp; + if (jj_3R_227()) { + jj_scanpos = xsp; + if (jj_3R_228()) { + jj_scanpos = xsp; + if (jj_3R_229()) { + jj_scanpos = xsp; + if (jj_3R_230()) { + jj_scanpos = xsp; + if (jj_3R_231()) { + jj_scanpos = xsp; + if (jj_3R_232()) { + jj_scanpos = xsp; + if (jj_3R_233()) { + jj_scanpos = xsp; + if (jj_3R_234()) { + jj_scanpos = xsp; + if (jj_3R_235()) { + jj_scanpos = xsp; + if (jj_3R_236()) return true; + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + return false; + } + + private boolean jj_3_1() { + if (jj_3R_176()) return true; + return false; + } + + private boolean jj_3R_181() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_195()) { + jj_scanpos = xsp; + if (jj_3R_196()) return true; + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_256() { + if (jj_scan_token(HASH)) return true; + return false; + } + + private boolean jj_3_4() { + if (jj_3R_179()) return true; + return false; + } + + private boolean jj_3R_245() { + if (jj_3R_186()) return true; + return false; + } + + private boolean jj_3R_257() { + if (jj_scan_token(URL)) return true; + return false; + } + + private boolean jj_3R_202() { + if (jj_3R_181()) return true; + return false; + } + + private boolean jj_3R_260() { + if (jj_scan_token(INTERPOLATION)) return true; + return false; + } - /** Enable tracing. */ - final public void enable_tracing() { + private boolean jj_3R_184() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_202()) { + jj_scanpos = xsp; + if (jj_3R_203()) return true; } + return false; + } - /** Disable tracing. */ - final public void disable_tracing() { - } + private boolean jj_3_9() { + if (jj_3R_185()) return true; + return false; + } - private void jj_rescan_token() { - jj_rescan = true; - for (int i = 0; i < 9; i++) { - try { - JJCalls p = jj_2_rtns[i]; - do { - if (p.gen > jj_gen) { - jj_la = p.arg; - jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: - jj_3_1(); - break; - case 1: - jj_3_2(); - break; - case 2: - jj_3_3(); - break; - case 3: - jj_3_4(); - break; - case 4: - jj_3_5(); - break; - case 5: - jj_3_6(); - break; - case 6: - jj_3_7(); - break; - case 7: - jj_3_8(); - break; - case 8: - jj_3_9(); - break; - } - } - p = p.next; - } while (p != null); - } catch (LookaheadSuccess ls) { - } - } - jj_rescan = false; - } + private boolean jj_3_3() { + if (jj_3R_176()) return true; + return false; + } - private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { - p = p.next = new JJCalls(); - break; - } - p = p.next; - } - p.gen = jj_gen + xla - jj_la; - p.first = token; - p.arg = xla; - } + private boolean jj_3R_267() { + if (jj_scan_token(PLUS)) return true; + return false; + } - static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; + private boolean jj_3R_253() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_266()) { + jj_scanpos = xsp; + if (jj_3R_267()) return true; } + return false; + } + + private boolean jj_3R_266() { + if (jj_scan_token(MINUS)) return true; + return false; + } + + private boolean jj_3R_258() { + if (jj_scan_token(UNICODERANGE)) return true; + return false; + } + + private boolean jj_3_8() { + Token xsp; + xsp = jj_scanpos; + if (jj_3_9()) jj_scanpos = xsp; + if (jj_3R_184()) return true; + return false; + } + + private boolean jj_3R_186() { + if (jj_scan_token(VARIABLE)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_189() { + if (jj_scan_token(SEMICOLON)) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_187() { + if (jj_3R_184()) return true; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_8()) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_244() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_259()) { + jj_scanpos = xsp; + if (jj_3R_260()) return true; + } + return false; + } + + private boolean jj_3R_259() { + if (jj_scan_token(IDENT)) return true; + return false; + } + + private boolean jj_3R_199() { + Token xsp; + if (jj_3R_244()) return true; + while (true) { + xsp = jj_scanpos; + if (jj_3R_244()) { jj_scanpos = xsp; break; } + } + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_209() { + if (jj_scan_token(MINUS)) return true; + Token xsp; + if (jj_scan_token(1)) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + private boolean jj_3R_188() { + if (jj_3R_210()) return true; + return false; + } + + private boolean jj_3R_208() { + if (jj_scan_token(PLUS)) return true; + Token xsp; + if (jj_scan_token(1)) return true; + while (true) { + xsp = jj_scanpos; + if (jj_scan_token(1)) { jj_scanpos = xsp; break; } + } + return false; + } + + /** Generated Token Manager. */ + public ParserTokenManager token_source; + /** Current token. */ + public Token token; + /** Next token. */ + public Token jj_nt; + private int jj_ntk; + private Token jj_scanpos, jj_lastpos; + private int jj_la; + private int jj_gen; + final private int[] jj_la1 = new int[261]; + static private int[] jj_la1_0; + static private int[] jj_la1_1; + static private int[] jj_la1_2; + static private int[] jj_la1_3; + static { + jj_la1_init_0(); + jj_la1_init_1(); + jj_la1_init_2(); + jj_la1_init_3(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x0,0x302,0x302,0x0,0x300,0x2,0x2,0x2,0xd4c40000,0x0,0x300,0x2,0x300,0x2,0x0,0x2,0x2,0x2,0x0,0x0,0x2,0x2,0x0,0x0,0x2,0x0,0x2,0x100000,0x2,0x0,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x2,0x2,0xd4fd1500,0x2,0xd4fd1500,0x2,0x2,0x0,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x391500,0xc40000,0xc40002,0xc40000,0x2,0x2,0x80120002,0x80120002,0x2,0x0,0x0,0x2,0x2,0x2,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0xd4c40000,0x2,0x84000000,0x84000000,0x84000000,0x84000000,0xd4000000,0x0,0x0,0x0,0x0,0x50000000,0x2,0x2,0x3f000,0x2,0x0,0x2,0x3f000,0x0,0x2,0x0,0x2,0x0,0x2,0x200000,0x0,0xd4c40000,0x0,0x134e0002,0x2,0xd4c40000,0xd4c40000,0x2,0x0,0x2,0x134e0002,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x134e0002,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x0,0x2,0xd4c40000,0xd4c40000,0x2,0x100000,0x2,0x2,0x2,0x100000,0x0,0x0,0x800c0000,0x2,0x0,0x100000,0x2,0x800c0000,0x2,0x0,0x2,0x2,0x0,0x2,0x200000,0x2,0xd4c40000,0xd4c40000,0x2,0x200400,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x2,0x0,0x2,0x2,0x2,0x100000,0x2,0x2,0x0,0x2,0x0,0x2,0x2,0x2,0x100000,0x0,0x2,0x2,0x0,0x2,0x2,0x2,0x200000,0x2,0x2,0x200000,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,0x0,0xd4c40000,0x2,0x0,0x2,0x0,0x200000,0x2,0x0,0x2,0x800c0400,0x2,0x0,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x321c0000,0xc0000,0x800c0000,0xc0000,0x0,0x80000000,0x0,0x80000000,0x800c0000,0x2,0x2,0x800c0000,0x2,0xd4c40000,0x2,0x2,0x2,0x0,0x200000,0x2,0x0,0x2,}; + } + private static void jj_la1_init_1() { + jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x566000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x120000,0x120000,0x0,0x120000,0x0,0x0,0x0,0x120000,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x60001c0,0x0,0x60001c0,0x0,0x0,0x0,0x40,0x0,0x80,0x0,0x0,0x80,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0xc2,0xc2,0x0,0x80,0x80,0x0,0x0,0x0,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0xc0,0x0,0x40,0x40,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x50000000,0x64000c0,0x50000000,0x3f,0x0,0x564000c0,0x564000c0,0x0,0x80000000,0x0,0x3f,0x0,0x0,0x564000c0,0x564000c0,0x0,0x3f,0x0,0x0,0x0,0x0,0x0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x564000c0,0x564000c0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x40,0x160040,0x0,0x40,0x0,0x0,0x160040,0x0,0x40,0x0,0x0,0x80,0x0,0x0,0x0,0x61200c0,0x61200c0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x0,0x6000000,0x0,0x0,0x60000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x6000000,0xc0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,0x160000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x160000,0x0,0x0,0x0,0x160000,0x160000,0x160000,0x0,0x0,0x160000,0x0,0x60000c0,0x0,0x0,0x0,0x80,0x0,0x0,0x80,0x0,}; + } + private static void jj_la1_init_2() { + jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x1000,0x0,0x0,0x0,0x0,0x880,0x0,0x0,0x0,0x100,0x100,0x0,0x0,0x2008,0x2008,0x0,0x2000,0x0,0x0,0x0,0x2000,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x2b88,0x0,0x2b88,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x2a80,0x0,0x0,0x0,0x0,0x0,0x380,0x380,0x0,0x100,0x100,0x0,0x0,0x0,0x0,0x1119,0x1119,0x0,0x0,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x100,0x100,0x100,0x100,0x100,0x100,0x0,0x0,0x0,0x0,0x180,0x0,0x0,0x0,0x0,0x100,0x0,0x40,0x0,0x0,0x0,0x109,0x1000,0x1300,0x0,0x1109,0x1109,0x0,0x0,0x0,0x1300,0x20,0x0,0x1109,0x1109,0x0,0x1300,0x0,0x0,0x0,0x1100,0x0,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x1109,0x1109,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x1000,0xfffffb80,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x1100,0x0,0x0,0x0,0x2100,0x2100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,0xfffffb80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffb80,0x0,0xffffe200,0x0,0x100,0x980,0xffffeb80,0x0,0x0,0xfffffb80,0x0,0x100,0x0,0x0,0x0,0x100,0x0,0x0,0x100,0x0,}; + } + private static void jj_la1_init_3() { + jj_la1_3 = new int[] {0x8,0x80,0x80,0x2,0x80,0x0,0x0,0x0,0x75,0x0,0x80,0x0,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0xc5,0x0,0x0,0x0,0xc401bf,0x0,0xc401bf,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc401be,0x0,0x0,0x0,0x0,0x0,0x400000,0x400000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc7,0xc7,0x0,0x0,0x0,0x1,0x0,0x1,0x1,0x1,0x1,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x0,0x0,0x45,0x80,0x200000,0x0,0xe5,0xe5,0x0,0x0,0x0,0x200000,0x0,0x0,0xe5,0xe5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x400000,0x0,0xf5,0xf5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x440001,0x0,0x0,0x0,0x0,0x400000,0x0,0x0,0x0,0x1,0x1,0x0,0x0,0x0,0x0,0x380000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x440001,0x0,0x400000,0x0,0x0,0x40001,0x440001,0x0,0x0,0x440001,0x0,0x37,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; + } + final private JJCalls[] jj_2_rtns = new JJCalls[9]; + private boolean jj_rescan = false; + private int jj_gc = 0; + + /** Constructor with user supplied CharStream. */ + public Parser(CharStream stream) { + token_source = new ParserTokenManager(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(CharStream stream) { + token_source.ReInit(stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Constructor with generated Token Manager. */ + public Parser(ParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + /** Reinitialise. */ + public void ReInit(ParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 261; i++) jj_la1[i] = -1; + for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); + } + + private Token jj_consume_token(int kind) throws ParseException { + Token oldToken; + if ((oldToken = token).next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + if (token.kind == kind) { + jj_gen++; + if (++jj_gc > 100) { + jj_gc = 0; + for (int i = 0; i < jj_2_rtns.length; i++) { + JJCalls c = jj_2_rtns[i]; + while (c != null) { + if (c.gen < jj_gen) c.first = null; + c = c.next; + } + } + } + return token; + } + token = oldToken; + jj_kind = kind; + throw generateParseException(); + } + + static private final class LookaheadSuccess extends java.lang.Error { } + final private LookaheadSuccess jj_ls = new LookaheadSuccess(); + private boolean jj_scan_token(int kind) { + if (jj_scanpos == jj_lastpos) { + jj_la--; + if (jj_scanpos.next == null) { + jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); + } else { + jj_lastpos = jj_scanpos = jj_scanpos.next; + } + } else { + jj_scanpos = jj_scanpos.next; + } + if (jj_rescan) { + int i = 0; Token tok = token; + while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } + if (tok != null) jj_add_error_token(kind, i); + } + if (jj_scanpos.kind != kind) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; + return false; + } + + +/** Get the next Token. */ + final public Token getNextToken() { + if (token.next != null) token = token.next; + else token = token.next = token_source.getNextToken(); + jj_ntk = -1; + jj_gen++; + return token; + } + +/** Get the specific Token. */ + final public Token getToken(int index) { + Token t = token; + for (int i = 0; i < index; i++) { + if (t.next != null) t = t.next; + else t = t.next = token_source.getNextToken(); + } + return t; + } + + private int jj_ntk() { + if ((jj_nt=token.next) == null) + return (jj_ntk = (token.next=token_source.getNextToken()).kind); + else + return (jj_ntk = jj_nt.kind); + } + + private java.util.List jj_expentries = new java.util.ArrayList(); + private int[] jj_expentry; + private int jj_kind = -1; + private int[] jj_lasttokens = new int[100]; + private int jj_endpos; + + private void jj_add_error_token(int kind, int pos) { + if (pos >= 100) return; + if (pos == jj_endpos + 1) { + jj_lasttokens[jj_endpos++] = kind; + } else if (jj_endpos != 0) { + jj_expentry = new int[jj_endpos]; + for (int i = 0; i < jj_endpos; i++) { + jj_expentry[i] = jj_lasttokens[i]; + } + jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { + int[] oldentry = (int[])(it.next()); + if (oldentry.length == jj_expentry.length) { + for (int i = 0; i < jj_expentry.length; i++) { + if (oldentry[i] != jj_expentry[i]) { + continue jj_entries_loop; + } + } + jj_expentries.add(jj_expentry); + break jj_entries_loop; + } + } + if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; + } + } + + /** Generate ParseException. */ + public ParseException generateParseException() { + jj_expentries.clear(); + boolean[] la1tokens = new boolean[120]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 261; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1< jj_gen) { + jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; + switch (i) { + case 0: jj_3_1(); break; + case 1: jj_3_2(); break; + case 2: jj_3_3(); break; + case 3: jj_3_4(); break; + case 4: jj_3_5(); break; + case 5: jj_3_6(); break; + case 6: jj_3_7(); break; + case 7: jj_3_8(); break; + case 8: jj_3_9(); break; + } + } + p = p.next; + } while (p != null); + } catch(LookaheadSuccess ls) { } + } + jj_rescan = false; + } + + private void jj_save(int index, int xla) { + JJCalls p = jj_2_rtns[index]; + while (p.gen > jj_gen) { + if (p.next == null) { p = p.next = new JJCalls(); break; } + p = p.next; + } + p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; + } + + static final class JJCalls { + int gen; + Token first; + int arg; + JJCalls next; + } } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj index 5fb7f2315f..196e02878a 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Parser.jj @@ -912,18 +912,24 @@ void media() : ( )* mediaStatement(ml) { start = true; documentHandler.startMedia(ml); } - ( )* ( debuggingDirective() | styleRule() | skipUnknownRule() )* ( )* + ( )* ( mediaDirective() )* ( )* } catch (ParseException e) { reportError(getLocator(), e); skipStatement(); // reportWarningSkipText(getLocator(), skipStatement()); } finally { if (start) { - documentHandler.endMedia(ml); + documentHandler.endMedia(ml); } } } +void mediaDirective() : +{} +{ + debuggingDirective() | styleRule() | skipUnknownRule() | contentDirective() +} + void mediaStatement(MediaListImpl ml) : { Token t; diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java index 26d1121f96..ba29df7d33 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/Token.java @@ -143,4 +143,4 @@ public class Token implements java.io.Serializable { } } -/* JavaCC - OriginalChecksum=dad2146dc89e68f66e77382c9e448fb7 (do not edit this line) */ +/* JavaCC - OriginalChecksum=8b653fc6be4ca9bd10137ee3ad4c32c4 (do not edit this line) */ diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java index f093357e96..1757cf6705 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/TokenMgrError.java @@ -159,4 +159,4 @@ public class TokenMgrError extends Error this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=c7c96e9cf4a9320d03dd722437439354 (do not edit this line) */ +/* JavaCC - OriginalChecksum=525946b34c715198d7c29f668b049f5d (do not edit this line) */ diff --git a/theme-compiler/tests/resources/automatic/css/media.css b/theme-compiler/tests/resources/automatic/css/media.css index f4183d9a07..5f7267fa9a 100644 --- a/theme-compiler/tests/resources/automatic/css/media.css +++ b/theme-compiler/tests/resources/automatic/css/media.css @@ -1,3 +1,14 @@ +@media screen { + .v-view { + overflow: visible; + } + .details { + font-size: 1pt; + font-weight: bold; + } + width: 100%; +} + @media screen and (max-width: 480px) { .abc { background: red; diff --git a/theme-compiler/tests/resources/automatic/scss/media.scss b/theme-compiler/tests/resources/automatic/scss/media.scss index 7db52de9ed..311c5088c8 100644 --- a/theme-compiler/tests/resources/automatic/scss/media.scss +++ b/theme-compiler/tests/resources/automatic/scss/media.scss @@ -1,3 +1,24 @@ +@mixin media-settings { + @media screen { + .v-view { + overflow: visible; + } + @content; + } +} + +@include media-settings { + .details { + font: { + size : 1pt; + weight: bold; + } + } + + width:100%; +} + + @media screen and (max-width: 480px) { .abc { background: red; diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Media.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Media.java index 1c84bf8c49..b7ca325aa7 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Media.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/css/Media.java @@ -33,4 +33,5 @@ public class Media extends AbstractTestBase { IOException { testParser(css); } + } -- cgit v1.2.3 From c54c5e26d82cf22ff182904323fb4f215b03a438 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 23 Jan 2014 23:10:21 +0200 Subject: Separate heartbeat functionality from ApplicationConnection * Correctly cancels the timer if the interval is updated * Listens to ApplicationStoppedEvents and disables the heartbeat (#13249) Change-Id: I5f4f778583954a1dd22ffeb39ef3b8fa07b85a1c --- .../com/vaadin/client/ApplicationConnection.java | 66 ++------ .../com/vaadin/client/communication/Heartbeat.java | 171 +++++++++++++++++++++ 2 files changed, 182 insertions(+), 55 deletions(-) create mode 100644 client/src/com/vaadin/client/communication/Heartbeat.java diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 8a3841b173..c4814d7e66 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -65,9 +65,11 @@ import com.google.gwt.user.client.Window.ClosingHandler; import com.google.gwt.user.client.ui.HasWidgets; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConfiguration.ErrorMessage; +import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; import com.vaadin.client.ResourceLoader.ResourceLoadEvent; import com.vaadin.client.ResourceLoader.ResourceLoadListener; import com.vaadin.client.communication.HasJavaScriptConnectorHelper; +import com.vaadin.client.communication.Heartbeat; import com.vaadin.client.communication.JavaScriptMethodInvocation; import com.vaadin.client.communication.JsonDecoder; import com.vaadin.client.communication.JsonEncoder; @@ -427,6 +429,8 @@ public class ApplicationConnection { private VLoadingIndicator loadingIndicator; + private Heartbeat heartbeat = GWT.create(Heartbeat.class); + public static class MultiStepDuration extends Duration { private int previousStep = elapsedMillis(); @@ -489,7 +493,7 @@ public class ApplicationConnection { getLoadingIndicator().show(); - scheduleHeartbeat(); + heartbeat.init(this); Window.addWindowClosingHandler(new ClosingHandler() { @Override @@ -3310,20 +3314,11 @@ public class ApplicationConnection { * interval elapses if the interval is a positive number. Otherwise, does * nothing. * - * @see #sendHeartbeat() - * @see ApplicationConfiguration#getHeartbeatInterval() + * @deprecated as of 7.2, use {@link Heartbeat#schedule()} instead */ + @Deprecated protected void scheduleHeartbeat() { - final int interval = getConfiguration().getHeartbeatInterval(); - if (interval > 0) { - VConsole.log("Scheduling heartbeat in " + interval + " seconds"); - new Timer() { - @Override - public void run() { - sendHeartbeat(); - } - }.schedule(interval * 1000); - } + heartbeat.schedule(); } /** @@ -3332,51 +3327,12 @@ public class ApplicationConnection { * Heartbeat requests are used to inform the server that the client-side is * still alive. If the client page is closed or the connection lost, the * server will eventually close the inactive UI. - *

- * TODO: Improved error handling, like in doUidlRequest(). * - * @see #scheduleHeartbeat() + * @deprecated as of 7.2, use {@link Heartbeat#send()} instead */ + @Deprecated protected void sendHeartbeat() { - final String uri = addGetParameters( - translateVaadinUri(ApplicationConstants.APP_PROTOCOL_PREFIX - + ApplicationConstants.HEARTBEAT_PATH + '/'), - UIConstants.UI_ID_PARAMETER + "=" - + getConfiguration().getUIId()); - - final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri); - - final RequestCallback callback = new RequestCallback() { - - @Override - public void onResponseReceived(Request request, Response response) { - int status = response.getStatusCode(); - if (status == Response.SC_OK) { - // TODO Permit retry in some error situations - VConsole.log("Heartbeat response OK"); - scheduleHeartbeat(); - } else if (status == Response.SC_GONE) { - showSessionExpiredError(null); - } else { - VConsole.error("Failed sending heartbeat to server. Error code: " - + status); - } - } - - @Override - public void onError(Request request, Throwable exception) { - VConsole.error("Exception sending heartbeat: " + exception); - } - }; - - rb.setCallback(callback); - - try { - VConsole.log("Sending heartbeat request..."); - rb.send(); - } catch (RequestException re) { - callback.onError(null, re); - } + heartbeat.send(); } /** diff --git a/client/src/com/vaadin/client/communication/Heartbeat.java b/client/src/com/vaadin/client/communication/Heartbeat.java new file mode 100644 index 0000000000..46c8d62c71 --- /dev/null +++ b/client/src/com/vaadin/client/communication/Heartbeat.java @@ -0,0 +1,171 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.communication; + +import java.util.logging.Logger; + +import com.google.gwt.http.client.Request; +import com.google.gwt.http.client.RequestBuilder; +import com.google.gwt.http.client.RequestCallback; +import com.google.gwt.http.client.RequestException; +import com.google.gwt.http.client.Response; +import com.google.gwt.user.client.Timer; +import com.vaadin.client.ApplicationConnection; +import com.vaadin.client.ApplicationConnection.ApplicationStoppedEvent; +import com.vaadin.shared.ApplicationConstants; +import com.vaadin.shared.ui.ui.UIConstants; + +/** + * Handles sending of heartbeats to the server and reacting to the response + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class Heartbeat { + + private int interval = -1; + private Timer timer = new Timer() { + @Override + public void run() { + send(); + } + }; + + private ApplicationConnection connection; + + private static Logger getLogger() { + return Logger.getLogger(Heartbeat.class.getName()); + } + + /** + * Initializes the heartbeat for the given application connection + * + * @param applicationConnection + * the connection + */ + public void init(ApplicationConnection applicationConnection) { + interval = applicationConnection.getConfiguration() + .getHeartbeatInterval(); + setInterval(interval); + schedule(); + + applicationConnection.addHandler( + ApplicationConnection.ApplicationStoppedEvent.TYPE, + new ApplicationConnection.ApplicationStoppedHandler() { + + @Override + public void onApplicationStopped( + ApplicationStoppedEvent event) { + setInterval(-1); + schedule(); + } + }); + + } + + /** + * Sends a heartbeat to the server + */ + public void send() { + final String uri = ApplicationConnection.addGetParameters( + getConnection().translateVaadinUri( + ApplicationConstants.APP_PROTOCOL_PREFIX + + ApplicationConstants.HEARTBEAT_PATH + '/'), + UIConstants.UI_ID_PARAMETER + "=" + + getConnection().getConfiguration().getUIId()); + + final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, uri); + + final RequestCallback callback = new RequestCallback() { + + @Override + public void onResponseReceived(Request request, Response response) { + int status = response.getStatusCode(); + if (status == Response.SC_OK) { + // TODO Permit retry in some error situations + getLogger().fine("Heartbeat response OK"); + schedule(); + } else if (status == Response.SC_GONE) { + // FIXME This should really do something else like send an + // event + getConnection().showSessionExpiredError(null); + } else { + getLogger().warning( + "Failed sending heartbeat to server. Error code: " + + status); + } + } + + @Override + public void onError(Request request, Throwable exception) { + getLogger().severe("Exception sending heartbeat: " + exception); + } + }; + + rb.setCallback(callback); + + try { + getLogger().fine("Sending heartbeat request..."); + rb.send(); + } catch (RequestException re) { + callback.onError(null, re); + } + + } + + /** + * @return the interval at which heartbeat requests are sent + */ + public int getInterval() { + return interval; + } + + /** + * sets the interval at which heartbeat requests are sent + * + * @param interval + * the new interval + */ + public void setInterval(int interval) { + this.interval = interval; + } + + /** + * Updates the schedule of the heartbeat to match the set interval. A + * negative interval disables the heartbeat. + */ + public void schedule() { + if (getInterval() > 0) { + getLogger() + .fine("Scheduling heartbeat in " + interval + " seconds"); + timer.schedule(interval * 1000); + } else { + if (timer != null) { + getLogger().fine("Disabling heartbeat"); + timer.cancel(); + } + } + + } + + /** + * @return the application connection + */ + protected ApplicationConnection getConnection() { + return connection; + } + +} -- cgit v1.2.3 From a52b0ba902781e5daeffa4f9bc2e48f35eea2c35 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Wed, 29 Jan 2014 11:05:04 +0200 Subject: Use Logger instead of System.out and System.err (#10328). Change-Id: Icf53bdb80caf7a6989b90cf5ce83dd328d3e73dd --- common.xml | 6 ++- theme-compiler/build.xml | 3 +- .../src/com/vaadin/sass/CustomConsoleHandler.java | 52 ++++++++++++++++++++++ .../com/vaadin/sass/internal/ScssStylesheet.java | 17 +++++++ .../internal/handler/SCSSDocumentHandlerImpl.java | 33 ++++++++++---- .../sass/internal/handler/SCSSErrorHandler.java | 36 +++++++-------- .../vaadin/sass/internal/parser/LocatorImpl.java | 29 ++++++++---- .../com/vaadin/sass/internal/parser/Parser.java | 8 ++-- .../src/com/vaadin/sass/internal/parser/Parser.jj | 6 ++- .../sass/internal/parser/ParserTokenManager.java | 2 + .../sass/internal/selector/SelectorUtil.java | 13 ++++-- .../com/vaadin/sass/internal/tree/BlockNode.java | 5 ++- .../com/vaadin/sass/internal/tree/ExtendNode.java | 5 ++- .../com/vaadin/sass/internal/tree/MixinNode.java | 5 ++- .../tree/controldirective/IfElseDefNode.java | 6 ++- .../com/vaadin/sass/internal/util/DeepCopy.java | 12 +++-- .../sass/internal/visitor/ImportNodeHandler.java | 8 +++- theme-compiler/src/logging.properties | 2 + 18 files changed, 190 insertions(+), 58 deletions(-) create mode 100644 theme-compiler/src/com/vaadin/sass/CustomConsoleHandler.java create mode 100644 theme-compiler/src/logging.properties diff --git a/common.xml b/common.xml index a1c086c57a..9104f57961 100644 --- a/common.xml +++ b/common.xml @@ -139,6 +139,7 @@ + @@ -184,7 +185,7 @@ - + @@ -277,6 +278,9 @@ + + + diff --git a/theme-compiler/build.xml b/theme-compiler/build.xml index 03d0531a68..324934bd10 100644 --- a/theme-compiler/build.xml +++ b/theme-compiler/build.xml @@ -20,8 +20,7 @@ - + + + + - + -- cgit v1.2.3 From b8be7d056af02b0017c2d6705d95f6aefeb7ceac Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 12 Feb 2014 00:05:11 +0200 Subject: Ignore JSON serializers which do not need to be serializable Change-Id: Iccfe06495bc69d46c9c69e987776a39f824caf2f --- server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java b/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java index 705bae3d98..0a36c7f7ce 100644 --- a/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java +++ b/server/tests/src/com/vaadin/tests/server/TestClassesSerializable.java @@ -50,6 +50,8 @@ public class TestClassesSerializable extends TestCase { "com\\.vaadin\\.server\\.communication\\.FileUploadHandler\\$SimpleMultiPartInputStream", // "com\\.vaadin\\.server\\.communication\\.PushRequestHandler.*", "com\\.vaadin\\.server\\.communication\\.PushHandler.*", // PushHandler + "com\\.vaadin\\.server\\.communication\\.DateSerializer", // + "com\\.vaadin\\.server\\.communication\\.JSONSerializer", // // and its inner classes do not need to be serializable "com\\.vaadin\\.util\\.SerializerHelper", // fully static // class level filtering, also affecting nested classes and -- cgit v1.2.3 From 8937de6edd1606477587e67b43562aa1531be1dd Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 11 Feb 2014 23:28:36 +0200 Subject: Collapse all permutations by default (#13274) Change-Id: I98b13000067d7be8caf94ebecda6e40b698b21e0 --- client/src/com/vaadin/DefaultWidgetSet.gwt.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml index 3aba1f6fee..2719493853 100755 --- a/client/src/com/vaadin/DefaultWidgetSet.gwt.xml +++ b/client/src/com/vaadin/DefaultWidgetSet.gwt.xml @@ -10,4 +10,8 @@ + + -- cgit v1.2.3 From 0ffcdf782ebeb72a345f5d737960258fc6581ef9 Mon Sep 17 00:00:00 2001 From: Henrik Paul Date: Mon, 3 Feb 2014 16:22:13 +0200 Subject: Adds tests to changeset 53282726 (#12337) Change-Id: Ic6dcd98483feb59942392834deb3db356b17b8ab --- .../TableRemovedQuicklySendsInvalidRpcCalls.java | 226 ++++++++++++++++++--- ...ableRemovedQuicklySendsInvalidRpcCallsTest.java | 55 +++++ 2 files changed, 255 insertions(+), 26 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java index 6e4b62e4f7..ab0198f39c 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java +++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCalls.java @@ -16,26 +16,217 @@ package com.vaadin.tests.components.table; +import java.util.ArrayList; +import java.util.Collection; + +import org.json.JSONObject; + import com.vaadin.annotations.Push; -import com.vaadin.event.ItemClickEvent; -import com.vaadin.event.ItemClickEvent.ItemClickListener; +import com.vaadin.server.ClientConnector; +import com.vaadin.server.StreamVariable; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ConnectorTracker; import com.vaadin.ui.Table; @Push public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { + public static final String SUCCESS_CAPTION = "Success!"; + public static final String BUTTON_ID = "blinkbutton"; + public static final String FAILURE_CAPTION = "Test failed"; + + private class WrappedConnectorTracker extends ConnectorTracker { + private ConnectorTracker tracker; + + private boolean initialDirtyHasBeenCalled = false; + + public WrappedConnectorTracker(ConnectorTracker tracker) { + super(TableRemovedQuicklySendsInvalidRpcCalls.this); + this.tracker = tracker; + } + + @Override + public void markAllConnectorsDirty() { + tracker.markAllConnectorsDirty(); + if (initialDirtyHasBeenCalled) { + button.setCaption(FAILURE_CAPTION); + } + initialDirtyHasBeenCalled = true; + } + + // DELEGATED METHODS BELOW: + + @Override + public void registerConnector(ClientConnector connector) { + tracker.registerConnector(connector); + } + + @Override + public void unregisterConnector(ClientConnector connector) { + tracker.unregisterConnector(connector); + } + + @Override + public boolean isClientSideInitialized(ClientConnector connector) { + return tracker.isClientSideInitialized(connector); + } + + @Override + public void markClientSideInitialized(ClientConnector connector) { + tracker.markClientSideInitialized(connector); + } + + @Override + public void markAllClientSidesUninitialized() { + tracker.markAllClientSidesUninitialized(); + } + + @Override + public ClientConnector getConnector(String connectorId) { + return tracker.getConnector(connectorId); + } + + @Override + public void cleanConnectorMap() { + tracker.cleanConnectorMap(); + } + + @Override + public void markDirty(ClientConnector connector) { + tracker.markDirty(connector); + } + + @Override + public void markClean(ClientConnector connector) { + tracker.markClean(connector); + } + + @Override + public void markAllConnectorsClean() { + tracker.markAllConnectorsClean(); + } + + @Override + public Collection getDirtyConnectors() { + return tracker.getDirtyConnectors(); + } + + @Override + public boolean hasDirtyConnectors() { + return tracker.hasDirtyConnectors(); + } + + @Override + public ArrayList getDirtyVisibleConnectors() { + return tracker.getDirtyVisibleConnectors(); + } + + @Override + public JSONObject getDiffState(ClientConnector connector) { + return tracker.getDiffState(connector); + } + + @Override + public void setDiffState(ClientConnector connector, JSONObject diffState) { + tracker.setDiffState(connector, diffState); + } + + @Override + public boolean isDirty(ClientConnector connector) { + return tracker.isDirty(connector); + } + + @Override + public boolean isWritingResponse() { + return tracker.isWritingResponse(); + } + + @Override + public void setWritingResponse(boolean writingResponse) { + tracker.setWritingResponse(writingResponse); + } + + @Override + public StreamVariable getStreamVariable(String connectorId, + String variableName) { + return tracker.getStreamVariable(connectorId, variableName); + } + + @Override + public void addStreamVariable(String connectorId, String variableName, + StreamVariable variable) { + tracker.addStreamVariable(connectorId, variableName, variable); + } + + @Override + public void cleanStreamVariable(String connectorId, String variableName) { + tracker.cleanStreamVariable(connectorId, variableName); + } + + @Override + public String getSeckey(StreamVariable variable) { + return tracker.getSeckey(variable); + } + + @Override + public boolean connectorWasPresentAsRequestWasSent(String connectorId, + long lastSyncIdSeenByClient) { + return tracker.connectorWasPresentAsRequestWasSent(connectorId, + lastSyncIdSeenByClient); + } + + @Override + public int getCurrentSyncId() { + return tracker.getCurrentSyncId(); + } + + @Override + public void cleanConcurrentlyRemovedConnectorIds( + int lastSyncIdSeenByClient) { + tracker.cleanConcurrentlyRemovedConnectorIds(lastSyncIdSeenByClient); + } + + @Override + public boolean equals(Object obj) { + return tracker.equals(obj); + } + + @Override + public int hashCode() { + return tracker.hashCode(); + } + + @Override + public String toString() { + return tracker.toString(); + } + } + + private Button button; + private WrappedConnectorTracker wrappedTracker = null; + @Override protected void setup(VaadinRequest request) { - addComponent(new Button("Blink a table", new Button.ClickListener() { + button = new Button("Blink a table", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { blinkTable(); } - })); + }); + button.setId(BUTTON_ID); + addComponent(button); + } + + @Override + public ConnectorTracker getConnectorTracker() { + if (wrappedTracker == null) { + wrappedTracker = new WrappedConnectorTracker( + super.getConnectorTracker()); + } + return wrappedTracker; } private void blinkTable() { @@ -47,25 +238,6 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { table.addItem(new Object[] { "Row" }, new Object()); } - table.addItemClickListener(new ItemClickListener() { - private int i; - - @Override - public void itemClick(ItemClickEvent event) { - /* - * Ignore implementation. This is only an easy way to make the - * client-side update table's variables (by furiously clicking - * on the table row. - * - * This way, we get variable changes queued. The push call will - * then remove the Table, while the variable changes being still - * in the queue, leading to the issue as described in the - * ticket. - */ - System.out.println("clicky " + (++i)); - } - }); - System.out.println("adding component"); addComponent(table); @@ -80,6 +252,7 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { public void run() { System.out.println("removing component"); removeComponent(table); + button.setCaption(SUCCESS_CAPTION); } }); } catch (InterruptedException e) { @@ -87,7 +260,7 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { } finally { getSession().unlock(); } - }; + } }.start(); } @@ -96,8 +269,9 @@ public class TableRemovedQuicklySendsInvalidRpcCalls extends AbstractTestUI { return "Adding and subsequently quickly removing a table " + "should not leave any pending RPC calls waiting " + "in a Timer. Issue can be reproduced by " - + "1) pressing the button 2) clicking furiously " - + "on a row in the table."; + + "1) pressing the button 2) checking the server " + + "log for any error messages starting with " + + "\"RPC call to...\" ."; } @Override diff --git a/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java new file mode 100644 index 0000000000..68c8dc9884 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRemovedQuicklySendsInvalidRpcCallsTest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.table; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class TableRemovedQuicklySendsInvalidRpcCallsTest extends + MultiBrowserTest { + + private static final String BUTTON_ID = TableRemovedQuicklySendsInvalidRpcCalls.BUTTON_ID; + private static final String FAILURE_CAPTION = TableRemovedQuicklySendsInvalidRpcCalls.FAILURE_CAPTION; + private static final String SUCCESS_CAPTION = TableRemovedQuicklySendsInvalidRpcCalls.SUCCESS_CAPTION; + + @Test + public void test() throws Exception { + setDebug(true); + openTestURL(); + + assertFalse("Test started with the error present.", button().getText() + .equals(FAILURE_CAPTION)); + assertFalse("Test jumped the gun.", + button().getText().equals(SUCCESS_CAPTION)); + + button().click(); + Thread.sleep(5000); + + assertFalse("Test failed after trying to trigger the error.", button() + .getText().equals(FAILURE_CAPTION)); + assertTrue("Test didn't end up in correct success state.", button() + .getText().equals(SUCCESS_CAPTION)); + } + + private WebElement button() { + return vaadinElementById(BUTTON_ID); + } +} -- cgit v1.2.3 From 5592f056be51e2d18498c067fa5232963677d32e Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Tue, 4 Feb 2014 13:11:39 +0200 Subject: Reduce generated ConnectorBundleLoaderImpl size. (#9379) Change-Id: I49411e6893f3adc1c41cc690aca35cd919769625 --- .../ConnectorBundleLoaderFactory.java | 288 +++++++++++++-------- .../widgetsetutils/metadata/ConnectorBundle.java | 92 ++----- .../widgetsetutils/metadata/FieldProperty.java | 19 +- .../widgetsetutils/metadata/MethodProperty.java | 78 +++--- .../server/widgetsetutils/metadata/Property.java | 24 ++ .../client/metadata/ConnectorBundleLoader.java | 8 +- .../src/com/vaadin/client/metadata/Property.java | 8 +- .../com/vaadin/client/metadata/TypeDataStore.java | 167 ++++++++---- 8 files changed, 420 insertions(+), 264 deletions(-) diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java index f8aa586064..1c06cea3fa 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ConnectorBundleLoaderFactory.java @@ -19,6 +19,8 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -74,6 +76,7 @@ public class ConnectorBundleLoaderFactory extends Generator { private final SourceWriter target; private final String baseName; private final int splitSize; + private final List methodNames; // Seems to be undercounted by about 15% private int approximateChars = 0; @@ -84,6 +87,8 @@ public class ConnectorBundleLoaderFactory extends Generator { this.target = target; this.baseName = baseName; this.splitSize = splitSize; + methodNames = new ArrayList(); + methodNames.add(baseName); } @Override @@ -169,17 +174,34 @@ public class ConnectorBundleLoaderFactory extends Generator { } public void splitIfNeeded() { + splitIfNeeded(false, null); + } + + public void splitIfNeeded(boolean isNative, String params) { if (approximateChars > splitSize) { String newMethod = baseName + wrapCount++; - println("%s();", newMethod); - outdent(); - println("}"); - println("private void %s() {", newMethod); + String args = params == null ? "" : params; + if (isNative) { + outdent(); + println("}-*/;"); + println("private native void %s(%s) /*-{", newMethod, args); + } else { + println("%s();", newMethod); + outdent(); + println("}"); + println("private void %s(%s) {", newMethod, args); + } + methodNames.add(newMethod); indent(); approximateChars = 0; } } + + public List getMethodNames() { + return Collections.unmodifiableList(methodNames); + } + } @Override @@ -227,6 +249,8 @@ public class ConnectorBundleLoaderFactory extends Generator { w.indent(); for (ConnectorBundle bundle : bundles) { + detectBadProperties(bundle, logger); + String name = bundle.getName(); boolean isEager = name .equals(ConnectorBundleLoader.EAGER_BUNDLE_NAME); @@ -275,12 +299,34 @@ public class ConnectorBundleLoaderFactory extends Generator { w.println("private void load() {"); w.indent(); - printBundleData(logger, w, bundle); + String loadNativeJsBundle = "loadJsBundle"; + printBundleData(logger, w, bundle, loadNativeJsBundle); // Close load method w.outdent(); w.println("}"); + // Separate method for loading native JS stuff (e.g. callbacks) + String loadNativeJsMethodName = "loadNativeJs"; + w.println("private native void %s(%s store) /*-{", + loadNativeJsMethodName, TypeDataStore.class.getName()); + w.indent(); + List jsMethodNames = printJsBundleData(logger, w, bundle, + loadNativeJsMethodName); + + w.outdent(); + w.println("}-*/;"); + + // Call all generated native method inside one Java method to avoid + // refercences inside native methods to each other + w.println("private void %s(%s store) {", loadNativeJsBundle, + TypeDataStore.class.getName()); + w.indent(); + printLoadJsBundleData(w, loadNativeJsBundle, jsMethodNames); + w.outdent(); + w.println("}"); + + // onFailure method declaration starts w.println("public void onFailure(Throwable reason) {"); w.indent(); @@ -315,27 +361,153 @@ public class ConnectorBundleLoaderFactory extends Generator { w.commit(logger); } + private void printLoadJsBundleData(SourceWriter w, String methodName, + List methods) { + SplittingSourceWriter writer = new SplittingSourceWriter(w, methodName, + 30000); + + for (String method : methods) { + writer.println("%s(store);", method); + writer.splitIfNeeded(); + } + } + + private void detectBadProperties(ConnectorBundle bundle, TreeLogger logger) + throws UnableToCompleteException { + Map> definedProperties = new HashMap>(); + + for (Property property : bundle.getNeedsProperty()) { + JClassType beanType = property.getBeanType(); + Set usedPropertyNames = definedProperties.get(beanType); + if (usedPropertyNames == null) { + usedPropertyNames = new HashSet(); + definedProperties.put(beanType, usedPropertyNames); + } + + String name = property.getName(); + if (!usedPropertyNames.add(name)) { + logger.log(Type.ERROR, beanType.getQualifiedSourceName() + + " has multiple properties with the name " + name + + ". This can happen if there are multiple " + + "setters with identical names ignoring case."); + throw new UnableToCompleteException(); + } + if (!property.hasAccessorMethods()) { + logger.log(Type.ERROR, beanType.getQualifiedSourceName() + + " has the property '" + name + + "' without getter defined."); + throw new UnableToCompleteException(); + } + } + } + + private List printJsBundleData(TreeLogger logger, SourceWriter w, + ConnectorBundle bundle, String methodName) { + SplittingSourceWriter writer = new SplittingSourceWriter(w, methodName, + 30000); + Set needsProperty = bundle.getNeedsProperty(); + for (Property property : needsProperty) { + writer.println("var data = {"); + writer.indent(); + + writer.println("setter: function(bean, value) {"); + writer.indent(); + property.writeSetterBody(logger, writer, "bean", "value"); + writer.outdent(); + writer.println("},"); + + writer.println("getter: function(bean) {"); + writer.indent(); + property.writeGetterBody(logger, writer, "bean"); + writer.outdent(); + writer.println("}"); + + writer.outdent(); + writer.println("};"); + + // Method declaration + writer.print( + "store.@%s::setPropertyData(Ljava/lang/Class;Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)", + TypeDataStore.class.getName()); + writer.println("(@%s::class, '%s', data);", property.getBeanType() + .getQualifiedSourceName(), property.getName()); + writer.println(); + writer.splitIfNeeded(true, + String.format("%s store", TypeDataStore.class.getName())); + } + return writer.getMethodNames(); + } + private void printBundleData(TreeLogger logger, SourceWriter sourceWriter, - ConnectorBundle bundle) throws UnableToCompleteException { + ConnectorBundle bundle, String loadNativeJsMethodName) + throws UnableToCompleteException { // Split into new load method when reaching approximately 30000 bytes SplittingSourceWriter w = new SplittingSourceWriter(sourceWriter, "load", 30000); + writeSuperClasses(w, bundle); writeIdentifiers(w, bundle); writeGwtConstructors(w, bundle); writeReturnTypes(w, bundle); writeInvokers(w, bundle); writeParamTypes(w, bundle); writeProxys(w, bundle); - wirteDelayedInfo(w, bundle); - writeProperites(logger, w, bundle); - writePropertyTypes(w, bundle); - writeSetters(logger, w, bundle); - writeGetters(logger, w, bundle); + writeDelayedInfo(w, bundle); + + w.println("%s(store);", loadNativeJsMethodName); + + // Must use Java code to generate Type data (because of Type[]), doing + // this after the JS property data has been initialized + writePropertyTypes(logger, w, bundle); writeSerializers(logger, w, bundle); writeDelegateToWidget(logger, w, bundle); } + private void writeSuperClasses(SplittingSourceWriter w, + ConnectorBundle bundle) { + List needsSuperclass = new ArrayList( + bundle.getNeedsSuperclass()); + // Emit in hierarchy order to ensure superclass is defined when + // referenced + Collections.sort(needsSuperclass, new Comparator() { + + @Override + public int compare(JClassType type1, JClassType type2) { + int depthDiff = getDepth(type1) - getDepth(type2); + if (depthDiff != 0) { + return depthDiff; + } else { + // Just something to get a stable compare + return type1.getName().compareTo(type2.getName()); + } + } + + private int getDepth(JClassType type) { + int depth = 0; + while (type != null) { + depth++; + type = type.getSuperclass(); + } + return depth; + } + }); + + for (JClassType jClassType : needsSuperclass) { + JClassType superclass = jClassType.getSuperclass(); + while (superclass != null && !superclass.isPublic()) { + superclass = superclass.getSuperclass(); + } + String classLiteralString; + if (superclass == null) { + classLiteralString = "null"; + } else { + classLiteralString = getClassLiteralString(superclass); + } + w.println("store.setSuperClass(%s, %s);", + getClassLiteralString(jClassType), classLiteralString); + } + } + private void writeDelegateToWidget(TreeLogger logger, SplittingSourceWriter w, ConnectorBundle bundle) { Set needsDelegateToWidget = bundle.getNeedsDelegateToWidget(); @@ -378,64 +550,9 @@ public class ConnectorBundleLoaderFactory extends Generator { } } - private void writeGetters(TreeLogger logger, SplittingSourceWriter w, + private void writePropertyTypes(TreeLogger logger, SplittingSourceWriter w, ConnectorBundle bundle) { - Set properties = bundle.getNeedsSetter(); - for (Property property : properties) { - w.print("store.setGetter("); - writeClassLiteral(w, property.getBeanType()); - w.print(", \""); - w.print(escape(property.getName())); - w.println("\", new Invoker() {"); - w.indent(); - - w.println("public Object invoke(Object bean, Object[] params) {"); - w.indent(); - - property.writeGetterBody(logger, w, "bean"); - w.println(); - - w.outdent(); - w.println("}"); - - w.outdent(); - w.println("});"); - - w.splitIfNeeded(); - } - } - - private void writeSetters(TreeLogger logger, SplittingSourceWriter w, - ConnectorBundle bundle) { - Set properties = bundle.getNeedsSetter(); - for (Property property : properties) { - w.print("store.setSetter("); - writeClassLiteral(w, property.getBeanType()); - w.print(", \""); - w.print(escape(property.getName())); - w.println("\", new Invoker() {"); - w.indent(); - - w.println("public Object invoke(Object bean, Object[] params) {"); - w.indent(); - - property.writeSetterBody(logger, w, "bean", "params[0]"); - - w.println("return null;"); - - w.outdent(); - w.println("}"); - - w.outdent(); - w.println("});"); - - w.splitIfNeeded(); - } - } - - private void writePropertyTypes(SplittingSourceWriter w, - ConnectorBundle bundle) { - Set properties = bundle.getNeedsType(); + Set properties = bundle.getNeedsProperty(); for (Property property : properties) { w.print("store.setPropertyType("); writeClassLiteral(w, property.getBeanType()); @@ -449,40 +566,7 @@ public class ConnectorBundleLoaderFactory extends Generator { } } - private void writeProperites(TreeLogger logger, SplittingSourceWriter w, - ConnectorBundle bundle) throws UnableToCompleteException { - Set needsPropertyListing = bundle.getNeedsPropertyListing(); - for (JClassType type : needsPropertyListing) { - w.print("store.setProperties("); - writeClassLiteral(w, type); - w.print(", new String[] {"); - - Set usedPropertyNames = new HashSet(); - Collection properties = bundle.getProperties(type); - for (Property property : properties) { - String name = property.getName(); - if (!usedPropertyNames.add(name)) { - logger.log( - Type.ERROR, - type.getQualifiedSourceName() - + " has multiple properties with the name " - + name - + ". This can happen if there are multiple setters with identical names exect casing."); - throw new UnableToCompleteException(); - } - - w.print("\""); - w.print(name); - w.print("\", "); - } - - w.println("});"); - - w.splitIfNeeded(); - } - } - - private void wirteDelayedInfo(SplittingSourceWriter w, + private void writeDelayedInfo(SplittingSourceWriter w, ConnectorBundle bundle) { Map> needsDelayedInfo = bundle .getNeedsDelayedInfo(); diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java index 4d6a7ff6d7..0064a24aef 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/ConnectorBundle.java @@ -59,7 +59,7 @@ public class ConnectorBundle { private final Set needsSerializeSupport = new HashSet(); private final Map serializers = new HashMap(); - private final Set needsPropertyList = new HashSet(); + private final Set needsSuperClass = new HashSet(); private final Set needsGwtConstructor = new HashSet(); private final Set visitedTypes = new HashSet(); private final Set needsProxySupport = new HashSet(); @@ -70,9 +70,7 @@ public class ConnectorBundle { private final Map> needsParamTypes = new HashMap>(); private final Map> needsDelayedInfo = new HashMap>(); - private final Set needsSetter = new HashSet(); - private final Set needsType = new HashSet(); - private final Set needsGetter = new HashSet(); + private final Set needsProperty = new HashSet(); private final Set needsDelegateToWidget = new HashSet(); private ConnectorBundle(String name, ConnectorBundle previousBundle, @@ -246,16 +244,18 @@ public class ConnectorBundle { logger.log(Type.INFO, "Will serialize " + type + " as a bean"); - setNeedsPropertyList(typeAsClass); + JClassType needsSuperClass = typeAsClass; + while (needsSuperClass != null) { + if (needsSuperClass.isPublic()) { + setNeedsSuperclass(needsSuperClass); + } + needsSuperClass = needsSuperClass.getSuperclass(); + } for (Property property : getProperties(typeAsClass)) { setNeedsGwtConstructor(property.getBeanType()); - setNeedsSetter(property); - // Getters needed for reading previous value that should be - // passed to sub encoder - setNeedsGetter(property); - setNeedsType(property); + setNeedsProperty(property); JType propertyType = property.getPropertyType(); setNeedsSerialize(propertyType); @@ -304,80 +304,42 @@ public class ConnectorBundle { return Collections.unmodifiableMap(serializers); } - private void setNeedsGetter(Property property) { - if (!isNeedsGetter(property)) { - needsGetter.add(property); - } - } - - private boolean isNeedsGetter(Property property) { - if (needsGetter.contains(property)) { - return true; - } else { - return previousBundle != null - && previousBundle.isNeedsGetter(property); - } - } - - public Set getNeedsGetter() { - return Collections.unmodifiableSet(needsGetter); - } - - private void setNeedsType(Property property) { - if (!isNeedsType(property)) { - needsType.add(property); - } - } - - public Set getNeedsType() { - return Collections.unmodifiableSet(needsType); - } - - private boolean isNeedsType(Property property) { - if (needsType.contains(property)) { - return true; - } else { - return previousBundle != null - && previousBundle.isNeedsType(property); - } - } - - public void setNeedsSetter(Property property) { - if (!isNeedsSetter(property)) { - needsSetter.add(property); + private void setNeedsSuperclass(JClassType typeAsClass) { + if (!isNeedsSuperClass(typeAsClass)) { + needsSuperClass.add(typeAsClass); } } - private boolean isNeedsSetter(Property property) { - if (needsSetter.contains(property)) { + private boolean isNeedsSuperClass(JClassType typeAsClass) { + if (needsSuperClass.contains(typeAsClass)) { return true; } else { return previousBundle != null - && previousBundle.isNeedsSetter(property); + && previousBundle.isNeedsSuperClass(typeAsClass); } } - public Set getNeedsSetter() { - return Collections.unmodifiableSet(needsSetter); + public Set getNeedsSuperclass() { + return Collections.unmodifiableSet(needsSuperClass); } - private void setNeedsPropertyList(JClassType type) { - if (!isNeedsPropertyList(type)) { - needsPropertyList.add(type); + private void setNeedsProperty(Property property) { + if (!isNeedsProperty(property)) { + needsProperty.add(property); } } - private boolean isNeedsPropertyList(JClassType type) { - if (needsPropertyList.contains(type)) { + private boolean isNeedsProperty(Property property) { + if (needsProperty.contains(property)) { return true; } else { return previousBundle != null - && previousBundle.isNeedsPropertyList(type); + && previousBundle.isNeedsProperty(property); } } - public Set getNeedsPropertyListing() { - return Collections.unmodifiableSet(needsPropertyList); + public Set getNeedsProperty() { + return Collections.unmodifiableSet(needsProperty); } public Collection getProperties(JClassType type) { @@ -623,4 +585,4 @@ public class ConnectorBundle { return Collections.unmodifiableSet(needsDelegateToWidget); } -} \ No newline at end of file +} diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java index 86b8260885..e9ff4587fb 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/FieldProperty.java @@ -37,19 +37,26 @@ public class FieldProperty extends Property { this.field = field; } + @Override + public boolean hasAccessorMethods() { + return true; + } + @Override public void writeSetterBody(TreeLogger logger, SourceWriter w, String beanVariable, String valueVariable) { - w.print("((%s) %s).%s = (%s)%s;", getBeanType() - .getQualifiedSourceName(), beanVariable, getName(), - getUnboxedPropertyTypeName(), valueVariable); + w.println("%s.@%s::%s = %s;", beanVariable, getBeanType() + .getQualifiedSourceName(), getName(), unboxValue(valueVariable)); } @Override public void writeGetterBody(TreeLogger logger, SourceWriter w, String beanVariable) { - w.print("return ((%s) %s).%s;", getBeanType().getQualifiedSourceName(), - beanVariable, getName()); + String value = String.format("%s.@%s::%s", beanVariable, getBeanType() + .getQualifiedSourceName(), getName()); + w.print("return "); + w.print(boxValue(value)); + w.println(";"); } public static Collection findProperties(JClassType type) { @@ -57,7 +64,7 @@ public class FieldProperty extends Property { List fields = getPublicFields(type); for (JField field : fields) { - properties.add(new FieldProperty(type, field)); + properties.add(new FieldProperty(field.getEnclosingType(), field)); } return properties; diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/MethodProperty.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/MethodProperty.java index 3c317e033e..1d9deef265 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/MethodProperty.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/MethodProperty.java @@ -19,7 +19,9 @@ package com.vaadin.server.widgetsetutils.metadata; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import com.google.gwt.core.ext.TreeLogger; import com.google.gwt.core.ext.typeinfo.JClassType; @@ -31,18 +33,29 @@ public class MethodProperty extends Property { private final JMethod setter; - private MethodProperty(JClassType beanType, JMethod setter) { + private final String getter; + + private MethodProperty(JClassType beanType, JMethod setter, String getter) { super(getTransportFieldName(setter), beanType, setter .getParameterTypes()[0]); this.setter = setter; + this.getter = getter; + } + + @Override + public boolean hasAccessorMethods() { + return getter != null; } public static Collection findProperties(JClassType type) { Collection properties = new ArrayList(); - List setters = getSetters(type); + Set getters = new HashSet(); + List setters = getSetters(type, getters); for (JMethod setter : setters) { - properties.add(new MethodProperty(type, setter)); + String getter = findGetter(type, setter); + properties.add(new MethodProperty(setter.getEnclosingType(), + setter, getters.contains(getter) ? getter : null)); } return properties; @@ -53,9 +66,12 @@ public class MethodProperty extends Property { * * @param beanType * The type to check + * @param getters + * Set that will be filled with names of getters. * @return A list of setter methods from the class and its parents */ - private static List getSetters(JClassType beanType) { + private static List getSetters(JClassType beanType, + Set getters) { List setterMethods = new ArrayList(); while (beanType != null @@ -63,13 +79,19 @@ public class MethodProperty extends Property { Object.class.getName())) { for (JMethod method : beanType.getMethods()) { // Process all setters that have corresponding fields - if (!method.isPublic() || method.isStatic() - || !method.getName().startsWith("set") - || method.getParameterTypes().length != 1) { - // Not setter, skip to next method + if (!method.isPublic() || method.isStatic()) { + // Not getter/setter, skip to next method continue; } - setterMethods.add(method); + String methodName = method.getName(); + if (methodName.startsWith("set") + && method.getParameterTypes().length == 1) { + setterMethods.add(method); + } else if (method.getParameterTypes().length == 0 + && methodName.startsWith("is") + || methodName.startsWith("get")) { + getters.add(methodName); + } } beanType = beanType.getSuperclass(); } @@ -78,34 +100,26 @@ public class MethodProperty extends Property { } @Override - public void writeSetterBody(TreeLogger logger, SourceWriter w, - String beanVariable, String valueVariable) { - w.print("(("); - w.print(getBeanType().getQualifiedSourceName()); - w.print(") "); - w.print(beanVariable); - w.print(")."); - w.print(setter.getName()); - w.print("(("); - w.print(getUnboxedPropertyTypeName()); - w.print(") "); - w.print(valueVariable); - w.println(");"); + public void writeGetterBody(TreeLogger logger, SourceWriter w, + String beanVariable) { + String value = String.format("%s.@%s::%s()()", beanVariable, + getBeanType().getQualifiedSourceName(), getter); + w.print("return "); + w.print(boxValue(value)); + w.println(";"); } @Override - public void writeGetterBody(TreeLogger logger, SourceWriter w, - String beanVariable) { - w.print("return (("); - w.print(getBeanType().getQualifiedSourceName()); - w.print(") "); - w.print(beanVariable); - w.print(")."); - w.print(findGetter(getBeanType(), setter)); - w.print("();"); + public void writeSetterBody(TreeLogger logger, SourceWriter w, + String beanVariable, String valueVariable) { + w.println("%s.@%s::%s(%s)(%s);", beanVariable, getBeanType() + .getQualifiedSourceName(), setter.getName(), setter + .getParameterTypes()[0].getJNISignature(), + unboxValue(valueVariable)); + } - private String findGetter(JClassType beanType, JMethod setterMethod) { + private static String findGetter(JClassType beanType, JMethod setterMethod) { JType setterParameterType = setterMethod.getParameterTypes()[0]; String fieldName = setterMethod.getName().substring(3); if (setterParameterType.getQualifiedSourceName().equals( diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/Property.java b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/Property.java index 02aad7bdf2..381af23b42 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/Property.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/metadata/Property.java @@ -53,6 +53,28 @@ public abstract class Property { } } + public String boxValue(String codeSnippet) { + JPrimitiveType primitive = propertyType.isPrimitive(); + if (primitive == null) { + return codeSnippet; + } else { + return String.format("@%s::valueOf(%s)(%s)", + primitive.getQualifiedBoxedSourceName(), + propertyType.getJNISignature(), codeSnippet); + } + } + + public String unboxValue(String codeSnippet) { + JPrimitiveType primitive = propertyType.isPrimitive(); + if (primitive == null) { + return codeSnippet; + } else { + return String.format("%s.@%s::%sValue()()", codeSnippet, + primitive.getQualifiedBoxedSourceName(), + primitive.getSimpleSourceName()); + } + } + public JClassType getBeanType() { return beanType; } @@ -63,6 +85,8 @@ public abstract class Property { public abstract void writeGetterBody(TreeLogger logger, SourceWriter w, String beanVariable); + public abstract boolean hasAccessorMethods(); + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java index f1a9fa1ee7..8148010b54 100644 --- a/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java +++ b/client/src/com/vaadin/client/metadata/ConnectorBundleLoader.java @@ -15,11 +15,10 @@ */ package com.vaadin.client.metadata; -import java.util.HashMap; import java.util.List; -import java.util.Map; import com.google.gwt.core.shared.GWT; +import com.vaadin.client.FastStringMap; import com.vaadin.client.metadata.AsyncBundleLoader.State; public abstract class ConnectorBundleLoader { @@ -28,8 +27,9 @@ public abstract class ConnectorBundleLoader { private static ConnectorBundleLoader impl; - private Map asyncBlockLoaders = new HashMap(); - private Map identifierToBundle = new HashMap(); + private FastStringMap asyncBlockLoaders = FastStringMap + .create(); + private FastStringMap identifierToBundle = FastStringMap.create(); private final TypeDataStore datStore = new TypeDataStore(); diff --git a/client/src/com/vaadin/client/metadata/Property.java b/client/src/com/vaadin/client/metadata/Property.java index 2e0ea49c88..64fbb79ca1 100644 --- a/client/src/com/vaadin/client/metadata/Property.java +++ b/client/src/com/vaadin/client/metadata/Property.java @@ -30,11 +30,11 @@ public class Property { } public Object getValue(Object bean) throws NoDataException { - return TypeDataStore.getGetter(this).invoke(bean); + return TypeDataStore.getValue(this, bean); } public void setValue(Object bean, Object value) throws NoDataException { - TypeDataStore.getSetter(this).invoke(bean, value); + TypeDataStore.setValue(this, bean, value); } public String getDelegateToWidgetMethodName() { @@ -50,6 +50,10 @@ public class Property { return TypeDataStore.getType(this); } + public Type getBeanType() { + return bean; + } + /** * The unique signature used to identify this property. The structure of the * returned string may change without notice and should not be used for any diff --git a/client/src/com/vaadin/client/metadata/TypeDataStore.java b/client/src/com/vaadin/client/metadata/TypeDataStore.java index 649f018f95..a3939b7994 100644 --- a/client/src/com/vaadin/client/metadata/TypeDataStore.java +++ b/client/src/com/vaadin/client/metadata/TypeDataStore.java @@ -34,8 +34,6 @@ public class TypeDataStore { .create(); private final FastStringMap proxyHandlers = FastStringMap .create(); - private final FastStringMap> properties = FastStringMap - .create(); private final FastStringMap delegateToWidgetProperties = FastStringMap .create(); @@ -46,12 +44,11 @@ public class TypeDataStore { private final FastStringMap invokers = FastStringMap.create(); private final FastStringMap paramTypes = FastStringMap.create(); - private final FastStringMap propertyTypes = FastStringMap.create(); - private final FastStringMap setters = FastStringMap.create(); - private final FastStringMap getters = FastStringMap.create(); private final FastStringMap delegateToWidget = FastStringMap .create(); + private final JavaScriptObject jsTypeData = JavaScriptObject.createObject(); + public static TypeDataStore get() { return ConnectorBundleLoader.get().getTypeDataStore(); } @@ -117,19 +114,10 @@ public class TypeDataStore { return invoker; } - public static Invoker getGetter(Property property) throws NoDataException { - Invoker getter = get().getters.get(property.getSignature()); - if (getter == null) { - throw new NoDataException("There is no getter for " - + property.getSignature()); - } - - return getter; - } - - public void setGetter(Class clazz, String propertyName, Invoker invoker) { - getters.put(new Property(getType(clazz), propertyName).getSignature(), - invoker); + public static Object getValue(Property property, Object target) + throws NoDataException { + return getJsPropertyValue(get().jsTypeData, property.getBeanType() + .getBaseTypeName(), property.getName(), target); } public static String getDelegateToWidget(Property property) { @@ -243,51 +231,31 @@ public class TypeDataStore { public static JsArrayObject getPropertiesAsArray(Type type) throws NoDataException { - JsArrayObject properties = get().properties.get(type - .getSignature()); - if (properties == null) { - throw new NoDataException("No property list for " - + type.getSignature()); - } - return properties; - } + JsArrayString names = getJsPropertyNames(get().jsTypeData, + type.getBaseTypeName()); - public void setProperties(Class clazz, String[] propertyNames) { + // Create Property instances for each property name JsArrayObject properties = JavaScriptObject.createArray() .cast(); - Type type = getType(clazz); - for (String name : propertyNames) { - properties.add(new Property(type, name)); + for (int i = 0; i < names.length(); i++) { + properties.add(new Property(type, names.get(i))); } - this.properties.put(type.getSignature(), properties); - } - public static Type getType(Property property) throws NoDataException { - Type type = get().propertyTypes.get(property.getSignature()); - if (type == null) { - throw new NoDataException("No return type for " - + property.getSignature()); - } - return type; + return properties; } - public void setPropertyType(Class clazz, String propertName, Type type) { - propertyTypes.put( - new Property(getType(clazz), propertName).getSignature(), type); + public static Type getType(Property property) throws NoDataException { + return getJsPropertyType(get().jsTypeData, property.getBeanType() + .getBaseTypeName(), property.getName()); } - public static Invoker getSetter(Property property) throws NoDataException { - Invoker setter = get().setters.get(property.getSignature()); - if (setter == null) { - throw new NoDataException("No setter for " - + property.getSignature()); - } - return setter; + public void setPropertyType(Class clazz, String propertyName, Type type) { + setJsPropertyType(jsTypeData, clazz.getName(), propertyName, type); } - public void setSetter(Class clazz, String propertyName, Invoker setter) { - setters.put(new Property(getType(clazz), propertyName).getSignature(), - setter); + public static void setValue(Property property, Object target, Object value) { + setJsPropertyValue(get().jsTypeData, property.getBeanType() + .getBaseTypeName(), property.getName(), target, value); } public void setSerializerFactory(Class clazz, Invoker factory) { @@ -304,6 +272,99 @@ public class TypeDataStore { } public static boolean hasProperties(Type type) { - return get().properties.containsKey(type.getSignature()); + return hasJsProperties(get().jsTypeData, type.getBaseTypeName()); + } + + public void setSuperClass(Class baseClass, Class superClass) { + String superClassName = superClass == null ? null : superClass + .getName(); + setSuperClass(jsTypeData, baseClass.getName(), superClassName); + } + + public void setPropertyData(Class type, String propertyName, + JavaScriptObject propertyData) { + setPropertyData(jsTypeData, type.getName(), propertyName, propertyData); } + + private static native void setPropertyData(JavaScriptObject typeData, + String className, String propertyName, JavaScriptObject propertyData) + /*-{ + typeData[className][propertyName] = propertyData; + }-*/; + + /* + * This method sets up prototypes chain for baseClassName. + * Precondition is : superClassName had to be handled before + * its child baseClassName. + * + * It makes all properties defined in the superClassName + * available for baseClassName as well. + */ + private static native void setSuperClass(JavaScriptObject typeData, + String baseClassName, String superClassName) + /*-{ + var parentType = typeData[superClassName]; + if (parentType !== undefined ){ + var ctor = function () {}; + ctor.prototype = parentType; + typeData[baseClassName] = new ctor; + } + else { + typeData[baseClassName] = {}; + } + }-*/; + + private static native boolean hasGetter(JavaScriptObject typeData, + String beanName, String propertyName) + /*-{ + return typeData[beanName][propertyName].getter !== undefined; + }-*/; + + private static native boolean hasSetter(JavaScriptObject typeData, + String beanName, String propertyName) + /*-{ + return typeData[beanName][propertyName].setter !== undefined; + }-*/; + + private static native Object getJsPropertyValue(JavaScriptObject typeData, + String beanName, String propertyName, Object beanInstance) + /*-{ + return typeData[beanName][propertyName].getter(beanInstance); + }-*/; + + private static native void setJsPropertyValue(JavaScriptObject typeData, + String beanName, String propertyName, Object beanInstance, + Object value) + /*-{ + typeData[beanName][propertyName].setter(beanInstance, value); + }-*/; + + private static native Type getJsPropertyType(JavaScriptObject typeData, + String beanName, String propertyName) + /*-{ + return typeData[beanName][propertyName].type; + }-*/; + + private static native void setJsPropertyType(JavaScriptObject typeData, + String beanName, String propertyName, Type type) + /*-{ + typeData[beanName][propertyName].type = type; + }-*/; + + private static native JsArrayString getJsPropertyNames( + JavaScriptObject typeData, String beanName) + /*-{ + var names = []; + for(var name in typeData[beanName]) { + names.push(name); + } + return names; + }-*/; + + private static native boolean hasJsProperties(JavaScriptObject typeData, + String beanName) + /*-{ + return typeData[beanName] !== undefined ; + }-*/; + } -- cgit v1.2.3 From d05dd140ce1d707d4362609f714fa861475f0975 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 12 Feb 2014 12:56:07 +0200 Subject: Add ' to allowed characters in LegacyLocator validation (#13329) Change-Id: I2503ce46b1abbf2fd237eaff538d77e565d25eb6 --- .../src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 56c86bab7b..2e9d0a16d0 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -75,7 +75,7 @@ public class LegacyLocatorStrategy implements LocatorStrategy { private final ApplicationConnection client; private static final RegExp validSyntax = RegExp - .compile("^((\\w+::)?((PID_S)?\\w[-$_a-zA-Z0-9. ]*)?)?(/[-$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); + .compile("^((\\w+::)?((PID_S)?\\w[-$_a-zA-Z0-9.' ]*)?)?(/[-$_a-zA-Z0-9]+\\[\\d+\\])*/?(#.*)?$"); public LegacyLocatorStrategy(ApplicationConnection clientConnection) { client = clientConnection; -- cgit v1.2.3 From 40e07d0172532ebf5750b8c2aab5ec892e42cdab Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Tue, 28 Jan 2014 16:22:22 +0200 Subject: Function compilation is refactored (#13253). Change-Id: Ic3c5d6822d90703d7f02de3d1a3d15fe4366af07 --- .../sass/internal/parser/LexicalUnitImpl.java | 72 ++++++++++++++-------- .../parser/function/AbsFunctionGenerator.java | 39 ++++++++++++ .../parser/function/CeilFunctionGenerator.java | 39 ++++++++++++ .../parser/function/DarkenFunctionGenerator.java | 38 ++++++++++++ .../parser/function/DefaultFunctionGenerator.java | 45 ++++++++++++++ .../parser/function/FloorFunctionGenerator.java | 40 ++++++++++++ .../parser/function/LightenFunctionGenerator.java | 38 ++++++++++++ .../parser/function/RoundFunctionGenerator.java | 39 ++++++++++++ .../parser/function/SCSSFunctionGenerator.java | 54 ++++++++++++++++ 9 files changed, 379 insertions(+), 25 deletions(-) create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/AbsFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/CeilFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/DarkenFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/DefaultFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/FloorFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/LightenFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/RoundFunctionGenerator.java create mode 100644 theme-compiler/src/com/vaadin/sass/internal/parser/function/SCSSFunctionGenerator.java diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java index af1165adac..96f841de0b 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/LexicalUnitImpl.java @@ -24,11 +24,22 @@ package com.vaadin.sass.internal.parser; import java.io.Serializable; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import org.w3c.css.sac.LexicalUnit; import com.vaadin.sass.internal.expression.exception.IncompatibleUnitsException; -import com.vaadin.sass.internal.util.ColorUtil; +import com.vaadin.sass.internal.parser.function.AbsFunctionGenerator; +import com.vaadin.sass.internal.parser.function.CeilFunctionGenerator; +import com.vaadin.sass.internal.parser.function.DarkenFunctionGenerator; +import com.vaadin.sass.internal.parser.function.DefaultFunctionGenerator; +import com.vaadin.sass.internal.parser.function.FloorFunctionGenerator; +import com.vaadin.sass.internal.parser.function.LightenFunctionGenerator; +import com.vaadin.sass.internal.parser.function.RoundFunctionGenerator; +import com.vaadin.sass.internal.parser.function.SCSSFunctionGenerator; import com.vaadin.sass.internal.util.DeepCopy; /** @@ -325,30 +336,7 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit, case LexicalUnit.SAC_RECT_FUNCTION: case LexicalUnit.SAC_FUNCTION: String funcName = getFunctionName(); - LexicalUnitImpl firstParam = getParameters(); - if ("round".equals(funcName)) { - firstParam - .setFloatValue(Math.round(firstParam.getFloatValue())); - text = firstParam.toString(); - } else if ("ceil".equals(funcName)) { - firstParam.setFloatValue((float) Math.ceil(firstParam - .getFloatValue())); - text = firstParam.toString(); - } else if ("floor".equals(funcName)) { - firstParam.setFloatValue((float) Math.floor(firstParam - .getFloatValue())); - text = firstParam.toString(); - } else if ("abs".equals(funcName)) { - firstParam.setFloatValue(Math.abs(firstParam.getFloatValue())); - text = firstParam.toString(); - } else if ("darken".equals(funcName)) { - LexicalUnitImpl dark = ColorUtil.darken(this); - text = dark.toString(); - } else if ("lighten".equals(funcName)) { - text = ColorUtil.lighten(this).toString(); - } else { - text = getFunctionName() + "(" + getParameters() + ")"; - } + text = serializeFunction(funcName); break; case LexicalUnit.SAC_IDENT: text = getStringValue(); @@ -778,4 +766,38 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit, } } + + private String serializeFunction(String funcName) { + return getSerializer(funcName).printState(this); + } + + private static SCSSFunctionGenerator getSerializer(String funcName) { + SCSSFunctionGenerator serializer = SERIALIZERS.get(funcName); + if (serializer == null) { + return DEFAULT_SERIALIZER; + } else { + return serializer; + } + } + + private static List initSerializers() { + List list = new LinkedList(); + list.add(new AbsFunctionGenerator()); + list.add(new CeilFunctionGenerator()); + list.add(new DarkenFunctionGenerator()); + list.add(new FloorFunctionGenerator()); + list.add(new LightenFunctionGenerator()); + list.add(new RoundFunctionGenerator()); + return list; + } + + private static final Map SERIALIZERS = new HashMap(); + + private static final SCSSFunctionGenerator DEFAULT_SERIALIZER = new DefaultFunctionGenerator(); + + static { + for (SCSSFunctionGenerator serializer : initSerializers()) { + SERIALIZERS.put(serializer.getFunctionName(), serializer); + } + } } diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/AbsFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/AbsFunctionGenerator.java new file mode 100644 index 0000000000..7f88649e84 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/AbsFunctionGenerator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class AbsFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "abs"; + } + + @Override + public String printState(LexicalUnitImpl function) { + LexicalUnitImpl firstParam = function.getParameters(); + firstParam.setFloatValue(Math.abs(firstParam.getFloatValue())); + return firstParam.toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/CeilFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/CeilFunctionGenerator.java new file mode 100644 index 0000000000..7d19734fe7 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/CeilFunctionGenerator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class CeilFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "ceil"; + } + + @Override + public String printState(LexicalUnitImpl function) { + LexicalUnitImpl firstParam = function.getParameters(); + firstParam.setFloatValue((float) Math.ceil(firstParam.getFloatValue())); + return firstParam.toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/DarkenFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/DarkenFunctionGenerator.java new file mode 100644 index 0000000000..2fbf0b2427 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/DarkenFunctionGenerator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; +import com.vaadin.sass.internal.util.ColorUtil; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class DarkenFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "darken"; + } + + @Override + public String printState(LexicalUnitImpl function) { + LexicalUnitImpl dark = ColorUtil.darken(function); + return dark.toString(); + } +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/DefaultFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/DefaultFunctionGenerator.java new file mode 100644 index 0000000000..d972a5bee8 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/DefaultFunctionGenerator.java @@ -0,0 +1,45 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class DefaultFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return null; + } + + @Override + public String printState(LexicalUnitImpl function) { + StringBuilder builder = new StringBuilder(function.getFunctionName()); + return builder.append('(').append(printParameters(function)) + .append(')').toString(); + } + + private String printParameters(LexicalUnitImpl function) { + if (function.getParameters() == null) { + return null; + } + return function.getParameters().toString(); + } +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/FloorFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/FloorFunctionGenerator.java new file mode 100644 index 0000000000..57a0dcbf56 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/FloorFunctionGenerator.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class FloorFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "floor"; + } + + @Override + public String printState(LexicalUnitImpl function) { + LexicalUnitImpl firstParam = function.getParameters(); + firstParam + .setFloatValue((float) Math.floor(firstParam.getFloatValue())); + return firstParam.toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/LightenFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/LightenFunctionGenerator.java new file mode 100644 index 0000000000..b911593457 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/LightenFunctionGenerator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; +import com.vaadin.sass.internal.util.ColorUtil; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class LightenFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "lighten"; + } + + @Override + public String printState(LexicalUnitImpl function) { + return ColorUtil.lighten(function).toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/RoundFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/RoundFunctionGenerator.java new file mode 100644 index 0000000000..b8e8194f21 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/RoundFunctionGenerator.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * + * @since 7.2 + * @author Vaadin Ltd + */ +public class RoundFunctionGenerator implements SCSSFunctionGenerator { + + @Override + public String getFunctionName() { + return "round"; + } + + @Override + public String printState(LexicalUnitImpl function) { + LexicalUnitImpl firstParam = function.getParameters(); + firstParam.setFloatValue(Math.round(firstParam.getFloatValue())); + return firstParam.toString(); + } + +} diff --git a/theme-compiler/src/com/vaadin/sass/internal/parser/function/SCSSFunctionGenerator.java b/theme-compiler/src/com/vaadin/sass/internal/parser/function/SCSSFunctionGenerator.java new file mode 100644 index 0000000000..4d34b59578 --- /dev/null +++ b/theme-compiler/src/com/vaadin/sass/internal/parser/function/SCSSFunctionGenerator.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.sass.internal.parser.function; + +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + +/** + * Generator class is used to handle SCSS functions. Generator is applied to the + * function lexical unit if its method {@link #getFunctionName()} returns name + * of the function. + * + * If there are no dedicated generator for the function then default generator + * is used. + * + * @since 7.2 + * @author Vaadin Ltd + */ +public interface SCSSFunctionGenerator { + + /** + * Returns function name handled by this generator. Default generator + * returns null and is used if there is no dedicated generator + * for given function. + * + * @since 7.2 + * @return + */ + String getFunctionName(); + + /** + * Prints out the current state of the function. State is SCSS content of + * the function before compilation and compiled CSS content after + * compilation. + * + * @since 7.2 + * @param function + * Function lexical unit to print its state + * @return String state representation of the function + */ + String printState(LexicalUnitImpl function); +} -- cgit v1.2.3