Java 类com.intellij.lang.DependentLanguage 实例源码

项目:intellij-ce-playground    文件:BaseMoveHandler.java   
@Nullable
private static PsiFile getRoot(final PsiFile file, final Editor editor) {
  if (file == null) return null;
  int offset = editor.getCaretModel().getOffset();
  if (offset == editor.getDocument().getTextLength()) offset--;
  if (offset<0) return null;
  PsiElement leafElement = file.findElementAt(offset);
  if (leafElement == null) return null;
  if (leafElement.getLanguage() instanceof DependentLanguage) {
    leafElement = file.getViewProvider().findElementAt(offset, file.getViewProvider().getBaseLanguage());
    if (leafElement == null) return null;
  }
  ASTNode node = leafElement.getNode();
  if (node == null) return null;
  return (PsiFile)PsiUtilBase.getRoot(node).getPsi();
}
项目:intellij-ce-playground    文件:LanguageResolvingUtil.java   
private static List<LanguageDefinition> collectLibraryLanguages(final ConvertContext context,
                                                                final Collection<PsiClass> allLanguages) {
  return ContainerUtil.mapNotNull(Language.getRegisteredLanguages(), new NullableFunction<Language, LanguageDefinition>() {
    @Override
    public LanguageDefinition fun(Language language) {
      if (language.getID().isEmpty() ||
          language instanceof DependentLanguage) {
        return null;
      }
      final PsiClass psiClass = DomJavaUtil.findClass(language.getClass().getName(), context.getInvocationElement());
      if (psiClass == null) {
        return null;
      }

      if (!allLanguages.contains(psiClass)) {
        return null;
      }

      final LanguageFileType type = language.getAssociatedFileType();
      final Icon icon = type != null ? type.getIcon() : null;
      return new LanguageDefinition(language.getID(),
                                    psiClass,
                                    icon, language.getDisplayName());
    }
  });
}
项目:tools-idea    文件:BaseMoveHandler.java   
@Nullable
private static PsiFile getRoot(final PsiFile file, final Editor editor) {
  if (file == null) return null;
  int offset = editor.getCaretModel().getOffset();
  if (offset == editor.getDocument().getTextLength()) offset--;
  if (offset<0) return null;
  PsiElement leafElement = file.findElementAt(offset);
  if (leafElement == null) return null;
  if (leafElement.getLanguage() instanceof DependentLanguage) {
    leafElement = file.getViewProvider().findElementAt(offset, file.getViewProvider().getBaseLanguage());
    if (leafElement == null) return null;
  }
  ASTNode node = leafElement.getNode();
  if (node == null) return null;
  return (PsiFile)PsiUtilBase.getRoot(node).getPsi();
}
项目:consulo    文件:BaseMoveHandler.java   
@Nullable
private static PsiFile getRoot(final PsiFile file, final Editor editor) {
  if (file == null) return null;
  int offset = editor.getCaretModel().getOffset();
  if (offset == editor.getDocument().getTextLength()) offset--;
  if (offset<0) return null;
  PsiElement leafElement = file.findElementAt(offset);
  if (leafElement == null) return null;
  if (leafElement.getLanguage() instanceof DependentLanguage) {
    leafElement = file.getViewProvider().findElementAt(offset, file.getViewProvider().getBaseLanguage());
    if (leafElement == null) return null;
  }
  ASTNode node = leafElement.getNode();
  if (node == null) return null;
  return (PsiFile)PsiUtilBase.getRoot(node).getPsi();
}
项目:intellij-ce-playground    文件:TemplateDataLanguageMappings.java   
public static List<Language> getTemplateableLanguages() {
  return ContainerUtil.findAll(Language.getRegisteredLanguages(), new Condition<Language>() {
    @Override
    public boolean value(final Language language) {
      if (language == Language.ANY) return false;
      if (language instanceof TemplateLanguage || language instanceof DependentLanguage || language instanceof InjectableLanguage) return false;
      if (language.getBaseLanguage() != null) return value(language.getBaseLanguage());
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:ChooseByNameLanguageFilter.java   
@NotNull
@Override
protected Collection<Language> getAllFilterValues() {
  final Collection<Language> registeredLanguages = Language.getRegisteredLanguages();
  List<Language> accepted = new ArrayList<Language>();
  for (Language language : registeredLanguages) {
    if (language != Language.ANY && !(language instanceof DependentLanguage)) {
      accepted.add(language);
    }
  }
  Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR);
  return accepted;
}
项目:tools-idea    文件:TemplateDataLanguageMappings.java   
public static List<Language> getTemplateableLanguages() {
  return ContainerUtil.findAll(Language.getRegisteredLanguages(), new Condition<Language>() {
    @Override
    public boolean value(final Language language) {
      if (language == Language.ANY) return false;
      if (language instanceof TemplateLanguage || language instanceof DependentLanguage || language instanceof InjectableLanguage) return false;
      if (language.getBaseLanguage() != null) return value(language.getBaseLanguage());
      return true;
    }
  });
}
项目:tools-idea    文件:ChooseByNameLanguageFilter.java   
@NotNull
@Override
protected Collection<Language> getAllFilterValues() {
  final Collection<Language> registeredLanguages = Language.getRegisteredLanguages();
  List<Language> accepted = new ArrayList<Language>();
  for (Language language : registeredLanguages) {
    if (language != Language.ANY && !(language instanceof DependentLanguage)) {
      accepted.add(language);
    }
  }
  Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR);
  return accepted;
}
项目:consulo    文件:TemplateDataLanguageMappings.java   
public static List<Language> getTemplateableLanguages() {
  return ContainerUtil.findAll(Language.getRegisteredLanguages(), new Condition<Language>() {
    @Override
    public boolean value(final Language language) {
      if (language == Language.ANY) return false;
      if (language instanceof TemplateLanguage || language instanceof DependentLanguage || language instanceof InjectableLanguage) return false;
      if (language.getBaseLanguage() != null) return value(language.getBaseLanguage());
      return true;
    }
  });
}
项目:consulo    文件:ChooseByNameLanguageFilter.java   
@Nonnull
@Override
protected Collection<Language> getAllFilterValues() {
  final Collection<Language> registeredLanguages = Language.getRegisteredLanguages();
  List<Language> accepted = new ArrayList<Language>();
  for (Language language : registeredLanguages) {
    if (language != Language.ANY && !(language instanceof DependentLanguage)) {
      accepted.add(language);
    }
  }
  Collections.sort(accepted, LanguageUtil.LANGUAGE_COMPARATOR);
  return accepted;
}