Java 类com.intellij.lang.properties.parsing.PropertiesTokenTypes 实例源码

项目:intellij-ce-playground    文件:PropertiesASTFactory.java   
@Override
@Nullable
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull CharSequence text) {
  if (type == PropertiesTokenTypes.KEY_CHARACTERS) {
    return new PropertyKeyImpl(type, text);
  }

  if (type == PropertiesTokenTypes.VALUE_CHARACTERS) {
    return new PropertyValueImpl(type, text);
  }

  if (type == PropertiesTokenTypes.END_OF_LINE_COMMENT) {
    return new PsiCommentImpl(type, text);
  }

  return new LeafPsiElement(type, text);
}
项目:intellij-ce-playground    文件:PropertyImpl.java   
@Nullable
public Character getKeyValueDelimiter() {
  final PsiElement delimiter = findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR);
  if (delimiter == null) {
    return null;
  }
  String separatorText = delimiter.getText();
  if (separatorText.isEmpty()) {
    return null;
  }
  separatorText = separatorText.trim();
  if (separatorText.isEmpty()) {
    separatorText = " ";
  }
  LOG.assertTrue(separatorText.length() == 1, "\"" + separatorText + "\"");
  return separatorText.charAt(0);
}
项目:intellij-ce-playground    文件:PropertiesFilterLexer.java   
public void advance() {
  final IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == PropertiesTokenTypes.KEY_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }
  else if (PropertiesTokenTypes.COMMENTS.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS | UsageSearchContext.IN_PLAIN_TEXT, false, false);
    advanceTodoItemCountsInToken();
  }
  else {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  getDelegate().advance();
}
项目:tools-idea    文件:PropertiesFilterLexer.java   
public void advance() {
  final IElementType tokenType = getDelegate().getTokenType();

  if (tokenType == PropertiesTokenTypes.KEY_CHARACTERS) {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }
  else if (PropertiesTokenTypes.COMMENTS.contains(tokenType)) {
    scanWordsInToken(UsageSearchContext.IN_COMMENTS | UsageSearchContext.IN_PLAIN_TEXT, false, false);
    advanceTodoItemCountsInToken();
  }
  else {
    scanWordsInToken(UsageSearchContext.IN_CODE | UsageSearchContext.IN_FOREIGN_LANGUAGES | UsageSearchContext.IN_PLAIN_TEXT, false, false);
  }

  getDelegate().advance();
}
项目:intellij-ce-playground    文件:EnterInPropertiesFileHandler.java   
private static void handleEnterInPropertiesFile(final Editor editor,
                                                final Document document,
                                                final PsiElement psiAtOffset,
                                                int caretOffset) {
  String text = document.getText();
  String line = text.substring(0, caretOffset);
  int i = line.lastIndexOf('\n');
  if (i > 0) {
    line = line.substring(i);
  }
  final String toInsert;
  if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(line)) {
    toInsert = "\n  ";
  }
  else {
    final IElementType elementType = psiAtOffset == null ? null : psiAtOffset.getNode().getElementType();

    if (elementType == PropertiesTokenTypes.VALUE_CHARACTERS) {
      toInsert = "\\\n  ";
    }
    else if (elementType == PropertiesTokenTypes.END_OF_LINE_COMMENT && "#!".indexOf(document.getText().charAt(caretOffset)) == -1) {
      toInsert = "\n#";
    }
    else {
      toInsert = "\n";
    }
  }
  document.insertString(caretOffset, toInsert);
  caretOffset+=toInsert.length();
  editor.getCaretModel().moveToOffset(caretOffset);
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  editor.getSelectionModel().removeSelection();
}
项目:intellij-ce-playground    文件:PropertyImpl.java   
public void replaceKeyValueDelimiterWithDefault() {
  PropertyImpl property = (PropertyImpl)PropertiesElementFactory.createProperty(getProject(), "yyy", "xxx");
  final ASTNode oldDelimiter = getNode().findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR);
  LOG.assertTrue(oldDelimiter != null);
  final ASTNode newDelimiter = property.getNode().findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR);
  LOG.assertTrue(newDelimiter != null);
  getNode().replaceChild(oldDelimiter, newDelimiter);
}
项目:intellij-ce-playground    文件:PropertiesHighlightingLexer.java   
public PropertiesHighlightingLexer() {
  super(new PropertiesLexer());
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                            new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.KEY_CHARACTERS, true, "#!=: "),
                            new IElementType[]{PropertiesTokenTypes.KEY_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
}
项目:intellij-ce-playground    文件:DGMReferenceContributor.java   
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
  registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.VALUE_CHARACTERS), new PsiReferenceProvider() {
    @NotNull
    @Override
    public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
      if (!DGMUtil.isInDGMFile(element)) return PsiReference.EMPTY_ARRAY;

      IProperty parent = (IProperty)element.getParent();
      if (!"extensionClasses".equals(parent.getName())) {
        return PsiReference.EMPTY_ARRAY;
      }

      ArrayList<PsiReference> result = new ArrayList<PsiReference>();

      String text = element.getText();

      int i = 0;
      while ((i = skipWhiteSpace(i, text)) < text.length()) {
        int end = findWhiteSpaceOrComma(i, text);
        if (end <= text.length()) {
          JavaClassReferenceSet set = new JavaClassReferenceSet(text.substring(i, end), element, i, true, myProvider);
          ContainerUtil.addAll(result, set.getAllReferences());
        }
        i = end;
        i = skipWhiteSpace(i, text);
        if (i == text.length()) break;
        if (text.charAt(i) == ',') i++;
        i = skipWhiteSpace(i, text);
      }

      return result.toArray(new PsiReference[result.size()]);
    }
  });
}
项目:IntelliJ_Jahia_plugin    文件:CndReferenceContributor.java   
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    CndReferenceProvider cndReferenceProvider = new CndReferenceProvider();
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),        cndReferenceProvider);  //Java

    registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUPER_TYPE),               cndReferenceProvider);  //Cnd super types
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.EXTENSION),                cndReferenceProvider);  //Cnd extends types
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUB_NODE_TYPE),            cndReferenceProvider);  //Cnd subnode types
    registrar.registerReferenceProvider(PlatformPatterns.psiElement(CndTypes.SUB_NODE_DEFAULT_TYPE),    cndReferenceProvider);  //Cnd subnode default type

    registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementType.XML_ATTRIBUTE_VALUE),    cndReferenceProvider);  //XML

    registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.KEY_CHARACTERS),    cndReferenceProvider);  //Properties
}
项目:tools-idea    文件:EnterInPropertiesFileHandler.java   
private static void handleEnterInPropertiesFile(final Editor editor,
                                                final Document document,
                                                final PsiElement psiAtOffset,
                                                int caretOffset) {
  String text = document.getText();
  String line = text.substring(0, caretOffset);
  int i = line.lastIndexOf('\n');
  if (i > 0) {
    line = line.substring(i);
  }
  final String toInsert;
  if (PropertiesUtil.isUnescapedBackSlashAtTheEnd(line)) {
    toInsert = "\n  ";
  }
  else {
    final IElementType elementType = psiAtOffset == null ? null : psiAtOffset.getNode().getElementType();

    if (elementType == PropertiesTokenTypes.VALUE_CHARACTERS) {
      toInsert = "\\\n  ";
    }
    else if (elementType == PropertiesTokenTypes.END_OF_LINE_COMMENT && "#!".indexOf(document.getText().charAt(caretOffset)) == -1) {
      toInsert = "\n#";
    }
    else {
      toInsert = "\n";
    }
  }
  document.insertString(caretOffset, toInsert);
  caretOffset+=toInsert.length();
  editor.getCaretModel().moveToOffset(caretOffset);
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  editor.getSelectionModel().removeSelection();
}
项目:tools-idea    文件:PropertiesHighlightingLexer.java   
public PropertiesHighlightingLexer() {
  super(new PropertiesLexer());
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                            new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
  registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.KEY_CHARACTERS, true, "#!=: "),
                            new IElementType[]{PropertiesTokenTypes.KEY_CHARACTERS},
                            IElementType.EMPTY_ARRAY);
}
项目:tools-idea    文件:PropertiesASTFactory.java   
@Nullable
public LeafElement createLeaf(final IElementType type, CharSequence text) {
  if (type == PropertiesTokenTypes.VALUE_CHARACTERS) {
    return new PropertyValueImpl(type, text);
  }

  if (type == PropertiesTokenTypes.END_OF_LINE_COMMENT) {
    return new PsiCommentImpl(type, text);
  }

  return new LeafPsiElement(type, text);
}
项目:tools-idea    文件:DGMReferenceContributor.java   
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
  registrar.registerReferenceProvider(PlatformPatterns.psiElement(PropertiesTokenTypes.VALUE_CHARACTERS), new PsiReferenceProvider() {
    @NotNull
    @Override
    public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
      if (!DGMUtil.isInDGMFile(element)) return PsiReference.EMPTY_ARRAY;

      IProperty parent = (IProperty)element.getParent();
      if (!"extensionClasses".equals(parent.getName())) {
        return PsiReference.EMPTY_ARRAY;
      }

      ArrayList<PsiReference> result = new ArrayList<PsiReference>();

      String text = element.getText();

      int i = 0;
      while ((i = skipWhiteSpace(i, text)) < text.length()) {
        int end = findWhiteSpaceOrComma(i, text);
        if (end <= text.length()) {
          JavaClassReferenceSet set = new JavaClassReferenceSet(text.substring(i, end), element, i, true, myProvider);
          ContainerUtil.addAll(result, set.getAllReferences());
        }
        i = end;
        i = skipWhiteSpace(i, text);
        if (i == text.length()) break;
        if (text.charAt(i) == ',') i++;
        i = skipWhiteSpace(i, text);
      }

      return result.toArray(new PsiReference[result.size()]);
    }
  });
}
项目:intellij-ce-playground    文件:PropertyImpl.java   
@Nullable
public ASTNode getKeyNode() {
  return getNode().findChildByType(PropertiesTokenTypes.KEY_CHARACTERS);
}
项目:intellij-ce-playground    文件:PropertyImpl.java   
@Nullable
public ASTNode getValueNode() {
  return getNode().findChildByType(PropertiesTokenTypes.VALUE_CHARACTERS);
}
项目:intellij-ce-playground    文件:PropertiesValueHighlightingLexer.java   
public PropertiesValueHighlightingLexer() {
    super(new DummyLexer(PropertiesTokenTypes.VALUE_CHARACTERS));

    registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                              new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS}, IElementType.EMPTY_ARRAY);
}
项目:tools-idea    文件:PropertyImpl.java   
@Nullable
public ASTNode getKeyNode() {
  return getNode().findChildByType(PropertiesTokenTypes.KEY_CHARACTERS);
}
项目:tools-idea    文件:PropertyImpl.java   
@Nullable
public ASTNode getValueNode() {
  return getNode().findChildByType(PropertiesTokenTypes.VALUE_CHARACTERS);
}
项目:tools-idea    文件:PropertiesValueHighlightingLexer.java   
public PropertiesValueHighlightingLexer() {
    super(new DummyLexer(PropertiesTokenTypes.VALUE_CHARACTERS));

    registerSelfStoppingLayer(new StringLiteralLexer(StringLiteralLexer.NO_QUOTE_CHAR, PropertiesTokenTypes.VALUE_CHARACTERS, true, "#!=:"),
                              new IElementType[]{PropertiesTokenTypes.VALUE_CHARACTERS}, IElementType.EMPTY_ARRAY);
}