Java Code Examples for com.intellij.lang.Language.equals()

The following are Jave code examples for showing how to use equals() of the com.intellij.lang.Language class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: intellij-ce-playground   File: SubstitutedFileType.java   Source Code and License Vote up 6 votes
@NotNull
public static FileType substituteFileType(@NotNull VirtualFile file, @NotNull FileType fileType, Project project) {
  if (project == null) {
    return fileType;
  }
  if (fileType instanceof LanguageFileType) {
    final Language language = ((LanguageFileType)fileType).getLanguage();
    final Language substitutedLanguage = LanguageSubstitutors.INSTANCE.substituteLanguage(language, file, project);
    LanguageFileType substFileType = substitutedLanguage.getAssociatedFileType();
    if (!substitutedLanguage.equals(language) && substFileType != null) {
      return new SubstitutedFileType(fileType, substFileType, substitutedLanguage);
    }
  }

  return fileType;
}
 
Example 2
Project: intellij-ce-playground   File: FormattingDocumentModelImpl.java   Source Code and License Vote up 6 votes
@Override
public boolean containsWhiteSpaceSymbolsOnly(int startOffset, int endOffset) {
  WhiteSpaceFormattingStrategy strategy = myWhiteSpaceStrategy;
  if (strategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset) {
    return true;
  }
  PsiElement injectedElement = myFile != null ? InjectedLanguageUtil.findElementAtNoCommit(myFile, startOffset) : null;
  if (injectedElement != null) {
    Language injectedLanguage = injectedElement.getLanguage();
    if (!injectedLanguage.equals(myFile.getLanguage())) {
      WhiteSpaceFormattingStrategy localStrategy = WhiteSpaceFormattingStrategyFactory.getStrategy(injectedLanguage);
      if (localStrategy != null) {
        return localStrategy.check(myDocument.getCharsSequence(), startOffset, endOffset) >= endOffset;
      }
    }
  }
  return false;
}
 
Example 3
Project: intellij-ce-playground   File: AntLikePropertySelectionHandler.java   Source Code and License Vote up 5 votes
@Override
public boolean canSelect(PsiElement e) {
  Language l = e.getLanguage();
  if (!(l.equals(JavaLanguage.INSTANCE)
        || l.equals(StdLanguages.XML)
        || l.equals(StdLanguages.ANT))) {
    return false;
  }

  return PsiTreeUtil.getParentOfType(e, PsiComment.class) == null;
}
 
Example 4
Project: intellij-ce-playground   File: ExtractIncludeFileBase.java   Source Code and License Vote up 5 votes
@Nullable
private static FileType getFileType(final Language language) {
  final FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes();
  for (FileType fileType : fileTypes) {
    if (fileType instanceof LanguageFileType && language.equals(((LanguageFileType)fileType).getLanguage())) return fileType;
  }

  return null;
}
 
Example 5
Project: intellij-ce-playground   File: TypeCookAction.java   Source Code and License Vote up 4 votes
public boolean isAvailableForLanguage(Language language) {
  return language.equals(JavaLanguage.INSTANCE);
}
 
Example 6
Project: intellij-ce-playground   File: JavaInlineActionHandler.java   Source Code and License Vote up 4 votes
@Override
public boolean isEnabledForLanguage(Language l) {
  return l instanceof JavaLanguage ||
         l.equals(StdFileTypes.JSPX.getLanguage()) ||
         l.equals(StdFileTypes.JSP.getLanguage());
}