• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CharFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.util.text.CharFilter的典型用法代码示例。如果您正苦于以下问题:Java CharFilter类的具体用法?Java CharFilter怎么用?Java CharFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CharFilter类属于com.intellij.openapi.util.text包,在下文中一共展示了CharFilter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doTestVariantsInner

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
protected void doTestVariantsInner(String fileName) throws Throwable {
  final VirtualFile virtualFile = myFixture.copyFileToProject(fileName);
  final Scanner in = new Scanner(virtualFile.getInputStream());

  final CompletionType type = CompletionType.valueOf(in.next());
  final int count = in.nextInt();
  final CheckType checkType = CheckType.valueOf(in.next());

  final List<String> variants = new ArrayList<>();
  while (in.hasNext()) {
    final String variant = StringUtil.strip(in.next(), CharFilter.NOT_WHITESPACE_FILTER);
    if (variant.length() > 0) {
      variants.add(variant);
    }
  }

  myFixture.complete(type, count);
  checkCompletion(checkType, variants);
}
 
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:20,代码来源:PantsCompletionTestBase.java


示例2: doTestVariantsInner

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
protected void doTestVariantsInner(String fileName) throws Throwable {
  final VirtualFile virtualFile = myFixture.copyFileToProject(fileName);
  final Scanner in = new Scanner(virtualFile.getInputStream());

  final CompletionType type = CompletionType.valueOf(in.next());
  final int count = in.nextInt();
  final CheckType checkType = CheckType.valueOf(in.next());

  final List<String> variants = new ArrayList<String>();
  while (in.hasNext()) {
    final String variant = StringUtil.strip(in.next(), CharFilter.NOT_WHITESPACE_FILTER);
    if (variant.length() > 0) {
      variants.add(variant);
    }
  }

  myFixture.complete(type, count);
  checkCompletion(checkType, variants);
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:20,代码来源:HaxeCompletionTestBase.java


示例3: createReferences

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
protected PsiReference[] createReferences(@NotNull PsiElement element, String s, int offset, final boolean soft) {
  int contentOffset = StringUtil.findFirst(s, CharFilter.NOT_WHITESPACE_FILTER);
  if (contentOffset >= 0) {
    offset += contentOffset;
  }
  return new FileReferenceSet(s.trim(), element, offset, this, true) {

    @Override
    protected boolean isSoft() {
      return soft;
    }
  }.getAllReferences();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PathListReferenceProvider.java


示例4: getStartOffset

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private int getStartOffset(@NotNull final PsiElement element, @NotNull final Editor editor) {
  if (isBunchOfElement(element)) {
    final PsiElement firstElement = getFirstElement(element);
    return firstElement != null? firstElement.getTextRange().getStartOffset()
                                      : element.getTextRange().getStartOffset();
  }
  final int offset = editor.getCaretModel().getOffset();
  final int elementTextOffset = element.getTextOffset();
  final Document document = editor.getDocument();
  int lineNumber = document.getLineNumber(offset);

  while (lineNumber != document.getLineNumber(elementTextOffset)) {
    final String text = document.getText(TextRange.create(document.getLineStartOffset(lineNumber),
                                                          document.getLineEndOffset(lineNumber)));
    if (StringUtil.isEmptyOrSpaces(text)) {
      lineNumber += 1;
      break;
    }
    lineNumber -= 1;
  }
  final int lineStartOffset = lineNumber == document.getLineNumber(elementTextOffset) ? elementTextOffset : document.getLineStartOffset(lineNumber);
  final String lineText = document
    .getText(TextRange.create(lineStartOffset, document.getLineEndOffset(lineNumber)));
  int shift = StringUtil.findFirst(lineText, CharFilter.NOT_WHITESPACE_FILTER);

  return lineStartOffset + shift;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ParagraphFillHandler.java


示例5: getPrefix

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
@NotNull
protected String getPrefix(@NotNull final PsiElement element) {
  final PyStringLiteralExpression stringLiteralExpression =
    PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class);
  if (stringLiteralExpression != null) {
    final String text = stringLiteralExpression.getText();
    final Pair<String,String> quotes =
      PythonStringUtil.getQuotes(text);
    final PyDocStringOwner docStringOwner = PsiTreeUtil.getParentOfType(stringLiteralExpression, PyDocStringOwner.class);
    if (docStringOwner != null && stringLiteralExpression.equals(docStringOwner.getDocStringExpression())) {
      String indent = getIndent(stringLiteralExpression);
      if (quotes != null) {
        final List<String> strings = StringUtil.split(text, "\n");
        if (strings.get(0).trim().equals(quotes.getFirst())) {
          return quotes.getFirst() + indent;
        }
        else {
          final String value = stringLiteralExpression.getStringValue();
          final int firstNotSpace = StringUtil.findFirst(value, CharFilter.NOT_WHITESPACE_FILTER);
          return quotes.getFirst() + value.substring(0, firstNotSpace);
        }
      }
      return "\"" + indent;
    }
    else
      return quotes != null? quotes.getFirst() : "\"";
  }
  return element instanceof PsiComment? "# " : "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PyFillParagraphHandler.java


示例6: findDigits

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private static String findDigits(String s) {
  int pos = StringUtil.findFirst(s, new CharFilter() {
    public boolean accept(char ch) {
      return Character.isDigit(ch);
    }
  });
  if (pos >= 0) {
    return s.substring(pos);
  }
  return s;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PythonSdkType.java


示例7: addLeadingSpaces

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private static String addLeadingSpaces(String text, final CharFilter filter, int indentSize, String indentChar) {
  final List<String> strings = StringUtil.split(text, "\n", false);
  if (strings.size() > 1) {
    int firstLineIndent = StringUtil.findFirst(strings.get(0), filter);
    int secondLineIndent = StringUtil.findFirst(strings.get(1), filter);
    final int diff = secondLineIndent - firstLineIndent;
    if (diff > indentSize) {
      text = StringUtil.repeat(indentChar, diff - indentSize) + text;
    }
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PythonCopyPasteProcessor.java


示例8: calculateIndentToRemove

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private static int calculateIndentToRemove(@NotNull String text, @NotNull final CharFilter filter) {
  final List<String> strings = StringUtil.split(text, "\n", false);
  int minIndent = StringUtil.findFirst(text, filter);
  for (String  s : strings) {
    final int indent = StringUtil.findFirst(s, filter);
    if (indent < minIndent && !StringUtil.isEmptyOrSpaces(s))
      minIndent = indent;
  }
  return minIndent >= 0 ? minIndent : 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PythonCopyPasteProcessor.java


示例9: createReferences

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
protected PsiReference[] createReferences(PsiElement element, String s, int offset, final boolean soft) {
  int contentOffset = StringUtil.findFirst(s, CharFilter.NOT_WHITESPACE_FILTER);
  if (contentOffset >= 0) {
    offset += contentOffset;
  }
  return new FileReferenceSet(s.trim(), element, offset, this, true) {

    @Override
    protected boolean isSoft() {
      return soft;
    }
  }.getAllReferences();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:PathListReferenceProvider.java


示例10: getStartOffset

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private int getStartOffset(@NotNull final PsiElement element, @NotNull final Editor editor) {
  if (isBunchOfElement(element)) {
    final PsiElement firstElement = getFirstElement(element);
    return firstElement != null? firstElement.getTextRange().getStartOffset()
                                      : element.getTextRange().getStartOffset();
  }
  final int offset = editor.getCaretModel().getOffset();
  final int elementTextOffset = element.getTextOffset();
  final Document document = editor.getDocument();
  int lineNumber = document.getLineNumber(offset);

  while (lineNumber != document.getLineNumber(elementTextOffset)) {
    final String text = document.getText(TextRange.create(document.getLineStartOffset(lineNumber),
                                                          document.getLineEndOffset(lineNumber)));
    if (StringUtil.isEmptyOrSpaces(text)) {
      lineNumber += 1;
      break;
    }
    lineNumber -= 1;
  }
  final int lineStartOffset = document.getLineStartOffset(lineNumber);
  final String lineText = document
    .getText(TextRange.create(lineStartOffset, document.getLineEndOffset(lineNumber)));
  int shift = StringUtil.findFirst(lineText, CharFilter.NOT_WHITESPACE_FILTER);

  return lineStartOffset + shift;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:ParagraphFillHandler.java


示例11: getStartOffset

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
private int getStartOffset(@Nonnull final PsiElement element, @Nonnull final Editor editor) {
  if (isBunchOfElement(element)) {
    final PsiElement firstElement = getFirstElement(element);
    return firstElement != null? firstElement.getTextRange().getStartOffset()
                               : element.getTextRange().getStartOffset();
  }
  final int offset = editor.getCaretModel().getOffset();
  final int elementTextOffset = element.getTextOffset();
  final Document document = editor.getDocument();
  int lineNumber = document.getLineNumber(offset);

  while (lineNumber != document.getLineNumber(elementTextOffset)) {
    final String text = document.getText(TextRange.create(document.getLineStartOffset(lineNumber),
                                                          document.getLineEndOffset(lineNumber)));
    if (StringUtil.isEmptyOrSpaces(text)) {
      lineNumber += 1;
      break;
    }
    lineNumber -= 1;
  }
  final int lineStartOffset = lineNumber == document.getLineNumber(elementTextOffset) ? elementTextOffset : document.getLineStartOffset(lineNumber);
  final String lineText = document
          .getText(TextRange.create(lineStartOffset, document.getLineEndOffset(lineNumber)));
  int shift = StringUtil.findFirst(lineText, CharFilter.NOT_WHITESPACE_FILTER);

  return lineStartOffset + shift;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:ParagraphFillHandler.java


示例12: preprocessOnPaste

import com.intellij.openapi.util.text.CharFilter; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(Project project,
                                PsiFile file,
                                Editor editor,
                                String text,
                                RawText rawText) {
  if (!CodeInsightSettings.getInstance().INDENT_TO_CARET_ON_PASTE || file.getLanguage() != PythonLanguage.getInstance()) {
    return text;
  }
  final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
  final boolean useTabs = codeStyleSettings.useTabCharacter(PythonFileType.INSTANCE);
  final int indentSize = codeStyleSettings.getIndentSize(PythonFileType.INSTANCE);
  CharFilter NOT_INDENT_FILTER = new CharFilter() {
    public boolean accept(char ch) {
      return useTabs? ch != '\t' : ch != ' ';
    }
  };
  final String indentChar = useTabs ? "\t" : " ";

  final CaretModel caretModel = editor.getCaretModel();
  final SelectionModel selectionModel = editor.getSelectionModel();
  final Document document = editor.getDocument();
  final int caretOffset = selectionModel.getSelectionStart() != selectionModel.getSelectionEnd() ?
                          selectionModel.getSelectionStart() : caretModel.getOffset();
  final int lineNumber = document.getLineNumber(caretOffset);
  final int lineStartOffset = getLineStartSafeOffset(document, lineNumber);
  final int lineEndOffset = document.getLineEndOffset(lineNumber);

  final PsiElement element = file.findElementAt(caretOffset);
  if (PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class) != null) return text;

  text = addLeadingSpaces(text, NOT_INDENT_FILTER, indentSize, indentChar);
  int firstLineIndent = StringUtil.findFirst(text, NOT_INDENT_FILTER);
  final String indentText = getIndentText(file, document, caretOffset, lineNumber, firstLineIndent);

  int toRemove = calculateIndentToRemove(text, NOT_INDENT_FILTER);

  final String toString = document.getText(TextRange.create(lineStartOffset, lineEndOffset));
  if (StringUtil.isEmptyOrSpaces(indentText) && isApplicable(file, text, caretOffset)) {
    caretModel.moveToOffset(lineStartOffset);

    if (StringUtil.isEmptyOrSpaces(toString)) {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          document.deleteString(lineStartOffset, lineEndOffset);
        }
      });
    }
    editor.getSelectionModel().setSelection(lineStartOffset, selectionModel.getSelectionEnd());
  }

  final List<String> strings = StringUtil.split(text, "\n", false);
  String newText = "";
  if (StringUtil.isEmptyOrSpaces(indentText)) {
    for (String s : strings) {
      newText += indentText + StringUtil.trimStart(s, StringUtil.repeat(indentChar, toRemove));
    }
  }
  else {
    newText = text;
  }

  if (addLinebreak(text, toString, useTabs) && selectionModel.getSelectionStart() == selectionModel.getSelectionEnd())
    newText += "\n";
  return newText;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:PythonCopyPasteProcessor.java



注:本文中的com.intellij.openapi.util.text.CharFilter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TByteList类代码示例发布时间:2022-05-22
下一篇:
Java ReplicaInPipeline类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap