Java Code Examples for com.intellij.psi.tree.IElementType#find()

The following examples show how to use com.intellij.psi.tree.IElementType#find() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnchorElementInfo.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public PsiElement restoreElement(@Nonnull SmartPointerManagerImpl manager) {
  long typeAndId = myStubElementTypeAndId;
  int stubId = (int)typeAndId;
  if (stubId != -1) {
    PsiFile file = restoreFile(manager);
    if (!(file instanceof PsiFileWithStubSupport)) return null;
    short index = (short)(typeAndId >> 32);
    IStubElementType stubElementType = (IStubElementType)IElementType.find(index);
    return PsiAnchor.restoreFromStubIndex((PsiFileWithStubSupport)file, stubId, stubElementType, false);
  }

  return super.restoreElement(manager);
}
 
Example 2
Source File: SyntaxTraverser.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public IElementType typeOf(@Nonnull PsiElement node) {
  IElementType type = PsiUtilCore.getElementType(node);
  return type != null ? type : IElementType.find((short)0);
}
 
Example 3
Source File: StubList.java    From consulo with Apache License 2.0 4 votes vote down vote up
IStubElementType<?, ?> getStubType(int id) {
  return (IStubElementType<?, ?>)IElementType.find(getStubTypeIndex(id));
}
 
Example 4
Source File: EmptyEditorHighlighter.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public HighlighterIterator createIterator(int startOffset) {
  return new HighlighterIterator(){
    private int index = 0;

    @Override
    public TextAttributes getTextAttributes() {
      return myAttributes;
    }

    @Override
    public int getStart() {
      return 0;
    }

    @Override
    public int getEnd() {
      return myTextLength;
    }

    @Override
    public void advance() {
      index++;
    }

    @Override
    public void retreat(){
      index--;
    }

    @Override
    public boolean atEnd() {
      return index != 0;
    }

    @Override
    public Document getDocument() {
      return myEditor.getDocument();
    }

    @Override
    public IElementType getTokenType(){
      return IElementType.find(IElementType.FIRST_TOKEN_INDEX);
    }
  };
}
 
Example 5
Source File: IntBasedStorage.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public IElementType unpackTokenFromData(int data) {
  return IElementType.find((short)(data & 0xffff));
}
 
Example 6
Source File: ShortBasedStorage.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public IElementType unpackTokenFromData(int data) {
  return IElementType.find((short)Math.abs(data));
}
 
Example 7
Source File: Identikit.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isForPsiFile() {
  if (myElementTypeId < 0) return false;
  IElementType elementType = IElementType.find(myElementTypeId);
  return elementType instanceof IFileElementType;
}