// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.lang.properties.propertyBased;

import com.intellij.lang.properties.PropertiesFileType;
import com.intellij.openapi.application.PathManager;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.SkipSlowTestLocally;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import com.intellij.testFramework.propertyBased.CheckHighlighterConsistency;
import com.intellij.testFramework.propertyBased.MadTestingAction;
import com.intellij.testFramework.propertyBased.MadTestingUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jetCheck.Generator;
import org.jetbrains.jetCheck.PropertyChecker;

import java.util.function.Function;
import java.util.function.Supplier;

@SkipSlowTestLocally
public class PropertiesCodeInsightSanityTest extends LightCodeInsightFixtureTestCase {

  public void testIncrementalHighlighterUpdate() {
    PropertyChecker.checkScenarios(actionsOnPropertiesFiles(CheckHighlighterConsistency.randomEditsWithHighlighterChecks));
  }

  public void testReparse() {
    PropertyChecker.checkScenarios(actionsOnPropertiesFiles(MadTestingUtil::randomEditsWithReparseChecks));
  }

  @NotNull
  private Supplier<MadTestingAction> actionsOnPropertiesFiles(Function<PsiFile, Generator<? extends MadTestingAction>> fileActions) {
    return MadTestingUtil.actionsOnFileContents(myFixture, PathManager.getHomePath(),
                                                f -> f.getName().endsWith(PropertiesFileType.DOT_DEFAULT_EXTENSION), fileActions);
  }
}

@@ -512,165 +512,9 @@
 sed.
-CheckHighlighterConsistency;%0Aimport com.intellij.testFramework.propertyBased.MadTestingAction;%0Aimport com.intellij.testFramework.propertyBased.MadTestingUtil
+*
 ;%0Aim
@@ -1147,16 +1147,1080 @@
 );%0A  %7D%0A%0A
+  public void testRandomActivity() %7B%0A    MadTestingUtil.enableAllInspections(getProject(), getTestRootDisposable());%0A    Function%3CPsiFile, Generator%3C? extends MadTestingAction%3E%3E fileActions =%0A      file -%3E Generator.sampledFrom(new InvokeIntention(file, new IntentionPolicy() %7B%0A                                      @Override%0A                                      protected boolean shouldSkipIntention(@NotNull String actionText) %7B%0A                                        return actionText.equals(%22Quote identifier%22) %7C%7C // todo IDEA-188706%0A                                               actionText.equals(%22Sort resource bundle files%22) %7C%7C // todo IDEA-194044%0A                                               actionText.startsWith(%22Suppress for%22); // todo IDEA-193419, IDEA-193420%0A                                      %7D%0A                                    %7D),%0A                                    new StripTestDataMarkup(file),%0A                                    new DeleteRange(file));%0A    PropertyChecker.checkScenarios(actionsOnPropertiesFiles(fileActions));%0A  %7D%0A%0A
   @NotNu
@@ -2494,16 +2494,75 @@
     f -%3E
+ %7B%0A                                                  return
  f.getNa
@@ -2616,16 +2616,204 @@
 TENSION)
+ &&%0A                                                         !%22CommentInjectorInProps.properties%22.equals(f.getName()); // todo IDEA-188706%0A                                                %7D
 , fileAc

add PropertiesCodeInsightSanityTest.testRandomActivity