Java Code Examples for com.intellij.lang.Language.ANY

The following are Jave code examples for showing how to use ANY 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: IElementType.java   Source Code and License Vote up 6 votes
protected IElementType(@NotNull @NonNls String debugName, @Nullable Language language, boolean register) {
  myDebugName = debugName;
  myLanguage = language == null ? Language.ANY : language;
  if (register) {
    synchronized (lock) {
      myIndex = size++;
      LOG.assertTrue(myIndex < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range.");
      IElementType[] newRegistry =
        myIndex >= ourRegistry.length ? ArrayUtil.realloc(ourRegistry, ourRegistry.length * 3 / 2 + 1, FACTORY) : ourRegistry;
      newRegistry[myIndex] = this;
      ourRegistry = newRegistry;
    }
  }
  else {
    myIndex = -1;
  }
}
 
Example 2
Project: intellij-ce-playground   File: SingleRootFileViewProvider.java   Source Code and License Vote up 6 votes
private static Language calcBaseLanguage(@NotNull VirtualFile file, @NotNull Project project, @NotNull final FileType fileType) {
  if (file instanceof LightVirtualFile) {
    final Language language = ((LightVirtualFile)file).getLanguage();
    if (language != null) {
      return language;
    }
  }

  if (fileType.isBinary()) return Language.ANY;
  if (isTooLargeForIntelligence(file)) return PlainTextLanguage.INSTANCE;

  if (fileType instanceof LanguageFileType) {
    return LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, project);
  }

  return PlainTextLanguage.INSTANCE;
}
 
Example 3
Project: intellij-ce-playground   File: PsiReferenceRegistrarImpl.java   Source Code and License Vote up 6 votes
public PsiReferenceRegistrarImpl(final Language language) {
  myBindingCache = new ConcurrentFactoryMap<Class, ProviderBinding[]>() {
    @Nullable
    @Override
    protected ProviderBinding[] create(Class key) {
      List<ProviderBinding> result = ContainerUtil.newSmartList();
      for (Class<?> bindingClass : myBindingsMap.keySet()) {
        if (bindingClass.isAssignableFrom(key)) {
          result.add(myBindingsMap.get(bindingClass));
        }
      }
      for (Class<?> bindingClass : myNamedBindingsMap.keySet()) {
        if (bindingClass.isAssignableFrom(key)) {
          result.add(myNamedBindingsMap.get(bindingClass));
        }
      }
      if (language != Language.ANY) {
        final PsiReferenceRegistrar anyRegistrar = ReferenceProvidersRegistry.getInstance().getRegistrar(Language.ANY);
        Collections.addAll(result, ((PsiReferenceRegistrarImpl)anyRegistrar).myBindingCache.get(key));
      }
      //noinspection unchecked
      return result.toArray(new ProviderBinding[result.size()]);
    }
  };
}
 
Example 4
Project: intellij-ce-playground   File: TokenSetTest.java   Source Code and License Vote up 5 votes
@BeforeClass
public static void setUp() {
  T1 = new IElementType("T1", Language.ANY);
  T2 = new IElementType("T2", Language.ANY);
  fakeElements(1, 128);
  T3 = new IElementType("T3", Language.ANY);
  T4 = new IElementType("T4", Language.ANY);
  fakeElements(201, 204);
  T5 = new IElementType("T5", Language.ANY);
  T6 = new IElementType("T6", Language.ANY);
}
 
Example 5
Project: intellij-ce-playground   File: PomTargetPsiElementImpl.java   Source Code and License Vote up 5 votes
@Override
@NotNull
public Language getLanguage() {
  if (myTarget instanceof PsiTarget) {
    return ((PsiTarget)myTarget).getNavigationElement().getLanguage();
  }
  return Language.ANY;
}
 
Example 6
Project: intellij-ce-playground   File: HtmlScriptLanguageInjector.java   Source Code and License Vote up 5 votes
/**
 * Finds language to be injected into &lt;script&gt; tag
 *
 * @param xmlTag &lt;script&gt; tag
 * @return language to inject or null if no language found or not a script tag at all
 */
@Nullable
public static Language getScriptLanguageToInject(@NotNull XmlTag xmlTag) {
  if (!HtmlUtil.isScriptTag(xmlTag)) {
    return null;
  }
  String mimeType = xmlTag.getAttributeValue("type");
  Collection<Language> languages = Language.findInstancesByMimeType(mimeType);
  return !languages.isEmpty() ? languages.iterator().next() : Language.ANY;
}
 
Example 7
Project: intellij-ce-playground   File: ChooseByNameLanguageFilter.java   Source Code and License Vote up 5 votes
@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;
}
 
Example 8
Project: intellij-ce-playground   File: XHtmlFilterLexer.java   Source Code and License Vote up 5 votes
@Override
public void advance() {
  final IElementType tokenType = myDelegate.getTokenType();

  if (tokenType == XmlTokenType.XML_COMMENT_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
    advanceTodoItemCountsInToken();
  } else if (tokenType == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN ||
      tokenType == XmlTokenType.XML_NAME ||
      tokenType == XmlTokenType.XML_TAG_NAME
     ) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, tokenType ==
                                                                                                 XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN,
                     false);
  } else if (tokenType.getLanguage() != XMLLanguage.INSTANCE &&
    tokenType.getLanguage() != Language.ANY         
  ) {
    boolean inComments = CacheUtil.isInComments(tokenType);
    scanWordsInToken((inComments)?UsageSearchContext.IN_COMMENTS:UsageSearchContext.IN_PLAIN_TEXT | UsageSearchContext.IN_FOREIGN_LANGUAGES, true,
                     false);
    
    if (inComments) advanceTodoItemCountsInToken();
  }
  else if (!XmlFilterLexer.ourNoWordsTokenSet.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  myDelegate.advance();
}
 
Example 9
Project: intellij-ce-playground   File: MockPsiDirectory.java   Source Code and License Vote up 4 votes
@NotNull
@Override
public Language getLanguage() {
  return Language.ANY;
}
 
Example 10
Project: intellij-ce-playground   File: PackagePrefixFileSystemItemImpl.java   Source Code and License Vote up 4 votes
@Override
@NotNull
public Language getLanguage() {
  return Language.ANY;
}
 
Example 11
Project: intellij-ce-playground   File: MockLanguageFileType.java   Source Code and License Vote up 4 votes
private MockLanguageFileType() {
  super(Language.ANY);
}
 
Example 12
Project: intellij-ce-playground   File: PsiUtilCore.java   Source Code and License Vote up 4 votes
public static Language getNotAnyLanguage(ASTNode node) {
  if (node == null) return Language.ANY;

  final Language lang = node.getElementType().getLanguage();
  return lang == Language.ANY ? getNotAnyLanguage(node.getTreeParent()) : lang;
}
 
Example 13
Project: intellij-ce-playground   File: TokenSetTest.java   Source Code and License Vote up 4 votes
private static void fakeElements(int from, int to) {
  for (int i = from; i <= to; i++) {
    new IElementType("Test element #" + i, Language.ANY);
  }
}
 
Example 14
Project: intellij-ce-playground   File: MultiplePsiFilesPerDocumentFileViewProvider.java   Source Code and License Vote up 4 votes
public MultiplePsiFilesPerDocumentFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled) {
  super(manager, virtualFile, eventSystemEnabled, Language.ANY);
}
 
Example 15
Project: intellij-ce-playground   File: FakePsiElement.java   Source Code and License Vote up 4 votes
@Override
@NotNull
public Language getLanguage() {
  return Language.ANY;
}
 
Example 16
Project: intellij-ce-playground   File: PsiBinaryFileImpl.java   Source Code and License Vote up 4 votes
@Override
@NotNull
public Language getLanguage() {
  return Language.ANY;
}
 
Example 17
Project: intellij-ce-playground   File: PsiDirectoryImpl.java   Source Code and License Vote up 4 votes
@Override
@NotNull
public Language getLanguage() {
  return Language.ANY;
}
 
Example 18
Project: intellij-ce-playground   File: SyntheticFileSystemItem.java   Source Code and License Vote up 4 votes
@Override
@NotNull
public Language getLanguage() {
  return Language.ANY;
}
 
Example 19
Project: intellij-ce-playground   File: ScopeTokenType.java   Source Code and License Vote up 4 votes
public ScopeTokenType(@NotNull @NonNls final String debugName) {
  super(debugName, Language.ANY);
}
 
Example 20
Project: intellij-ce-playground   File: StubIndexImpl.java   Source Code and License Vote up 4 votes
@Override
protected <Psi extends PsiElement> void reportStubPsiMismatch(Psi psi, VirtualFile file, Class<Psi> requiredClass) {
  if (file == null) {
    super.reportStubPsiMismatch(psi, file, requiredClass);
    return;
  }

  StringWriter writer = new StringWriter();
  //noinspection IOResourceOpenedButNotSafelyClosed
  PrintWriter out = new PrintWriter(writer);

  out.print("Invalid stub element type in index:");
  out.printf("\nfile: %s\npsiElement: %s\nrequiredClass: %s\nactualClass: %s",
             file, psi, requiredClass, psi.getClass());

  FileType fileType = file.getFileType();
  Language language = fileType instanceof LanguageFileType ?
                      LanguageSubstitutors.INSTANCE.substituteLanguage(((LanguageFileType)fileType).getLanguage(), file, psi.getProject()) :
                      Language.ANY;
  out.printf("\nvirtualFile: size:%s; stamp:%s; modCount:%s; fileType:%s; language:%s",
             file.getLength(), file.getModificationStamp(), file.getModificationCount(),
             fileType.getName(), language.getID());

  Document document = FileDocumentManager.getInstance().getCachedDocument(file);
  if (document != null) {
    boolean committed = PsiDocumentManager.getInstance(psi.getProject()).isCommitted(document);
    boolean saved = !FileDocumentManager.getInstance().isDocumentUnsaved(document);
    out.printf("\ndocument: size:%s; stamp:%s; committed:%s; saved:%s",
               document.getTextLength(), document.getModificationStamp(), committed, saved);
  }

  PsiFile psiFile = psi.getManager().findFile(file);
  if (psiFile != null) {
    out.printf("\npsiFile: size:%s; stamp:%s; class:%s; language:%s",
               psiFile.getTextLength(), psiFile.getViewProvider().getModificationStamp(), psiFile.getClass().getName(),
               psiFile.getLanguage().getID());
  }

  StubTree stub = psiFile instanceof PsiFileWithStubSupport ? ((PsiFileWithStubSupport)psiFile).getStubTree() : null;
  FileElement treeElement = stub == null && psiFile instanceof PsiFileImpl? ((PsiFileImpl)psiFile).getTreeElement() : null;
  if (stub != null) {
    out.printf("\nstubInfo: " + stub.getDebugInfo());
  }
  else if (treeElement != null) {
    out.printf("\nfileAST: size:%s; parsed:%s", treeElement.getTextLength(), treeElement.isParsed());
  }

  out.printf("\nindexing info: " + StubUpdatingIndex.getIndexingStampInfo(file));
  LOG.error(writer.toString());
}