From 3d2f4f5c90bb4982620e39df791f4f64d24b2f02 Mon Sep 17 00:00:00 2001 From: Alexander Kass Date: Mon, 27 Feb 2017 11:20:27 +0300 Subject: [PATCH 01/20] DBE: pass value from editor on-the-fly (in mappings) --- .../encoding/FileEncodingConfigurable.java | 15 +++- .../util/ui/tree/PerFileConfigurableBase.java | 84 +++++++++++++------ 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java index cc56a3f8f91a..e75d70b75c27 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java +++ b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/FileEncodingConfigurable.java @@ -151,7 +151,20 @@ public class FileEncodingConfigurable extends PerFileConfigurableBase { @Override public JComponent createComponent() { myTablePanel.add(super.createComponent(), BorderLayout.CENTER); - JPanel p = createActionPanel(null, () -> myPropsCharset, o -> myPropsCharset = o); + JPanel p = createActionPanel(null, new Value() { + @Override + public void commit() {} + + @Override + public Charset get() { + return myPropsCharset; + } + + @Override + public void set(Charset value) { + myPropsCharset = value; + } + }); myPropertiesFilesEncodingCombo.add(p, BorderLayout.CENTER); return myPanel; } diff --git a/platform/lang-impl/src/com/intellij/util/ui/tree/PerFileConfigurableBase.java b/platform/lang-impl/src/com/intellij/util/ui/tree/PerFileConfigurableBase.java index 211801fb51b6..03f1f5407e52 100644 --- a/platform/lang-impl/src/com/intellij/util/ui/tree/PerFileConfigurableBase.java +++ b/platform/lang-impl/src/com/intellij/util/ui/tree/PerFileConfigurableBase.java @@ -93,6 +93,10 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab private final List, Consumer>> myDefaultProps = ContainerUtil.newArrayList(); private VirtualFile myFileToSelect; + protected interface Value extends Setter, Getter { + void commit(); + } + protected PerFileConfigurableBase(@NotNull Project project, @NotNull PerFileMappings mappings) { myProject = project; myMappings = mappings; @@ -210,9 +214,20 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab for (Trinity, Consumer> prop : myDefaultProps) { myDefaultVals.put(prop.first, prop.second.produce()); - JPanel p = createActionPanel(null, - () -> myDefaultVals.get(prop.first), - o -> myDefaultVals.put(prop.first, adjustChosenValue(null, o))); + JPanel p = createActionPanel(null, new Value() { + @Override + public void commit() {} + + @Override + public T get() { + return myDefaultVals.get(prop.first); + } + + @Override + public void set(T value) { + myDefaultVals.put(prop.first, adjustChosenValue(null, value)); + } + }); panel.add(new JBLabel(prop.first + ":"), cons1); panel.add(p, cons2); } @@ -477,20 +492,31 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab editorValue = pair.second; // (T)value if (!canEditTarget(target, editorValue)) return null; - JPanel panel = createActionPanel(target, () -> editorValue, chosen -> { - editorValue = adjustChosenValue(target, chosen); - TableUtil.stopEditing(myTable); - selectRows(new int[]{modelRow}, true); - if (Comparing.equal(editorValue, pair.second)) { - // do nothing + JPanel panel = createActionPanel(target, new Value() { + @Override + public T get() { + return editorValue; } - else { - int ret = clearSubdirectoriesOnDemandOrCancel(false, target); - if (ret == Messages.CANCEL) { - myModel.setValueAt(value, modelRow, column); - } + + @Override + public void set(T value) { + editorValue = adjustChosenValue(target, value); + } + + @Override + public void commit() { + TableUtil.stopEditing(myTable); selectRows(new int[]{modelRow}, true); - } + if (Comparing.equal(editorValue, pair.second)) { + // do nothing + } + else { + int ret = clearSubdirectoriesOnDemandOrCancel(false, target); + if (ret == Messages.CANCEL) { + myModel.setValueAt(value, modelRow, column); + } + selectRows(new int[]{modelRow}, true); + } } }, true); AbstractButton button = UIUtil.uiTraverser(panel).filter(JButton.class).first(); @@ -516,13 +542,13 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab } @NotNull - protected JPanel createActionPanel(@Nullable Object target, Producer value, @NotNull Consumer consumer) { - return createActionPanel(target, value, consumer, false); + protected JPanel createActionPanel(@Nullable Object target, @NotNull Value value) { + return createActionPanel(target, value, false); } @NotNull - private JPanel createActionPanel(@Nullable Object target, Producer value, @NotNull Consumer consumer, boolean editor) { - AnAction changeAction = createValueAction(target, value, consumer); + private JPanel createActionPanel(@Nullable Object target, @NotNull Value value, boolean editor) { + AnAction changeAction = createValueAction(target, value); JComponent comboComponent = ((CustomComponentAction)changeAction).createCustomComponent(changeAction.getTemplatePresentation()); JPanel panel = new JPanel(new BorderLayout()) { @Override @@ -620,10 +646,10 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab } @NotNull - protected final AnAction createValueAction(@Nullable Object target, Producer value, @NotNull Consumer consumer) { + protected final AnAction createValueAction(@Nullable Object target, @NotNull Value value) { return new ComboBoxAction() { void updateText() { - String text = renderValue(value.produce(), StringUtil.notNullize(getNullValueText(target))); + String text = renderValue(value.get(), StringUtil.notNullize(getNullValueText(target))); getTemplatePresentation().setText(StringUtil.shortenTextWithEllipsis(text, 40, 0)); } @@ -642,10 +668,10 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab protected ComboBoxButton createComboBoxButton(Presentation presentation) { return new ComboBoxButton(presentation) { protected JBPopup createPopup(Runnable onDispose) { - JBPopup popup = createValueEditorPopup(target, value.produce(), onDispose, getDataContext(), o -> { - consumer.consume(o); + JBPopup popup = createValueEditorPopup(target, value.get(), onDispose, getDataContext(), o -> { + value.set(o); updateText(); - }); + }, value::commit); popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight())); return popup; } @@ -654,7 +680,7 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab @Override public String getToolTipText() { boolean cellEditor = UIUtil.uiParents(this, true).take(4).filter(JBTable.class).first() != null; - return cellEditor ? null : getToolTipFor(value.produce()); + return cellEditor ? null : getToolTipFor(value.get()); } }; } @@ -666,8 +692,12 @@ public abstract class PerFileConfigurableBase implements SearchableConfigurab @Nullable T value, @Nullable Runnable onDispose, @NotNull DataContext dataContext, - @NotNull Consumer onChosen) { - return createValueEditorActionListPopup(target, onDispose, dataContext, onChosen); + @NotNull Consumer onChosen, + @NotNull Runnable onCommit) { + return createValueEditorActionListPopup(target, onDispose, dataContext, chosen -> { + onChosen.consume(chosen); + onCommit.run(); + }); } @NotNull From a21a33fa3c2f739680d1e1091f1f5ea533c29758 Mon Sep 17 00:00:00 2001 From: Maxim Kropotov Date: Wed, 22 Feb 2017 20:48:04 +0300 Subject: [PATCH 02/20] WEB-25551 Show HTML code style when you search for JSX --- .../application/options/CodeStyleConfigurableWrapper.java | 7 ++++++- .../application/options/HtmlCodeStyleSettingsProvider.java | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleConfigurableWrapper.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleConfigurableWrapper.java index 6d37e0b5bd02..490d71192efc 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleConfigurableWrapper.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleConfigurableWrapper.java @@ -118,7 +118,7 @@ public class CodeStyleConfigurableWrapper @Override @NotNull public String getId() { - return "preferences.sourceCode." + getDisplayName(); + return getConfigurableId(getDisplayName()); } @Override @@ -149,4 +149,9 @@ public class CodeStyleConfigurableWrapper } return myPanel.processListOptions(); } + + @NotNull + public static String getConfigurableId(String configurableDisplayName) { + return "preferences.sourceCode." + configurableDisplayName; + } } diff --git a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java index 9593c4626ee1..2a9795c64d80 100644 --- a/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java +++ b/xml/impl/src/com/intellij/application/options/HtmlCodeStyleSettingsProvider.java @@ -25,10 +25,13 @@ import org.jetbrains.annotations.NotNull; * @author yole */ public class HtmlCodeStyleSettingsProvider extends CodeStyleSettingsProvider { + + public static final String DISPLAY_NAME = ApplicationBundle.message("title.html"); + @Override @NotNull public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) { - return new CodeStyleAbstractConfigurable(settings, originalSettings, ApplicationBundle.message("title.html")) { + return new CodeStyleAbstractConfigurable(settings, originalSettings, DISPLAY_NAME) { @Override protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) { return new HtmlCodeStyleMainPanel(settings, originalSettings); @@ -43,6 +46,6 @@ public class HtmlCodeStyleSettingsProvider extends CodeStyleSettingsProvider { @Override public String getConfigurableDisplayName() { - return ApplicationBundle.message("title.html"); + return DISPLAY_NAME; } } From afc78ac84b60132cc26e408eb7ca2bbafbf68193 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 27 Feb 2017 10:57:40 +0700 Subject: [PATCH 03/20] Migrate to simplified collection: moved to Migration/Java 9 group --- .../src/messages/InspectionsBundle.properties | 3 ++- resources/src/META-INF/IdeaPlugin.xml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index dfb627d3a738..da7a4f566441 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -542,8 +542,9 @@ group.names.j2me.issues=J2ME issues group.names.control.flow.issues=Control flow issues group.names.numeric.issues=Numeric issues group.names.language.level.specific.issues.and.migration.aids=Java language level migration aids -group.names.language.level.specific.issues.and.migration.aids8=Java 8 group.names.language.level.specific.issues.and.migration.aids7=Java 7 +group.names.language.level.specific.issues.and.migration.aids8=Java 8 +group.names.language.level.specific.issues.and.migration.aids9=Java 9 group.names.javabeans.issues=JavaBeans issues group.names.inheritance.issues=Inheritance issues group.names.data.flow.issues=Data flow issues diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 0d4f2b17d58a..6625b9dedb99 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -857,9 +857,9 @@ groupKey="group.names.language.level.specific.issues.and.migration.aids8" enabledByDefault="true" level="WARNING" implementationClass="com.intellij.codeInspection.java18api.Java8MapForEachInspection" displayName="Replace with Map.forEach"/> - Date: Mon, 27 Feb 2017 16:28:46 +0700 Subject: [PATCH 04/20] Migrate to simplified collection: disable if null or repeating constant value; checkbox to not warn on non-constant content --- .../Java9CollectionFactoryInspection.java | 57 ++++++++++++++++--- .../java9CollectionFactory/afterAsList.java | 2 +- .../afterHashSetAsList.java | 2 +- .../afterHashSetAsListRepeating.java | 11 ++++ .../java9CollectionFactory/beforeAsList.java | 2 +- .../beforeAsListNull.java | 8 +++ .../beforeHashSetAsList.java | 2 +- .../siyeh/ig/psiutils/ExpressionUtils.java | 29 ++++++++++ .../Java9CollectionFactory.html | 3 + 9 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsListRepeating.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/beforeAsListNull.java diff --git a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java index 57cb4b8a45f0..51998391a999 100644 --- a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java @@ -17,9 +17,12 @@ package com.intellij.codeInspection.java19api; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.codeInspection.ex.BaseLocalInspectionTool; +import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; import com.intellij.openapi.project.Project; +import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.controlFlow.DefUseUtil; import com.intellij.psi.util.PsiTreeUtil; @@ -27,16 +30,16 @@ import com.intellij.psi.util.PsiUtil; import com.intellij.util.containers.ContainerUtil; import com.siyeh.ig.callMatcher.CallMapper; import com.siyeh.ig.callMatcher.CallMatcher; -import com.siyeh.ig.psiutils.ClassUtils; -import com.siyeh.ig.psiutils.CommentTracker; -import com.siyeh.ig.psiutils.ConstructionUtils; -import com.siyeh.ig.psiutils.MethodCallUtils; +import com.siyeh.ig.psiutils.*; +import one.util.streamex.IntStreamEx; import one.util.streamex.StreamEx; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.util.*; +import java.util.function.Function; import static com.intellij.util.ObjectUtils.tryCast; @@ -65,6 +68,14 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { .register(UNMODIFIABLE_SET, call -> PrepopulatedCollectionModel.fromSet(call.getArgumentList().getExpressions()[0])) .register(UNMODIFIABLE_LIST, call -> PrepopulatedCollectionModel.fromList(call.getArgumentList().getExpressions()[0])); + public boolean IGNORE_NON_CONSTANT = false; + + @Nullable + @Override + public JComponent createOptionsPanel() { + return new SingleCheckboxOptionsPanel("Do not warn when content is non-constant", this, "IGNORE_NON_CONSTANT"); + } + @NotNull @Override public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) { @@ -75,10 +86,17 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { @Override public void visitMethodCallExpression(PsiMethodCallExpression call) { PrepopulatedCollectionModel model = MAPPER.mapFirst(call); - if(model != null) { - PsiElement element = call.getMethodExpression().getReferenceNameElement(); + if (model != null && model.isValid()) { + ProblemHighlightType type = model.myConstantContent || !IGNORE_NON_CONSTANT + ? ProblemHighlightType.GENERIC_ERROR_OR_WARNING + : ProblemHighlightType.INFORMATION; + if (type == ProblemHighlightType.INFORMATION && !isOnTheFly) return; + boolean wholeStatement = isOnTheFly && + (type == ProblemHighlightType.INFORMATION || + InspectionProjectProfileManager.isInformationLevel(getShortName(), call)); + PsiElement element = wholeStatement ? call : call.getMethodExpression().getReferenceNameElement(); if(element != null) { - holder.registerProblem(element, "Can be replaced with '"+model.myType+".of' call", + holder.registerProblem(element, "Can be replaced with '" + model.myType + ".of' call", type, new ReplaceWithCollectionFactoryFix(model.myType)); } } @@ -90,11 +108,34 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { final List myContent; final List myElementsToDelete; final String myType; + final boolean myConstantContent; + final boolean myRepeatingKeys; + final boolean myHasNulls; PrepopulatedCollectionModel(List content, List delete, String type) { myContent = content; myElementsToDelete = delete; myType = type; + Map> constants = StreamEx.of(myContent) + .cross(ExpressionUtils::possibleValues).mapValues(ExpressionUtils::computeConstantExpression).distinct().grouping(); + myConstantContent = StreamEx.ofValues(constants).flatCollection(Function.identity()).allMatch(Objects::nonNull); + myRepeatingKeys = keyExpressions().flatCollection(constants::get).nonNull().distinct(2).findAny().isPresent(); + myHasNulls = StreamEx.of(myContent).flatMap(ExpressionUtils::possibleValues).map(PsiExpression::getType).has(PsiType.NULL); + } + + public boolean isValid() { + return !myHasNulls && !myRepeatingKeys; + } + + private StreamEx keyExpressions() { + switch (myType) { + case "Set": + return StreamEx.of(myContent); + case "Map": + return IntStreamEx.range(0, myContent.size(), 2).elements(myContent); + default: + return StreamEx.empty(); + } } public static PrepopulatedCollectionModel fromList(PsiExpression listDefinition) { @@ -254,7 +295,7 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(descriptor.getStartElement(), PsiMethodCallExpression.class); + PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(descriptor.getStartElement(), PsiMethodCallExpression.class, false); if(call == null) return; PrepopulatedCollectionModel model = MAPPER.mapFirst(call); if(model == null) return; diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/afterAsList.java b/java/java-tests/testData/inspection/java9CollectionFactory/afterAsList.java index 9bc05d254d49..29392eb96ab9 100644 --- a/java/java-tests/testData/inspection/java9CollectionFactory/afterAsList.java +++ b/java/java-tests/testData/inspection/java9CollectionFactory/afterAsList.java @@ -4,5 +4,5 @@ import java.util.Collections; import java.util.List; public class Test { - public static final List EVEN = List.of(2, 4, 6, 8, 10); + public static final List EVEN = List.of(2, 4, 6, 8, 10, 2); } diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsList.java b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsList.java index d14c53688cf8..7f2c1ffa5879 100644 --- a/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsList.java +++ b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsList.java @@ -5,5 +5,5 @@ import java.util.HashSet; import java.util.Set; public class Test { - public static final Set MY_SET = Set.of("a", "b", "c"); + public static final Set MY_SET = Set.of("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d"); } diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsListRepeating.java b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsListRepeating.java new file mode 100644 index 000000000000..a01fa043f554 --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashSetAsListRepeating.java @@ -0,0 +1,11 @@ +// "Replace with 'Set.of' call" "false" +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +public class Test { + static final String CONST = "b"; + + public static final Set MY_SET = Set.of("a", "b", "c", CONST); +} diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsList.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsList.java index ea64a58b74db..383522202477 100644 --- a/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsList.java +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsList.java @@ -4,5 +4,5 @@ import java.util.Collections; import java.util.List; public class Test { - public static final List EVEN = Collections.unmodifiableList(Arrays.asList(2,4,6,8,10)); + public static final List EVEN = Collections.unmodifiableList(Arrays.asList(2,4,6,8,10,2)); } diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsListNull.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsListNull.java new file mode 100644 index 000000000000..022087b887ee --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeAsListNull.java @@ -0,0 +1,8 @@ +// "Replace with 'List.of' call" "false" +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class Test { + public static final List EVEN = Collections.unmodifiableList(Arrays.asList(2,4,6,8,10,Math.random() > 0.5 ? 12 : null)); +} diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashSetAsList.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashSetAsList.java index e62f7e66e076..4787fb52a5c1 100644 --- a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashSetAsList.java +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashSetAsList.java @@ -5,5 +5,5 @@ import java.util.HashSet; import java.util.Set; public class Test { - public static final Set MY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("a", "b", "c"))); + public static final Set MY_SET = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d"))); } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java index 9b455cd1eb2a..0b04c00eb39f 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java @@ -26,6 +26,7 @@ import com.intellij.psi.util.InheritanceUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.ObjectUtils; import com.siyeh.HardcodedMethodConstants; +import one.util.streamex.StreamEx; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -34,6 +35,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import java.util.stream.Stream; public class ExpressionUtils { @NonNls static final Set convertableBoxedClassNames = new HashSet<>(3); @@ -222,11 +224,38 @@ public class ExpressionUtils { return "\"\"".equals(text); } + @Contract("null -> false") public static boolean isNullLiteral(@Nullable PsiExpression expression) { expression = ParenthesesUtils.stripParentheses(expression); return expression != null && PsiType.NULL.equals(expression.getType()); } + /** + * Returns stream of sub-expressions of supplied expression which could be equal (by ==) to resulting + * value of the expression. The expressions in returned stream are guaranteed not to be each other ancestors. + * Also the expression value is guaranteed to be equal to one of returned sub-expressions. + * + *

+ * E.g. for {@code ((a) ? b : (c))} the stream will contain b and c. + *

+ * + * @param expression expression to create a stream from + * @return a new stream + */ + public static Stream possibleValues(@NotNull PsiExpression expression) { + return StreamEx.ofTree(expression, e -> { + if (e instanceof PsiConditionalExpression) { + PsiConditionalExpression ternary = (PsiConditionalExpression)e; + return StreamEx.of(ternary.getThenExpression(), ternary.getElseExpression()).nonNull(); + } + if (e instanceof PsiParenthesizedExpression) { + return StreamEx.ofNullable(((PsiParenthesizedExpression)e).getExpression()); + } + return null; + }).remove(e -> e instanceof PsiConditionalExpression || + e instanceof PsiParenthesizedExpression); + } + public static boolean isZero(@Nullable PsiExpression expression) { if (expression == null) { return false; diff --git a/resources-en/src/inspectionDescriptions/Java9CollectionFactory.html b/resources-en/src/inspectionDescriptions/Java9CollectionFactory.html index 536407a7bdf3..fc6c57a7981a 100644 --- a/resources-en/src/inspectionDescriptions/Java9CollectionFactory.html +++ b/resources-en/src/inspectionDescriptions/Java9CollectionFactory.html @@ -3,6 +3,9 @@ This inspection helps to convert unmodifiable collections created before Java 9 to new collection factory methods like List.of or Set.of. +

Note that Java 9 collection factory methods do not accept null values. Also set elements and map keys are required to be different. +It's not always possible to statically check whether original elements are different and not null. Using the checkbox you may enforce +the inspection to warn only if original elements are compile-time constants, so the conversion is guaranteed to be correct.

This inspection is available since Java 9 only.

New in 2017.2 From 05a2a2930073f6fdfd10f9f64f5737c3728888e5 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 27 Feb 2017 16:34:09 +0700 Subject: [PATCH 05/20] Migrate to simplified collection: i18n --- .../Java9CollectionFactoryInspection.java | 14 ++++++-------- .../src/messages/InspectionsBundle.properties | 5 +++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java index 51998391a999..ae6daeba43fc 100644 --- a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java @@ -15,10 +15,7 @@ */ package com.intellij.codeInspection.java19api; -import com.intellij.codeInspection.LocalQuickFix; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ProblemHighlightType; -import com.intellij.codeInspection.ProblemsHolder; +import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.BaseLocalInspectionTool; import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; import com.intellij.openapi.project.Project; @@ -73,7 +70,8 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { @Nullable @Override public JComponent createOptionsPanel() { - return new SingleCheckboxOptionsPanel("Do not warn when content is non-constant", this, "IGNORE_NON_CONSTANT"); + return new SingleCheckboxOptionsPanel(InspectionsBundle.message("inspection.collection.factories.option.ignore.non.constant"), this, + "IGNORE_NON_CONSTANT"); } @NotNull @@ -96,7 +94,7 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { InspectionProjectProfileManager.isInformationLevel(getShortName(), call)); PsiElement element = wholeStatement ? call : call.getMethodExpression().getReferenceNameElement(); if(element != null) { - holder.registerProblem(element, "Can be replaced with '" + model.myType + ".of' call", type, + holder.registerProblem(element, InspectionsBundle.message("inspection.collection.factories.message", model.myType), type, new ReplaceWithCollectionFactoryFix(model.myType)); } } @@ -283,14 +281,14 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { @NotNull @Override public String getName() { - return "Replace with '"+myType+".of' call"; + return InspectionsBundle.message("inspection.collection.factories.fix.name", myType); } @Nls @NotNull @Override public String getFamilyName() { - return "Replace with collection factory call"; + return InspectionsBundle.message("inspection.collection.factories.fix.family.name"); } @Override diff --git a/platform/platform-resources-en/src/messages/InspectionsBundle.properties b/platform/platform-resources-en/src/messages/InspectionsBundle.properties index da7a4f566441..e3eec188c06e 100644 --- a/platform/platform-resources-en/src/messages/InspectionsBundle.properties +++ b/platform/platform-resources-en/src/messages/InspectionsBundle.properties @@ -784,3 +784,8 @@ inspection.redundant.stream.optional.call.option.streamboxing=Report useless box inspection.map.foreach.message=Can be replaced with 'Map.forEach' inspection.map.foreach.fix.name=Replace with Map.forEach inspection.map.foreach.option.no.loops=Do not report loops + +inspection.collection.factories.message=Can be replaced with ''{0}.of'' call +inspection.collection.factories.option.ignore.non.constant=Do not warn when content is non-constant +inspection.collection.factories.fix.family.name=Replace with collection factory call +inspection.collection.factories.fix.name=Replace with ''{0}.of'' call From 0deb0dac6f31300fa57798b282898af1926373e3 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 27 Feb 2017 17:23:21 +0700 Subject: [PATCH 06/20] Migrate to simplified collection: Map support --- .../Java9CollectionFactoryInspection.java | 70 +++++++++++-------- .../afterHashMap10.java | 9 +++ .../afterHashMapSimple.java | 9 +++ .../beforeHashMap10.java | 19 +++++ .../beforeHashMap11.java | 20 ++++++ .../beforeHashMapRepeatingKey.java | 11 +++ .../beforeHashMapSimple.java | 11 +++ 7 files changed, 118 insertions(+), 31 deletions(-) create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/afterHashMap10.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/afterHashMapSimple.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap10.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap11.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapRepeatingKey.java create mode 100644 java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapSimple.java diff --git a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java index ae6daeba43fc..256bd8f24d6c 100644 --- a/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/java19api/Java9CollectionFactoryInspection.java @@ -46,12 +46,16 @@ import static com.intellij.util.ObjectUtils.tryCast; public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { private static final CallMatcher UNMODIFIABLE_SET = CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_COLLECTIONS, "unmodifiableSet").parameterCount(1); + private static final CallMatcher UNMODIFIABLE_MAP = + CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_COLLECTIONS, "unmodifiableMap").parameterCount(1); private static final CallMatcher UNMODIFIABLE_LIST = CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_COLLECTIONS, "unmodifiableList").parameterCount(1); private static final CallMatcher ARRAYS_AS_LIST = CallMatcher.staticCall(CommonClassNames.JAVA_UTIL_ARRAYS, "asList"); private static final CallMatcher COLLECTION_ADD = CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_COLLECTION, "add").parameterCount(1); + private static final CallMatcher MAP_PUT = + CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_MAP, "put").parameterCount(2); private static final CallMatcher STREAM_COLLECT = CallMatcher.instanceCall(CommonClassNames.JAVA_UTIL_STREAM_STREAM, "collect").parameterCount(1); private static final CallMatcher STREAM_OF = @@ -63,6 +67,7 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { private static final CallMapper MAPPER = new CallMapper() .register(UNMODIFIABLE_SET, call -> PrepopulatedCollectionModel.fromSet(call.getArgumentList().getExpressions()[0])) + .register(UNMODIFIABLE_MAP, call -> PrepopulatedCollectionModel.fromMap(call.getArgumentList().getExpressions()[0])) .register(UNMODIFIABLE_LIST, call -> PrepopulatedCollectionModel.fromList(call.getArgumentList().getExpressions()[0])); public boolean IGNORE_NON_CONSTANT = false; @@ -122,7 +127,8 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { } public boolean isValid() { - return !myHasNulls && !myRepeatingKeys; + boolean mapOfTooManyParameters = myType.equals("Map") && myContent.size() > 20; + return !myHasNulls && !myRepeatingKeys && !mapOfTooManyParameters; } private StreamEx keyExpressions() { @@ -143,54 +149,56 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { if (ARRAYS_AS_LIST.test(call)) { return new PrepopulatedCollectionModel(Arrays.asList(call.getArgumentList().getExpressions()), Collections.emptyList(), "List"); } - if(STREAM_COLLECT.test(call) && COLLECTORS_TO_LIST.matches(call.getArgumentList().getExpressions()[0])) { - PsiMethodCallExpression qualifier = MethodCallUtils.getQualifierMethodCall(call); - if(STREAM_OF.matches(qualifier)) { - return new PrepopulatedCollectionModel(Arrays.asList(qualifier.getArgumentList().getExpressions()), Collections.emptyList(), - "List"); - } - } + return fromCollect(call, "List", COLLECTORS_TO_LIST); } if(listDefinition instanceof PsiNewExpression) { return fromNewExpression((PsiNewExpression)listDefinition, "List", CommonClassNames.JAVA_UTIL_ARRAY_LIST); } if (listDefinition instanceof PsiReferenceExpression) { - PsiLocalVariable variable = tryCast(((PsiReferenceExpression)listDefinition).resolve(), PsiLocalVariable.class); - if (variable != null) { - return fromVariable(variable, listDefinition, "List", CommonClassNames.JAVA_UTIL_ARRAY_LIST); - } + return fromVariable((PsiReferenceExpression)listDefinition, "List", CommonClassNames.JAVA_UTIL_ARRAY_LIST, COLLECTION_ADD); } return null; } public static PrepopulatedCollectionModel fromSet(PsiExpression setDefinition) { setDefinition = PsiUtil.skipParenthesizedExprDown(setDefinition); - if(setDefinition instanceof PsiNewExpression) { + if (setDefinition instanceof PsiMethodCallExpression) { + return fromCollect((PsiMethodCallExpression)setDefinition, "Set", COLLECTORS_TO_SET); + } + if (setDefinition instanceof PsiNewExpression) { return fromNewExpression((PsiNewExpression)setDefinition, "Set", CommonClassNames.JAVA_UTIL_HASH_SET); } - if(setDefinition instanceof PsiMethodCallExpression) { - PsiMethodCallExpression call = (PsiMethodCallExpression)setDefinition; - if(STREAM_COLLECT.test(call) && COLLECTORS_TO_SET.matches(call.getArgumentList().getExpressions()[0])) { - PsiMethodCallExpression qualifier = MethodCallUtils.getQualifierMethodCall(call); - if(STREAM_OF.matches(qualifier)) { - return new PrepopulatedCollectionModel(Arrays.asList(qualifier.getArgumentList().getExpressions()), Collections.emptyList(), - "Set"); - } - } - } if (setDefinition instanceof PsiReferenceExpression) { - PsiLocalVariable variable = tryCast(((PsiReferenceExpression)setDefinition).resolve(), PsiLocalVariable.class); - if (variable != null) { - return fromVariable(variable, setDefinition, "Set", CommonClassNames.JAVA_UTIL_HASH_SET); + return fromVariable((PsiReferenceExpression)setDefinition, "Set", CommonClassNames.JAVA_UTIL_HASH_SET, COLLECTION_ADD); + } + return null; + } + + public static PrepopulatedCollectionModel fromMap(PsiExpression mapDefinition) { + mapDefinition = PsiUtil.skipParenthesizedExprDown(mapDefinition); + if (mapDefinition instanceof PsiReferenceExpression) { + return fromVariable((PsiReferenceExpression)mapDefinition, "Map", CommonClassNames.JAVA_UTIL_HASH_MAP, MAP_PUT); + } + return null; + } + + @Nullable + private static PrepopulatedCollectionModel fromCollect(PsiMethodCallExpression call, String typeName, CallMatcher collector) { + if (STREAM_COLLECT.test(call) && collector.matches(call.getArgumentList().getExpressions()[0])) { + PsiMethodCallExpression qualifier = MethodCallUtils.getQualifierMethodCall(call); + if (STREAM_OF.matches(qualifier)) { + return new PrepopulatedCollectionModel(Arrays.asList(qualifier.getArgumentList().getExpressions()), Collections.emptyList(), + typeName); } } return null; } @Nullable - private static PrepopulatedCollectionModel fromVariable(PsiLocalVariable variable, - PsiExpression expression, - String typeName, String collectionClass) { + private static PrepopulatedCollectionModel fromVariable(PsiReferenceExpression expression, + String typeName, String collectionClass, CallMatcher addMethod) { + PsiLocalVariable variable = tryCast(expression.resolve(), PsiLocalVariable.class); + if (variable == null) return null; PsiCodeBlock block = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class); PsiDeclarationStatement declaration = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class); if (block == null || declaration == null) return null; @@ -211,9 +219,9 @@ public class Java9CollectionFactoryInspection extends BaseLocalInspectionTool { if (PsiTreeUtil.isAncestor(cur, expression, false)) break; if (!(cur instanceof PsiExpressionStatement)) return null; PsiMethodCallExpression call = tryCast(((PsiExpressionStatement)cur).getExpression(), PsiMethodCallExpression.class); - if (!COLLECTION_ADD.test(call)) return null; + if (!addMethod.test(call)) return null; if (!refs.remove(call.getMethodExpression().getQualifierExpression())) return null; - contents.add(call.getArgumentList().getExpressions()[0]); + contents.addAll(Arrays.asList(call.getArgumentList().getExpressions())); elementsToRemove.add(cur); } if (!refs.isEmpty()) return null; diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMap10.java b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMap10.java new file mode 100644 index 000000000000..8a084000a148 --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMap10.java @@ -0,0 +1,9 @@ +// "Replace with 'Map.of' call" "true" +import java.util.*; + +public class Test { + public void test() { + Map myMap; + myMap = Map.of("a", "1", "b", "1", "c", "1", "d", "1", "e", "1", "f", "1", "g", "1", "h", "1", "i", "1", "j", "1"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMapSimple.java b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMapSimple.java new file mode 100644 index 000000000000..a5dcd1da34d4 --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/afterHashMapSimple.java @@ -0,0 +1,9 @@ +// "Replace with 'Map.of' call" "true" +import java.util.*; + +public class Test { + public void test() { + Map myMap; + myMap = Map.of("a", "b", "c", "b"); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap10.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap10.java new file mode 100644 index 000000000000..42de56cd715f --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap10.java @@ -0,0 +1,19 @@ +// "Replace with 'Map.of' call" "true" +import java.util.*; + +public class Test { + public void test() { + Map myMap = new HashMap<>(); + myMap.put("a", "1"); + myMap.put("b", "1"); + myMap.put("c", "1"); + myMap.put("d", "1"); + myMap.put("e", "1"); + myMap.put("f", "1"); + myMap.put("g", "1"); + myMap.put("h", "1"); + myMap.put("i", "1"); + myMap.put("j", "1"); + myMap = Collections.unmodifiableMap(myMap); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap11.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap11.java new file mode 100644 index 000000000000..2fb562b37e1d --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMap11.java @@ -0,0 +1,20 @@ +// "Replace with 'Map.of' call" "false" +import java.util.*; + +public class Test { + public void test() { + Map myMap = new HashMap<>(); + myMap.put("a", "1"); + myMap.put("b", "1"); + myMap.put("c", "1"); + myMap.put("d", "1"); + myMap.put("e", "1"); + myMap.put("f", "1"); + myMap.put("g", "1"); + myMap.put("h", "1"); + myMap.put("i", "1"); + myMap.put("j", "1"); + myMap.put("k", "1"); + myMap = Collections.unmodifiableMap(myMap); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapRepeatingKey.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapRepeatingKey.java new file mode 100644 index 000000000000..be80f59cf89e --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapRepeatingKey.java @@ -0,0 +1,11 @@ +// "Replace with 'Map.of' call" "false" +import java.util.*; + +public class Test { + public void test() { + Map myMap = new HashMap<>(); + myMap.put("a", "b"); + myMap.put("a", "c"); + myMap = Collections.unmodifiableMap(myMap); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapSimple.java b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapSimple.java new file mode 100644 index 000000000000..0abc6109d594 --- /dev/null +++ b/java/java-tests/testData/inspection/java9CollectionFactory/beforeHashMapSimple.java @@ -0,0 +1,11 @@ +// "Replace with 'Map.of' call" "true" +import java.util.*; + +public class Test { + public void test() { + Map myMap = new HashMap<>(); + myMap.put("a", "b"); + myMap.put("c", "b"); + myMap = Collections.unmodifiableMap(myMap); + } +} \ No newline at end of file From 706239f214668dfeecb92dfa32d5e98ecffb8153 Mon Sep 17 00:00:00 2001 From: Valentin Fondaratov Date: Mon, 27 Feb 2017 13:46:32 +0300 Subject: [PATCH 07/20] RUBY-19104: respect tags when processing scalar values --- .../org/jetbrains/yaml/YAMLElementTypes.java | 8 ++ .../yaml/psi/impl/YAMLBlockScalarImpl.java | 17 ++-- .../yaml/psi/impl/YAMLPlainTextImpl.java | 11 ++- .../yaml/psi/impl/YAMLQuotedTextImpl.java | 41 +++++---- .../yaml/psi/impl/YAMLScalarImpl.java | 31 +++++-- .../yaml/psi/YAMLScalarContentTest.java | 22 ++++- .../psi/YAMLScalarLiteralEscaperTest.java | 28 ++++-- .../psi/data/doubleQuoteTag.positions.txt | 14 +++ .../yaml/psi/data/doubleQuoteTag.txt | 3 + .../yaml/psi/data/doubleQuoteTag.yml | 1 + .../psi/data/foldedStyle4Tag.positions.txt | 86 +++++++++++++++++++ .../yaml/psi/data/foldedStyle4Tag.txt | 9 ++ .../yaml/psi/data/foldedStyle4Tag.yml | 16 ++++ .../psi/data/plainScalar3Tag.positions.txt | 30 +++++++ .../yaml/psi/data/plainScalar3Tag.txt | 3 + .../yaml/psi/data/plainScalar3Tag.yml | 7 ++ .../psi/data/singleQuote1Tag.positions.txt | 19 ++++ .../yaml/psi/data/singleQuote1Tag.txt | 1 + .../yaml/psi/data/singleQuote1Tag.yml | 1 + 19 files changed, 302 insertions(+), 46 deletions(-) create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.positions.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.yml create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.positions.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.yml create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.positions.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.yml create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.positions.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.yml diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java index 143cb3c0d36f..d5fdf2de8530 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java +++ b/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java @@ -1,5 +1,6 @@ package org.jetbrains.yaml; +import com.intellij.psi.TokenType; import com.intellij.psi.tree.IFileElementType; import com.intellij.psi.tree.TokenSet; @@ -32,4 +33,11 @@ public interface YAMLElementTypes { YAMLTokenTypes.TEXT, SCALAR_LIST_VALUE ); + + TokenSet BLANK_ELEMENTS = TokenSet.create( + YAMLTokenTypes.WHITESPACE, + TokenType.WHITE_SPACE, + YAMLTokenTypes.EOL, + YAMLTokenTypes.INDENT, + YAMLTokenTypes.COMMENT); } diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java index 0e3d189b9f3e..e9425dca3fd0 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java +++ b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java @@ -3,6 +3,7 @@ package org.jetbrains.yaml.psi.impl; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; +import com.intellij.psi.impl.source.tree.TreeUtil; import com.intellij.psi.tree.IElementType; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -16,7 +17,7 @@ import java.util.List; public abstract class YAMLBlockScalarImpl extends YAMLScalarImpl { protected static final int DEFAULT_CONTENT_INDENT = 2; - + public YAMLBlockScalarImpl(@NotNull ASTNode node) { super(node); } @@ -32,13 +33,17 @@ public abstract class YAMLBlockScalarImpl extends YAMLScalarImpl { @NotNull @Override public List getContentRanges() { - final int myStart = getTextOffset(); - final ASTNode node = getNode(); + final ASTNode firstContentChild = getFirstContentNode(); + if (firstContentChild == null) { + return Collections.emptyList(); + } + + final int myStart = getTextRange().getStartOffset(); final List result = new ArrayList<>(); final int indent = locateIndent(); - final ASTNode firstEol = node.findChildByType(YAMLTokenTypes.EOL); + final ASTNode firstEol = TreeUtil.findSibling(firstContentChild, YAMLTokenTypes.EOL); if (firstEol == null) { return Collections.emptyList(); } @@ -47,7 +52,7 @@ public abstract class YAMLBlockScalarImpl extends YAMLScalarImpl { for (ASTNode child = firstEol.getTreeNext(); child != null; child = child.getTreeNext()) { final IElementType childType = child.getElementType(); final TextRange childRange = child.getTextRange(); - + if (childType == YAMLTokenTypes.INDENT && isEol(child.getTreePrev())) { thisLineStart = child.getStartOffset() + Math.min(indent, child.getTextLength()); } @@ -89,7 +94,7 @@ public abstract class YAMLBlockScalarImpl extends YAMLScalarImpl { } return 0; } - + private static boolean isEol(@Nullable ASTNode node) { return node != null && node.getElementType() == YAMLTokenTypes.EOL; } diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java index baa70994ead9..748cb2083272 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java +++ b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java @@ -21,12 +21,11 @@ public class YAMLPlainTextImpl extends YAMLScalarImpl implements YAMLScalar { @NotNull @Override public List getContentRanges() { - final int myStart = getTextOffset(); - final ASTNode node = getNode(); + final int myStart = getTextRange().getStartOffset(); final List result = new ArrayList<>(); boolean seenText = false; - for (ASTNode child = node.getFirstChildNode(); child != null; child = child.getTreeNext()) { + for (ASTNode child = getFirstContentNode(); child != null; child = child.getTreeNext()) { if (child.getElementType() == YAMLTokenTypes.TEXT) { seenText = true; result.add(child.getTextRange().shiftRight(-myStart)); @@ -52,7 +51,7 @@ public class YAMLPlainTextImpl extends YAMLScalarImpl implements YAMLScalar { return " "; } } - + private static boolean isNewline(@NotNull CharSequence text, @NotNull TextRange range) { return range.getLength() == 1 && text.charAt(range.getStartOffset()) == '\n'; } @@ -79,10 +78,10 @@ public class YAMLPlainTextImpl extends YAMLScalarImpl implements YAMLScalar { currentLength = 0; continue; } - + currentLength++; } - + return result; } diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java index 21a61b22e7fb..b56f47e59b4e 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java +++ b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java @@ -14,6 +14,7 @@ import org.jetbrains.yaml.lexer.YAMLGrammarCharUtil; import org.jetbrains.yaml.psi.YAMLQuotedText; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -22,17 +23,25 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText public YAMLQuotedTextImpl(@NotNull ASTNode node) { super(node); - myIsSingleQuoted = getNode().getFirstChildNode().getElementType() == YAMLTokenTypes.SCALAR_STRING; + final ASTNode firstContentNode = getFirstContentNode(); + myIsSingleQuoted = firstContentNode != null && firstContentNode.getElementType() == YAMLTokenTypes.SCALAR_STRING; } @NotNull @Override public List getContentRanges() { - List result = new ArrayList<>(); + final ASTNode firstContentNode = getFirstContentNode(); + if (firstContentNode == null) { + return Collections.emptyList(); + } - final List lines = StringUtil.split(getText(), "\n", true, false); + List result = new ArrayList<>(); + TextRange contentRange = TextRange.create(firstContentNode.getStartOffset(), getTextRange().getEndOffset()) + .shiftRight(-getTextRange().getStartOffset()); + + final List lines = StringUtil.split(contentRange.substring(getText()), "\n", true, false); // First line has opening quote - int cumulativeOffset = 0; + int cumulativeOffset = contentRange.getStartOffset(); for (int i = 0; i < lines.size(); ++i) { final String line = lines.get(i); @@ -82,9 +91,9 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText @Override protected List> getDecodeReplacements(@NotNull CharSequence input) { List> result = new ArrayList<>(); - + for (int i = 0; i + 1 < input.length(); ++i) { - + if (isSingleQuote() && input.charAt(i) == '\'' && input.charAt(i + 1) == '\'') { result.add(Pair.create(TextRange.from(i, 2), "'")); i++; @@ -115,10 +124,10 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText } } } - + final int indent = YAMLUtil.getIndentToThisElement(this); final String indentString = StringUtil.repeatSymbol(' ', indent); - + final List> result = new ArrayList<>(); int currentLength = 0; for (int i = 0; i < input.length(); ++i) { @@ -138,7 +147,7 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText } - if (currentLength > MAX_SCALAR_LENGTH_PREDEFINED + if (currentLength > MAX_SCALAR_LENGTH_PREDEFINED && (!isSingleQuote() || (c == ' ' && isSurroundedByNoSpace(input, i)))) { final String replacement; if (isSingleQuote()) { @@ -155,12 +164,12 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText } currentLength++; - + if (isSingleQuote() && c == '\'') { result.add(Pair.create(TextRange.from(i, 1), "''")); continue; } - + if (!isSingleQuote()) { if (c == '"') { result.add(Pair.create(TextRange.from(i, 1), "\\\"")); @@ -186,7 +195,7 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText public String toString() { return "YAML quoted text"; } - + private static class Escaper { private static final int[][] ONE_LETTER_CONVERSIONS = new int[][] { {'0', 0}, @@ -208,7 +217,7 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText {'L', 8232}, {'P', 8233}, }; - + private static final NotNullLazyValue> ESC_TO_CODE = new NotNullLazyValue>() { @NotNull @Override @@ -232,12 +241,12 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText return map; } }; - + static int findEscapementLength(@NotNull CharSequence text, int pos) { if (pos + 1 >= text.length() || text.charAt(pos) != '\\') { throw new IllegalArgumentException("This is not an escapement start"); } - + final char c = text.charAt(pos + 1); if (c == 'x') { return 3; @@ -252,7 +261,7 @@ public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText return 1; } } - + static int toUnicodeChar(@NotNull CharSequence text, int pos, int length) { if (length > 1) { CharSequence s = text.subSequence(pos + 2, Math.min(text.length(), pos + length + 1)); diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java index 54134b8ad200..940027b6af1b 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java +++ b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java @@ -10,6 +10,9 @@ import com.intellij.psi.PsiReference; import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.yaml.YAMLElementTypes; +import org.jetbrains.yaml.YAMLTokenTypes; import org.jetbrains.yaml.lexer.YAMLGrammarCharUtil; import org.jetbrains.yaml.psi.YAMLScalar; @@ -18,7 +21,7 @@ import java.util.List; public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar { protected static final int MAX_SCALAR_LENGTH_PREDEFINED = 60; - + public YAMLScalarImpl(@NotNull ASTNode node) { super(node); } @@ -28,11 +31,11 @@ public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar @NotNull protected abstract String getRangesJoiner(@NotNull CharSequence text, @NotNull List contentRanges, int indexBefore); - + protected List> getDecodeReplacements(@NotNull CharSequence input) { return Collections.emptyList(); } - + protected List> getEncodeReplacements(@NotNull CharSequence input) throws IllegalArgumentException { throw new IllegalArgumentException("Not implemented"); } @@ -47,7 +50,7 @@ public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar for (int i = 0; i < contentRanges.size(); i++) { final TextRange range = contentRanges.get(i); - + final CharSequence curString = range.subSequence(text); builder.append(curString); @@ -85,10 +88,10 @@ public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar public LiteralTextEscaper createLiteralTextEscaper() { return new MyLiteralTextEscaper(this); } - - @NotNull - static String processReplacements(@NotNull CharSequence input, - @NotNull List> replacements) throws IndexOutOfBoundsException { + + @NotNull + static String processReplacements(@NotNull CharSequence input, + @NotNull List> replacements) throws IndexOutOfBoundsException { StringBuilder result = new StringBuilder(); int currentOffset = 0; for (Pair replacement : replacements) { @@ -105,6 +108,16 @@ public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar && (pos + 1 >= text.length() || !YAMLGrammarCharUtil.isSpaceLike(text.charAt(pos + 1))); } + @Nullable + protected final ASTNode getFirstContentNode() { + ASTNode node = getNode().getFirstChildNode(); + while (node != null && ( + node.getElementType() == YAMLTokenTypes.TAG || YAMLElementTypes.BLANK_ELEMENTS.contains(node.getElementType()))) { + node = node.getTreeNext(); + } + return node; + } + private static class MyLiteralTextEscaper extends LiteralTextEscaper { public MyLiteralTextEscaper(YAMLScalarImpl scalar) { super(scalar); @@ -120,7 +133,7 @@ public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar public int getOffsetInHost(int offsetInDecoded, @NotNull TextRange rangeInsideHost) { final String text = myHost.getText(); final List contentRanges = myHost.getContentRanges(); - + int currentOffsetInDecoded = 0; for (int i = 0; i < contentRanges.size(); i++) { diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java index d5d529003d70..373e8c0a4017 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java @@ -30,6 +30,10 @@ public class YAMLScalarContentTest extends LightPlatformCodeInsightFixtureTestCa doTest(); } + public void testPlainScalar3Tag() { + doTest(); + } + public void testLiteralStyle1() { doTest(); } @@ -57,7 +61,11 @@ public class YAMLScalarContentTest extends LightPlatformCodeInsightFixtureTestCa public void testFoldedStyle4() { doTest(); } - + + public void testFoldedStyle4Tag() { + doTest(); + } + public void testFoldedStyle5() { doTest(); } @@ -70,6 +78,10 @@ public class YAMLScalarContentTest extends LightPlatformCodeInsightFixtureTestCa doTest(); } + public void testSingleQuote1Tag() { + doTest(); + } + public void testSingleQuote2() { doTest(); } @@ -77,15 +89,19 @@ public class YAMLScalarContentTest extends LightPlatformCodeInsightFixtureTestCa public void testDoubleQuote1() { doTest(); } - + public void testDoubleQuote2() { doTest(); } - + public void testDoubleQuote4() { doTest(); } + public void testDoubleQuoteTag() { + doTest(); + } + private void doTest() { myFixture.configureByFile(getTestName(true) + ".yml"); diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarLiteralEscaperTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarLiteralEscaperTest.java index d2e13d90a26f..8402d45413b3 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarLiteralEscaperTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarLiteralEscaperTest.java @@ -50,6 +50,10 @@ public class YAMLScalarLiteralEscaperTest extends LightPlatformCodeInsightFixtur doTest(); } + public void testPlainScalar3Tag() { + doTest(); + } + public void testLiteralStyle1() { doTest(); } @@ -78,10 +82,18 @@ public class YAMLScalarLiteralEscaperTest extends LightPlatformCodeInsightFixtur doTest(); } + public void testFoldedStyle4Tag() { + doTest(); + } + public void testSingleQuote1() { doTest(); } + public void testSingleQuote1Tag() { + doTest(); + } + public void testSingleQuote2() { doTest(); } @@ -89,15 +101,19 @@ public class YAMLScalarLiteralEscaperTest extends LightPlatformCodeInsightFixtur public void testDoubleQuote1() { doTest(); } - + public void testDoubleQuote2() { doTest(); } - + public void testDoubleQuote3() { doTest(); } + public void testDoubleQuoteTag() { + doTest(); + } + private void doTest() { myFixture.configureByFile(getTestName(true) + ".yml"); @@ -112,12 +128,12 @@ public class YAMLScalarLiteralEscaperTest extends LightPlatformCodeInsightFixtur final StringBuilder builder = new StringBuilder(); assertTrue(elementLiteralEscaper.decode(scalarElement.getTextRange(), builder)); assertEquals(scalarElement.getTextValue(), builder.toString()); - + int[] offsets = new int[builder.length() + 1]; for (int i = 0; i < builder.length() + 1; ++i) { offsets[i] = elementLiteralEscaper.getOffsetInHost(i, TextRange.from(0, scalarElement.getTextLength())); } - + final String elementText = scalarElement.getText(); StringBuilder description = new StringBuilder(); for (int i = 0; i < builder.length(); ++i) { @@ -126,8 +142,8 @@ public class YAMLScalarLiteralEscaperTest extends LightPlatformCodeInsightFixtur .append(elementText.subSequence(offsets[i], offsets[i + 1])) .append('\n'); } - assertSameLinesWithFile(getTestDataPath() + getTestName(true) + ".positions.txt", - Arrays.toString(offsets) + "\n" + description, + assertSameLinesWithFile(getTestDataPath() + getTestName(true) + ".positions.txt", + Arrays.toString(offsets) + "\n" + description, false); } } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.positions.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.positions.txt new file mode 100644 index 000000000000..7e482f3b6341 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.positions.txt @@ -0,0 +1,14 @@ +[6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] + +->\n + +->\n +'->' +'->' +c->c +o->o +n->n +t->t +e->e +n->n +t->t diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.txt new file mode 100644 index 000000000000..2328b801fc07 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.txt @@ -0,0 +1,3 @@ + + +''content \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.yml new file mode 100644 index 000000000000..7fbe6bd27f2b --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuoteTag.yml @@ -0,0 +1 @@ +!Tag "\n\n''content" \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.positions.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.positions.txt new file mode 100644 index 000000000000..91cf1f06bd87 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.positions.txt @@ -0,0 +1,86 @@ +[7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 22, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 80] + +-> + +f->f +o->o +l->l +d->d +e->e +d->d + -> + +l->l +i->i +n->n +e->e + + +-> + +n->n +e->e +x->x +t->t + -> + +l->l +i->i +n->n +e->e + +-> + + -> + -> +*->* + -> +b->b +u->u +l->l +l->l +e->e +t->t + +-> + + +-> + + -> + -> +*->* + -> +l->l +i->i +s->s +t->t + +-> + + -> + -> +*->* + -> +l->l +i->i +n->n +e->e + +-> + + +-> + +l->l +a->a +s->s +t->t + -> + +l->l +i->i +n->n +e->e + +-> diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.txt new file mode 100644 index 000000000000..dd52fe1a9aeb --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.txt @@ -0,0 +1,9 @@ + +folded line +next line + * bullet + + * list + * line + +last line diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.yml new file mode 100644 index 000000000000..eded121da682 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4Tag.yml @@ -0,0 +1,16 @@ +!Tag > + + folded + line + + next + line + * bullet + + * list + * line + + last + line + +# Comment \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.positions.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.positions.txt new file mode 100644 index 000000000000..eae97a24cb18 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.positions.txt @@ -0,0 +1,30 @@ +[5, 6, 7, 8, 13, 14, 15, 16, 19, 20, 21, 23, 26, 27, 28, 30, 33, 34, 35, 36, 37, 38] +f->f +o->o +o->o + -> + +b->b +a->a +r->r + -> + +f->f +a->a +r->r + + +-> + +b->b +a->a +z->z + + +-> + +b->b +a->a +a->a +a->a +z->z diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.txt new file mode 100644 index 000000000000..bfd5a52af53c --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.txt @@ -0,0 +1,3 @@ +foo bar far +baz +baaaz \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.yml new file mode 100644 index 000000000000..ee3228e6c4ed --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3Tag.yml @@ -0,0 +1,7 @@ +- !Tag foo + bar + far + + baz + + baaaz \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.positions.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.positions.txt new file mode 100644 index 000000000000..dbd5b52f6307 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.positions.txt @@ -0,0 +1,19 @@ +[6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] +h->h +e->e +r->r +e->e +'->'' +s->s + -> +t->t +o->o + -> +"->" +q->q +u->u +o->o +t->t +e->e +s->s +"->" diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.txt new file mode 100644 index 000000000000..a2ea44eb512d --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.txt @@ -0,0 +1 @@ +here's to "quotes" \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.yml new file mode 100644 index 000000000000..5c5c2163eb8f --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1Tag.yml @@ -0,0 +1 @@ +!Tag 'here''s to "quotes"' \ No newline at end of file From 31d5224b22c043af540f95783d0af86314200d35 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Mon, 27 Feb 2017 14:06:58 +0300 Subject: [PATCH 08/20] PY-22822 Wrong behaviour of Emacs Tab and FormattingModelInconsistencyException --- .../python/editor/PyEmacsHandler.java | 8 +- .../com/jetbrains/python/PyEmacsTabTest.java | 74 +++++++++---------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/python/src/com/jetbrains/python/editor/PyEmacsHandler.java b/python/src/com/jetbrains/python/editor/PyEmacsHandler.java index 2019b23aa6a5..51b0e6ba4c9e 100644 --- a/python/src/com/jetbrains/python/editor/PyEmacsHandler.java +++ b/python/src/com/jetbrains/python/editor/PyEmacsHandler.java @@ -101,7 +101,13 @@ public class PyEmacsHandler implements EmacsProcessingHandler { } ChangeIndentContext context = new ChangeIndentContext(project, file, editor, document, caretLine); - + int targetLineIndent = getLineIndent(context, context.targetLine); + int soleLineIndent = getSoleIndent(context); + int lineStart = context.document.getLineStartOffset(context.targetLine); + if (caretOffset - lineStart < targetLineIndent) { + changeIndent(context, soleLineIndent); + return Result.STOP; + } switch (tryToIndentToRight(context)) { case STOP_SUCCESSFUL: return Result.STOP; case STOP_UNSUCCESSFUL: return Result.CONTINUE; diff --git a/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java b/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java index 9ef92443de2c..32689b757007 100644 --- a/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java +++ b/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java @@ -35,44 +35,44 @@ public class PyEmacsTabTest extends PyTestCase { " if name != \"\":\n" + " print name" ); - - doTest( - "def test(name):\n" + - " if name != \"\":\n" + - " print name", - "def test(name):\n" + - " if name != \"\":\n" + - " print name" - ); - - doTest( - "def test(name):\n" + - " if name != \"\":\n" + - " print name", - "def test(name):\n" + - " if name != \"\":\n" + - " print name" - ); - - doTest( - "def test(name):\n" + - " if name != \"\":\n" + - " print name", - "def test(name):\n" + - " if name != \"\":\n" + - " print name" - ); - - doTest( - "def test(name):\n" + - " if name != \"\":\n" + - " print name", - "def test(name):\n" + - " if name != \"\":\n" + - " print name" - ); + // + //doTest( + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name", + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name" + //); + // + //doTest( + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name", + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name" + //); + // + //doTest( + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name", + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name" + //); + // + //doTest( + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name", + // "def test(name):\n" + + // " if name != \"\":\n" + + // " print name" + //); } - + public void testIndentToRight() { doTest( "def test(name):\n" + From d37c134432a3a359b9f9085a16d1f5020a479e95 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Mon, 27 Feb 2017 14:09:38 +0300 Subject: [PATCH 09/20] reverted tests back --- .../com/jetbrains/python/PyEmacsTabTest.java | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java b/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java index 32689b757007..e7c6e0a2bd7c 100644 --- a/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java +++ b/python/testSrc/com/jetbrains/python/PyEmacsTabTest.java @@ -35,42 +35,42 @@ public class PyEmacsTabTest extends PyTestCase { " if name != \"\":\n" + " print name" ); - // - //doTest( - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name", - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name" - //); - // - //doTest( - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name", - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name" - //); - // - //doTest( - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name", - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name" - //); - // - //doTest( - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name", - // "def test(name):\n" + - // " if name != \"\":\n" + - // " print name" - //); + + doTest( + "def test(name):\n" + + " if name != \"\":\n" + + " print name", + "def test(name):\n" + + " if name != \"\":\n" + + " print name" + ); + + doTest( + "def test(name):\n" + + " if name != \"\":\n" + + " print name", + "def test(name):\n" + + " if name != \"\":\n" + + " print name" + ); + + doTest( + "def test(name):\n" + + " if name != \"\":\n" + + " print name", + "def test(name):\n" + + " if name != \"\":\n" + + " print name" + ); + + doTest( + "def test(name):\n" + + " if name != \"\":\n" + + " print name", + "def test(name):\n" + + " if name != \"\":\n" + + " print name" + ); } public void testIndentToRight() { From 36f87d0438fd523ffcda0aa0d1326d87fc311810 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 27 Feb 2017 12:14:33 +0100 Subject: [PATCH 10/20] RIDER-4427 Select Solution Path window assistive text is too small on High DPI displays --- .../openapi/fileChooser/ex/FileChooserDialogImpl.java | 10 +++++----- .../cvsSupport2/ui/experts/SelectLocationStep.java | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java index 4b0bafd39fac..33b2c778fdb9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java @@ -81,8 +81,7 @@ import java.util.Map; public class FileChooserDialogImpl extends DialogWrapper implements FileChooserDialog, PathChooserDialog, FileLookup { @NonNls public static final String FILE_CHOOSER_SHOW_PATH_PROPERTY = "FileChooser.ShowPath"; public static final String RECENT_FILES_KEY = "file.chooser.recent.files"; - public static final String DRAG_N_DROP_HINT = - "
Drag and drop a file into the space above to quickly locate it in the tree
"; + public static final String DRAG_N_DROP_HINT = "Drag and drop a file into the space above to quickly locate it in the tree"; private final FileChooserDescriptor myChooserDescriptor; protected FileSystemTreeImpl myFileSystemTree; private Project myProject; @@ -342,9 +341,10 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(JBUI.size(400)); - - panel.add(new JLabel(DRAG_N_DROP_HINT, SwingConstants.CENTER), BorderLayout.SOUTH); - + JLabel dndLabel = new JLabel(DRAG_N_DROP_HINT, SwingConstants.CENTER); + dndLabel.setFont(JBUI.Fonts.miniFont()); + dndLabel.setForeground(UIUtil.getLabelDisabledForeground()); + panel.add(dndLabel, BorderLayout.SOUTH); ApplicationManager.getApplication().getMessageBus().connect(getDisposable()) .subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/SelectLocationStep.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/SelectLocationStep.java index 4b3ff29e318c..0b1c50a4ef50 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/SelectLocationStep.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/SelectLocationStep.java @@ -40,6 +40,8 @@ import com.intellij.ui.PopupHandler; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.labels.LinkLabel; import com.intellij.ui.components.labels.LinkListener; +import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.UiNotifyConnector; import com.intellij.util.ui.update.Update; @@ -143,7 +145,10 @@ public abstract class SelectLocationStep extends WizardStep { myNorthPanel.add(toolbarPanel, BorderLayout.NORTH); panel.add(myNorthPanel, BorderLayout.NORTH); panel.add(ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()), BorderLayout.CENTER); - panel.add(new JLabel(FileChooserDialogImpl.DRAG_N_DROP_HINT, SwingConstants.CENTER), BorderLayout.SOUTH); + JLabel dndLabel = new JLabel(FileChooserDialogImpl.DRAG_N_DROP_HINT, SwingConstants.CENTER); + dndLabel.setFont(JBUI.Fonts.miniFont()); + dndLabel.setForeground(UIUtil.getLabelDisabledForeground()); + panel.add(dndLabel, BorderLayout.SOUTH); myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel); Disposer.register(myFileSystemTree, myUiUpdater); new UiNotifyConnector(panel, myUiUpdater); From 85696d7125e0539a31a0e9ede8857677be64f1c4 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 27 Feb 2017 11:48:25 +0100 Subject: [PATCH 11/20] document document commit threading requirements --- .../src/com/intellij/psi/PsiDocumentManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/core-api/src/com/intellij/psi/PsiDocumentManager.java b/platform/core-api/src/com/intellij/psi/PsiDocumentManager.java index 5f56ae7e38d1..d6dc310a93ee 100644 --- a/platform/core-api/src/com/intellij/psi/PsiDocumentManager.java +++ b/platform/core-api/src/com/intellij/psi/PsiDocumentManager.java @@ -88,7 +88,9 @@ public abstract class PsiDocumentManager { /** * Commits (updates the PSI tree for) all modified but not committed documents. * Before a modified document is committed, accessing its PSI may return elements - * corresponding to original (unmodified) state of the document. + * corresponding to original (unmodified) state of the document.

+ * + * Should be called in UI thread in a write-safe context (see {@link com.intellij.openapi.application.TransactionGuard}) */ public abstract void commitAllDocuments(); @@ -100,7 +102,11 @@ public abstract class PsiDocumentManager { /** * Updates the PSI tree for the specified document. * Before a modified document is committed, accessing its PSI may return elements - * corresponding to original (unmodified) state of the document. + * corresponding to original (unmodified) state of the document.

+ * + * For documents corresponding to PSI with events enabled (see {@link FileViewProvider#isEventSystemEnabled()}, this should be called + * in UI thread in a write-safe context (see {@link com.intellij.openapi.application.TransactionGuard}). For non-physical files, this can be + * called in any thread. In the latter case, clients hold themselves all responsibility for synchronizing that PSI. * * @param document the document to commit. */ From fb5be8bdac23ce7f4cb43be4a887a1691e0dcd69 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 27 Feb 2017 12:18:30 +0100 Subject: [PATCH 12/20] correct PsiEnumConstant#isDeprecated (IDEA-168740) --- .../intellij/psi/impl/source/PsiEnumConstantImpl.java | 9 +-------- .../com/intellij/psi/impl/source/PsiFieldImpl.java | 9 ++++++--- .../testSrc/com/intellij/psi/JavaStubsTest.groovy | 11 +++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiEnumConstantImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiEnumConstantImpl.java index 47b3d271e948..7dd1ba92b01e 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiEnumConstantImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiEnumConstantImpl.java @@ -194,14 +194,7 @@ public class PsiEnumConstantImpl extends JavaStubPsiElement implem @Override public boolean isDeprecated() { - final PsiFieldStub stub = getGreenStub(); - if (stub != null) { - return stub.isDeprecated(); - } - - PsiDocComment docComment = getDocComment(); - return docComment != null && docComment.findTagByName("deprecated") != null || - getModifierList().findAnnotation("java.lang.Deprecated") != null; + return PsiFieldImpl.isFieldDeprecated(this, getGreenStub()); } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiFieldImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiFieldImpl.java index 64d346f7aeff..8f9e15f9b36a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiFieldImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiFieldImpl.java @@ -299,12 +299,15 @@ public class PsiFieldImpl extends JavaStubPsiElement implements Ps @Override public boolean isDeprecated() { - final PsiFieldStub stub = getGreenStub(); + return isFieldDeprecated(this, getGreenStub()); + } + + static boolean isFieldDeprecated(@NotNull PsiField field, @Nullable PsiFieldStub stub) { if (stub != null) { - return stub.isDeprecated() || stub.hasDeprecatedAnnotation() && PsiImplUtil.isDeprecatedByAnnotation(this); + return stub.isDeprecated() || stub.hasDeprecatedAnnotation() && PsiImplUtil.isDeprecatedByAnnotation(field); } - return PsiImplUtil.isDeprecatedByDocTag(this) || PsiImplUtil.isDeprecatedByAnnotation(this); + return PsiImplUtil.isDeprecatedByDocTag(field) || PsiImplUtil.isDeprecatedByAnnotation(field); } @Override diff --git a/java/java-tests/testSrc/com/intellij/psi/JavaStubsTest.groovy b/java/java-tests/testSrc/com/intellij/psi/JavaStubsTest.groovy index c802cb8f79e6..f2878e438275 100644 --- a/java/java-tests/testSrc/com/intellij/psi/JavaStubsTest.groovy +++ b/java/java-tests/testSrc/com/intellij/psi/JavaStubsTest.groovy @@ -159,4 +159,15 @@ import java.lang.annotation.*; assert list.parametersCount == list.parameters.size() } + void "test deprecated enum constant"() { + def cls = myFixture.addClass("enum Foo { c1, @Deprecated c2, /** @deprecated */ c3 }") + assert !((PsiFileImpl) cls.containingFile).contentsLoaded + + assert !cls.fields[0].deprecated + assert cls.fields[1].deprecated + assert cls.fields[2].deprecated + + assert !((PsiFileImpl) cls.containingFile).contentsLoaded + } + } \ No newline at end of file From b7f4c1ddb08a76ffc11ded87156df422f5badf39 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 27 Feb 2017 12:20:54 +0100 Subject: [PATCH 13/20] greenify SaveAsTemplateAction (IDEA-CR-18548) --- .../template/actions/SaveAsTemplateAction.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/actions/SaveAsTemplateAction.java b/platform/lang-impl/src/com/intellij/codeInsight/template/actions/SaveAsTemplateAction.java index 76ad01ef247d..6d068e1051eb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/actions/SaveAsTemplateAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/actions/SaveAsTemplateAction.java @@ -26,7 +26,6 @@ package com.intellij.codeInsight.template.actions; import com.intellij.codeInsight.completion.CompletionUtil; import com.intellij.codeInsight.completion.OffsetKey; -import com.intellij.codeInsight.completion.OffsetMap; import com.intellij.codeInsight.completion.OffsetsInFile; import com.intellij.codeInsight.template.TemplateContextType; import com.intellij.codeInsight.template.impl.*; @@ -49,10 +48,7 @@ import com.intellij.psi.util.PsiElementFilter; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.containers.HashMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; public class SaveAsTemplateAction extends AnAction { @@ -61,8 +57,8 @@ public class SaveAsTemplateAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); - final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); - PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); + Editor editor = Objects.requireNonNull(CommonDataKeys.EDITOR.getData(dataContext)); + PsiFile file = Objects.requireNonNull(CommonDataKeys.PSI_FILE.getData(dataContext)); final Project project = file.getProject(); PsiDocumentManager.getInstance(project).commitAllDocuments(); From c27b4e24326c24eafc2c2304d63c4a56e2ad4759 Mon Sep 17 00:00:00 2001 From: Valentin Fondaratov Date: Mon, 27 Feb 2017 14:32:28 +0300 Subject: [PATCH 14/20] RUBY-19105: allow block sequences right under sequence items --- .../org/jetbrains/yaml/lexer/_YAMLLexer.java | 421 +++++++++--------- .../src/org/jetbrains/yaml/lexer/yaml.flex | 4 + .../jetbrains/yaml/lexer/YAMLLexerTest.java | 6 +- .../jetbrains/yaml/lexer/data/ruby19105.txt | 12 + .../jetbrains/yaml/lexer/data/ruby19105.yml | 2 + .../jetbrains/yaml/parser/YAMLParserTest.java | 19 +- .../jetbrains/yaml/parser/data/Ruby19105.txt | 35 ++ 7 files changed, 279 insertions(+), 220 deletions(-) create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.yml create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby19105.txt diff --git a/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java b/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java index 4d5daf6037fb..9b5b8f8e1dd8 100644 --- a/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java +++ b/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java @@ -36,7 +36,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { * l is of the form l = 2*k, k a non negative integer */ private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 + 0, 0, 1, 1, 2, 2, 0, 0, 3, 3, 4, 4 }; /** @@ -75,9 +75,9 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\16\0\1\1\1\2\1\3\1\4\1\5\1\2\1\6"+ + "\15\0\1\1\1\2\1\3\1\4\1\5\1\2\1\6"+ "\1\7\1\10\2\2\1\11\1\12\4\2\1\13\1\2"+ - "\1\1\1\4\2\2\1\11\1\2\1\1\1\4\5\2"+ + "\1\1\1\4\2\2\1\11\1\2\1\1\1\4\4\2"+ "\1\1\1\4\2\2\1\14\1\15\1\16\10\0\1\1"+ "\1\0\1\17\1\0\2\20\2\21\2\22\6\0\1\23"+ "\2\0\1\24\1\0\2\25\4\0\2\26\1\0\1\1"+ @@ -88,7 +88,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { "\3\0\2\1\1\0\4\1\1\0\1\1\2\0\1\1"; private static int [] zzUnpackAction() { - int [] result = new int[170]; + int [] result = new int[168]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -114,30 +114,29 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\34\0\70\0\124\0\160\0\214\0\250\0\304"+ - "\0\340\0\374\0\u0118\0\u0134\0\u0150\0\u016c\0\u0188\0\u01a4"+ - "\0\u01a4\0\u01c0\0\u01dc\0\u01f8\0\u01a4\0\u0214\0\u01a4\0\u0230"+ - "\0\u024c\0\u0268\0\u01a4\0\u0284\0\u02a0\0\u02bc\0\u02d8\0\u01a4"+ + "\0\340\0\374\0\u0118\0\u0134\0\u0150\0\u016c\0\u0188\0\u0188"+ + "\0\u01a4\0\u01c0\0\u01dc\0\u0188\0\u01f8\0\u0188\0\u0214\0\u0230"+ + "\0\u024c\0\u0188\0\u0268\0\u0284\0\u02a0\0\u02bc\0\u0188\0\u02d8"+ "\0\u02f4\0\u0310\0\u032c\0\u0348\0\u0364\0\u0380\0\u039c\0\u03b8"+ - "\0\u03d4\0\u03f0\0\u03d4\0\u040c\0\u0428\0\u01c0\0\u0444\0\u0460"+ - "\0\u047c\0\u0460\0\u0498\0\u01a4\0\u04b4\0\u04d0\0\u01a4\0\u04ec"+ - "\0\u0508\0\u0524\0\u0540\0\u055c\0\u0578\0\u0594\0\u05b0\0\u05cc"+ - "\0\u0188\0\u01a4\0\u05e8\0\u01a4\0\u0604\0\u01a4\0\u0620\0\u063c"+ - "\0\u0658\0\u0674\0\u02a0\0\u040c\0\u0690\0\u06ac\0\u02bc\0\u0428"+ - "\0\u06c8\0\u06e4\0\u01a4\0\u0700\0\u071c\0\u0738\0\u0754\0\u0770"+ - "\0\u01a4\0\u078c\0\u07a8\0\u07c4\0\u07e0\0\u07fc\0\u0310\0\u0818"+ - "\0\u0834\0\u0850\0\u086c\0\u03d4\0\u03b8\0\u0888\0\u01a4\0\u08a4"+ - "\0\u08c0\0\u08dc\0\u0460\0\u0444\0\u01a4\0\u08f8\0\u0914\0\u0930"+ - "\0\u08f8\0\u094c\0\u0968\0\u0984\0\u0524\0\u09a0\0\u09bc\0\u055c"+ - "\0\u01a4\0\u01a4\0\u09d8\0\u09f4\0\u0a10\0\u0a2c\0\u01a4\0\u0a48"+ - "\0\u0a64\0\u0a80\0\u01a4\0\u0a9c\0\u0ab8\0\u0ad4\0\u0af0\0\u0b0c"+ - "\0\u0b28\0\u0b44\0\u0b60\0\u0b7c\0\u0b98\0\u0bb4\0\u0bd0\0\u0bec"+ - "\0\u09f4\0\u0c08\0\u0c24\0\u0c40\0\u0c5c\0\u0c78\0\u0c94\0\u0cb0"+ - "\0\u0ccc\0\u0ce8\0\u0d04\0\u0ab8\0\u0d20\0\u0d3c\0\u0d58\0\u0d74"+ - "\0\u0b60\0\u0d90\0\u0dac\0\u0dc8\0\u0de4\0\u0e00\0\u0e1c\0\u0c78"+ - "\0\u0e38\0\u0e54"; + "\0\u03d4\0\u03b8\0\u03f0\0\u040c\0\u0428\0\u0444\0\u0460\0\u0444"+ + "\0\u047c\0\u0188\0\u0498\0\u04b4\0\u0188\0\u04d0\0\u04ec\0\u0508"+ + "\0\u0524\0\u0540\0\u055c\0\u0578\0\u0594\0\u05b0\0\u016c\0\u0188"+ + "\0\u05cc\0\u0188\0\u05e8\0\u0188\0\u0604\0\u0620\0\u063c\0\u0658"+ + "\0\u0284\0\u03f0\0\u0674\0\u0690\0\u02a0\0\u040c\0\u06ac\0\u06c8"+ + "\0\u0188\0\u06e4\0\u0700\0\u071c\0\u0738\0\u0754\0\u0188\0\u0770"+ + "\0\u078c\0\u07a8\0\u07c4\0\u07e0\0\u02f4\0\u07fc\0\u0818\0\u0834"+ + "\0\u0850\0\u03b8\0\u039c\0\u086c\0\u0188\0\u0888\0\u08a4\0\u08c0"+ + "\0\u0444\0\u0428\0\u0188\0\u08dc\0\u08f8\0\u0914\0\u08dc\0\u0930"+ + "\0\u094c\0\u0968\0\u0508\0\u0984\0\u09a0\0\u0540\0\u0188\0\u0188"+ + "\0\u09bc\0\u09d8\0\u09f4\0\u0a10\0\u0188\0\u0a2c\0\u0a48\0\u0a64"+ + "\0\u0188\0\u0a80\0\u0a9c\0\u0ab8\0\u0ad4\0\u0af0\0\u0b0c\0\u0b28"+ + "\0\u0b44\0\u0b60\0\u0b7c\0\u0b98\0\u0bb4\0\u0bd0\0\u09d8\0\u0bec"+ + "\0\u0c08\0\u0c24\0\u0c40\0\u0c5c\0\u0c78\0\u0c94\0\u0cb0\0\u0ccc"+ + "\0\u0ce8\0\u0a9c\0\u0d04\0\u0d20\0\u0d3c\0\u0d58\0\u0b44\0\u0d74"+ + "\0\u0d90\0\u0dac\0\u0dc8\0\u0de4\0\u0e00\0\u0c5c\0\u0e1c\0\u0e38"; private static int [] zzUnpackRowMap() { - int [] result = new int[170]; + int [] result = new int[168]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -160,183 +159,179 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\17\2\20\1\21\1\22\1\23\1\24\1\25\1\26"+ - "\1\27\1\30\1\26\1\31\1\32\1\33\1\34\1\17"+ - "\1\35\1\36\3\17\1\20\1\37\1\17\1\40\1\17"+ - "\1\41\1\42\2\20\1\21\1\43\1\23\1\44\1\25"+ - "\1\26\1\27\1\45\1\26\1\20\1\46\1\33\1\47"+ - "\1\42\1\35\1\36\3\42\1\20\1\37\1\42\1\40"+ - "\1\42\1\20\1\50\2\20\1\21\1\51\1\23\1\52"+ - "\1\25\1\26\1\27\1\53\1\26\1\31\1\32\1\33"+ - "\1\34\1\50\1\54\1\55\3\50\1\20\1\37\1\50"+ - "\1\40\1\50\1\41\1\17\2\20\1\21\1\22\1\23"+ - "\1\24\1\25\1\26\1\27\1\56\1\26\1\31\1\32"+ - "\1\33\1\34\1\17\1\35\1\36\3\17\1\20\1\37"+ - "\1\17\1\40\1\17\1\41\1\57\2\20\1\21\1\60"+ - "\1\23\1\61\1\25\1\26\1\27\1\62\1\26\1\31"+ - "\1\46\1\33\1\47\1\57\1\54\1\55\3\57\1\20"+ - "\1\37\1\57\1\40\1\57\1\41\7\63\1\64\1\65"+ - "\2\63\1\65\20\63\27\0\1\66\13\0\1\67\1\70"+ - "\2\0\1\70\20\0\1\71\3\0\1\72\1\0\1\72"+ - "\3\0\1\72\5\0\1\71\2\0\3\71\2\0\1\71"+ - "\1\0\1\71\2\0\1\67\1\0\1\67\3\0\3\67"+ - "\1\0\1\67\1\0\2\67\12\0\1\67\2\0\1\73"+ - "\3\0\1\74\1\0\1\74\3\0\1\74\5\0\1\73"+ - "\2\0\3\73\2\0\1\73\1\0\1\73\2\0\1\67"+ - "\5\0\2\67\2\0\1\67\34\0\1\75\52\0\1\75"+ - "\1\76\1\0\3\76\1\77\1\100\1\0\1\101\2\76"+ - "\1\101\20\76\34\0\1\17\1\0\5\17\2\0\2\17"+ - "\1\0\20\17\7\23\1\0\24\23\1\17\1\0\5\17"+ - "\1\102\1\103\2\17\1\103\20\17\10\0\1\26\2\0"+ - "\1\26\20\0\1\17\1\0\5\17\1\104\1\105\2\17"+ - "\1\105\20\17\7\0\1\106\1\107\1\0\1\110\1\107"+ - "\16\0\1\110\16\0\1\111\33\0\1\112\16\0\7\113"+ - "\1\114\10\113\1\115\1\116\12\113\7\117\1\120\12\117"+ - "\1\121\11\117\4\0\3\122\1\123\1\124\1\0\1\125"+ - "\1\124\3\0\1\126\2\0\1\122\2\125\2\122\1\127"+ - "\1\130\1\0\1\122\10\0\1\131\1\132\1\0\1\133"+ - "\1\132\16\0\1\133\1\0\1\134\1\0\1\134\1\135"+ - "\1\134\1\135\1\136\1\0\1\137\1\135\1\134\1\137"+ - "\1\134\2\135\12\134\1\135\2\134\1\42\1\0\1\42"+ - "\1\0\3\42\3\0\1\42\1\0\1\42\2\0\12\42"+ - "\1\0\3\42\1\0\1\42\1\0\3\42\1\102\1\103"+ - "\1\0\1\42\1\103\1\42\2\0\12\42\1\0\3\42"+ - "\1\0\1\42\1\0\3\42\1\104\1\105\1\0\1\42"+ - "\1\105\1\42\2\0\12\42\1\0\2\42\15\0\1\140"+ - "\33\0\1\141\16\0\1\142\1\0\3\142\1\143\1\144"+ - "\1\0\1\145\2\142\1\145\20\142\1\50\1\0\5\50"+ - "\2\0\2\50\1\0\21\50\1\0\5\50\1\102\1\103"+ - "\2\50\1\103\20\50\20\114\1\146\1\147\12\114\22\120"+ - "\1\150\11\120\1\151\1\0\1\151\1\152\1\151\1\152"+ - "\1\153\1\0\1\154\1\152\1\151\1\154\1\151\2\152"+ - "\12\151\1\152\2\151\1\57\1\0\1\57\1\0\3\57"+ - "\3\0\1\57\1\0\1\57\2\0\12\57\1\0\3\57"+ - "\1\0\1\57\1\0\3\57\1\102\1\103\1\0\1\57"+ - "\1\103\1\57\2\0\12\57\1\0\2\57\7\63\1\0"+ - "\24\63\7\0\1\155\1\65\2\0\1\65\24\0\3\156"+ - "\3\0\1\157\4\0\1\160\2\0\1\156\2\157\2\156"+ - "\1\161\1\162\1\0\1\156\11\0\1\70\2\0\1\70"+ - "\20\0\1\163\1\0\1\163\1\164\1\163\1\164\1\165"+ - "\1\0\1\71\1\164\1\163\1\71\1\163\2\164\12\163"+ - "\1\164\2\163\1\71\1\0\1\71\1\0\3\71\3\0"+ - "\1\71\1\0\1\71\2\0\12\71\1\0\2\71\1\166"+ - "\1\0\3\166\1\167\1\170\1\0\1\73\2\166\1\73"+ - "\20\166\1\73\1\0\5\73\2\0\2\73\1\0\20\73"+ - "\12\0\1\171\17\0\1\171\1\0\1\76\1\0\4\76"+ - "\1\100\1\0\1\101\2\76\1\101\20\76\5\0\1\17"+ - "\26\0\1\17\1\172\5\17\2\172\2\17\1\172\20\17"+ - "\10\0\1\103\2\0\1\103\30\0\1\105\2\0\1\105"+ - "\30\0\1\107\2\0\1\107\27\0\1\106\1\107\2\0"+ - "\1\107\20\0\5\173\1\0\1\173\1\0\1\173\3\0"+ - "\1\173\2\0\12\173\1\0\2\173\1\174\3\112\1\175"+ - "\1\112\1\175\1\0\2\112\1\175\3\112\1\176\1\112"+ - "\1\174\2\112\3\174\2\112\1\174\1\112\1\174\1\112"+ - "\7\113\1\114\24\113\6\0\1\177\33\0\1\177\13\0"+ - "\1\117\15\0\3\122\1\123\1\124\1\0\1\122\1\124"+ - "\3\0\1\126\2\0\5\122\3\0\1\122\11\0\1\124"+ - "\2\0\1\124\24\0\3\122\1\123\1\124\1\0\1\125"+ - "\1\124\3\0\1\126\2\0\1\122\2\125\2\122\1\127"+ - "\2\0\1\122\24\0\1\200\14\0\3\122\3\0\1\122"+ - "\4\0\1\126\2\0\5\122\3\0\1\122\4\0\4\201"+ - "\2\0\2\201\4\0\1\202\2\0\6\201\1\0\2\201"+ - "\11\0\1\132\2\0\1\132\27\0\1\131\1\132\2\0"+ - "\1\132\20\0\1\134\1\0\1\134\1\135\2\134\1\136"+ - "\1\0\1\137\1\135\1\134\1\137\1\134\2\135\12\134"+ - "\1\135\2\134\5\0\1\42\26\0\1\42\1\203\1\42"+ - "\1\203\3\42\3\203\1\42\1\203\1\42\2\203\12\42"+ - "\1\203\2\42\5\204\1\0\1\204\1\0\1\204\3\0"+ - "\1\204\2\0\12\204\1\0\2\204\1\205\3\141\1\206"+ - "\1\141\1\206\1\0\2\141\1\206\3\141\1\207\1\141"+ - "\1\205\2\141\3\205\2\141\1\205\1\141\1\205\1\141"+ - "\1\142\1\0\4\142\1\144\1\0\1\145\2\142\1\145"+ - "\20\142\5\0\1\50\26\0\34\114\22\0\1\120\11\0"+ - "\1\151\1\0\1\151\1\152\2\151\1\153\1\0\1\154"+ - "\1\152\1\151\1\154\1\151\2\152\12\151\1\152\2\151"+ - "\5\0\1\57\32\0\3\156\3\0\1\156\4\0\1\160"+ - "\2\0\5\156\3\0\1\156\5\0\3\156\3\0\1\157"+ - "\4\0\1\160\2\0\1\156\2\157\2\156\1\161\2\0"+ - "\1\156\24\0\1\210\13\0\4\211\2\0\2\211\4\0"+ - "\1\212\2\0\6\211\1\0\2\211\1\0\1\163\1\0"+ - "\1\163\1\164\2\163\1\165\1\0\1\71\1\164\1\163"+ - "\1\71\1\163\2\164\12\163\1\164\2\163\5\0\1\71"+ - "\26\0\1\166\1\0\4\166\1\170\1\0\1\73\2\166"+ - "\1\73\20\166\5\0\1\73\26\0\1\213\3\173\1\214"+ - "\1\0\1\144\1\0\1\173\1\0\1\214\1\173\2\0"+ - "\1\215\1\173\1\213\2\173\3\213\2\173\1\213\1\0"+ - "\1\213\1\173\1\216\1\112\2\216\1\217\1\220\1\175"+ - "\1\0\1\221\1\216\1\217\1\221\2\216\1\222\15\216"+ - "\1\174\1\112\2\174\1\217\1\174\1\217\1\0\1\112"+ - "\1\174\1\217\1\112\2\174\1\223\15\174\1\50\3\0"+ - "\1\144\1\0\1\144\3\0\1\144\5\0\1\50\2\0"+ - "\3\50\2\0\1\50\1\0\1\50\24\0\1\122\13\0"+ - "\4\201\2\0\2\201\1\0\1\224\2\0\1\202\2\0"+ - "\6\201\1\0\2\201\24\0\1\225\10\0\1\226\3\204"+ - "\1\227\1\0\1\153\1\0\1\204\1\0\1\227\1\204"+ - "\2\0\1\230\1\204\1\226\2\204\3\226\2\204\1\226"+ - "\1\0\1\226\1\204\1\231\1\141\1\231\1\232\1\233"+ - "\1\232\1\206\1\0\1\234\1\232\1\233\1\234\1\231"+ - "\1\232\1\235\12\231\1\232\2\231\1\205\1\141\1\205"+ - "\1\141\1\233\1\205\1\233\1\0\2\141\1\233\1\141"+ - "\1\205\1\141\1\207\12\205\1\141\2\205\1\57\3\0"+ - "\1\153\1\0\1\153\3\0\1\153\5\0\1\57\2\0"+ - "\3\57\2\0\1\57\1\0\1\57\24\0\1\156\13\0"+ - "\4\211\2\0\2\211\1\0\1\171\2\0\1\212\2\0"+ - "\6\211\1\0\2\211\24\0\1\236\10\0\1\237\1\173"+ - "\2\237\1\240\1\143\1\144\1\0\1\241\1\142\1\240"+ - "\1\241\2\142\1\242\12\237\1\142\2\237\1\213\1\173"+ - "\2\213\1\240\1\50\1\243\1\0\1\173\1\50\1\240"+ - "\1\173\2\50\1\244\12\213\1\50\2\213\1\50\3\0"+ - "\1\144\1\0\1\144\3\0\1\144\3\0\1\176\1\0"+ - "\1\50\2\0\3\50\2\0\1\50\1\0\1\50\1\0"+ - "\1\216\1\112\2\216\1\217\1\216\1\175\1\0\1\221"+ - "\1\216\1\217\1\221\2\216\1\222\16\216\1\112\2\216"+ - "\1\217\1\216\1\217\1\0\1\221\1\216\1\217\1\221"+ - "\2\216\1\222\15\216\1\174\3\112\1\175\1\174\1\175"+ - "\1\0\2\112\1\175\3\112\1\176\1\112\1\174\2\112"+ - "\3\174\2\112\1\174\1\112\1\174\1\112\1\142\1\0"+ - "\2\142\1\243\1\142\1\144\1\0\1\145\1\142\1\243"+ - "\1\145\21\142\1\0\2\142\1\243\1\143\1\144\1\0"+ - "\1\145\1\142\1\243\1\145\20\142\7\0\1\123\1\124"+ - "\2\0\1\124\43\0\1\201\10\0\1\245\1\204\1\245"+ - "\1\246\1\247\1\152\1\153\1\0\1\250\1\152\1\247"+ - "\1\250\1\151\1\152\1\251\12\245\1\152\2\245\1\226"+ - "\1\204\1\226\1\204\1\247\1\57\1\252\1\0\1\204"+ - "\1\0\1\247\1\204\1\57\1\0\1\230\12\226\1\0"+ - "\2\226\1\57\3\0\1\153\1\0\1\153\3\0\1\153"+ - "\3\0\1\207\1\0\1\57\2\0\3\57\2\0\1\57"+ - "\1\0\1\57\1\0\1\231\1\141\1\231\1\232\1\233"+ - "\1\231\1\206\1\0\1\234\1\232\1\233\1\234\1\231"+ - "\1\232\1\235\12\231\1\232\2\231\1\205\3\141\1\206"+ - "\1\205\1\206\1\0\2\141\1\206\3\141\1\207\1\141"+ - "\1\205\2\141\3\205\2\141\1\205\1\141\1\205\1\141"+ - "\1\231\1\141\1\231\1\232\1\233\1\231\1\233\1\0"+ - "\1\234\1\232\1\233\1\234\1\231\1\232\1\235\12\231"+ - "\1\232\2\231\1\57\3\0\1\153\1\57\1\153\3\0"+ - "\1\153\5\0\1\57\2\0\3\57\2\0\1\57\1\0"+ - "\1\57\24\0\1\211\10\0\1\237\1\173\2\237\1\240"+ - "\1\142\1\144\1\0\1\241\1\142\1\240\1\241\2\142"+ - "\1\242\12\237\1\142\3\237\1\173\2\237\1\240\1\142"+ - "\1\243\1\0\1\241\1\142\1\240\1\241\2\142\1\242"+ - "\12\237\1\142\2\237\1\142\1\0\2\142\1\243\1\142"+ - "\1\144\1\0\1\145\1\142\1\243\1\145\2\142\1\222"+ - "\16\142\1\0\4\142\1\243\1\0\1\145\2\142\1\145"+ - "\21\142\1\0\2\142\1\243\1\143\1\144\1\0\1\145"+ - "\1\142\1\243\1\145\2\142\1\222\15\142\1\245\1\204"+ - "\1\245\1\246\1\247\1\151\1\153\1\0\1\250\1\152"+ - "\1\247\1\250\1\151\1\152\1\251\12\245\1\152\2\245"+ - "\1\226\3\204\1\227\1\57\1\153\1\0\1\204\1\0"+ - "\1\227\1\204\2\0\1\230\1\204\1\226\2\204\3\226"+ - "\2\204\1\226\1\0\1\226\1\204\1\245\1\204\1\245"+ - "\1\246\1\247\1\151\1\252\1\0\1\250\1\152\1\247"+ - "\1\250\1\151\1\152\1\251\12\245\1\152\2\245\1\57"+ - "\3\0\1\153\1\57\1\153\3\0\1\153\3\0\1\207"+ - "\1\0\1\57\2\0\3\57\2\0\1\57\1\0\1\57"+ - "\1\0\1\151\1\0\1\151\1\152\2\151\1\252\1\0"+ - "\1\154\1\152\1\151\1\154\1\151\2\152\12\151\1\152"+ - "\2\151"; + "\1\16\2\17\1\20\1\21\1\22\1\23\1\24\1\25"+ + "\1\26\1\27\1\25\1\30\1\31\1\32\1\33\1\16"+ + "\1\34\1\35\3\16\1\17\1\36\1\16\1\37\1\16"+ + "\1\40\1\41\2\17\1\20\1\42\1\22\1\43\1\24"+ + "\1\25\1\26\1\44\1\25\1\17\1\45\1\32\1\46"+ + "\1\41\1\34\1\35\3\41\1\17\1\36\1\41\1\37"+ + "\1\41\1\17\1\47\2\17\1\20\1\50\1\22\1\51"+ + "\1\24\1\25\1\26\1\52\1\25\1\30\1\31\1\32"+ + "\1\33\1\47\1\53\1\54\3\47\1\17\1\36\1\47"+ + "\1\37\1\47\1\40\1\55\2\17\1\20\1\56\1\22"+ + "\1\57\1\24\1\25\1\26\1\60\1\25\1\30\1\45"+ + "\1\32\1\46\1\55\1\53\1\54\3\55\1\17\1\36"+ + "\1\55\1\37\1\55\1\40\7\61\1\62\1\63\2\61"+ + "\1\63\20\61\27\0\1\64\13\0\1\65\1\66\2\0"+ + "\1\66\20\0\1\67\3\0\1\70\1\0\1\70\3\0"+ + "\1\70\5\0\1\67\2\0\3\67\2\0\1\67\1\0"+ + "\1\67\2\0\1\65\1\0\1\65\3\0\3\65\1\0"+ + "\1\65\1\0\2\65\12\0\1\65\2\0\1\71\3\0"+ + "\1\72\1\0\1\72\3\0\1\72\5\0\1\71\2\0"+ + "\3\71\2\0\1\71\1\0\1\71\2\0\1\65\5\0"+ + "\2\65\2\0\1\65\34\0\1\73\52\0\1\73\1\74"+ + "\1\0\3\74\1\75\1\76\1\0\1\77\2\74\1\77"+ + "\20\74\34\0\1\16\1\0\5\16\2\0\2\16\1\0"+ + "\20\16\7\22\1\0\24\22\1\16\1\0\5\16\1\100"+ + "\1\101\2\16\1\101\20\16\10\0\1\25\2\0\1\25"+ + "\20\0\1\16\1\0\5\16\1\102\1\103\2\16\1\103"+ + "\20\16\7\0\1\104\1\105\1\0\1\106\1\105\16\0"+ + "\1\106\16\0\1\107\33\0\1\110\16\0\7\111\1\112"+ + "\10\111\1\113\1\114\12\111\7\115\1\116\12\115\1\117"+ + "\11\115\4\0\3\120\1\121\1\122\1\0\1\123\1\122"+ + "\3\0\1\124\2\0\1\120\2\123\2\120\1\125\1\126"+ + "\1\0\1\120\10\0\1\127\1\130\1\0\1\131\1\130"+ + "\16\0\1\131\1\0\1\132\1\0\1\132\1\133\1\132"+ + "\1\133\1\134\1\0\1\135\1\133\1\132\1\135\1\132"+ + "\2\133\12\132\1\133\2\132\1\41\1\0\1\41\1\0"+ + "\3\41\3\0\1\41\1\0\1\41\2\0\12\41\1\0"+ + "\3\41\1\0\1\41\1\0\3\41\1\100\1\101\1\0"+ + "\1\41\1\101\1\41\2\0\12\41\1\0\3\41\1\0"+ + "\1\41\1\0\3\41\1\102\1\103\1\0\1\41\1\103"+ + "\1\41\2\0\12\41\1\0\2\41\15\0\1\136\33\0"+ + "\1\137\16\0\1\140\1\0\3\140\1\141\1\142\1\0"+ + "\1\143\2\140\1\143\20\140\1\47\1\0\5\47\2\0"+ + "\2\47\1\0\21\47\1\0\5\47\1\100\1\101\2\47"+ + "\1\101\20\47\20\112\1\144\1\145\12\112\22\116\1\146"+ + "\11\116\1\147\1\0\1\147\1\150\1\147\1\150\1\151"+ + "\1\0\1\152\1\150\1\147\1\152\1\147\2\150\12\147"+ + "\1\150\2\147\1\55\1\0\1\55\1\0\3\55\3\0"+ + "\1\55\1\0\1\55\2\0\12\55\1\0\3\55\1\0"+ + "\1\55\1\0\3\55\1\100\1\101\1\0\1\55\1\101"+ + "\1\55\2\0\12\55\1\0\2\55\7\61\1\0\24\61"+ + "\7\0\1\153\1\63\2\0\1\63\24\0\3\154\3\0"+ + "\1\155\4\0\1\156\2\0\1\154\2\155\2\154\1\157"+ + "\1\160\1\0\1\154\11\0\1\66\2\0\1\66\20\0"+ + "\1\161\1\0\1\161\1\162\1\161\1\162\1\163\1\0"+ + "\1\67\1\162\1\161\1\67\1\161\2\162\12\161\1\162"+ + "\2\161\1\67\1\0\1\67\1\0\3\67\3\0\1\67"+ + "\1\0\1\67\2\0\12\67\1\0\2\67\1\164\1\0"+ + "\3\164\1\165\1\166\1\0\1\71\2\164\1\71\20\164"+ + "\1\71\1\0\5\71\2\0\2\71\1\0\20\71\12\0"+ + "\1\167\17\0\1\167\1\0\1\74\1\0\4\74\1\76"+ + "\1\0\1\77\2\74\1\77\20\74\5\0\1\16\26\0"+ + "\1\16\1\170\5\16\2\170\2\16\1\170\20\16\10\0"+ + "\1\101\2\0\1\101\30\0\1\103\2\0\1\103\30\0"+ + "\1\105\2\0\1\105\27\0\1\104\1\105\2\0\1\105"+ + "\20\0\5\171\1\0\1\171\1\0\1\171\3\0\1\171"+ + "\2\0\12\171\1\0\2\171\1\172\3\110\1\173\1\110"+ + "\1\173\1\0\2\110\1\173\3\110\1\174\1\110\1\172"+ + "\2\110\3\172\2\110\1\172\1\110\1\172\1\110\7\111"+ + "\1\112\24\111\6\0\1\175\33\0\1\175\13\0\1\115"+ + "\15\0\3\120\1\121\1\122\1\0\1\120\1\122\3\0"+ + "\1\124\2\0\5\120\3\0\1\120\11\0\1\122\2\0"+ + "\1\122\24\0\3\120\1\121\1\122\1\0\1\123\1\122"+ + "\3\0\1\124\2\0\1\120\2\123\2\120\1\125\2\0"+ + "\1\120\24\0\1\176\14\0\3\120\3\0\1\120\4\0"+ + "\1\124\2\0\5\120\3\0\1\120\4\0\4\177\2\0"+ + "\2\177\4\0\1\200\2\0\6\177\1\0\2\177\11\0"+ + "\1\130\2\0\1\130\27\0\1\127\1\130\2\0\1\130"+ + "\20\0\1\132\1\0\1\132\1\133\2\132\1\134\1\0"+ + "\1\135\1\133\1\132\1\135\1\132\2\133\12\132\1\133"+ + "\2\132\5\0\1\41\26\0\1\41\1\201\1\41\1\201"+ + "\3\41\3\201\1\41\1\201\1\41\2\201\12\41\1\201"+ + "\2\41\5\202\1\0\1\202\1\0\1\202\3\0\1\202"+ + "\2\0\12\202\1\0\2\202\1\203\3\137\1\204\1\137"+ + "\1\204\1\0\2\137\1\204\3\137\1\205\1\137\1\203"+ + "\2\137\3\203\2\137\1\203\1\137\1\203\1\137\1\140"+ + "\1\0\4\140\1\142\1\0\1\143\2\140\1\143\20\140"+ + "\5\0\1\47\26\0\34\112\22\0\1\116\11\0\1\147"+ + "\1\0\1\147\1\150\2\147\1\151\1\0\1\152\1\150"+ + "\1\147\1\152\1\147\2\150\12\147\1\150\2\147\5\0"+ + "\1\55\32\0\3\154\3\0\1\154\4\0\1\156\2\0"+ + "\5\154\3\0\1\154\5\0\3\154\3\0\1\155\4\0"+ + "\1\156\2\0\1\154\2\155\2\154\1\157\2\0\1\154"+ + "\24\0\1\206\13\0\4\207\2\0\2\207\4\0\1\210"+ + "\2\0\6\207\1\0\2\207\1\0\1\161\1\0\1\161"+ + "\1\162\2\161\1\163\1\0\1\67\1\162\1\161\1\67"+ + "\1\161\2\162\12\161\1\162\2\161\5\0\1\67\26\0"+ + "\1\164\1\0\4\164\1\166\1\0\1\71\2\164\1\71"+ + "\20\164\5\0\1\71\26\0\1\211\3\171\1\212\1\0"+ + "\1\142\1\0\1\171\1\0\1\212\1\171\2\0\1\213"+ + "\1\171\1\211\2\171\3\211\2\171\1\211\1\0\1\211"+ + "\1\171\1\214\1\110\2\214\1\215\1\216\1\173\1\0"+ + "\1\217\1\214\1\215\1\217\2\214\1\220\15\214\1\172"+ + "\1\110\2\172\1\215\1\172\1\215\1\0\1\110\1\172"+ + "\1\215\1\110\2\172\1\221\15\172\1\47\3\0\1\142"+ + "\1\0\1\142\3\0\1\142\5\0\1\47\2\0\3\47"+ + "\2\0\1\47\1\0\1\47\24\0\1\120\13\0\4\177"+ + "\2\0\2\177\1\0\1\222\2\0\1\200\2\0\6\177"+ + "\1\0\2\177\24\0\1\223\10\0\1\224\3\202\1\225"+ + "\1\0\1\151\1\0\1\202\1\0\1\225\1\202\2\0"+ + "\1\226\1\202\1\224\2\202\3\224\2\202\1\224\1\0"+ + "\1\224\1\202\1\227\1\137\1\227\1\230\1\231\1\230"+ + "\1\204\1\0\1\232\1\230\1\231\1\232\1\227\1\230"+ + "\1\233\12\227\1\230\2\227\1\203\1\137\1\203\1\137"+ + "\1\231\1\203\1\231\1\0\2\137\1\231\1\137\1\203"+ + "\1\137\1\205\12\203\1\137\2\203\1\55\3\0\1\151"+ + "\1\0\1\151\3\0\1\151\5\0\1\55\2\0\3\55"+ + "\2\0\1\55\1\0\1\55\24\0\1\154\13\0\4\207"+ + "\2\0\2\207\1\0\1\167\2\0\1\210\2\0\6\207"+ + "\1\0\2\207\24\0\1\234\10\0\1\235\1\171\2\235"+ + "\1\236\1\141\1\142\1\0\1\237\1\140\1\236\1\237"+ + "\2\140\1\240\12\235\1\140\2\235\1\211\1\171\2\211"+ + "\1\236\1\47\1\241\1\0\1\171\1\47\1\236\1\171"+ + "\2\47\1\242\12\211\1\47\2\211\1\47\3\0\1\142"+ + "\1\0\1\142\3\0\1\142\3\0\1\174\1\0\1\47"+ + "\2\0\3\47\2\0\1\47\1\0\1\47\1\0\1\214"+ + "\1\110\2\214\1\215\1\214\1\173\1\0\1\217\1\214"+ + "\1\215\1\217\2\214\1\220\16\214\1\110\2\214\1\215"+ + "\1\214\1\215\1\0\1\217\1\214\1\215\1\217\2\214"+ + "\1\220\15\214\1\172\3\110\1\173\1\172\1\173\1\0"+ + "\2\110\1\173\3\110\1\174\1\110\1\172\2\110\3\172"+ + "\2\110\1\172\1\110\1\172\1\110\1\140\1\0\2\140"+ + "\1\241\1\140\1\142\1\0\1\143\1\140\1\241\1\143"+ + "\21\140\1\0\2\140\1\241\1\141\1\142\1\0\1\143"+ + "\1\140\1\241\1\143\20\140\7\0\1\121\1\122\2\0"+ + "\1\122\43\0\1\177\10\0\1\243\1\202\1\243\1\244"+ + "\1\245\1\150\1\151\1\0\1\246\1\150\1\245\1\246"+ + "\1\147\1\150\1\247\12\243\1\150\2\243\1\224\1\202"+ + "\1\224\1\202\1\245\1\55\1\250\1\0\1\202\1\0"+ + "\1\245\1\202\1\55\1\0\1\226\12\224\1\0\2\224"+ + "\1\55\3\0\1\151\1\0\1\151\3\0\1\151\3\0"+ + "\1\205\1\0\1\55\2\0\3\55\2\0\1\55\1\0"+ + "\1\55\1\0\1\227\1\137\1\227\1\230\1\231\1\227"+ + "\1\204\1\0\1\232\1\230\1\231\1\232\1\227\1\230"+ + "\1\233\12\227\1\230\2\227\1\203\3\137\1\204\1\203"+ + "\1\204\1\0\2\137\1\204\3\137\1\205\1\137\1\203"+ + "\2\137\3\203\2\137\1\203\1\137\1\203\1\137\1\227"+ + "\1\137\1\227\1\230\1\231\1\227\1\231\1\0\1\232"+ + "\1\230\1\231\1\232\1\227\1\230\1\233\12\227\1\230"+ + "\2\227\1\55\3\0\1\151\1\55\1\151\3\0\1\151"+ + "\5\0\1\55\2\0\3\55\2\0\1\55\1\0\1\55"+ + "\24\0\1\207\10\0\1\235\1\171\2\235\1\236\1\140"+ + "\1\142\1\0\1\237\1\140\1\236\1\237\2\140\1\240"+ + "\12\235\1\140\3\235\1\171\2\235\1\236\1\140\1\241"+ + "\1\0\1\237\1\140\1\236\1\237\2\140\1\240\12\235"+ + "\1\140\2\235\1\140\1\0\2\140\1\241\1\140\1\142"+ + "\1\0\1\143\1\140\1\241\1\143\2\140\1\220\16\140"+ + "\1\0\4\140\1\241\1\0\1\143\2\140\1\143\21\140"+ + "\1\0\2\140\1\241\1\141\1\142\1\0\1\143\1\140"+ + "\1\241\1\143\2\140\1\220\15\140\1\243\1\202\1\243"+ + "\1\244\1\245\1\147\1\151\1\0\1\246\1\150\1\245"+ + "\1\246\1\147\1\150\1\247\12\243\1\150\2\243\1\224"+ + "\3\202\1\225\1\55\1\151\1\0\1\202\1\0\1\225"+ + "\1\202\2\0\1\226\1\202\1\224\2\202\3\224\2\202"+ + "\1\224\1\0\1\224\1\202\1\243\1\202\1\243\1\244"+ + "\1\245\1\147\1\250\1\0\1\246\1\150\1\245\1\246"+ + "\1\147\1\150\1\247\12\243\1\150\2\243\1\55\3\0"+ + "\1\151\1\55\1\151\3\0\1\151\3\0\1\205\1\0"+ + "\1\55\2\0\3\55\2\0\1\55\1\0\1\55\1\0"+ + "\1\147\1\0\1\147\1\150\2\147\1\250\1\0\1\152"+ + "\1\150\1\147\1\152\1\147\2\150\12\147\1\150\2\147"; private static int [] zzUnpackTrans() { - int [] result = new int[3696]; + int [] result = new int[3668]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -374,8 +369,8 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\16\0\1\1\2\11\3\1\1\11\1\1\1\11\3\1"+ - "\1\11\4\1\1\11\23\1\1\11\2\1\1\11\1\1"+ + "\15\0\1\1\2\11\3\1\1\11\1\1\1\11\3\1"+ + "\1\11\4\1\1\11\22\1\1\11\2\1\1\11\1\1"+ "\4\0\2\1\1\0\1\1\1\0\1\11\1\1\1\11"+ "\1\1\1\11\1\1\6\0\1\1\2\0\1\1\1\0"+ "\1\11\1\1\4\0\1\11\1\1\1\0\1\1\1\0"+ @@ -387,7 +382,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { "\2\0\1\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[170]; + int [] result = new int[168]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -905,7 +900,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { case 43: break; case 18: // general lookahead, find correct zzMarkedPos - { int zzFState = 12; + { int zzFState = 11; int zzFPos = zzStartRead; if (zzFin.length <= zzBufferL.length()) { zzFin = new boolean[zzBufferL.length()+1]; } boolean zzFinL[] = zzFin; @@ -920,7 +915,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { zzFinL[zzFPos++] = false; } - zzFState = 7; + zzFState = 6; zzFPos = zzMarkedPos; while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { zzInput = Character.codePointBefore(zzBufferL, zzFPos/*, zzStartRead*/); @@ -945,7 +940,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { case 46: break; case 21: // general lookahead, find correct zzMarkedPos - { int zzFState = 6; + { int zzFState = 5; int zzFPos = zzStartRead; if (zzFin.length <= zzBufferL.length()) { zzFin = new boolean[zzBufferL.length()+1]; } boolean zzFinL[] = zzFin; @@ -960,7 +955,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { zzFinL[zzFPos++] = false; } - zzFState = 7; + zzFState = 6; zzFPos = zzMarkedPos; while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { zzInput = Character.codePointBefore(zzBufferL, zzFPos/*, zzStartRead*/); @@ -974,7 +969,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { case 47: break; case 22: // general lookahead, find correct zzMarkedPos - { int zzFState = 13; + { int zzFState = 12; int zzFPos = zzStartRead; if (zzFin.length <= zzBufferL.length()) { zzFin = new boolean[zzBufferL.length()+1]; } boolean zzFinL[] = zzFin; @@ -989,7 +984,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { zzFinL[zzFPos++] = false; } - zzFState = 7; + zzFState = 6; zzFPos = zzMarkedPos; while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { zzInput = Character.codePointBefore(zzBufferL, zzFPos/*, zzStartRead*/); @@ -1013,7 +1008,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { case 49: break; case 24: // general lookahead, find correct zzMarkedPos - { int zzFState = 10; + { int zzFState = 9; int zzFPos = zzStartRead; if (zzFin.length <= zzBufferL.length()) { zzFin = new boolean[zzBufferL.length()+1]; } boolean zzFinL[] = zzFin; @@ -1028,7 +1023,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { zzFinL[zzFPos++] = false; } - zzFState = 11; + zzFState = 10; zzFPos = zzMarkedPos; while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { zzInput = Character.codePointBefore(zzBufferL, zzFPos/*, zzStartRead*/); @@ -1047,7 +1042,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { case 51: break; case 26: // general lookahead, find correct zzMarkedPos - { int zzFState = 8; + { int zzFState = 7; int zzFPos = zzStartRead; if (zzFin.length <= zzBufferL.length()) { zzFin = new boolean[zzBufferL.length()+1]; } boolean zzFinL[] = zzFin; @@ -1062,7 +1057,7 @@ public class _YAMLLexer implements FlexLexer, YAMLTokenTypes { zzFinL[zzFPos++] = false; } - zzFState = 9; + zzFState = 8; zzFPos = zzMarkedPos; while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) { zzInput = Character.codePointBefore(zzBufferL, zzFPos/*, zzStartRead*/); diff --git a/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex b/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex index 4fe2f1322e87..d8caeb53da8e 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex +++ b/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex @@ -260,6 +260,10 @@ C_NS_TAG_PROPERTY = {C_VERBATIM_TAG} | {C_NS_SHORTHAND_TAG} | {C_NON_SPECIFIC_TA return tokenOrForbidden(TEXT); } +} + + { + "-" / ({WHITE_SPACE} | {EOL}) { yyBegin(VALUE_OR_KEY); return SEQUENCE_MARKER; } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java index 28111244c258..a0267bd03810 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java @@ -161,6 +161,10 @@ public class YAMLLexerTest extends LexerTestCase { doTest(); } + public void testRuby19105() throws Throwable { + doTest(); + } + public void testEmptyMultiline() throws Throwable { doTest(); } @@ -204,7 +208,7 @@ public class YAMLLexerTest extends LexerTestCase { public void testSingleQuotedEscapes() { doTest(); } - + public void testUnicodeNewlines() { doTest(); } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.txt new file mode 100644 index 000000000000..210e33a00955 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.txt @@ -0,0 +1,12 @@ +- ('-') +whitespace (' ') +- ('-') +whitespace (' ') +scalar key ('Ref:') +whitespace (' ') +text ('hostedZoneName') +Eol ('\n') +indent (' ') +- ('-') +whitespace (' ') +text ('a') diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.yml new file mode 100644 index 000000000000..819c37335ebd --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby19105.yml @@ -0,0 +1,2 @@ +- - Ref: hostedZoneName + - a \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java index eb06d53dcedb..4b9767ee4525 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java @@ -135,6 +135,13 @@ public class YAMLParserTest extends ParsingTestCase { "bar: \"baz\""); } + public void testRuby19105() throws Throwable { + doCodeTest("'Fn::Join':\n" + + " - ''\n" + + " - - Ref: hostedZoneName\n" + + " - a"); + } + public void testRuby15345() throws IOException { doCodeTest("- !qualified.class.name\n" + " propertyOne: bla bla\n" + @@ -176,7 +183,7 @@ public class YAMLParserTest extends ParsingTestCase { public void testStringWithTag() throws IOException { doCodeTest("foo: ! \"tratata\""); } - + public void testIncompleteKeyWithWhitespace() throws IOException { doCodeTest("logging:\n" + " config:\n" + @@ -201,23 +208,23 @@ public class YAMLParserTest extends ParsingTestCase { public void testAnsibleRoleElkMain() { doTest(true); } - + public void testBlockMapping() { doTest(true); } - + public void testIncompleteKeyInHierarchy() { doTest(true); } - + public void testKeyValueWithEmptyLineAhead() { doTest(true); } - + public void testMultipleDocsWithMappings() { doTest(true); } - + public void testScalarsWithNewlines() { doTest(true); } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby19105.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby19105.txt new file mode 100644 index 000000000000..ede8fa4c1ec8 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby19105.txt @@ -0,0 +1,35 @@ +YAML file + YAML document + YAML mapping + YAML key value + PsiElement(scalar key)(''Fn::Join':') + PsiElement(Eol)('\n') + PsiElement(indent)(' ') + YAML sequence + YAML sequence item + PsiElement(-)('-') + PsiWhiteSpace(' ') + YAML quoted text + PsiElement(scalar string)('''') + PsiElement(Eol)('\n') + PsiElement(indent)(' ') + YAML sequence item + PsiElement(-)('-') + PsiWhiteSpace(' ') + YAML sequence + YAML sequence item + PsiElement(-)('-') + PsiWhiteSpace(' ') + YAML mapping + YAML key value + PsiElement(scalar key)('Ref:') + PsiWhiteSpace(' ') + YAML plain scalar text + PsiElement(text)('hostedZoneName') + PsiElement(Eol)('\n') + PsiElement(indent)(' ') + YAML sequence item + PsiElement(-)('-') + PsiWhiteSpace(' ') + YAML plain scalar text + PsiElement(text)('a') \ No newline at end of file From 7469ae5161d0ac86f3f48c0626c1cb6d7aca055f Mon Sep 17 00:00:00 2001 From: "Vladislav.Soroka" Date: Mon, 27 Feb 2017 14:42:13 +0300 Subject: [PATCH 15/20] ChangesView tip of the day updated --- platform/platform-resources-en/src/tips/ChangesView.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/tips/ChangesView.html b/platform/platform-resources-en/src/tips/ChangesView.html index 737d91a56e60..ae2ccf852e10 100644 --- a/platform/platform-resources-en/src/tips/ChangesView.html +++ b/platform/platform-resources-en/src/tips/ChangesView.html @@ -6,7 +6,7 @@

The Version Control tool window shows all deleted, modified, and unversioned files in a single view. Use &shortcut:ActivateChangesToolWindow; keyboard shortcut to show or hide this tool window.

-

From the Changes tool window you can perform all the necessary version control +

From the Version Control tool window you can perform all the necessary version control actions: commit changes, manage changelists, put resources under version control, examine differences and more.

From 82e2ff65720462155b79e265cf4ca28b93082129 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 27 Feb 2017 13:05:11 +0100 Subject: [PATCH 16/20] add x-ijt to allowed headers --- platform/platform-impl/src/org/jetbrains/io/NettyUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java index 9c9ba6fb96a9..38a90eaeb9a8 100644 --- a/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java +++ b/platform/platform-impl/src/org/jetbrains/io/NettyUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -107,7 +107,7 @@ public final class NettyUtil { .allowCredentials() .allowNullOrigin() .allowedRequestMethods(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.HEAD, HttpMethod.PATCH) - .allowedRequestHeaders("origin", "accept", "authorization", "content-type") + .allowedRequestHeaders("origin", "accept", "authorization", "content-type", "x-ijt") .build())); } From 7e434c6521fa408b5ae18149efe738a8a7b627ba Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 27 Feb 2017 15:14:38 +0300 Subject: [PATCH 17/20] prevent UI-designer-specific inspections to run on every java file and use more specific language for UI-form file inspections --- .../testFramework/InspectionTestCase.java | 3 +- .../testFramework/InspectionTestUtil.java | 30 ++++++++++++------- plugins/java-i18n/java-i18n.iml | 1 + .../i18n/I18NInspectionTest.java | 10 ++++++- plugins/ui-designer/src/META-INF/plugin.xml | 16 ++++------ .../inspections/BaseFormInspection.java | 2 +- 6 files changed, 39 insertions(+), 23 deletions(-) diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java index 18bba87c8617..5ad8b8655f5b 100644 --- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java @@ -49,6 +49,7 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -119,7 +120,7 @@ public abstract class InspectionTestCase extends PsiTestCase { final String testDir = getTestDataPath() + "/" + folderName; GlobalInspectionContextImpl context = runTool(testDir, jdkName, runDeadCodeFirst, toolWrapper, additional); - InspectionTestUtil.compareToolResults(context, toolWrapper, checkRange, testDir); + InspectionTestUtil.compareToolResults(context, checkRange, testDir, ContainerUtil.append(Collections.singletonList(toolWrapper), additional)); } protected void runTool(@NonNls @NotNull String testDir, @NonNls final String jdkName, @NotNull InspectionToolWrapper tool) { diff --git a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java index 98773afb443b..cb2b23b104b0 100644 --- a/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/InspectionTestUtil.java @@ -32,6 +32,7 @@ import com.intellij.util.ui.UIUtil; import org.jdom.Document; import org.jdom.Element; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import org.junit.Assert; import java.io.CharArrayReader; @@ -50,7 +51,7 @@ public class InspectionTestUtil { Element[] expectedArray = expectedProblems.toArray(new Element[expectedProblems.size()]); boolean failed = false; -expected: + expected: for (Element expectedProblem : expectedArray) { Element[] reportedArrayed = reportedProblems.toArray(new Element[reportedProblems.size()]); for (Element reportedProblem : reportedArrayed) { @@ -62,13 +63,13 @@ expected: } Document missing = new Document(expectedProblem.clone()); - System.out.println("The following haven't been reported as expected: " + new String(JDOMUtil.printDocument(missing, "\n"))); + System.out.println("The following haven't been reported as expected: " + JDOMUtil.writeDocument(missing, "\n")); failed = true; } for (Element reportedProblem : reportedProblems) { Document extra = new Document(reportedProblem.clone()); - System.out.println("The following has been unexpectedly reported: " + new String(JDOMUtil.printDocument(extra, "\n"))); + System.out.println("The following has been unexpectedly reported: " + JDOMUtil.writeDocument(extra, "\n")); failed = true; } @@ -136,23 +137,32 @@ expected: public static void compareToolResults(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionToolWrapper toolWrapper, boolean checkRange, - String testDir) { + @NotNull String testDir) { + compareToolResults(context, checkRange, testDir, Collections.singletonList(toolWrapper)); + } + + static void compareToolResults(@NotNull GlobalInspectionContextImpl context, + boolean checkRange, + @NotNull String testDir, + @NotNull Collection toolWrappers) { final Element root = new Element("problems"); - final Document doc = new Document(root); - InspectionToolPresentation presentation = context.getPresentation(toolWrapper); - presentation.updateContent(); //e.g. dead code need check for reachables - presentation.exportResults(root, x -> false, x -> false); + for (InspectionToolWrapper toolWrapper : toolWrappers) { + InspectionToolPresentation presentation = context.getPresentation(toolWrapper); + presentation.updateContent(); //e.g. dead code need check for reachables + presentation.exportResults(root, x -> false, x -> false); + } - File file = new File(testDir + "/expected.xml"); try { - compareWithExpected(JDOMUtil.loadDocument(file), doc, checkRange); + File file = new File(testDir + "/expected.xml"); + compareWithExpected(JDOMUtil.loadDocument(file), new Document(root), checkRange); } catch (Exception e) { throw new RuntimeException(e); } } + @TestOnly public static void runTool(@NotNull InspectionToolWrapper toolWrapper, @NotNull final AnalysisScope scope, @NotNull final GlobalInspectionContextForTests globalContext) { diff --git a/plugins/java-i18n/java-i18n.iml b/plugins/java-i18n/java-i18n.iml index 6cc212d8a002..f15c227ff827 100644 --- a/plugins/java-i18n/java-i18n.iml +++ b/plugins/java-i18n/java-i18n.iml @@ -22,5 +22,6 @@ + \ No newline at end of file diff --git a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java index dd0a1ac39fa1..d3ba5134c57c 100644 --- a/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java +++ b/plugins/java-i18n/testSrc/com/intellij/codeInspection/i18n/I18NInspectionTest.java @@ -3,11 +3,14 @@ */ package com.intellij.codeInspection.i18n; +import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.openapi.application.PluginPathManager; import com.intellij.openapi.roots.LanguageLevelProjectExtension; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.JavaPsiFacade; import com.intellij.testFramework.InspectionTestCase; +import com.intellij.testFramework.InspectionsKt; +import com.intellij.uiDesigner.i18n.I18nFormInspection; /** * @author lesya @@ -40,7 +43,12 @@ public class I18NInspectionTest extends InspectionTestCase { } } - public void testFormTabbedPaneTitle() throws Exception { doTest(); } + public void testFormTabbedPaneTitle() throws Exception { + LocalInspectionToolWrapper wrapper = new LocalInspectionToolWrapper(new I18nFormInspection()); + InspectionsKt.enableInspectionTool(getProject(), wrapper, getTestRootDisposable()); + doTest("i18n/" + getTestName(true), new LocalInspectionToolWrapper(new I18nInspection()), "java 1.4", false, false, + wrapper); + } public void testVarargNonNlsParameter() throws Exception { doTest(); } public void testInitializerInAnonymousClass() throws Exception{ doTest(); } public void testNonNlsArray() throws Exception{ doTest(); } diff --git a/plugins/ui-designer/src/META-INF/plugin.xml b/plugins/ui-designer/src/META-INF/plugin.xml index b9067a72b01e..552c196a10ac 100644 --- a/plugins/ui-designer/src/META-INF/plugin.xml +++ b/plugins/ui-designer/src/META-INF/plugin.xml @@ -32,10 +32,6 @@ - - - - @@ -46,22 +42,22 @@ - - - - - - Date: Mon, 27 Feb 2017 15:16:53 +0300 Subject: [PATCH 18/20] inherit language for the local inspection from the corresponding global one to prevent them running on unrelated files --- .../codeInspection/ex/GlobalInspectionToolWrapper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java index ad448ad6a8d7..ee0cc713bd5c 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionToolWrapper.java @@ -91,6 +91,12 @@ public class GlobalInspectionToolWrapper extends InspectionToolWrapper - - - - -