/*
 * 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.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.vcs.commit;

import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
import com.intellij.codeInspection.ex.InspectionToolWrapper;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

import static com.intellij.util.ObjectUtils.notNull;
import static com.intellij.util.containers.ContainerUtil.find;

public class CommitMessageSpellCheckingInspection extends BaseCommitMessageInspection {

  private static final Logger LOG = Logger.getInstance(CommitMessageSpellCheckingInspection.class);

  private static final LocalInspectionTool ourSpellCheckingInspection = createSpellCheckingInspection();

  @Nullable
  private static LocalInspectionTool createSpellCheckingInspection() {
    LocalInspectionTool result = null;
    List<InspectionToolWrapper> tools = InspectionToolRegistrar.getInstance().createTools();
    InspectionToolWrapper spellCheckingWrapper = find(tools, wrapper -> wrapper.getShortName().equals("SpellCheckingInspection"));

    if (spellCheckingWrapper == null) {
      LOG.error("Could not find default spell checking inspection");
    }
    else if (!(spellCheckingWrapper instanceof LocalInspectionToolWrapper)) {
      LOG.error("Found spell checking wrapper is not local " + spellCheckingWrapper);
    }
    else {
      result = ((LocalInspectionToolWrapper)spellCheckingWrapper).getTool();
    }

    return result;
  }


  @NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return ourSpellCheckingInspection != null
           ? ourSpellCheckingInspection.buildVisitor(holder, isOnTheFly)
           : super.buildVisitor(holder, isOnTheFly);
  }

  @Nls
  @NotNull
  @Override
  public String getDisplayName() {
    return "Spelling";
  }

  @NotNull
  @Override
  public HighlightDisplayLevel getDefaultLevel() {
    return notNull(HighlightDisplayLevel.find("TYPO"), HighlightDisplayLevel.WARNING);
  }

  @Override
  public boolean isEnabledByDefault() {
    return true;
  }
}
@@ -1028,24 +1028,82 @@
 tic.Logger;%0A
+import com.intellij.openapi.util.AtomicNullableLazyValue;%0A
 import com.i
@@ -1217,75 +1217,109 @@
 ll;%0A
+%0A
 import 
-org.jetbrains.annotations.Nullable;%0A%0Aimport java.util.List;%0A
+java.util.List;%0A%0Aimport static com.intellij.openapi.util.AtomicNullableLazyValue.createValue;
 %0Aimp
@@ -1649,120 +1649,32 @@
 nal 
-LocalInspectionTool ourSpellCheckingInspection = createSpellCheckingInspection();%0A%0A  @Nullable%0A  private static 
+AtomicNullableLazyValue%3C
 Loca
@@ -1692,15 +1692,13 @@
 Tool
- create
+%3E our
 Spel
@@ -1716,18 +1716,36 @@
 spection
-()
+ = createValue(() -%3E
  %7B%0A    L
@@ -2405,17 +2405,18 @@
 ult;%0A  %7D
-%0A
+);
 %0A%0A  @Not
@@ -2530,22 +2530,42 @@
 ) %7B%0A    
-return
+LocalInspectionTool tool =
  ourSpel
@@ -2587,56 +2587,52 @@
 tion
- != null%0A           ? ourSpellCheckingInspection
+.getValue();%0A%0A    return tool != null ? tool
 .bui
@@ -2664,19 +2664,8 @@
 Fly)
-%0A          
  : s

Fix "NoClassDefFoundError" for "CommitMessageSpellCheckingInspection"