Java 类com.intellij.psi.templateLanguages.TemplateDataLanguageMappings 实例源码

项目:bamboo-soy    文件:SoyLayeredHighlighter.java   
public SoyLayeredHighlighter(
    @Nullable Project project,
    @Nullable VirtualFile virtualFile,
    @NotNull EditorColorsScheme colors) {
  // Creating main highlighter.
  super(new SoySyntaxHighlighter(), colors);

  // Highlighter for the outer language.
  FileType type = null;
  if (project == null || virtualFile == null) {
    type = StdFileTypes.PLAIN_TEXT;
  } else {
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    if (language != null) type = language.getAssociatedFileType();
    if (type == null) type = SoyLanguage.getDefaultTemplateLang();
  }

  SyntaxHighlighter outerHighlighter =
      SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);

  registerLayer(OTHER, new LayerDescriptor(outerHighlighter, ""));
}
项目:rythm_plugin    文件:RythmFileType.java   
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = RythmLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:GoJetPlugin    文件:JetFileType.java   
private static LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = JetLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:GoJetPlugin    文件:JetLayeredSyntaxHighlighter.java   
public JetLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) {
    super(new JetSyntaxHighlighter(), scheme);

    // highlighter for outer ide
    FileType type = null;
    if (project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if (language != null) type = language.getAssociatedFileType();
        if (type == null) type = JetLanguage.getDefaultTemplateLang();
    }

    SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
    registerLayer(TEXT, new LayerDescriptor(outerHighlighter, ""));
}
项目:idea-doT    文件:DotTemplateHighlighter.java   
public DotTemplateHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) {
    // create main highlighter
    super(new DotHighlighter(), colors);

    // highlighter for outer lang
    FileType type = null;
    if(project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if(language != null) type = language.getAssociatedFileType();
        if(type == null) type = DotLanguage.getDefaultTemplateLang();
    }
    @SuppressWarnings ("deprecation") // deprecated in IDEA 12, still needed in IDEA 11 TODO remove when IDEA 11 support is dropped
            SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type, project, virtualFile);

    registerLayer(DotTokenTypes.CONTENT, new LayerDescriptor(outerHighlighter, ""));
}
项目:idea-doT    文件:DotFileType.java   
private LanguageFileType getAssociatedFileType(VirtualFile file, Project project) {
    if (project == null) {
        return null;
    }
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(file);

    LanguageFileType associatedFileType = null;
    if (language != null) {
        associatedFileType = language.getAssociatedFileType();
    }

    if (language == null || associatedFileType == null) {
        associatedFileType = DotLanguage.getDefaultTemplateLang();
    }
    return associatedFileType;
}
项目:Intellij-Dust    文件:DustLayeredSyntaxHighlighter.java   
public DustLayeredSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile, @NotNull EditorColorsScheme colors) {
  // create main highlighter
  super(new DustSyntaxHighlighter(), colors);

  // highlighter for outer lang
  FileType type = null;
  if(project == null || virtualFile == null) {
    type = StdFileTypes.PLAIN_TEXT;
  } else {
    Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    if(language != null) type = language.getAssociatedFileType();
    if(type == null) type = StdFileTypes.HTML;
  }
  SyntaxHighlighter outerHighlighter = SyntaxHighlighter.PROVIDER.create(type, project, virtualFile);

  registerLayer(DustTypes.HTML, new LayerDescriptor(outerHighlighter, ""));
}
项目:rythm_plugin    文件:RythmLayeredSyntaxHighlighter.java   
public RythmLayeredSyntaxHighlighter(Project project, EditorColorsScheme scheme, FileType ptype, VirtualFile virtualFile) {
    super(new RythmSyntaxHighlighter(), scheme);

    FileType type = null;

    //Test for Java implementation
    FileType type1 = null;

    if (project == null || virtualFile == null) {
        type = StdFileTypes.PLAIN_TEXT;
    } else {
        Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
        if (language != null) type = language.getAssociatedFileType();
        if (type == null) {
            type = RythmLanguage.getDefaultTemplateLang();

            //Test for Java implementation
            //type1 = RythmLanguage.getLanguage();
        }

    }

    SyntaxHighlighter outerHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type, project, virtualFile);
    registerLayer(TEXT, new LayerDescriptor(outerHighlighter, ""));


    //Test for Java implementation
   /* SyntaxHighlighter middleHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(type1, project, virtualFile);
    registerLayer(TEXT, new LayerDescriptor(middleHighlighter, ""));
   */

}
项目:GoJetPlugin    文件:JetFileViewProvider.java   
public JetFileViewProvider(PsiManager manager, VirtualFile file, boolean physical) {
    super(manager, file, physical);

    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if (dataLang == null) dataLang = StdFileTypes.HTML.getLanguage();

    if (dataLang instanceof TemplateLanguage) {
        myTemplateDataLanguage = PlainTextLanguage.INSTANCE;
    } else {
        myTemplateDataLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());
    }
}
项目:intellij-ce-playground    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) {
  myPatternField.setText(initialPatterns);

  if (fileType instanceof TemplateLanguageFileType) {
    final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel();
    model.addElement(null);
    final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
    Collections.sort(languages, new Comparator<Language>() {
      @Override
      public int compare(final Language o1, final Language o2) {
        return o1.getID().compareTo(o2.getID());
      }
    });
    for (Language language : languages) {
      model.addElement(language);
    }
    myLanguageCombo.setRenderer(new ListCellRendererWrapper() {
      @Override
      public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getDisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:tools-idea    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) {
  myPatternField.setText(initialPatterns);

  if (fileType instanceof TemplateLanguageFileType) {
    final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel();
    model.addElement(null);
    final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
    Collections.sort(languages, new Comparator<Language>() {
      @Override
      public int compare(final Language o1, final Language o2) {
        return o1.getID().compareTo(o2.getID());
      }
    });
    for (Language language : languages) {
      model.addElement(language);
    }
    myLanguageCombo.setRenderer(new ListCellRendererWrapper() {
      @Override
      public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getDisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:idea-doT    文件:DotFileViewProvider.java   
private Language getTemplateDataLanguage(PsiManager manager, VirtualFile file) {
    Language dataLang = TemplateDataLanguageMappings.getInstance(manager.getProject()).getMapping(file);
    if(dataLang == null) {
        dataLang = DotLanguage.getDefaultTemplateLang().getLanguage();
    }

    Language substituteLang = LanguageSubstitutors.INSTANCE.substituteLanguage(dataLang, file, manager.getProject());

    // only use a substituted language if it's templateable
    if (TemplateDataLanguageMappings.getTemplateableLanguages().contains(substituteLang)) {
        dataLang = substituteLang;
    }

    return dataLang;
}
项目:consulo    文件:FileTypePatternDialog.java   
public FileTypePatternDialog(@Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) {
  myPatternField.setText(initialPatterns);

  if (fileType instanceof TemplateLanguageFileType) {
    final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel();
    model.addElement(null);
    final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages();
    Collections.sort(languages, new Comparator<Language>() {
      @Override
      public int compare(final Language o1, final Language o2) {
        return o1.getID().compareTo(o2.getID());
      }
    });
    for (Language language : languages) {
      model.addElement(language);
    }
    myLanguageCombo.setRenderer(new ListCellRendererWrapper() {
      @Override
      public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
        setText(value == null ? "" : ((Language) value).getDisplayName());
        if (value != null) {
          final FileType type = ((Language)value).getAssociatedFileType();
          if (type != null) {
            setIcon(type.getIcon());
          }
        }
      }
    });
    myLanguageCombo.setSelectedItem(templateDataLanguage);
  } else {
    myLanguageCombo.setVisible(false);
    myTemplateDataLanguageButton.setVisible(false);
  }
}
项目:consulo    文件:LightPlatformTestCase.java   
public static void doTearDown(@Nonnull final Project project, ApplicationStarter application, boolean checkForEditors) throws Exception {
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  checkAllTimersAreDisposed();
  UsefulTestCase.doPostponedFormatting(project);

  LookupManager lookupManager = LookupManager.getInstance(project);
  if (lookupManager != null) {
    lookupManager.hideActiveLookup();
  }
  ((StartupManagerImpl)StartupManager.getInstance(project)).prepareForNextTest();
  InspectionProfileManager.getInstance().deleteProfile(PROFILE);
  assertNotNull("Application components damaged", ProjectManager.getInstance());

  new WriteCommandAction.Simple(project) {
    @Override
    @RequiredWriteAction
    protected void run() throws Throwable {
      if (ourSourceRoot != null) {
        try {
          final VirtualFile[] children = ourSourceRoot.getChildren();
          for (VirtualFile child : children) {
            child.delete(this);
          }
        }
        catch (IOException e) {
          //noinspection CallToPrintStackTrace
          e.printStackTrace();
        }
      }
      EncodingManager encodingManager = EncodingManager.getInstance();
      if (encodingManager instanceof EncodingManagerImpl) ((EncodingManagerImpl)encodingManager).clearDocumentQueue();

      FileDocumentManager manager = FileDocumentManager.getInstance();

      ApplicationManager.getApplication().runWriteAction(EmptyRunnable.getInstance()); // Flush postponed formatting if any.
      manager.saveAllDocuments();
      if (manager instanceof FileDocumentManagerImpl) {
        ((FileDocumentManagerImpl)manager).dropAllUnsavedDocuments();
      }
    }
  }.execute().throwException();

  assertFalse(PsiManager.getInstance(project).isDisposed());
  if (!ourAssertionsInTestDetected) {
    if (IdeaLogger.ourErrorsOccurred != null) {
      throw IdeaLogger.ourErrorsOccurred;
    }
  }
  PsiDocumentManagerImpl documentManager = clearUncommittedDocuments(project);
  ((HintManagerImpl)HintManager.getInstance()).cleanup();

  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      ((UndoManagerImpl)UndoManager.getGlobalInstance()).dropHistoryInTests();
      ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

      UIUtil.dispatchAllInvocationEvents();
    }
  });

  TemplateDataLanguageMappings.getInstance(project).cleanupForNextTest();

  ProjectManagerEx.getInstanceEx().closeTestProject(project);
  //application.setDataProvider(null);
  ourTestCase = null;
  ((PsiManagerImpl)PsiManager.getInstance(project)).cleanupForNextTest();

  CompletionProgressIndicator.cleanupForNextTest();

  if (checkForEditors) {
    checkEditorsReleased();
  }
  if (isLight(project)) {
    // mark temporarily as disposed so that rogue component trying to access it will fail
    ((ProjectImpl)project).setTemporarilyDisposed(true);
    documentManager.clearUncommittedDocuments();
  }
}
项目:consulo-apache-velocity    文件:VtlFileViewProvider.java   
@NotNull
static Language getTemplateDataLanguage(@NotNull VirtualFile virtualFile, @NotNull Project project) {
    final Language language = TemplateDataLanguageMappings.getInstance(project).getMapping(virtualFile);
    return language == null ? getTemplateDataLanguageByExtention(virtualFile) : language;
}
项目:consulo-apache-velocity    文件:Util.java   
static void mapTemplateDataLanguageFor(PsiFile file, Language dataLanguage) {
    TemplateDataLanguageMappings mappings = TemplateDataLanguageMappings.getInstance(file.getProject());
    mappings.setMapping(file.getViewProvider().getVirtualFile(), dataLanguage);
    Assert.assertSame(dataLanguage, mappings.getMapping(file.getViewProvider().getVirtualFile()));
}