Problem 17716. another Throwable: PsiImplUtil.getParameterIndex
[fedora-idea.git] / plugins / IntelliLang / src / org / intellij / plugins / intelliLang / inject / TemporaryPlacesInjector.java
blobda038de69acbbac43f8d0a5939afddb88f6f35d5
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.intellij.plugins.intelliLang.inject;
19 import com.intellij.lang.injection.MultiHostInjector;
20 import com.intellij.lang.injection.MultiHostRegistrar;
21 import com.intellij.openapi.util.Trinity;
22 import com.intellij.psi.ElementManipulators;
23 import com.intellij.psi.PsiElement;
24 import com.intellij.psi.PsiLanguageInjectionHost;
25 import com.intellij.psi.util.PsiUtilBase;
26 import org.jetbrains.annotations.NotNull;
28 import java.util.Collections;
29 import java.util.List;
31 /**
32 * @author Gregory.Shrago
34 public class TemporaryPlacesInjector implements MultiHostInjector {
36 @NotNull
37 public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
38 return Collections.singletonList(PsiLanguageInjectionHost.class);
41 public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
42 final PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
43 final PsiLanguageInjectionHost originalHost = PsiUtilBase.getOriginalElement(host, host.getClass());
44 final List<TemporaryPlacesRegistry.TemporaryPlace> list = TemporaryPlacesRegistry.getInstance(context.getProject()).getTempInjectionsSafe(originalHost);
45 for (final TemporaryPlacesRegistry.TemporaryPlace pair : list) {
46 InjectorUtils.registerInjection(pair.language.getLanguage(), Collections.singletonList(
47 Trinity.create(host, pair.language, ElementManipulators.getManipulator(host).getRangeInElement(host))), context.getContainingFile(),
48 registrar);