package com.siyeh.ig.style;

import com.intellij.codeInspection.InspectionProfileEntry;
import com.intellij.testFramework.LightProjectDescriptor;
import com.siyeh.ig.LightInspectionTestCase;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class StringBufferReplaceableByStringInspectionTest extends LightInspectionTestCase {

  public void testStringBufferReplaceableByString() {
    doTest();
  }

  @NotNull
  @Override
  protected LightProjectDescriptor getProjectDescriptor() {
    return JAVA_8;
  }

  @Nullable
  @Override
  protected InspectionProfileEntry getInspection() {
    return new StringBufferReplaceableByStringInspection();
  }
}
@@ -1,88 +1,320 @@
-package com.siyeh.ig.style;%0A%0Aimport com.intellij.codeInspection.InspectionProfileEnt
+// Copyright 2000-2019 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.%0Apackage com.siyeh.ig.style;%0A%0Aimport com.intellij.codeInspection.InspectionProfileEntry;%0Aimport com.intellij.psi.JavaCodeFragment;%0Aimport com.intellij.psi.JavaCodeFragmentFacto
 ry;%0A
@@ -665,24 +665,558 @@
 est();%0A  %7D%0A%0A
+  public void testFragment() %7B%0A    String text = %22StringBuilder %3Cwarning descr=%5C%22'StringBuilder sb' can be replaced with 'String'%5C%22%3Esb%3C/warning%3E = new StringBuilder();%5Cn%22 +%0A                  %22sb.append(%5C%22foo%5C%22);%5Cn%22 +%0A                  %22System.out.println(sb.toString());%22;%0A    JavaCodeFragment fragment = JavaCodeFragmentFactory.getInstance(getProject()).createCodeBlockCodeFragment(text, null, true);%0A    myFixture.configureFromExistingVirtualFile(fragment.getVirtualFile());%0A    myFixture.testHighlighting(true, false, false);%0A  %7D%0A%0A
   @NotNull%0A 

add fragment test