本文整理汇总了Java中com.intellij.spellchecker.tokenizer.TokenConsumer类的典型用法代码示例。如果您正苦于以下问题:Java TokenConsumer类的具体用法?Java TokenConsumer怎么用?Java TokenConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TokenConsumer类属于com.intellij.spellchecker.tokenizer包,在下文中一共展示了TokenConsumer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiLiteralExpression element, TokenConsumer consumer) {
PsiLiteralExpressionImpl literalExpression = (PsiLiteralExpressionImpl)element;
if (literalExpression.getLiteralElementType() != JavaTokenType.STRING_LITERAL) return; // not a string literal
String text = literalExpression.getInnerText();
if (StringUtil.isEmpty(text) || text.length() <= 2) { // optimisation to avoid expensive injection check
return;
}
if (InjectedLanguageUtil.hasInjections(literalExpression)) return;
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
if (listOwner != null && AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS), false, false)) {
return;
}
if (!text.contains("\\")) {
consumer.consumeToken(element, PlainTextSplitter.getInstance());
}
else {
processTextWithEscapeSequences(element, text, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:LiteralExpressionTokenizer.java
示例2: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiDocComment comment, TokenConsumer consumer) {
final CommentSplitter splitter = CommentSplitter.getInstance();
for (PsiElement el : comment.getChildren()) {
if (el instanceof PsiDocTag) {
PsiDocTag tag = (PsiDocTag)el;
if (!excludedTags.contains(tag.getName())) {
for (PsiElement data : tag.getDataElements()) {
consumer.consumeToken(data, splitter);
}
}
}
else {
consumer.consumeToken(el, splitter);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DocCommentTokenizer.java
示例3: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull T element, TokenConsumer consumer) {
final PsiIdentifier psiIdentifier = PsiTreeUtil.getChildOfType(element, PsiIdentifier.class);
final PsiTypeElement psiType = PsiTreeUtil.getChildOfType(element, PsiTypeElement.class);
if (psiIdentifier == null) {
return;
}
final String identifier = psiIdentifier.getText();
final String type = psiType==null?null:psiType.getText();
if (identifier == null) {
return;
}
if (type == null || !type.equalsIgnoreCase(identifier)) {
myIdentifierTokenizer.tokenize(psiIdentifier, consumer);
}
if (psiType != null) {
myTypeTokenizer.tokenize(psiType, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:NamedElementTokenizer.java
示例4: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull JsonStringLiteral element, TokenConsumer consumer) {
final PlainTextSplitter textSplitter = PlainTextSplitter.getInstance();
if (element.getText().contains("\\")) {
final List<Pair<TextRange, String>> fragments = element.getTextFragments();
for (Pair<TextRange, String> fragment : fragments) {
final String fragmentText = fragment.getSecond();
final TextRange fragmentRange = fragment.getFirst();
if (!fragmentText.startsWith("\\")) {
consumer.consumeToken(element, fragmentText, false, fragmentRange.getStartOffset(), TextRange.allOf(fragmentText), textSplitter);
}
}
}
else {
consumer.consumeToken(element, textSplitter);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JsonSpellcheckerStrategy.java
示例5: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull final XmlAttributeValue element, final TokenConsumer consumer) {
final AndroidResourceReferenceBase reference = findResourceReference(element);
if (reference != null) {
if (reference.getResourceValue().getPackage() == null) {
consumer.consumeToken(element, true, TextSplitter.getInstance());
}
return;
}
// The super implementation already filters out hex color definitions like #001122, but it's limited to RGB colors, not ARGB.
if (isColorString(element.getValue())) {
return;
}
super.tokenize(element, consumer);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AndroidXmlSpellcheckingStrategy.java
示例6: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiLiteralExpression element, TokenConsumer consumer) {
PsiLiteralExpressionImpl literalExpression = (PsiLiteralExpressionImpl) element;
if (literalExpression.getLiteralElementType() != JavaTokenType.STRING_LITERAL) {
return; // not a string literal
}
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
if (listOwner != null && AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS), false, false)) {
return;
}
String text = literalExpression.getInnerText();
if (text == null) {
return;
}
if (!text.contains("\\")) {
consumer.consumeToken(element, PlainTextSplitter.getInstance());
}
else {
processTextWithEscapeSequences(element, text, consumer);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:LiteralExpressionTokenizer.java
示例7: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiTypeElement element, TokenConsumer consumer) {
final PsiType type = element.getType();
if (type instanceof PsiDisjunctionType) {
tokenizeComplexType(element, consumer);
return;
}
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
if (psiClass == null || psiClass.getContainingFile() == null || psiClass.getContainingFile().getVirtualFile() == null) {
return;
}
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile);
if (isInSource) {
consumer.consumeToken(element, element.getText(), true, 0, getRangeToCheck(element.getText(), psiClass.getName()),
IdentifierSplitter.getInstance());
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:PsiTypeTokenizer.java
示例8: processTextWithEscapeSequences
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
public static void processTextWithEscapeSequences(PsiLiteralExpression element, String text, TokenConsumer consumer) {
StringBuilder unescapedText = new StringBuilder();
int[] offsets = new int[text.length()+1];
PsiLiteralExpressionImpl.parseStringCharacters(text, unescapedText, offsets);
processTextWithOffsets(element, consumer, unescapedText, offsets, 1);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:LiteralExpressionTokenizer.java
示例9: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiMethod element, TokenConsumer consumer) {
final PsiMethod[] methods = (element).findDeepestSuperMethods();
boolean isInSource = true;
for (PsiMethod psiMethod : methods) {
isInSource &= isMethodDeclarationInSource(psiMethod);
}
if (isInSource) {
super.tokenize(element, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MethodNameTokenizerJava.java
示例10: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiTypeElement element, TokenConsumer consumer) {
final PsiType type = element.getType();
if (type instanceof PsiDisjunctionType) {
tokenizeComplexType(element, consumer);
return;
}
final PsiClass psiClass = PsiUtil.resolveClassInType(type);
if (psiClass == null || psiClass.getContainingFile() == null || psiClass.getContainingFile().getVirtualFile() == null) {
return;
}
final String name = psiClass.getName();
if (name == null) {
return;
}
final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
final boolean isInSource = (virtualFile != null) && fileIndex.isInContent(virtualFile);
if (isInSource) {
final String elementText = element.getText();
if (elementText.contains(name)) {
consumer.consumeToken(element, elementText, true, 0, getRangeToCheck(elementText, name), IdentifierSplitter.getInstance());
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PsiTypeTokenizer.java
示例11: processLeafsNames
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
protected void processLeafsNames(@NotNull final PsiElement leafElement, @NotNull final HashSet<String> seenNames) {
final Language language = leafElement.getLanguage();
SpellCheckingInspection.tokenize(leafElement, language, new TokenConsumer() {
@Override
public void consumeToken(PsiElement element, final String text, boolean useRename, int offset, TextRange rangeToCheck, Splitter splitter) {
splitter.split(text, rangeToCheck, new Consumer<TextRange>() {
@Override
public void consume(TextRange textRange) {
final String word = textRange.substring(text);
addSeenWord(seenNames, word, language);
}
});
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SpellCheckerDictionaryGenerator.java
示例12: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PyStringLiteralExpression element, TokenConsumer consumer) {
String stringValue = element.getStringValue();
List<PyStringFormatParser.FormatStringChunk> chunks = PyStringFormatParser.parsePercentFormat(stringValue);
Splitter splitter = PlainTextSplitter.getInstance();
for (PyStringFormatParser.FormatStringChunk chunk : chunks) {
if (chunk instanceof PyStringFormatParser.ConstantChunk) {
int startIndex = element.valueOffsetToTextOffset(chunk.getStartIndex());
int endIndex = element.valueOffsetToTextOffset(chunk.getEndIndex());
String text = element.getText().substring(startIndex, endIndex);
consumer.consumeToken(element, text, false, startIndex, TextRange.allOf(text), splitter);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PythonSpellcheckerStrategy.java
示例13: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiElement literal, TokenConsumer consumer) {
String text = GrStringUtil.removeQuotes(literal.getText());
if (!text.contains("\\")) {
consumer.consumeToken(literal, PlainTextSplitter.getInstance());
}
else {
StringBuilder unescapedText = new StringBuilder();
int[] offsets = new int[text.length() + 1];
GrStringUtil.parseStringCharacters(text, unescapedText, offsets);
processTextWithOffsets(literal, consumer, unescapedText, offsets, GrStringUtil.getStartQuote(literal.getText()).length());
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:GroovySpellcheckingStrategy.java
示例14: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull MultiMarkdownNamedElement element, TokenConsumer consumer) {
StringBuilder text = new StringBuilder(element.getTextLength());
int offset = -1;
int nodeOffset = -1;
int firstOffset = -1;
int lastOffset = -1;
// extract a range of spell checkable elements, leave out any leading/trailing non-checkable
// and any non-checkable in the middle replace with spaces
for (ASTNode astNode : element.getNode().getChildren(null)) {
if (!MultiMarkdownSpellcheckingStrategy.NO_SPELL_CHECK_SET.contains(astNode.getElementType())) {
offset = astNode.getStartOffset();
if (firstOffset < 0) firstOffset = offset;
else if (lastOffset < offset) appendSpaces(text, offset - lastOffset);
text.append(astNode.getChars());
lastOffset = offset + astNode.getTextLength();
}
if (nodeOffset < 0) {
nodeOffset = offset >= 0 ? offset : astNode.getStartOffset();
}
}
if (nodeOffset < 0) {
// leaf element, take all text, if it is not to be spell checked then should not be here
String elemText = element.getText();
consumer.consumeToken(element, elemText, true, 0, TextRange.allOf(elemText), IdentifierSplitter.getInstance());
} else if (firstOffset >= 0) {
consumer.consumeToken(element, text.toString(), true, firstOffset - element.getNode().getStartOffset(), TextRange.create(0, lastOffset - firstOffset), IdentifierSplitter.getInstance());
}
}
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:33,代码来源:MultiMarkdownIdentifierTokenizer.java
示例15: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiElement literal, TokenConsumer consumer) {
String text = GrStringUtil.removeQuotes(literal.getText());
if (!text.contains("\\")) {
consumer.consumeToken(literal, PlainTextSplitter.getInstance());
}
else {
StringBuilder unescapedText = new StringBuilder();
int[] offsets = new int[text.length() + 1];
GrStringUtil.parseStringCharacters(text, unescapedText, offsets);
EscapeSequenceTokenizer.processTextWithOffsets(literal, consumer, unescapedText, offsets, GrStringUtil.getStartQuote(literal.getText()).length());
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:GroovySpellcheckingStrategy.java
示例16: processTextWithEscapeSequences
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
public static void processTextWithEscapeSequences(PsiLiteralExpression element, String text, TokenConsumer consumer) {
StringBuilder unescapedText = new StringBuilder();
int[] offsets = new int[text.length()+1];
PsiLiteralExpressionImpl.parseStringCharacters(text, unescapedText, offsets);
EscapeSequenceTokenizer.processTextWithOffsets(element, consumer, unescapedText, offsets, 1);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:8,代码来源:LiteralExpressionTokenizer.java
示例17: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
@RequiredReadAction
public void tokenize(@NotNull PsiNameIdentifierOwner owner, TokenConsumer tokenConsumer)
{
PsiElement identifier = owner.getNameIdentifier();
if(identifier == null)
{
return;
}
PsiElement parent = owner;
TextRange range = identifier.getTextRange();
if(range.isEmpty())
{
return;
}
String oldText = identifier.getText();
if(oldText.charAt(0) == '@')
{
range = new TextRange(range.getStartOffset() + 1, range.getEndOffset());
}
int offset = range.getStartOffset() - parent.getTextRange().getStartOffset();
if(offset < 0)
{
parent = PsiTreeUtil.findCommonParent(identifier, owner);
offset = range.getStartOffset() - parent.getTextRange().getStartOffset();
}
String text = CSharpPsiUtilImpl.getNameWithoutAt(oldText);
tokenConsumer.consumeToken(parent, text, true, offset, TextRange.allOf(text), IdentifierSplitter.getInstance());
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:34,代码来源:CSharpSpellcheckingStrategy.java
示例18: tokenizeComplexType
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
private void tokenizeComplexType(PsiTypeElement element, TokenConsumer consumer) {
final List<PsiTypeElement> subTypes = PsiTreeUtil.getChildrenOfTypeAsList(element, PsiTypeElement.class);
for (PsiTypeElement subType : subTypes) {
tokenize(subType, consumer);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:PsiTypeTokenizer.java
示例19: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiIdentifier element, TokenConsumer consumer) {
consumer.consumeToken(element, true, IdentifierSplitter.getInstance());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:PsiIdentifierTokenizer.java
示例20: tokenize
import com.intellij.spellchecker.tokenizer.TokenConsumer; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiElement element, TokenConsumer consumer) {
consumer.consumeToken(element, PlainTextSplitter.getInstance());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:RestSpellcheckerStrategy.java
注:本文中的com.intellij.spellchecker.tokenizer.TokenConsumer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论