diff options
Diffstat (limited to 'xml')
33 files changed, 487 insertions, 995 deletions
diff --git a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java index 9f17824657ef..14886ebe1e82 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/tree/DomModelTreeView.java @@ -190,7 +190,7 @@ public class DomModelTreeView extends Wrapper implements DataProvider, Disposabl if (simpleNode instanceof AbstractDomElementNode) { final DomElement domElement = ((AbstractDomElementNode)simpleNode).getDomElement(); if (domElement != null && domElement.isValid()) { - if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) { + if (CommonDataKeys.NAVIGATABLE_ARRAY.is(dataId)) { final XmlElement tag = domElement.getXmlElement(); if (tag instanceof Navigatable) { return new Navigatable[] { (Navigatable)tag }; diff --git a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java index 6cb6fc8d25c3..31629d52f5fa 100644 --- a/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java +++ b/xml/dom-openapi/src/com/intellij/util/xml/ui/actions/AddDomElementAction.java @@ -115,7 +115,7 @@ public abstract class AddDomElementAction extends AnAction { @NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { - Project project = e == null ? null : PlatformDataKeys.PROJECT.getData(e.getDataContext()); + Project project = e == null ? null : CommonDataKeys.PROJECT.getData(e.getDataContext()); if (project == null) return AnAction.EMPTY_ARRAY; DomCollectionChildDescription[] descriptions = getDomCollectionChildDescriptions(e); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java index c2f13f6368cb..8488e6a69743 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java @@ -75,6 +75,7 @@ public abstract class DomHardCoreTestCase extends CodeInsightTestCase { final XmlTagValue tagValue = value.getXmlTag().getValue(); final TextRange textRange = tagValue.getTextRange(); final String s = value.getStringValue(); + assertNotNull(s); final int i = tagValue.getText().indexOf(s); return assertReference(value, resolveTo, textRange.getStartOffset() + i + s.length()); } @@ -83,18 +84,21 @@ public abstract class DomHardCoreTestCase extends CodeInsightTestCase { final XmlTag tag = value.getXmlTag(); final PsiReference reference = tag.getContainingFile().findReferenceAt(offset); assertNotNull(reference); + reference.getVariants(); assertEquals(resolveTo, reference.resolve()); return reference; } protected PsiReference getReference(final GenericAttributeValue value) { final XmlAttributeValue attributeValue = value.getXmlAttributeValue(); + assertNotNull(attributeValue); final PsiReference reference = attributeValue.getContainingFile().findReferenceAt(attributeValue.getTextRange().getStartOffset() + 1); assertNotNull(reference); assertEquals(attributeValue, reference.resolve()); return reference; } + @SuppressWarnings("deprecation") protected void assertVariants(PsiReference reference, String... variants) { Object[] refVariants = reference.getVariants(); assertNotNull(refVariants); diff --git a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java b/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java deleted file mode 100644 index 9980cb841342..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/CssEditPrefixesListPanel.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * 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.intellij.application.options.emmet; - -import com.intellij.openapi.ui.Messages; -import com.intellij.ui.*; -import com.intellij.ui.components.JBCheckBox; -import com.intellij.ui.table.TableView; -import com.intellij.util.ui.ColumnInfo; -import com.intellij.util.ui.ListTableModel; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Sets.newHashSet; - -/** - * User: zolotov - * Date: 2/20/13 - */ -public class CssEditPrefixesListPanel { - private final ListTableModel<CssPrefixInfo> myPrefixesModel; - private final TableView<CssPrefixInfo> myPrefixesTableView; - - public CssEditPrefixesListPanel() { - ColumnInfo[] columns = new ColumnInfo[CssPrefix.values().length + 1]; - columns[0] = new PropertyColumn(); - CssPrefix[] values = CssPrefix.values(); - for (int i = 0; i < values.length; i++) { - columns[i + 1] = new PrefixColumnInfo(values[i]); - } - - myPrefixesModel = new ListTableModel<CssPrefixInfo>(columns, new ArrayList<CssPrefixInfo>(), 0); - myPrefixesModel.setSortable(true); - myPrefixesTableView = new TableView<CssPrefixInfo>(myPrefixesModel); - myPrefixesTableView.setAutoCreateRowSorter(true); - myPrefixesTableView.setBorder(null); - myPrefixesTableView.setStriped(true); - myPrefixesTableView.getRowSorter().toggleSortOrder(0); - - new TableViewSpeedSearch<CssPrefixInfo>(myPrefixesTableView) { - @Override - protected String getItemText(@NotNull CssPrefixInfo element) { - return element.getPropertyName(); - } - }; - } - - public void setEnabled(boolean value) { - myPrefixesTableView.setEnabled(value); - } - - public void setState(Set<CssPrefixInfo> prefixInfos) { - myPrefixesModel.setItems(newArrayList(prefixInfos)); - } - - public Set<CssPrefixInfo> getState() { - return newHashSet(myPrefixesModel.getItems()); - } - - public JPanel createMainComponent() { - final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myPrefixesTableView); - decorator.disableUpDownActions(); - final JPanel panel = decorator.createPanel(); - decorator.setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - TableUtil.stopEditing(myPrefixesTableView); - String propertyName = Messages.showInputDialog(myPrefixesTableView, "Property name:", "New Css Property", null); - if (propertyName != null && !propertyName.isEmpty()) { - List<CssPrefixInfo> items = myPrefixesModel.getItems(); - for (CssPrefixInfo state : items) { - if (propertyName.equals(state.getPropertyName())) { - myPrefixesTableView.clearSelection(); - myPrefixesTableView.addSelection(state); - scrollToSelection(); - return; - } - } - CssPrefixInfo newPrefixInfo = new CssPrefixInfo(propertyName); - myPrefixesModel.addRow(newPrefixInfo); - myPrefixesTableView.clearSelection(); - myPrefixesTableView.addSelection(newPrefixInfo); - scrollToSelection(); - } - myPrefixesTableView.requestFocus(); - } - - private void scrollToSelection() { - int selectedRow = myPrefixesTableView.getSelectedRow(); - if (selectedRow >= 0) { - myPrefixesTableView.scrollRectToVisible(myPrefixesTableView.getCellRect(selectedRow, 0, true)); - } - } - }).setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - TableUtil.stopEditing(myPrefixesTableView); - CssPrefixInfo selectedObject = myPrefixesTableView.getSelectedObject(); - int selectedRow = myPrefixesTableView.getSelectedRow(); - int index = myPrefixesModel.indexOf(selectedObject); - if (0 <= index && index < myPrefixesModel.getRowCount()) { - myPrefixesModel.removeRow(index); - if (selectedRow < myPrefixesTableView.getRowCount()) { - myPrefixesTableView.setRowSelectionInterval(selectedRow, selectedRow); - } - else { - if (selectedRow > 0) { - myPrefixesTableView.setRowSelectionInterval(selectedRow - 1, selectedRow - 1); - } - } - } - myPrefixesTableView.getParent().repaint(); - myPrefixesTableView.requestFocus(); - } - }); - return panel; - } - - private static class PropertyColumn extends ColumnInfo<CssPrefixInfo, String> { - public PropertyColumn() { - super("Property"); - } - - @Nullable - @Override - public String valueOf(CssPrefixInfo prefixInfo) { - return prefixInfo.getPropertyName(); - } - } - - private class PrefixColumnInfo extends ColumnInfo<CssPrefixInfo, Boolean> { - private final CssPrefix myPrefix; - private final BooleanTableCellRenderer myCellRenderer = new BooleanTableCellRenderer(); - - @Nullable - @Override - public TableCellRenderer getRenderer(CssPrefixInfo state) { - return myCellRenderer; - } - - public PrefixColumnInfo(CssPrefix prefix) { - super(prefix.getText()); - myPrefix = prefix; - } - - @Nullable - @Override - public TableCellEditor getEditor(CssPrefixInfo prefixInfo) { - JBCheckBox box = new JBCheckBox(); - box.setHorizontalAlignment(SwingConstants.CENTER); - return new DefaultCellEditor(box); - } - - @Override - public boolean isCellEditable(CssPrefixInfo prefixInfo) { - return myPrefixesTableView.isEnabled(); - } - - public final Class<Boolean> getColumnClass() { - return Boolean.class; - } - - @Override - public final void setValue(final CssPrefixInfo prefixInfo, final Boolean aValue) { - prefixInfo.setValue(myPrefix, aValue); - } - - @Nullable - @Override - public final Boolean valueOf(CssPrefixInfo state) { - return state.getValue(myPrefix); - } - } -} diff --git a/xml/impl/src/com/intellij/application/options/emmet/CssPrefix.java b/xml/impl/src/com/intellij/application/options/emmet/CssPrefix.java deleted file mode 100644 index da3bae3ab476..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/CssPrefix.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * 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.intellij.application.options.emmet; - -/** -* User: zolotov -* Date: 2/21/13 -*/ -public enum CssPrefix { - WEBKIT(0x1), MOZ(0x2), MS(0x4), O(0x8); - - final int myIntMask; - - CssPrefix(int intMask) { - myIntMask = intMask; - } - - public String getText() { - return "-" + toString().toLowerCase(); - } -} diff --git a/xml/impl/src/com/intellij/application/options/emmet/CssPrefixInfo.java b/xml/impl/src/com/intellij/application/options/emmet/CssPrefixInfo.java deleted file mode 100644 index 4f67b14423c4..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/CssPrefixInfo.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * 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.intellij.application.options.emmet; - -import org.jetbrains.annotations.NotNull; - -import java.util.Collection; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Sets.newHashSet; - -/** - * User: zolotov - * Date: 2/20/13 - */ -public class CssPrefixInfo { - @NotNull - private final String myPropertyName; - @NotNull - private final Collection<CssPrefix> myEnabledPrefixes; - - public CssPrefixInfo(@NotNull String propertyName, CssPrefix... enabledPrefixes) { - myPropertyName = propertyName; - myEnabledPrefixes = newHashSet(enabledPrefixes); - for (CssPrefix prefix : enabledPrefixes) { - setValue(prefix, true); - } - } - - public CssPrefixInfo(@NotNull String propertyName, Collection<CssPrefix> enabledPrefixes) { - myPropertyName = propertyName; - myEnabledPrefixes = newHashSet(enabledPrefixes); - for (CssPrefix prefix : enabledPrefixes) { - setValue(prefix, true); - } - } - - @NotNull - public Collection<CssPrefix> getEnabledPrefixes() { - return myEnabledPrefixes; - } - - public void setValue(CssPrefix prefix, boolean value) { - if (value) { - myEnabledPrefixes.add(prefix); - } else { - myEnabledPrefixes.remove(prefix); - } - } - - public boolean getValue(CssPrefix prefix) { - return myEnabledPrefixes.contains(prefix); - } - - @NotNull - public String getPropertyName() { - return myPropertyName; - } - - public static CssPrefixInfo fromIntegerValue(String propertyName, Integer value) { - if (value == null) { - return new CssPrefixInfo(propertyName); - } - List<CssPrefix> enabledPrefixes = newArrayList(); - for (CssPrefix prefix : CssPrefix.values()) { - if ((value & prefix.myIntMask) > 0) { - enabledPrefixes.add(prefix); - } - } - return new CssPrefixInfo(propertyName, enabledPrefixes); - } - - public int toIntegerValue() { - int result = 0; - for (CssPrefix prefix : myEnabledPrefixes) { - if (getValue(prefix)) { - result |= prefix.myIntMask; - } - } - return result; - } - - @Override - public String toString() { - return "CssPrefixInfo{" + - "myPropertyName='" + myPropertyName + '\'' + - ", myEnabledPrefixes=" + myEnabledPrefixes + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CssPrefixInfo that = (CssPrefixInfo)o; - - if (!myEnabledPrefixes.equals(that.myEnabledPrefixes)) return false; - if (!myPropertyName.equals(that.myPropertyName)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myPropertyName.hashCode(); - result = 31 * result + myEnabledPrefixes.hashCode(); - return result; - } -} diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.form b/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.form new file mode 100644 index 000000000000..851f9174bebf --- /dev/null +++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.form @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.emmet.EmmetCompositeConfigurable"> + <grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <xy x="20" y="20" width="500" height="400"/> + </constraints> + <properties/> + <border type="none"/> + <children> + <grid id="3afd2" binding="myGeneratorSettingsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="6" anchor="1" fill="1" indent="0" use-parent-layout="false"/> + </constraints> + <properties/> + <border type="none"/> + <children/> + </grid> + <component id="665fd" class="com.intellij.ui.components.JBLabel"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/> + </constraints> + <properties> + <labelFor value="59f5a"/> + <text resource-bundle="messages/XmlBundle" key="emmet.expand.abbreviation.with"/> + </properties> + </component> + <component id="d121d" class="javax.swing.JComboBox" binding="myEmmetExpandShortcutCombo"> + <constraints> + <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <model/> + </properties> + </component> + </children> + </grid> +</form> diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.java new file mode 100644 index 000000000000..5416ab156f12 --- /dev/null +++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetCompositeConfigurable.java @@ -0,0 +1,150 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * 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.intellij.application.options.emmet; + +import com.intellij.codeInsight.CodeInsightBundle; +import com.intellij.codeInsight.template.emmet.generators.ZenCodingGenerator; +import com.intellij.codeInsight.template.impl.TemplateSettings; +import com.intellij.openapi.options.*; +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.xml.XmlBundle; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; +import java.util.List; + +/** + * User: zolotov + * Date: 9/24/13 + */ +public class EmmetCompositeConfigurable extends CompositeConfigurable<UnnamedConfigurable> implements Configurable.NoScroll, + SearchableConfigurable { + private JPanel myRootPanel; + private JPanel myGeneratorSettingsPanel; + private JComboBox myEmmetExpandShortcutCombo; + + private static final String SPACE = CodeInsightBundle.message("template.shortcut.space"); + private static final String TAB = CodeInsightBundle.message("template.shortcut.tab"); + private static final String ENTER = CodeInsightBundle.message("template.shortcut.enter"); + + public EmmetCompositeConfigurable() { + myEmmetExpandShortcutCombo.addItem(SPACE); + myEmmetExpandShortcutCombo.addItem(TAB); + myEmmetExpandShortcutCombo.addItem(ENTER); + } + + @Nls + @Override + public String getDisplayName() { + return XmlBundle.message("emmet.configuration.title"); + } + + @Nullable + @Override + public String getHelpTopic() { + return getId(); + } + + @Nullable + @Override + public JComponent createComponent() { + final List<UnnamedConfigurable> configurables = getConfigurables(); + myGeneratorSettingsPanel.setLayout(new GridLayoutManager(configurables.size(), 1, new Insets(0, 0, 10, 0), -1, -1)); + for (int i = 0; i < configurables.size(); i++) { + UnnamedConfigurable configurable = configurables.get(i); + final JComponent component = configurable.createComponent(); + myGeneratorSettingsPanel.add(component, + new GridConstraints(i, 0, 1, 1, 0, GridConstraints.FILL_HORIZONTAL, + GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, + GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_CAN_SHRINK, + new Dimension(-1, -1), new Dimension(-1, -1), new Dimension(-1, -1))); + } + myGeneratorSettingsPanel.revalidate(); + myRootPanel.revalidate(); + return myRootPanel; + } + + @Override + public void reset() { + final EmmetOptions emmetOptions = EmmetOptions.getInstance(); + char shortcut = (char)emmetOptions.getEmmetExpandShortcut(); + if (shortcut == TemplateSettings.TAB_CHAR) { + myEmmetExpandShortcutCombo.setSelectedItem(TAB); + } + else if (shortcut == TemplateSettings.ENTER_CHAR) { + myEmmetExpandShortcutCombo.setSelectedItem(ENTER); + } + else { + myEmmetExpandShortcutCombo.setSelectedItem(SPACE); + } + super.reset(); + } + + @Override + public void apply() throws ConfigurationException { + final EmmetOptions emmetOptions = EmmetOptions.getInstance(); + emmetOptions.setEmmetExpandShortcut(getSelectedEmmetExpandShortcut()); + super.apply(); + } + + @Override + public boolean isModified() { + return EmmetOptions.getInstance().getEmmetExpandShortcut() != getSelectedEmmetExpandShortcut() || super.isModified(); + } + + @Override + public void disposeUIResources() { + myGeneratorSettingsPanel.removeAll(); + super.disposeUIResources(); + } + + @Override + protected List<UnnamedConfigurable> createConfigurables() { + List<UnnamedConfigurable> configurables = ContainerUtil.newArrayList(); + for (ZenCodingGenerator zenCodingGenerator : ZenCodingGenerator.getInstances()) { + ContainerUtil.addIfNotNull(configurables, zenCodingGenerator.createConfigurable()); + } + return configurables; + } + + private char getSelectedEmmetExpandShortcut() { + Object selectedItem = myEmmetExpandShortcutCombo.getSelectedItem(); + if (TAB.equals(selectedItem)) { + return TemplateSettings.TAB_CHAR; + } + else if (ENTER.equals(selectedItem)) { + return TemplateSettings.ENTER_CHAR; + } + return TemplateSettings.SPACE_CHAR; + } + + @NotNull + @Override + public String getId() { + return "reference.idesettings.emmet"; + } + + @Nullable + @Override + public Runnable enableSearch(String option) { + return null; + } +} diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.form b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.form deleted file mode 100644 index e427db7d292c..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.form +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.emmet.EmmetConfigurable"> - <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <xy x="20" y="20" width="500" height="400"/> - </constraints> - <properties/> - <border type="none"/> - <children> - <component id="446a3" class="com.intellij.ui.components.JBCheckBox" binding="myEnableEmmetJBCheckBox" default-binding="true"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/XmlBundle" key="zen.coding.enable.label"/> - </properties> - </component> - <component id="c71a" class="com.intellij.ui.components.JBLabel"> - <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/> - </constraints> - <properties> - <labelFor value="59f5a"/> - <text resource-bundle="messages/XmlBundle" key="emmet.expand.abbreviation.with"/> - </properties> - </component> - <component id="59f5a" class="javax.swing.JComboBox" binding="myEmmetExpandShortcutCombo"> - <constraints> - <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <model/> - </properties> - </component> - <grid id="369dc" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title="XML"/> - <children> - <component id="9ed4c" class="com.intellij.ui.components.JBCheckBox" binding="myEnableBEMFilterJBCheckBox" default-binding="true"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/XmlBundle" key="emmet.enable.bem.filter"/> - </properties> - </component> - </children> - </grid> - <grid id="bd64d" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title="CSS"/> - <children> - <component id="65354" class="com.intellij.ui.components.JBCheckBox" binding="myAutoInsertCssVendorJBCheckBox" default-binding="true"> - <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/XmlBundle" key="emmet.auto.insert.vendor.prefixes"/> - </properties> - </component> - <grid id="612b" binding="myPrefixesPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <border type="none"/> - <children/> - </grid> - <component id="b1849" class="com.intellij.ui.components.JBCheckBox" binding="myEnabledFuzzySearchJBCheckBox"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/XmlBundle" key="emmet.fuzzy.search"/> - </properties> - </component> - </children> - </grid> - </children> - </grid> -</form> diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java deleted file mode 100644 index 9dbfc55456fd..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurable.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * 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.intellij.application.options.emmet; - -import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.template.impl.TemplateSettings; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.options.Configurable; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.ui.components.JBCheckBox; -import com.intellij.xml.XmlBundle; -import org.jetbrains.annotations.Nls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - * User: zolotov - * Date: 2/20/13 - */ -public class EmmetConfigurable implements SearchableConfigurable, Disposable, Configurable.NoScroll { - private JBCheckBox myEnableEmmetJBCheckBox; - private JComboBox myEmmetExpandShortcutCombo; - private JBCheckBox myEnableBEMFilterJBCheckBox; - private JBCheckBox myAutoInsertCssVendorJBCheckBox; - private JBCheckBox myEnabledFuzzySearchJBCheckBox; - private JPanel myPanel; - private JPanel myPrefixesPanel; - - private CssEditPrefixesListPanel myCssEditPrefixesListPanel; - - private static final String SPACE = CodeInsightBundle.message("template.shortcut.space"); - private static final String TAB = CodeInsightBundle.message("template.shortcut.tab"); - private static final String ENTER = CodeInsightBundle.message("template.shortcut.enter"); - - public EmmetConfigurable() { - myEnableEmmetJBCheckBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boolean selected = myEnableEmmetJBCheckBox.isSelected(); - myEmmetExpandShortcutCombo.setEnabled(selected); - //myInsertFallbackGradientColorJBCheckBox.setEnabled(selected); - myAutoInsertCssVendorJBCheckBox.setEnabled(selected); - myCssEditPrefixesListPanel.setEnabled(selected && myAutoInsertCssVendorJBCheckBox.isSelected()); - myEnableBEMFilterJBCheckBox.setEnabled(selected); - myEnabledFuzzySearchJBCheckBox.setEnabled(selected); - } - }); - - myAutoInsertCssVendorJBCheckBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - myCssEditPrefixesListPanel.setEnabled(myAutoInsertCssVendorJBCheckBox.isSelected()); - } - }); - - myEmmetExpandShortcutCombo.addItem(SPACE); - myEmmetExpandShortcutCombo.addItem(TAB); - myEmmetExpandShortcutCombo.addItem(ENTER); - } - - private char getSelectedEmmetExpandShortcut() { - Object selectedItem = myEmmetExpandShortcutCombo.getSelectedItem(); - if (TAB.equals(selectedItem)) { - return TemplateSettings.TAB_CHAR; - } - else if (ENTER.equals(selectedItem)) { - return TemplateSettings.ENTER_CHAR; - } - return TemplateSettings.SPACE_CHAR; - } - - @Override - public void dispose() { - } - - @NotNull - @Override - public String getId() { - return "reference.idesettings.emmet"; - } - - @Nullable - @Override - public Runnable enableSearch(String option) { - return null; - } - - @Nls - @Override - public String getDisplayName() { - return XmlBundle.message("emmet.configuration.title"); - } - - @Nullable - @Override - public String getHelpTopic() { - return getId(); - } - - @Nullable - @Override - public JComponent createComponent() { - return myPanel; - } - - @Override - public boolean isModified() { - EmmetOptions emmetOptions = EmmetOptions.getInstance(); - return emmetOptions.isEmmetEnabled() != myEnableEmmetJBCheckBox.isSelected() || - emmetOptions.isBemFilterEnabledByDefault() != myEnableBEMFilterJBCheckBox.isSelected() || - emmetOptions.isAutoInsertCssPrefixedEnabled() != myAutoInsertCssVendorJBCheckBox.isSelected() || - emmetOptions.isFuzzySearchEnabled() != myEnabledFuzzySearchJBCheckBox.isSelected() || - !emmetOptions.getAllPrefixInfo().equals(myCssEditPrefixesListPanel.getState()) || - emmetOptions.getEmmetExpandShortcut() != getSelectedEmmetExpandShortcut(); - } - - - @Override - public void apply() throws ConfigurationException { - EmmetOptions emmetOptions = EmmetOptions.getInstance(); - emmetOptions.setEmmetEnabled(myEnableEmmetJBCheckBox.isSelected()); - emmetOptions.setBemFilterEnabledByDefault(myEnableBEMFilterJBCheckBox.isSelected()); - emmetOptions.setEmmetExpandShortcut(getSelectedEmmetExpandShortcut()); - emmetOptions.setAutoInsertCssPrefixedEnabled(myAutoInsertCssVendorJBCheckBox.isSelected()); - emmetOptions.setFuzzySearchEnabled(myEnabledFuzzySearchJBCheckBox.isSelected()); - emmetOptions.setPrefixInfo(myCssEditPrefixesListPanel.getState()); - } - - @Override - public void reset() { - EmmetOptions emmetOptions = EmmetOptions.getInstance(); - myEnableEmmetJBCheckBox.setSelected(emmetOptions.isEmmetEnabled()); - myEnableBEMFilterJBCheckBox.setEnabled(emmetOptions.isEmmetEnabled()); - myEnableBEMFilterJBCheckBox.setSelected(emmetOptions.isBemFilterEnabledByDefault()); - myEmmetExpandShortcutCombo.setEnabled(emmetOptions.isEmmetEnabled()); - myAutoInsertCssVendorJBCheckBox.setEnabled(emmetOptions.isEmmetEnabled()); - myAutoInsertCssVendorJBCheckBox.setSelected(emmetOptions.isAutoInsertCssPrefixedEnabled()); - myEnabledFuzzySearchJBCheckBox.setEnabled(emmetOptions.isEmmetEnabled()); - myEnabledFuzzySearchJBCheckBox.setSelected(emmetOptions.isFuzzySearchEnabled()); - //myInsertFallbackGradientColorJBCheckBox.setEnabled(emmetOptions.isEmmetEnabled()); - //myInsertFallbackGradientColorJBCheckBox.setSelected(emmetOptions.isInsertFallbackGradientColorEnabled()); - - myCssEditPrefixesListPanel.setEnabled(emmetOptions.isEmmetEnabled() && emmetOptions.isAutoInsertCssPrefixedEnabled()); - myCssEditPrefixesListPanel.setState(emmetOptions.getAllPrefixInfo()); - - char shortcut = (char)emmetOptions.getEmmetExpandShortcut(); - if (shortcut == TemplateSettings.TAB_CHAR) { - myEmmetExpandShortcutCombo.setSelectedItem(TAB); - } - else if (shortcut == TemplateSettings.ENTER_CHAR) { - myEmmetExpandShortcutCombo.setSelectedItem(ENTER); - } - else { - myEmmetExpandShortcutCombo.setSelectedItem(SPACE); - } - } - - @Override - public void disposeUIResources() { - myCssEditPrefixesListPanel = null; - myPrefixesPanel = null; - } - - private void createUIComponents() { - myCssEditPrefixesListPanel = new CssEditPrefixesListPanel(); - myPrefixesPanel = myCssEditPrefixesListPanel.createMainComponent(); - myPrefixesPanel.setEnabled(true); - } -} diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurableProvider.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurableProvider.java index 2d13a7382516..6128439c4ee2 100644 --- a/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurableProvider.java +++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetConfigurableProvider.java @@ -27,6 +27,6 @@ public class EmmetConfigurableProvider extends ConfigurableProvider { @Nullable @Override public Configurable createConfigurable() { - return new EmmetConfigurable(); + return new EmmetCompositeConfigurable(); } } diff --git a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java index 614e17a736a7..d41799aab632 100644 --- a/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java +++ b/xml/impl/src/com/intellij/application/options/emmet/EmmetOptions.java @@ -15,27 +15,16 @@ */ package com.intellij.application.options.emmet; -import com.google.common.collect.Sets; import com.intellij.application.options.editor.WebEditorOptions; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.xmlb.XmlSerializerUtil; import com.intellij.xml.XmlBundle; -import org.jdom.Document; -import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.util.Collection; import java.util.Map; -import java.util.Set; - -import static com.google.common.collect.Maps.newHashMap; -import static com.google.common.io.Resources.getResource; /** * User: zolotov @@ -57,24 +46,6 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp @Nullable private Map<String, Integer> prefixes = null; - public void setPrefixInfo(Collection<CssPrefixInfo> prefixInfos) { - prefixes = newHashMap(); - for (CssPrefixInfo state : prefixInfos) { - prefixes.put(state.getPropertyName(), state.toIntegerValue()); - } - } - - public CssPrefixInfo getPrefixStateForProperty(String propertyName) { - return CssPrefixInfo.fromIntegerValue(propertyName, getPrefixes().get(propertyName)); - } - - public Set<CssPrefixInfo> getAllPrefixInfo() { - Set<CssPrefixInfo> result = Sets.newHashSetWithExpectedSize(getPrefixes().size()); - for (Map.Entry<String, Integer> entry : getPrefixes().entrySet()) { - result.add(CssPrefixInfo.fromIntegerValue(entry.getKey(), entry.getValue())); - } - return result; - } public boolean isBemFilterEnabledByDefault() { return myBemFilterEnabledByDefault; @@ -100,18 +71,26 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp myEmmetEnabled = emmetEnabled; } + @Deprecated + //use {@link CssEmmetOptions} public boolean isAutoInsertCssPrefixedEnabled() { return myAutoInsertCssPrefixedEnabled; } + @Deprecated + //use {@link CssEmmetOptions} public void setAutoInsertCssPrefixedEnabled(boolean autoInsertCssPrefixedEnabled) { myAutoInsertCssPrefixedEnabled = autoInsertCssPrefixedEnabled; } + @Deprecated + //use {@link CssEmmetOptions} public void setFuzzySearchEnabled(boolean fuzzySearchEnabled) { myFuzzySearchEnabled = fuzzySearchEnabled; } + @Deprecated + //use {@link CssEmmetOptions} public boolean isFuzzySearchEnabled() { return myFuzzySearchEnabled; } @@ -142,37 +121,17 @@ public class EmmetOptions implements PersistentStateComponent<EmmetOptions>, Exp return ServiceManager.getService(EmmetOptions.class); } - @NotNull + @Nullable + @Deprecated + //use {@link CssEmmetOptions} public Map<String, Integer> getPrefixes() { - if (prefixes == null) { - prefixes = loadDefaultPrefixes(); - } return prefixes; } @SuppressWarnings("UnusedDeclaration") + @Deprecated + //use {@link CssEmmetOptions} public void setPrefixes(@Nullable Map<String, Integer> prefixes) { this.prefixes = prefixes; } - - public Map<String, Integer> loadDefaultPrefixes() { - Map<String, Integer> result = newHashMap(); - try { - Document document = JDOMUtil.loadDocument(getResource(EmmetOptions.class, "emmet_default_options.xml")); - Element prefixesElement = document.getRootElement().getChild("prefixes"); - if (prefixesElement != null) { - for (Object entry : prefixesElement.getChildren("entry")) { - Element entryElement = (Element)entry; - String propertyName = entryElement.getAttributeValue("key"); - Integer value = StringUtil.parseInt(entryElement.getAttributeValue("value"), 0); - result.put(propertyName, value); - } - } - } - catch (Exception e) { - Logger.getInstance(EmmetOptions.class).warn(e); - return result; - } - return result; - } } diff --git a/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.form b/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.form new file mode 100644 index 000000000000..378f1062072f --- /dev/null +++ b/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.form @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.emmet.XmlEmmetConfigurable"> + <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <xy x="20" y="20" width="500" height="400"/> + </constraints> + <properties/> + <border type="none"/> + <children> + <grid id="369dc" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + </constraints> + <properties/> + <clientProperties> + <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> + </clientProperties> + <border type="none" title="XML"/> + <children> + <component id="9ed4c" class="com.intellij.ui.components.JBCheckBox" binding="myEnableBEMFilterJBCheckBox" default-binding="true"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text resource-bundle="messages/XmlBundle" key="emmet.enable.bem.filter"/> + </properties> + </component> + <component id="446a3" class="com.intellij.ui.components.JBCheckBox" binding="myEnableEmmetJBCheckBox" default-binding="true"> + <constraints> + <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text resource-bundle="messages/XmlBundle" key="emmet.enable.label"/> + </properties> + </component> + </children> + </grid> + <vspacer id="27c08"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + </constraints> + </vspacer> + </children> + </grid> +</form> diff --git a/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.java b/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.java new file mode 100644 index 000000000000..07091343ba3a --- /dev/null +++ b/xml/impl/src/com/intellij/application/options/emmet/XmlEmmetConfigurable.java @@ -0,0 +1,84 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * 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.intellij.application.options.emmet; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.options.Configurable; +import com.intellij.openapi.options.ConfigurationException; +import com.intellij.openapi.options.UnnamedConfigurable; +import com.intellij.ui.components.JBCheckBox; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * User: zolotov + * Date: 2/20/13 + */ +public class XmlEmmetConfigurable implements UnnamedConfigurable, Disposable, Configurable.NoScroll { + private JBCheckBox myEnableBEMFilterJBCheckBox; + private JPanel myPanel; + private JBCheckBox myEnableEmmetJBCheckBox; + + public XmlEmmetConfigurable() { + myEnableEmmetJBCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boolean selected = myEnableEmmetJBCheckBox.isSelected(); + myEnableBEMFilterJBCheckBox.setEnabled(selected); + } + }); + } + + @Override + public void dispose() { + } + + @Nullable + @Override + public JComponent createComponent() { + return myPanel; + } + + @Override + public boolean isModified() { + EmmetOptions emmetOptions = EmmetOptions.getInstance(); + return emmetOptions.isEmmetEnabled() != myEnableEmmetJBCheckBox.isSelected() || + emmetOptions.isBemFilterEnabledByDefault() != myEnableBEMFilterJBCheckBox.isSelected(); + } + + + @Override + public void apply() throws ConfigurationException { + EmmetOptions emmetOptions = EmmetOptions.getInstance(); + emmetOptions.setEmmetEnabled(myEnableEmmetJBCheckBox.isSelected()); + emmetOptions.setBemFilterEnabledByDefault(myEnableBEMFilterJBCheckBox.isSelected()); + } + + @Override + public void reset() { + EmmetOptions emmetOptions = EmmetOptions.getInstance(); + myEnableEmmetJBCheckBox.setSelected(emmetOptions.isEmmetEnabled()); + myEnableBEMFilterJBCheckBox.setEnabled(emmetOptions.isEmmetEnabled()); + myEnableBEMFilterJBCheckBox.setSelected(emmetOptions.isBemFilterEnabledByDefault()); + } + + @Override + public void disposeUIResources() { + } +} diff --git a/xml/impl/src/com/intellij/application/options/emmet/emmet_default_options.xml b/xml/impl/src/com/intellij/application/options/emmet/emmet_default_options.xml deleted file mode 100644 index 287ab5f703f3..000000000000 --- a/xml/impl/src/com/intellij/application/options/emmet/emmet_default_options.xml +++ /dev/null @@ -1,216 +0,0 @@ -<DefaultEmmetOptions> - <prefixes> - <entry key="accelerator" value="4"/> - <entry key="accesskey" value="8"/> - <entry key="animation" value="9"/> - <entry key="animation-delay" value="11"/> - <entry key="animation-direction" value="11"/> - <entry key="animation-duration" value="11"/> - <entry key="animation-fill-mode" value="11"/> - <entry key="animation-iteration-count" value="11"/> - <entry key="animation-name" value="11"/> - <entry key="animation-play-state" value="11"/> - <entry key="animation-timing-function" value="11"/> - <entry key="appearance" value="3"/> - <entry key="backface-visibility" value="7"/> - <entry key="background-clip" value="3"/> - <entry key="background-composite" value="1"/> - <entry key="background-inline-policy" value="2"/> - <entry key="background-origin" value="1"/> - <entry key="background-position-x" value="4"/> - <entry key="background-position-y" value="4"/> - <entry key="background-size" value="1"/> - <entry key="behavior" value="4"/> - <entry key="binding" value="2"/> - <entry key="block-progression" value="4"/> - <entry key="border-bottom-colors" value="2"/> - <entry key="border-fit" value="1"/> - <entry key="border-horizontal-spacing" value="1"/> - <entry key="border-image" value="11"/> - <entry key="border-left-colors" value="2"/> - <entry key="border-radius" value="3"/> - <entry key="border-right-colors" value="2"/> - <entry key="border-top-colors" value="2"/> - <entry key="border-vertical-spacing" value="1"/> - <entry key="box-align" value="7"/> - <entry key="box-direction" value="7"/> - <entry key="box-flex" value="7"/> - <entry key="box-flex-group" value="1"/> - <entry key="box-line-progression" value="4"/> - <entry key="box-lines" value="5"/> - <entry key="box-ordinal-group" value="7"/> - <entry key="box-orient" value="7"/> - <entry key="box-pack" value="7"/> - <entry key="box-reflect" value="1"/> - <entry key="box-shadow" value="3"/> - <entry key="box-sizing" value="3"/> - <entry key="color-correction" value="1"/> - <entry key="column-break-after" value="1"/> - <entry key="column-break-before" value="1"/> - <entry key="column-break-inside" value="1"/> - <entry key="column-count" value="3"/> - <entry key="column-gap" value="3"/> - <entry key="column-rule-color" value="3"/> - <entry key="column-rule-style" value="3"/> - <entry key="column-rule-width" value="3"/> - <entry key="column-span" value="1"/> - <entry key="column-width" value="3"/> - <entry key="content-zoom-boundary" value="4"/> - <entry key="content-zoom-boundary-max" value="4"/> - <entry key="content-zoom-boundary-min" value="4"/> - <entry key="content-zoom-chaining" value="4"/> - <entry key="content-zoom-snap" value="4"/> - <entry key="content-zoom-snap-points" value="4"/> - <entry key="content-zoom-snap-type" value="4"/> - <entry key="content-zooming" value="4"/> - <entry key="dashboard-region" value="9"/> - <entry key="filter" value="4"/> - <entry key="float-edge" value="2"/> - <entry key="flow-from" value="4"/> - <entry key="flow-into" value="4"/> - <entry key="font-feature-settings" value="6"/> - <entry key="font-language-override" value="2"/> - <entry key="font-smoothing" value="1"/> - <entry key="force-broken-image-icon" value="2"/> - <entry key="grid-column" value="4"/> - <entry key="grid-column-align" value="4"/> - <entry key="grid-column-span" value="4"/> - <entry key="grid-columns" value="4"/> - <entry key="grid-layer" value="4"/> - <entry key="grid-row" value="4"/> - <entry key="grid-row-align" value="4"/> - <entry key="grid-row-span" value="4"/> - <entry key="grid-rows" value="4"/> - <entry key="high-contrast-adjust" value="4"/> - <entry key="highlight" value="1"/> - <entry key="hyphenate-character" value="1"/> - <entry key="hyphenate-limit-after" value="1"/> - <entry key="hyphenate-limit-before" value="1"/> - <entry key="hyphenate-limit-chars" value="4"/> - <entry key="hyphenate-limit-lines" value="4"/> - <entry key="hyphenate-limit-zone" value="4"/> - <entry key="hyphens" value="7"/> - <entry key="image-region" value="2"/> - <entry key="ime-mode" value="4"/> - <entry key="input-format" value="8"/> - <entry key="input-required" value="8"/> - <entry key="interpolation-mode" value="4"/> - <entry key="layout-flow" value="4"/> - <entry key="layout-grid" value="4"/> - <entry key="layout-grid-char" value="4"/> - <entry key="layout-grid-line" value="4"/> - <entry key="layout-grid-mode" value="4"/> - <entry key="layout-grid-type" value="4"/> - <entry key="line-box-contain" value="1"/> - <entry key="line-break" value="5"/> - <entry key="line-clamp" value="1"/> - <entry key="link" value="8"/> - <entry key="link-source" value="8"/> - <entry key="locale" value="1"/> - <entry key="margin-after-collapse" value="1"/> - <entry key="margin-before-collapse" value="1"/> - <entry key="marquee-dir" value="8"/> - <entry key="marquee-direction" value="1"/> - <entry key="marquee-increment" value="1"/> - <entry key="marquee-loop" value="8"/> - <entry key="marquee-repetition" value="1"/> - <entry key="marquee-speed" value="8"/> - <entry key="marquee-style" value="9"/> - <entry key="mask-attachment" value="1"/> - <entry key="mask-box-image" value="1"/> - <entry key="mask-box-image-outset" value="1"/> - <entry key="mask-box-image-repeat" value="1"/> - <entry key="mask-box-image-slice" value="1"/> - <entry key="mask-box-image-source" value="1"/> - <entry key="mask-box-image-width" value="1"/> - <entry key="mask-clip" value="1"/> - <entry key="mask-composite" value="1"/> - <entry key="mask-image" value="1"/> - <entry key="mask-origin" value="1"/> - <entry key="mask-position" value="1"/> - <entry key="mask-repeat" value="1"/> - <entry key="mask-size" value="1"/> - <entry key="nbsp-mode" value="1"/> - <entry key="object-fit" value="8"/> - <entry key="object-position" value="8"/> - <entry key="orient" value="2"/> - <entry key="outline-radius-bottomleft" value="2"/> - <entry key="outline-radius-bottomright" value="2"/> - <entry key="outline-radius-topleft" value="2"/> - <entry key="outline-radius-topright" value="2"/> - <entry key="overflow-style" value="4"/> - <entry key="perspective" value="7"/> - <entry key="perspective-origin" value="7"/> - <entry key="perspective-origin-x" value="4"/> - <entry key="perspective-origin-y" value="4"/> - <entry key="rtl-ordering" value="1"/> - <entry key="scroll-boundary" value="4"/> - <entry key="scroll-boundary-bottom" value="4"/> - <entry key="scroll-boundary-left" value="4"/> - <entry key="scroll-boundary-right" value="4"/> - <entry key="scroll-boundary-top" value="4"/> - <entry key="scroll-chaining" value="4"/> - <entry key="scroll-rails" value="4"/> - <entry key="scroll-snap-points-x" value="4"/> - <entry key="scroll-snap-points-y" value="4"/> - <entry key="scroll-snap-type" value="4"/> - <entry key="scroll-snap-x" value="4"/> - <entry key="scroll-snap-y" value="4"/> - <entry key="scrollbar-arrow-color" value="4"/> - <entry key="scrollbar-base-color" value="4"/> - <entry key="scrollbar-darkshadow-color" value="4"/> - <entry key="scrollbar-face-color" value="4"/> - <entry key="scrollbar-highlight-color" value="4"/> - <entry key="scrollbar-shadow-color" value="4"/> - <entry key="scrollbar-track-color" value="4"/> - <entry key="stack-sizing" value="2"/> - <entry key="svg-shadow" value="1"/> - <entry key="tab-size" value="10"/> - <entry key="table-baseline" value="8"/> - <entry key="text-align-last" value="4"/> - <entry key="text-autospace" value="4"/> - <entry key="text-blink" value="2"/> - <entry key="text-combine" value="1"/> - <entry key="text-decoration-color" value="2"/> - <entry key="text-decoration-line" value="2"/> - <entry key="text-decoration-style" value="2"/> - <entry key="text-decorations-in-effect" value="1"/> - <entry key="text-emphasis-color" value="1"/> - <entry key="text-emphasis-position" value="1"/> - <entry key="text-emphasis-style" value="1"/> - <entry key="text-fill-color" value="1"/> - <entry key="text-justify" value="4"/> - <entry key="text-kashida-space" value="4"/> - <entry key="text-orientation" value="1"/> - <entry key="text-overflow" value="4"/> - <entry key="text-security" value="1"/> - <entry key="text-size-adjust" value="6"/> - <entry key="text-stroke-color" value="1"/> - <entry key="text-stroke-width" value="1"/> - <entry key="text-underline-position" value="4"/> - <entry key="touch-action" value="4"/> - <entry key="transform" value="15"/> - <entry key="transform-origin" value="15"/> - <entry key="transform-origin-x" value="4"/> - <entry key="transform-origin-y" value="4"/> - <entry key="transform-origin-z" value="4"/> - <entry key="transform-style" value="7"/> - <entry key="transition" value="15"/> - <entry key="transition-delay" value="15"/> - <entry key="transition-duration" value="15"/> - <entry key="transition-property" value="15"/> - <entry key="transition-timing-function" value="15"/> - <entry key="user-drag" value="1"/> - <entry key="user-focus" value="2"/> - <entry key="user-input" value="2"/> - <entry key="user-modify" value="3"/> - <entry key="user-select" value="7"/> - <entry key="window-shadow" value="2"/> - <entry key="word-break" value="4"/> - <entry key="word-wrap" value="4"/> - <entry key="wrap-flow" value="4"/> - <entry key="wrap-margin" value="4"/> - <entry key="wrap-through" value="4"/> - <entry key="writing-mode" value="5"/> - </prefixes> -</DefaultEmmetOptions>
\ No newline at end of file diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java index 6637befbded8..9a3e9d64e954 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/EnterBetweenXmlTagsHandler.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.editorActions; import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegateAdapter; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.Editor; @@ -37,7 +38,7 @@ import org.jetbrains.annotations.NotNull; public class EnterBetweenXmlTagsHandler extends EnterHandlerDelegateAdapter { public Result preprocessEnter(@NotNull final PsiFile file, @NotNull final Editor editor, @NotNull final Ref<Integer> caretOffset, @NotNull final Ref<Integer> caretAdvance, @NotNull final DataContext dataContext, final EditorActionHandler originalHandler) { - final Project project = PlatformDataKeys.PROJECT.getData(dataContext); + final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (file instanceof XmlFile && isBetweenXmlTags(project, editor, file, caretOffset.get().intValue())) { originalHandler.execute(editor, dataContext); diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java index a57464ba7e20..f259f1741cf4 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -282,16 +282,13 @@ public class ZenCodingTemplate implements CustomLiveTemplate { } public boolean isApplicable(PsiFile file, int offset, boolean wrapping) { - EmmetOptions emmetOptions = EmmetOptions.getInstance(); - if (!emmetOptions.isEmmetEnabled()) { - return false; - } if (file == null) { return false; } PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments(); PsiElement element = CustomTemplateCallback.getContext(file, offset); - return findApplicableDefaultGenerator(element, wrapping) != null; + final ZenCodingGenerator applicableGenerator = findApplicableDefaultGenerator(element, wrapping); + return applicableGenerator != null && applicableGenerator.isEnabled(); } public static void doWrap(final String selection, diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java index d595af8403f6..0fc0c6971e1f 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/XmlZenCodingGeneratorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ */ package com.intellij.codeInsight.template.emmet.generators; +import com.intellij.application.options.emmet.EmmetOptions; +import com.intellij.application.options.emmet.XmlEmmetConfigurable; import com.intellij.codeInsight.template.HtmlTextContextType; import com.intellij.codeInsight.template.emmet.ZenCodingUtil; import com.intellij.lang.ASTNode; @@ -25,6 +27,7 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; +import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.VirtualFile; @@ -90,6 +93,11 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { return "html"; } + @Override + public boolean isEnabled() { + return EmmetOptions.getInstance().isEmmetEnabled(); + } + public boolean isAppliedByDefault(@NotNull PsiElement context) { return true; } @@ -141,4 +149,10 @@ public class XmlZenCodingGeneratorImpl extends XmlZenCodingGenerator { final ASTNode endTagEnd = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(node); return emptyTagEnd != null || endTagEnd != null; } + + @Nullable + @Override + public UnnamedConfigurable createConfigurable() { + return new XmlEmmetConfigurable(); + } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java index 363572a1bbd0..5c23ba994e84 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/generators/ZenCodingGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.intellij.codeInsight.template.emmet.tokens.ZenCodingToken; import com.intellij.codeInsight.template.impl.TemplateImpl; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.options.UnnamedConfigurable; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiErrorElement; import com.intellij.psi.PsiWhiteSpace; @@ -61,6 +62,8 @@ public abstract class ZenCodingGenerator { } public abstract boolean isAppliedByDefault(@NotNull PsiElement context); + + public abstract boolean isEnabled(); public static List<ZenCodingGenerator> getInstances() { List<ZenCodingGenerator> generators = new ArrayList<ZenCodingGenerator>(); @@ -72,6 +75,8 @@ public abstract class ZenCodingGenerator { @Nullable public String computeTemplateKey(@NotNull CustomTemplateCallback callback) { Editor editor = callback.getEditor(); + final int currentOffset = editor.getCaretModel().getOffset(); + final CharSequence documentText = editor.getDocument().getCharsSequence(); PsiElement element = callback.getContext(); int line = editor.getCaretModel().getLogicalPosition().line; int lineStart = editor.getDocument().getLineStartOffset(line); @@ -84,8 +89,8 @@ public abstract class ZenCodingGenerator { e = e.getPrevSibling(); } if (elementStart >= 0) { - int startOffset = elementStart > lineStart ? elementStart : lineStart; - String key = computeKey(editor, startOffset); + int startOffset = Math.max(elementStart, lineStart); + String key = computeKey(startOffset, currentOffset, documentText); if (key != null) { while (key.length() > 0 && !ZenCodingTemplate.checkTemplateKey(key, callback, this)) { key = key.substring(1); @@ -102,9 +107,11 @@ public abstract class ZenCodingGenerator { } @Nullable - protected static String computeKey(Editor editor, int startOffset) { - int offset = editor.getCaretModel().getOffset(); - String s = editor.getDocument().getCharsSequence().subSequence(startOffset, offset).toString(); + protected static String computeKey(int startOffset, int currentOffset, CharSequence documentText) { + if (currentOffset < startOffset || startOffset > documentText.length() || currentOffset > documentText.length()) { + return null; + } + String s = documentText.subSequence(startOffset, currentOffset).toString(); int index = 0; while (index < s.length() && Character.isWhitespace(s.charAt(index))) { index++; @@ -167,4 +174,9 @@ public abstract class ZenCodingGenerator { boolean surroundWithTemplate) { return new XmlEmmetParser(tokens, callback, generator, surroundWithTemplate); } + + @Nullable + public UnnamedConfigurable createConfigurable() { + return null; + } } diff --git a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java index b44c50f9ad3f..ed4c271996f2 100644 --- a/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java +++ b/xml/impl/src/com/intellij/html/index/Html5CustomAttributesIndex.java @@ -21,6 +21,7 @@ import com.intellij.lang.xhtml.XHTMLLanguage; import com.intellij.lexer.HtmlHighlightingLexer; import com.intellij.lexer.Lexer; import com.intellij.lexer.XHtmlHighlightingLexer; +import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.LanguageFileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.vfs.LocalFileSystem; @@ -51,7 +52,7 @@ public class Html5CustomAttributesIndex extends ScalarIndexExtension<String> { CharSequence input = inputData.getContentAsText(); Language language = ((LanguageFileType)inputData.getFileType()).getLanguage(); if (language == HTMLLanguage.INSTANCE || language == XHTMLLanguage.INSTANCE) { - final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer() : new XHtmlHighlightingLexer()); + final Lexer lexer = (language == HTMLLanguage.INSTANCE ? new HtmlHighlightingLexer(FileTypeManager.getInstance().getStdFileType("CSS")) : new XHtmlHighlightingLexer()); lexer.start(input); Map<String, Void> result = new HashMap<String, Void>(); IElementType tokenType = lexer.getTokenType(); diff --git a/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java b/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java index 0062567ed16f..7e822817a44e 100644 --- a/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java +++ b/xml/impl/src/com/intellij/ide/browsers/OpenFileInDefaultBrowserAction.java @@ -37,7 +37,7 @@ public class OpenFileInDefaultBrowserAction extends DumbAwareAction { @Override public void update(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); - final PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext); + final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); final Presentation presentation = e.getPresentation(); if (file == null || file.getVirtualFile() == null) { @@ -99,7 +99,7 @@ public class OpenFileInDefaultBrowserAction extends DumbAwareAction { @Override public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); - PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext); + PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(dataContext); LOG.assertTrue(psiFile != null); InputEvent event = e.getInputEvent(); doOpen(psiFile, event != null && event.isShiftDown()); diff --git a/xml/impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java b/xml/impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java index 151b4aa26ca6..dd9ea6556b25 100644 --- a/xml/impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java +++ b/xml/impl/src/com/intellij/ide/highlighter/HtmlFileHighlighter.java @@ -20,6 +20,7 @@ import com.intellij.lexer.Lexer; import com.intellij.openapi.editor.HighlighterColors; import com.intellij.openapi.editor.XmlHighlighterColors; import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.SyntaxHighlighterBase; import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlTokenType; @@ -83,7 +84,7 @@ public class HtmlFileHighlighter extends SyntaxHighlighterBase { @Override @NotNull public Lexer getHighlightingLexer() { - return new HtmlHighlightingLexer(); + return new HtmlHighlightingLexer(FileTypeManager.getInstance().getStdFileType("CSS")); } @Override diff --git a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java index 95f196d860c0..617f5a9bb814 100644 --- a/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java +++ b/xml/impl/src/com/intellij/javaee/MapExternalResourceDialog.java @@ -234,8 +234,8 @@ public class MapExternalResourceDialog extends DialogWrapper { myExplorerPanel = new JBPanel(new BorderLayout()) { @Override public void calcData(DataKey key, DataSink sink) { - if (key == PlatformDataKeys.VIRTUAL_FILE_ARRAY) { - sink.put(PlatformDataKeys.VIRTUAL_FILE_ARRAY, myExplorer.getSelectedFiles()); + if (key == CommonDataKeys.VIRTUAL_FILE_ARRAY) { + sink.put(CommonDataKeys.VIRTUAL_FILE_ARRAY, myExplorer.getSelectedFiles()); } else if (key == FileSystemTree.DATA_KEY) { sink.put(FileSystemTree.DATA_KEY, myExplorer); diff --git a/xml/impl/src/com/intellij/lexer/XHtmlHighlightingLexer.java b/xml/impl/src/com/intellij/lexer/XHtmlHighlightingLexer.java index 5f89e2096cb3..c71924b78ce9 100644 --- a/xml/impl/src/com/intellij/lexer/XHtmlHighlightingLexer.java +++ b/xml/impl/src/com/intellij/lexer/XHtmlHighlightingLexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,18 @@ */ package com.intellij.lexer; +import com.intellij.openapi.fileTypes.FileTypeManager; + public class XHtmlHighlightingLexer extends HtmlHighlightingLexer { public XHtmlHighlightingLexer() { this(new XmlLexer(true)); } public XHtmlHighlightingLexer(Lexer baseLexer) { - super(baseLexer,false); + super(baseLexer,false, FileTypeManager.getInstance().getStdFileType("CSS")); } + @Override protected boolean isHtmlTagState(int state) { return state == __XmlLexer.TAG || state == __XmlLexer.END_TAG; } diff --git a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java index 907743a3e334..2fe8b09837ad 100644 --- a/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java +++ b/xml/impl/src/com/intellij/psi/impl/cache/impl/idCache/HtmlIdIndexer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.psi.impl.cache.impl.idCache; import com.intellij.lexer.HtmlHighlightingLexer; import com.intellij.lexer.Lexer; +import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.psi.impl.cache.impl.OccurrenceConsumer; import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer; @@ -26,6 +27,6 @@ public class HtmlIdIndexer extends LexerBasedIdIndexer { } static XHtmlFilterLexer createIndexingLexer(OccurrenceConsumer consumer) { - return new XHtmlFilterLexer(new HtmlHighlightingLexer(), consumer); + return new XHtmlFilterLexer(new HtmlHighlightingLexer(FileTypeManager.getInstance().getStdFileType("CSS")), consumer); } } diff --git a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java b/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java index 6881e9ba7a65..8abbe220e60b 100644 --- a/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java +++ b/xml/impl/src/com/intellij/xml/actions/validate/ValidateXmlAction.java @@ -50,7 +50,7 @@ public class ValidateXmlAction extends AnAction { } public void actionPerformed(AnActionEvent e) { - final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext()); + final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(e.getDataContext()); if (psiFile != null) { doRunAction(psiFile); } @@ -90,7 +90,7 @@ public class ValidateXmlAction extends AnAction { super.update(event); Presentation presentation = event.getPresentation(); - PsiElement psiElement = LangDataKeys.PSI_FILE.getData(event.getDataContext()); + PsiElement psiElement = CommonDataKeys.PSI_FILE.getData(event.getDataContext()); boolean flag = psiElement instanceof XmlFile; presentation.setVisible(flag); diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java index 22c7bbb7a5df..be0b8bf29558 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateInstanceDocumentFromSchemaAction.java @@ -19,6 +19,7 @@ import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -53,7 +54,7 @@ import java.util.List; public class GenerateInstanceDocumentFromSchemaAction extends AnAction { @Override public void update(AnActionEvent e) { - final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); + final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final boolean enabled = isAcceptableFile(file); e.getPresentation().setEnabled(enabled); if (ActionPlaces.isPopupPlace(e.getPlace())) { @@ -62,8 +63,8 @@ public class GenerateInstanceDocumentFromSchemaAction extends AnAction { } public void actionPerformed(AnActionEvent e) { - final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); + final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext()); + final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final GenerateInstanceDocumentFromSchemaDialog dialog = new GenerateInstanceDocumentFromSchemaDialog(project, file); dialog.setOkAction(new Runnable() { diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java index 62bdcb7b177a..615b74a4763a 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/GenerateSchemaFromInstanceDocumentAction.java @@ -19,6 +19,7 @@ import com.intellij.javaee.ExternalResourceManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ActionPlaces; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileDocumentManager; @@ -58,7 +59,7 @@ public class GenerateSchemaFromInstanceDocumentAction extends AnAction { @Override public void update(AnActionEvent e) { - final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); + final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final boolean enabled = isAcceptableFile(file); e.getPresentation().setEnabled(enabled); if (ActionPlaces.isPopupPlace(e.getPlace())) { @@ -68,7 +69,7 @@ public class GenerateSchemaFromInstanceDocumentAction extends AnAction { public void actionPerformed(AnActionEvent e) { final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext()); - final VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); + final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext()); final GenerateSchemaFromInstanceDocumentDialog dialog = new GenerateSchemaFromInstanceDocumentDialog(project, file); dialog.setOkAction(new Runnable() { diff --git a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java index e2531e7956fc..10ef18756a18 100644 --- a/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java +++ b/xml/impl/src/com/intellij/xml/refactoring/XmlTagRenameHandler.java @@ -25,6 +25,7 @@ package com.intellij.xml.refactoring; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.ide.TitledHandler; import com.intellij.lang.Language; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; @@ -100,7 +101,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { @Nullable private static Editor getEditor(@Nullable DataContext context) { - return PlatformDataKeys.EDITOR.getData(context); + return CommonDataKeys.EDITOR.getData(context); } @Nullable @@ -109,7 +110,7 @@ public class XmlTagRenameHandler implements RenameHandler, TitledHandler { final Editor editor = getEditor(context); if (editor != null) { final int offset = editor.getCaretModel().getOffset(); - final PsiFile file = LangDataKeys.PSI_FILE.getData(context); + final PsiFile file = CommonDataKeys.PSI_FILE.getData(context); if (file instanceof XmlFile) { return file.getViewProvider().findElementAt(offset); } diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java index 7c9eb3eae4ff..9ae107994aa4 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaAction.java @@ -18,6 +18,7 @@ package org.intellij.plugins.relaxNG.convert; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; @@ -43,7 +44,7 @@ import java.io.File; public class ConvertSchemaAction extends AnAction { public void update(AnActionEvent e) { - final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); + final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); final Project project = e.getData(PlatformDataKeys.PROJECT); if (files != null && project != null) { final SchemaType type = getInputType(project, files); @@ -93,10 +94,10 @@ public class ConvertSchemaAction extends AnAction { } public void actionPerformed(AnActionEvent e) { - final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); + final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); final Project project = e.getData(PlatformDataKeys.PROJECT); if (file != null && project != null) { - final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); + final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY); assert files != null; final SchemaType type = getInputType(project, files); diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java index ae84e2e4396e..f45b89cef2c7 100644 --- a/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java +++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/validation/ValidateAction.java @@ -19,6 +19,7 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.application.ApplicationManager; @@ -82,7 +83,7 @@ public class ValidateAction extends AnAction { super.update(e); myOrigAction.update(e); - final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE); + final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); if (file != null) { if (file.getUserData(IN_PROGRESS_KEY) == Boolean.TRUE) { e.getPresentation().setEnabled(false); @@ -91,11 +92,11 @@ public class ValidateAction extends AnAction { } private boolean actionPerformedImpl(AnActionEvent e) { - final PsiFile file = e.getData(LangDataKeys.PSI_FILE); + final PsiFile file = e.getData(CommonDataKeys.PSI_FILE); if (file == null) { return false; } - final Project project = e.getData(PlatformDataKeys.PROJECT); + final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) { return false; } diff --git a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java index 013d94e63d09..c0030d89ff57 100644 --- a/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/BaseHtmlLexer.java @@ -72,6 +72,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { @NonNls private static final String TOKEN_STYLE = "style"; @NonNls private static final String TOKEN_ON = "on"; + @Override public void handleElement(Lexer lexer) { final CharSequence buffer; if (lexerOfCacheBufferSequence == lexer) { @@ -132,6 +133,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { } class XmlAttributeValueEndHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { if (seenAttribute) { seenStyle = false; @@ -143,6 +145,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { } class XmlAttributeValueHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { if (seenContentType) { if(!seenScript || seenAttribute) { @@ -184,6 +187,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { } class XmlTagClosedHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { if (seenAttribute) { seenScript=false; @@ -199,6 +203,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { } class XmlTagEndHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { seenStyle=false; seenScript=false; @@ -230,6 +235,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { if (tokenHandler != null) { final TokenHandler newHandler = value; value = new TokenHandler() { + @Override public void handleElement(final Lexer lexer) { tokenHandler.handleElement(lexer); newHandler.handleElement(lexer); @@ -240,6 +246,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { tokenHandlers.put(elementType,value); } + @Override public void start(@NotNull final CharSequence buffer, final int startOffset, final int endOffset, final int initialState) { initState(initialState); super.start(buffer, startOffset, endOffset, initialState & BASE_STATE_MASK); @@ -344,6 +351,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { tokenType == XmlTokenType.XML_CHAR_ENTITY_REF; } + @Override public void advance() { super.advance(); IElementType type = getDelegate().getTokenType(); @@ -352,6 +360,7 @@ abstract class BaseHtmlLexer extends DelegateLexer { } + @Override public int getState() { int state = super.getState(); diff --git a/xml/impl/src/com/intellij/lexer/HtmlHighlightingLexer.java b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java index 660e21556c3e..27b972887a83 100644 --- a/xml/impl/src/com/intellij/lexer/HtmlHighlightingLexer.java +++ b/xml/xml-psi-impl/src/com/intellij/lexer/HtmlHighlightingLexer.java @@ -17,10 +17,7 @@ package com.intellij.lexer; import com.intellij.lang.*; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; +import com.intellij.openapi.fileTypes.*; import com.intellij.psi.tree.IElementType; import com.intellij.psi.xml.XmlTokenType; import org.jetbrains.annotations.NotNull; @@ -37,9 +34,10 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { private Lexer scriptLexer; protected Lexer elLexer; private boolean hasNoEmbeddments; - private final static FileType ourStyleFileType = FileTypeManager.getInstance().getStdFileType("CSS"); + private final FileType ourStyleFileType;// = FileTypeManager.getInstance().getStdFileType("CSS"); private static FileType ourInlineScriptFileType = null; + static { // At the moment only JS. HtmlInlineScriptTokenTypesProvider provider = @@ -48,17 +46,18 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } public class XmlEmbeddmentHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { if (!hasSeenStyle() && !hasSeenScript() || hasNoEmbeddments) return; final IElementType tokenType = lexer.getTokenType(); - if ((tokenType==XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && hasSeenAttribute()) || - (tokenType==XmlTokenType.XML_DATA_CHARACTERS && hasSeenTag()) || - tokenType==XmlTokenType.XML_COMMENT_CHARACTERS && hasSeenTag() - ) { + if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && hasSeenAttribute() || + tokenType == XmlTokenType.XML_DATA_CHARACTERS && hasSeenTag() || + tokenType == XmlTokenType.XML_COMMENT_CHARACTERS && hasSeenTag() + ) { setEmbeddedLexer(); - if (embeddedLexer!=null) { + if (embeddedLexer != null) { embeddedLexer.start( getBufferSequence(), HtmlHighlightingLexer.super.getTokenStart(), @@ -76,6 +75,7 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } public class ElEmbeddmentHandler implements TokenHandler { + @Override public void handleElement(Lexer lexer) { setEmbeddedLexer(); if (embeddedLexer != null) { @@ -84,28 +84,31 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } } - public HtmlHighlightingLexer() { - this(new MergingLexerAdapter(new FlexAdapter(new _HtmlLexer()),TOKENS_TO_MERGE),true); + public HtmlHighlightingLexer(FileType styleFileType) { + this(new MergingLexerAdapter(new FlexAdapter(new _HtmlLexer()), TOKENS_TO_MERGE), true, styleFileType); } - protected HtmlHighlightingLexer(Lexer lexer, boolean caseInsensitive) { - super(lexer,caseInsensitive); + protected HtmlHighlightingLexer(Lexer lexer, boolean caseInsensitive, FileType styleFileType) { + super(lexer, caseInsensitive); + ourStyleFileType = styleFileType; XmlEmbeddmentHandler value = new XmlEmbeddmentHandler(); - registerHandler(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,value); - registerHandler(XmlTokenType.XML_DATA_CHARACTERS,value); - registerHandler(XmlTokenType.XML_COMMENT_CHARACTERS,value); + registerHandler(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN, value); + registerHandler(XmlTokenType.XML_DATA_CHARACTERS, value); + registerHandler(XmlTokenType.XML_COMMENT_CHARACTERS, value); } + @Override public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) { super.start(buffer, startOffset, endOffset, initialState); - if ((initialState & EMBEDDED_LEXER_ON)!=0) { + if ((initialState & EMBEDDED_LEXER_ON) != 0) { int state = initialState >> EMBEDDED_LEXER_STATE_SHIFT; setEmbeddedLexer(); - LOG.assertTrue(embeddedLexer!=null); - embeddedLexer.start(buffer,startOffset,skipToTheEndOfTheEmbeddment(),state); - } else { + LOG.assertTrue(embeddedLexer != null); + embeddedLexer.start(buffer, startOffset, skipToTheEndOfTheEmbeddment(), state); + } + else { embeddedLexer = null; scriptLexer = null; } @@ -114,24 +117,28 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { private void setEmbeddedLexer() { Lexer newLexer = null; if (hasSeenStyle()) { - if (styleLexer==null) { - styleLexer = (ourStyleFileType!=null)? SyntaxHighlighterFactory.getSyntaxHighlighter(ourStyleFileType, null, null).getHighlightingLexer():null; + if (styleLexer == null) { + styleLexer = ourStyleFileType == null + ? null + : SyntaxHighlighterFactory.getSyntaxHighlighter(ourStyleFileType, null, null).getHighlightingLexer(); } newLexer = styleLexer; - } else if (hasSeenScript()) { + } + else if (hasSeenScript()) { if (scriptLexer == null) { if (hasSeenTag()) { HtmlScriptContentProvider provider = findScriptContentProvider(scriptType); if (provider != null) { scriptLexer = provider.getHighlightingLexer(); - } else { - scriptLexer = SyntaxHighlighterFactory.getSyntaxHighlighter(StdLanguages.TEXT, null, null).getHighlightingLexer(); + } + else { + scriptLexer = SyntaxHighlighterFactory.getSyntaxHighlighter(PlainTextLanguage.INSTANCE, null, null).getHighlightingLexer(); } } else if (hasSeenAttribute()) { SyntaxHighlighter syntaxHighlighter = - (ourInlineScriptFileType != null) ? SyntaxHighlighterFactory.getSyntaxHighlighter(ourInlineScriptFileType, null, null) : null; + ourInlineScriptFileType != null ? SyntaxHighlighterFactory.getSyntaxHighlighter(ourInlineScriptFileType, null, null) : null; scriptLexer = syntaxHighlighter != null ? syntaxHighlighter.getHighlightingLexer() : null; } } @@ -141,7 +148,7 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { newLexer = createELLexer(newLexer); } - if (newLexer!=null) { + if (newLexer != null) { embeddedLexer = newLexer; } } @@ -151,29 +158,32 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { return newLexer; } + @Override public void advance() { - if (embeddedLexer!=null) { + if (embeddedLexer != null) { embeddedLexer.advance(); - if (embeddedLexer.getTokenType()==null) { - embeddedLexer=null; + if (embeddedLexer.getTokenType() == null) { + embeddedLexer = null; } } - if (embeddedLexer==null) { + if (embeddedLexer == null) { super.advance(); } } + @Override public IElementType getTokenType() { - if (embeddedLexer!=null) { + if (embeddedLexer != null) { return embeddedLexer.getTokenType(); - } else { + } + else { IElementType tokenType = super.getTokenType(); // TODO: fix no DOCTYPE highlighting if (tokenType == null) return tokenType; - if (tokenType==XmlTokenType.XML_NAME) { + if (tokenType == XmlTokenType.XML_NAME) { // we need to convert single xml_name for tag name and attribute name into to separate // lex types for the highlighting! final int state = getState() & BASE_STATE_MASK; @@ -185,12 +195,14 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { else if (tokenType == XmlTokenType.XML_WHITE_SPACE || tokenType == XmlTokenType.XML_REAL_WHITE_SPACE) { if (hasSeenTag() && (hasSeenStyle() || hasSeenScript())) { tokenType = XmlTokenType.XML_WHITE_SPACE; - } else { - tokenType = (getState()!=0)?XmlTokenType.TAG_WHITE_SPACE:XmlTokenType.XML_REAL_WHITE_SPACE; } - } else if (tokenType == XmlTokenType.XML_CHAR_ENTITY_REF || + else { + tokenType = getState() != 0 ? XmlTokenType.TAG_WHITE_SPACE : XmlTokenType.XML_REAL_WHITE_SPACE; + } + } + else if (tokenType == XmlTokenType.XML_CHAR_ENTITY_REF || tokenType == XmlTokenType.XML_ENTITY_REF_TOKEN - ) { + ) { // we need to convert char entity ref & entity ref in comments as comment chars final int state = getState() & BASE_STATE_MASK; if (state == _HtmlLexer.COMMENT) return XmlTokenType.XML_COMMENT_CHARACTERS; @@ -199,34 +211,40 @@ public class HtmlHighlightingLexer extends BaseHtmlLexer { } } + @Override public int getTokenStart() { - if (embeddedLexer!=null) { + if (embeddedLexer != null) { return embeddedLexer.getTokenStart(); - } else { + } + else { return super.getTokenStart(); } } + @Override public int getTokenEnd() { - if (embeddedLexer!=null) { + if (embeddedLexer != null) { return embeddedLexer.getTokenEnd(); - } else { + } + else { return super.getTokenEnd(); } } + @Override public int getState() { int state = super.getState(); - state |= ((embeddedLexer!=null)?EMBEDDED_LEXER_ON:0); - if (embeddedLexer!=null) state |= (embeddedLexer.getState() << EMBEDDED_LEXER_STATE_SHIFT); + state |= embeddedLexer != null ? EMBEDDED_LEXER_ON : 0; + if (embeddedLexer != null) state |= embeddedLexer.getState() << EMBEDDED_LEXER_STATE_SHIFT; return state; } + @Override protected boolean isHtmlTagState(int state) { return state == _HtmlLexer.START_TAG_NAME || state == _HtmlLexer.END_TAG_NAME || - state == _HtmlLexer.START_TAG_NAME2 || state == _HtmlLexer.END_TAG_NAME2; + state == _HtmlLexer.START_TAG_NAME2 || state == _HtmlLexer.END_TAG_NAME2; } public void setHasNoEmbeddments(boolean hasNoEmbeddments) { |