/*
 * 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 org.jetbrains.idea.devkit.inspections;

import com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool;
import com.intellij.codeInspection.ProblemsHolder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.psi.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.devkit.module.PluginModuleType;
import org.jetbrains.idea.devkit.util.PsiUtil;

/**
 * @author yole
 */
public abstract class DevKitUastInspectionBase extends AbstractBaseUastLocalInspectionTool {

  @NotNull
  @Override
  public final PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return isAllowed(holder) ? buildInternalVisitor(holder, isOnTheFly) : PsiElementVisitor.EMPTY_VISITOR;
  }

  protected boolean isAllowed(ProblemsHolder holder) {
    if (PsiUtil.isIdeaProject(holder.getProject())) {
      return true;
    }

    Module module = ModuleUtilCore.findModuleForPsiElement(holder.getFile());
    if (PluginModuleType.isPluginModuleOrDependency(module)) {
      return true;
    }

    // always run in tests
    return ApplicationManager.getApplication().isUnitTestMode();
  }

  protected PsiElementVisitor buildInternalVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return super.buildVisitor(holder, isOnTheFly);
  }
}

@@ -1688,51 +1688,172 @@
 if (
-PluginModuleType.isPluginModuleOrDependency
+module == null) %7B%0A      return false;%0A    %7D%0A%0A    if (PluginModuleType.isPluginModuleOrDependency(module)) %7B%0A      return true;%0A    %7D%0A%0A    if (PsiUtil.isPluginModule
 (mod

align with DevKitInspectionBase changes