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

Java RawText类代码示例

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

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



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

示例1: TextBlockTransferable

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
public TextBlockTransferable(@NotNull String text, @NotNull Collection<TextBlockTransferableData> extraData, @Nullable RawText rawText) {
  myText = cleanFromNullsIfNeeded(text);
  myExtraData = extraData;
  myRawText = rawText;

  List<DataFlavor> dataFlavors = new ArrayList<DataFlavor>();
  Collections.addAll(dataFlavors, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor);
  final DataFlavor flavor = RawText.getDataFlavor();
  if (myRawText != null && flavor != null) {
    dataFlavors.add(flavor);
  }
  for(TextBlockTransferableData data: extraData) {
    final DataFlavor blockFlavor = data.getFlavor();
    if (blockFlavor != null) {
      dataFlavors.add(blockFlavor);
    }
  }
  myTransferDataFlavors = dataFlavors.toArray(new DataFlavor[dataFlavors.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TextBlockTransferable.java


示例2: getTransferData

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
  try {
    for(TextBlockTransferableData data: myExtraData) {
      if (Comparing.equal(data.getFlavor(), flavor)) {
        return data;
      }
    }
    if (myRawText != null && Comparing.equal(RawText.getDataFlavor(), flavor)) {
      return myRawText;
    }
    else if (DataFlavor.stringFlavor.equals(flavor)) {
      return myText;
    }
    else if (DataFlavor.plainTextFlavor.equals(flavor)) {
      return new StringReader(myText);
    }
  }
  catch(NoClassDefFoundError e) {
    // ignore
  }
  throw new UnsupportedFlavorException(flavor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:TextBlockTransferable.java


示例3: TextBlockTransferable

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
public TextBlockTransferable(String text, Collection<TextBlockTransferableData> extraData, RawText rawText) {
  myText = text;
  myExtraData = extraData;
  myRawText = rawText;

  List<DataFlavor> dataFlavors = new ArrayList<DataFlavor>();
  Collections.addAll(dataFlavors, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor);
  final DataFlavor flavor = RawText.getDataFlavor();
  if (myRawText != null && flavor != null) {
    dataFlavors.add(flavor);
  }
  for(TextBlockTransferableData data: extraData) {
    final DataFlavor blockFlavor = data.getFlavor();
    if (blockFlavor != null) {
      dataFlavors.add(blockFlavor);
    }
  }
  myTransferDataFlavors = dataFlavors.toArray(new DataFlavor[dataFlavors.size()]);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:TextBlockTransferable.java


示例4: TextBlockTransferable

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
public TextBlockTransferable(@Nonnull String text, @Nonnull Collection<TextBlockTransferableData> extraData, @Nullable RawText rawText) {
  myText = cleanFromNullsIfNeeded(text);
  myExtraData = extraData;
  myRawText = rawText;

  List<DataFlavor> dataFlavors = new ArrayList<DataFlavor>();
  Collections.addAll(dataFlavors, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor);
  final DataFlavor flavor = RawText.getDataFlavor();
  if (myRawText != null && flavor != null) {
    dataFlavors.add(flavor);
  }
  for(TextBlockTransferableData data: extraData) {
    final DataFlavor blockFlavor = data.getFlavor();
    if (blockFlavor != null) {
      dataFlavors.add(blockFlavor);
    }
  }
  myTransferDataFlavors = dataFlavors.toArray(new DataFlavor[dataFlavors.size()]);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:TextBlockTransferable.java


示例5: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor
  final int selectionStart = selectionModel.getSelectionStart();
  final int selectionEnd = selectionModel.getSelectionEnd();
  PsiElement token = findLiteralTokenType(file, selectionStart, selectionEnd);
  if (token == null) {
    return text;
  }

  if (isStringLiteral(token)) {
    StringBuilder buffer = new StringBuilder(text.length());
    @NonNls String breaker = getLineBreaker(token);
    final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true);
    for (int i = 0; i < lines.length; i++) {
      buffer.append(escapeCharCharacters(lines[i], token));
      if (i != lines.length - 1) {
        buffer.append(breaker);
      }
      else if (text.endsWith("\n")) {
        buffer.append("\\n");
      }
    }
    text = buffer.toString();
  }
  else if (isCharLiteral(token)) {
    return escapeCharCharacters(text, token);
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:StringLiteralCopyPasteProcessor.java


示例6: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  if (editor.getUserData(REMOVE_NEWLINES_ON_PASTE) != null) {
    return StringUtil.convertLineSeparators(text, " ");
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:DebuggerCopyPastePreprocessor.java


示例7: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Override
@NotNull
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  int caretOffset = editor.getCaretModel().getOffset();
  PsiElement element = PsiUtilCore.getElementAtOffset(file, caretOffset);

  ASTNode node = element.getNode();
  if (node != null) {
    boolean hasMarkup = text.indexOf('>') >= 0 || text.indexOf('<') >= 0;
    if (element.getTextOffset() == caretOffset &&
        node.getElementType() == XmlTokenType.XML_END_TAG_START &&
        node.getTreePrev().getElementType() == XmlTokenType.XML_TAG_END) {

       return hasMarkup ? text : encode(text, element);
    } else {
      XmlElement parent = PsiTreeUtil.getParentOfType(element, XmlText.class, XmlAttributeValue.class);
      if (parent != null) {
        if (parent instanceof XmlText && hasMarkup) {
          return text;
        }

        if (TreeUtil.findParent(node, XmlElementType.XML_CDATA) == null &&
            TreeUtil.findParent(node, XmlElementType.XML_COMMENT) == null) {
          return encode(text, element);
        }
      }
    }
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:XmlCopyPastePreProcessor.java


示例8: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor
  final int selectionStart = selectionModel.getSelectionStart();
  final int selectionEnd = selectionModel.getSelectionEnd();
  PsiElement token = findLiteralTokenType(file, selectionStart, selectionEnd);
  if (token == null) {
    return text;
  }

  if (isStringLiteral(token)) {
    StringBuilder buffer = new StringBuilder(text.length());
    @NonNls String breaker = getLineBreaker(token);
    final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true);
    for (int i = 0; i < lines.length; i++) {
      buffer.append(escapeCharCharacters(lines[i], token));
      if (i != lines.length - 1 || "\n".equals(breaker) && text.endsWith("\n")) {
        buffer.append(breaker);
      }
    }
    text = buffer.toString();
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GroovyLiteralCopyPasteProcessor.java


示例9: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
    if (!canPasteForFile(file)) {
        return text;
    }
    return preprocessedText(text);
}
 
开发者ID:platan,项目名称:idea-gradle-dependencies-formatter,代码行数:9,代码来源:MavenToGradleDependenciesCopyPasteProcessor.java


示例10: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@NotNull
@Override
public String preprocessOnPaste(
    Project project, PsiFile psiFile, Editor editor, String text, RawText rawText) {
  if (!(psiFile instanceof BuckFile)) {
    return text;
  }
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // Pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor.
  final int selectionStart = selectionModel.getSelectionStart();
  final PsiElement element = psiFile.findElementAt(selectionStart);
  if (element == null) {
    return text;
  }

  if (BuckPsiUtils.hasElementType(
      element.getNode(),
      TokenType.WHITE_SPACE,
      BuckTypes.SINGLE_QUOTED_STRING,
      BuckTypes.DOUBLE_QUOTED_STRING)) {
    PsiElement property = BuckPsiUtils.findAncestorWithType(element, BuckTypes.PROPERTY);
    if (checkPropertyName(property)) {
      text = buildBuckDependencyPath(element, project, text);
    }
  }
  return text;
}
 
开发者ID:wangyanxing,项目名称:Buck-IntelliJ-Plugin,代码行数:31,代码来源:BuckCopyPasteProcessor.java


示例11: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Override
public String preprocessOnPaste(final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor
  final int selectionStart = selectionModel.getSelectionStart();
  final int selectionEnd = selectionModel.getSelectionEnd();
  PsiElement token = findLiteralTokenType(file, selectionStart, selectionEnd);
  if (token == null) {
    return text;
  }

  if (isStringLiteral(token)) {
    StringBuilder buffer = new StringBuilder(text.length());
    @NonNls String breaker = getLineBreaker(token);
    final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true);
    for (int i = 0; i < lines.length; i++) {
      buffer.append(escapeCharCharacters(lines[i], token));
      if (i != lines.length - 1) {
        buffer.append(breaker);
      }
      else if (text.endsWith("\n")) {
        buffer.append("\\n");
      }
    }
    text = buffer.toString();
  }
  else if (isCharLiteral(token)) {
    return escapeCharCharacters(text, token);
  }
  return text;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:StringLiteralCopyPasteProcessor.java


示例12: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  int caretOffset = editor.getCaretModel().getOffset();
  PsiElement element = PsiUtilCore.getElementAtOffset(file, caretOffset);

  ASTNode node = element.getNode();
  if (node != null) {
    boolean hasMarkup = text.indexOf('>') >= 0 || text.indexOf('<') >= 0;
    if (element.getTextOffset() == caretOffset &&
        node.getElementType() == XmlElementType.XML_END_TAG_START &&
        node.getTreePrev().getElementType() == XmlElementType.XML_TAG_END) {

       return hasMarkup ? text : encode(text, element);
    } else {
      XmlElement parent = PsiTreeUtil.getParentOfType(element, XmlText.class, XmlAttributeValue.class);
      if (parent != null) {
        if (parent instanceof XmlText && hasMarkup) {
          return text;
        }

        if (TreeUtil.findParent(node, XmlElementType.XML_CDATA) == null &&
            TreeUtil.findParent(node, XmlElementType.XML_COMMENT) == null) {
          return encode(text, element);
        }
      }
    }
  }
  return text;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:XmlCopyPastePreProcessor.java


示例13: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Override
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor
  final int selectionStart = selectionModel.getSelectionStart();
  final int selectionEnd = selectionModel.getSelectionEnd();
  PsiElement token = findLiteralTokenType(file, selectionStart, selectionEnd);
  if (token == null) {
    return text;
  }

  if (isStringLiteral(token)) {
    StringBuilder buffer = new StringBuilder(text.length());
    @NonNls String breaker = getLineBreaker(token);
    final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true);
    for (int i = 0; i < lines.length; i++) {
      buffer.append(escapeCharCharacters(lines[i], token));
      if (i != lines.length - 1 || "\n".equals(breaker) && text.endsWith("\n")) {
        buffer.append(breaker);
      }
    }
    text = buffer.toString();
  }
  return text;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:GroovyLiteralCopyPasteProcessor.java


示例14: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Nonnull
@Override
public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
  if (editor.getUserData(REMOVE_NEWLINES_ON_PASTE) != null) {
    return StringUtil.convertLineSeparators(text, " ");
  }
  return text;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:DebuggerCopyPastePreprocessor.java


示例15: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
@Override
public String preprocessOnPaste(
    Project project, PsiFile psiFile, Editor editor, String text, RawText rawText) {
  if (!(psiFile instanceof BuckFile)) {
    return text;
  }
  final Document document = editor.getDocument();
  PsiDocumentManager.getInstance(project).commitDocument(document);
  final SelectionModel selectionModel = editor.getSelectionModel();

  // Pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor.
  final int selectionStart = selectionModel.getSelectionStart();
  final PsiElement element = psiFile.findElementAt(selectionStart);
  if (element == null) {
    return text;
  }

  ASTNode elementNode = element.getNode();
  // A simple test of the element type
  boolean isQuotedString =
      BuckPsiUtils.hasElementType(
          elementNode, BuckTypes.SINGLE_QUOTED_STRING, BuckTypes.DOUBLE_QUOTED_STRING);
  // isQuotedString will be true if the caret is under the left quote, the right quote,
  // or anywhere in between. But pasting with caret under the left quote acts differently than
  // pasting in other isQuotedString positions: Text will be inserted before the quotes, not
  // inside them
  boolean inQuotedString = false;
  if (isQuotedString) {
    inQuotedString =
        element instanceof TreeElement
            && ((TreeElement) element).getStartOffset() < selectionStart;
  }
  if (isQuotedString || BuckPsiUtils.hasElementType(elementNode, TokenType.WHITE_SPACE)) {
    if (inQuotedString) {
      // We want to impose the additional requirement that the string is currently empty. That is,
      // if you are pasting into an existing target, we don't want to process the paste text.
      String elementText = elementNode.getText().trim();
      if (!(elementText.equals("''") || elementText.equals("\"\""))) {
        return text;
      }
    }

    PsiElement property = BuckPsiUtils.findAncestorWithType(element, BuckTypes.PROPERTY);
    if (checkPropertyName(property)) {
      return formatPasteText(text, element, project, inQuotedString);
    }
  }
  return text;
}
 
开发者ID:facebook,项目名称:buck,代码行数:50,代码来源:BuckCopyPasteProcessor.java


示例16: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
/**
 * Replaces pasted text. <code>text</code> value should be returned if no processing is required.
 */
@NotNull
String preprocessOnPaste(final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText);
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:CopyPastePreProcessor.java


示例17: preprocessOnPaste

import com.intellij.openapi.editor.RawText; //导入依赖的package包/类
String preprocessOnPaste(final Project project, final PsiFile file, final Editor editor, String text, final RawText rawText); 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:2,代码来源:CopyPastePreProcessor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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