/*
 * Copyright 2000-2013 JetBrains s.r.o.
 * Copyright 2014-2014 AS3Boyan
 * Copyright 2014-2014 Elias Ku
 *
 * 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.plugins.haxe.lang.parser;

import com.intellij.lang.LanguageASTFactory;
import com.intellij.plugins.haxe.HaxeFileType;
import com.intellij.plugins.haxe.HaxeLanguage;
import com.intellij.plugins.haxe.util.HaxeTestUtils;
import com.intellij.testFramework.ParsingTestCase;

abstract public class HaxeParsingTestBase extends ParsingTestCase {
  public HaxeParsingTestBase(String... path) {
    super(getPath(path), HaxeFileType.DEFAULT_EXTENSION, new HaxeParserDefinition());
  }

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    addExplicitExtension(LanguageASTFactory.INSTANCE, HaxeLanguage.INSTANCE, new HaxeAstFactory());
  }

  private static String getPath(String... args) {
    final StringBuilder result = new StringBuilder();
    for (String folder : args) {
      if (result.length() > 0) {
        result.append("/");
      }
      result.append(folder);
    }
    return result.toString();
  }

  @Override
  protected String getTestDataPath() {
    return HaxeTestUtils.BASE_TEST_DATA_PATH;
  }

  @Override
  protected boolean skipSpaces() {
    return true;
  }
}

@@ -100,16 +100,47 @@
 lias Ku%0A
+ * Copyright 2019 Eric Bishton%0A
  *%0A * Li
@@ -806,567 +806,1912 @@
 lij.
-plugins.haxe.HaxeFileType;%0Aimport com.intellij.plugins.haxe.HaxeLanguage;%0Aimport com.intellij.plugins.haxe.util.HaxeTestUtils;%0Aimport com.intellij.testFramework.ParsingTestCase;%0A%0Aabstract public class HaxeParsingTestBase extends ParsingTestCase %7B%0A  public HaxeParsingTestBase(String... path) %7B%0A    super(getPath(path), HaxeFileType.DEFAULT_EXTENSION, new HaxeParserDefinition());%0A  %7D%0A%0A  @Override%0A  protected void setUp() throws Exception %7B%0A    super.setUp();%0A    addExplicitExtension(LanguageASTFactory.INSTANCE, HaxeLanguage.INSTANCE, new HaxeAstFactory());
+lang.injection.InjectedLanguageManager;%0Aimport com.intellij.lang.injection.MultiHostInjector;%0Aimport com.intellij.lang.injection.MultiHostRegistrar;%0Aimport com.intellij.mock.MockDumbService;%0Aimport com.intellij.openapi.extensions.Extensions;%0Aimport com.intellij.plugins.haxe.HaxeFileType;%0Aimport com.intellij.plugins.haxe.HaxeLanguage;%0Aimport com.intellij.plugins.haxe.lang.RegexLanguageInjector;%0Aimport com.intellij.plugins.haxe.util.HaxeTestUtils;%0Aimport com.intellij.psi.LanguageInjector;%0Aimport com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl;%0Aimport com.intellij.testFramework.ParsingTestCase;%0Aimport org.assertj.core.util.Lists;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport java.util.List;%0A%0Aabstract public class HaxeParsingTestBase extends ParsingTestCase %7B%0A  public HaxeParsingTestBase(String... path) %7B%0A    super(getPath(path), HaxeFileType.DEFAULT_EXTENSION, new HaxeParserDefinition());%0A  %7D%0A%0A  @Override%0A  protected void setUp() throws Exception %7B%0A    super.setUp();%0A    addExplicitExtension(LanguageASTFactory.INSTANCE, HaxeLanguage.INSTANCE, new HaxeAstFactory());%0A%0A    // Work around @NotNull bug down in the test fixture.  Since no InjectedLanguageManager%0A    // was registered, null was passed to a @NotNull function.  This affected testSimple().%0A    registerExtensionPoint(Extensions.getArea(myProject), MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME, MockMultiHostInjector.class);%0A    registerExtensionPoint(Extensions.getArea(null), LanguageInjector.EXTENSION_POINT_NAME, RegexLanguageInjector.class); // Might as well use the real one.%0A    InjectedLanguageManagerImpl manager = new InjectedLanguageManagerImpl(myProject,%0A                                                                           new MockDumbService(myProject));%0A    myProject.registerService(InjectedLanguageManager.class, manager);%0A    // End workaround.
 %0A  %7D
@@ -3157,11 +3157,363 @@
 rue;%0A  %7D
+%0A%0A  public static class MockMultiHostInjector implements MultiHostInjector %7B%0A    @Override%0A    public void getLanguagesToInject(@NotNull MultiHostRegistrar registrar, @NotNull PsiElement context) %7B%0A%0A    %7D%0A%0A    @NotNull%0A    @Override%0A    public List%3C? extends Class%3C? extends PsiElement%3E%3E elementsToInjectIn() %7B%0A      return Lists.emptyList();%0A    %7D%0A  %7D
 %0A%7D%0A

Work around @NotNull test framework bug that was checking for an unregistered (and unneeded) InjectedLanguageManager service. The fix was to instantiate the service for the test.