// 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.
package com.intellij.sh.run;

import com.intellij.execution.lineMarker.RunLineMarkerContributor;
import com.intellij.icons.AllIcons;
import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.sh.ShBundle;
import com.intellij.sh.psi.ShFile;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ShRunLineMarkerContributor extends RunLineMarkerContributor implements DumbAware {
  @Nullable
  @Override
  public Info getInfo(@NotNull PsiElement element) {
    if (!(element instanceof LeafElement) || element.getTextRange().getStartOffset() != 0) return null;
    PsiFile psiFile = element.getContainingFile();
    if (!(psiFile instanceof ShFile) && !element.getText().startsWith("#!")) return null;
    InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(element.getProject());
    if (injectedLanguageManager.isInjectedFragment(psiFile)) return null;

    AnAction[] actions = {ActionManager.getInstance().getAction(ShRunFileAction.ID)};
    return new Info(AllIcons.RunConfigurations.TestState.Run, actions,
        psiElement -> StringUtil.join(ContainerUtil.mapNotNull(actions, action -> ShBundle
          .message("line.marker.run.0", psiElement.getContainingFile().getName())), "\n"));
  }
}

@@ -646,32 +646,100 @@
 ee.LeafElement;%0A
+import com.intellij.psi.templateLanguages.OuterLanguageElementImpl;%0A
 import com.intel
@@ -1108,16 +1108,63 @@
     if (
+element instanceof OuterLanguageElementImpl %7C%7C 
 !(elemen
@@ -1187,16 +1187,17 @@
 fElement
+ 
 ) %7C%7C ele
@@ -1238,16 +1238,22 @@
 () != 0)
+%0A     
  return 

Fix Shell run marker creating for the first cell in Zeppelin notes.