Java 类com.intellij.psi.impl.source.xml.XmlContentDFA 实例源码

项目:intellij-ce-playground    文件:GenerateXmlTagAction.java   
@Nullable
private static XmlTag getAnchor(@NotNull XmlTag contextTag, Editor editor, XmlElementDescriptor selected) {
  XmlContentDFA contentDFA = XmlContentDFA.getContentDFA(contextTag);
  int offset = editor.getCaretModel().getOffset();
  if (contentDFA == null) {
    return null;
  }
  XmlTag anchor = null;
  boolean previousPositionIsPossible = true;
  for (XmlTag subTag : contextTag.getSubTags()) {
    if (contentDFA.getPossibleElements().contains(selected)) {
      if (subTag.getTextOffset() > offset) {
        break;
      }
      anchor = subTag;
      previousPositionIsPossible = true;
    }
    else {
      previousPositionIsPossible = false;
    }
    contentDFA.transition(subTag);
  }
  return previousPositionIsPossible ? null : anchor;
}
项目:tools-idea    文件:GenerateXmlTagAction.java   
@Nullable
private static XmlTag getAnchor(@NotNull XmlTag contextTag, Editor editor, XmlElementDescriptor selected) {
  XmlContentDFA contentDFA = XmlContentDFA.getContentDFA(contextTag);
  int offset = editor.getCaretModel().getOffset();
  if (contentDFA == null) {
    return null;
  }
  XmlTag anchor = null;
  boolean previousPositionIsPossible = true;
  for (XmlTag subTag : contextTag.getSubTags()) {
    if (contentDFA.getPossibleElements().contains(selected)) {
      if (subTag.getTextOffset() > offset) {
        break;
      }
      anchor = subTag;
      previousPositionIsPossible = true;
    }
    else {
      previousPositionIsPossible = false;
    }
    contentDFA.transition(subTag);
  }
  return previousPositionIsPossible ? null : anchor;
}
项目:consulo-xml    文件:GenerateXmlTagAction.java   
@Nullable
private static XmlTag getAnchor(@NotNull XmlTag contextTag, Editor editor, XmlElementDescriptor selected) {
  XmlContentDFA contentDFA = XmlContentDFA.getContentDFA(contextTag);
  int offset = editor.getCaretModel().getOffset();
  if (contentDFA == null) {
    return null;
  }
  XmlTag anchor = null;
  boolean previousPositionIsPossible = true;
  for (XmlTag subTag : contextTag.getSubTags()) {
    if (contentDFA.getPossibleElements().contains(selected)) {
      if (subTag.getTextOffset() > offset) {
        break;
      }
      anchor = subTag;
      previousPositionIsPossible = true;
    }
    else {
      previousPositionIsPossible = false;
    }
    contentDFA.transition(subTag);
  }
  return previousPositionIsPossible ? null : anchor;
}
项目:intellij-ce-playground    文件:XmlSmartCompletionProvider.java   
public void complete(CompletionParameters parameters, final CompletionResultSet result, PsiElement element) {
  if (!XmlCompletionContributor.isXmlNameCompletion(parameters)) {
    return;
  }
  result.stopHere();
  if (!(element.getParent() instanceof XmlTag)) {
    return;
  }

  final XmlTag tag = (XmlTag)element.getParent();
  final XmlTag parentTag = tag.getParentTag();
  if (parentTag == null) return;
  final XmlContentDFA dfa = XmlContentDFA.getContentDFA(parentTag);
  if (dfa == null) return;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      for (XmlTag subTag : parentTag.getSubTags()) {
        if (subTag == tag) {
          break;
        }
        dfa.transition(subTag);
      }
      List<XmlElementDescriptor> elements = dfa.getPossibleElements();
      for (XmlElementDescriptor elementDescriptor: elements) {
        addElementToResult(elementDescriptor, result);
      }
    }
  });
}
项目:tools-idea    文件:XmlSmartCompletionProvider.java   
public void complete(CompletionParameters parameters, final CompletionResultSet result, PsiElement element) {
  if (!XmlCompletionContributor.isXmlNameCompletion(parameters)) {
    return;
  }
  result.stopHere();
  if (!(element.getParent() instanceof XmlTag)) {
    return;
  }

  final XmlTag tag = (XmlTag)element.getParent();
  final XmlTag parentTag = tag.getParentTag();
  if (parentTag == null) return;
  final XmlContentDFA dfa = XmlContentDFA.getContentDFA(parentTag);
  if (dfa == null) return;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      for (XmlTag subTag : parentTag.getSubTags()) {
        if (subTag == tag) {
          break;
        }
        dfa.transition(subTag);
      }
      List<XmlElementDescriptor> elements = dfa.getPossibleElements();
      for (XmlElementDescriptor elementDescriptor: elements) {
        addElementToResult(elementDescriptor, result);
      }
    }
  });
}
项目:consulo-xml    文件:XmlSmartCompletionProvider.java   
public void complete(CompletionParameters parameters, final CompletionResultSet result, PsiElement element) {
  if (!XmlCompletionContributor.isXmlNameCompletion(parameters)) {
    return;
  }
  result.stopHere();
  if (!(element.getParent() instanceof XmlTag)) {
    return;
  }

  final XmlTag tag = (XmlTag)element.getParent();
  final XmlTag parentTag = tag.getParentTag();
  if (parentTag == null) return;
  final XmlContentDFA dfa = XmlContentDFA.getContentDFA(parentTag);
  if (dfa == null) return;
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    @Override
    public void run() {
      for (XmlTag subTag : parentTag.getSubTags()) {
        if (subTag == tag) {
          break;
        }
        dfa.transition(subTag);
      }
      List<XmlElementDescriptor> elements = dfa.getPossibleElements();
      for (XmlElementDescriptor elementDescriptor: elements) {
        addElementToResult(elementDescriptor, result);
      }
    }
  });
}