当前位置: 首页>>代码示例>>Java>>正文


Java LineSeparator.LF属性代码示例

本文整理汇总了Java中com.intellij.util.LineSeparator.LF属性的典型用法代码示例。如果您正苦于以下问题:Java LineSeparator.LF属性的具体用法?Java LineSeparator.LF怎么用?Java LineSeparator.LF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.util.LineSeparator的用法示例。


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

示例1: createTempFile

@NotNull
private static File createTempFile(@NotNull final DocumentContent content, @NotNull String tempFileName) throws IOException {
  FileDocumentManager.getInstance().saveDocument(content.getDocument());

  LineSeparator separator = content.getLineSeparator();
  if (separator == null) separator = LineSeparator.getSystemLineSeparator();

  Charset charset = content.getCharset();
  if (charset == null) charset = Charset.defaultCharset();

  String contentData = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return content.getDocument().getText();
    }
  });
  if (separator != LineSeparator.LF) {
    contentData = StringUtil.convertLineSeparators(contentData, separator.getSeparatorString());
  }

  byte[] bytes = contentData.getBytes(charset);
  return createFile(bytes, tempFileName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExternalDiffToolUtil.java

示例2: createSeparatorPanel

@NotNull
private static JComponent createSeparatorPanel(@NotNull LineSeparator separator) {
  JLabel label = new JLabel(separator.name());
  Color color;
  if (separator == LineSeparator.CRLF) {
    color = JBColor.RED;
  }
  else if (separator == LineSeparator.LF) {
    color = JBColor.BLUE;
  }
  else if (separator == LineSeparator.CR) {
    color = JBColor.MAGENTA;
  }
  else {
    color = JBColor.BLACK;
  }
  label.setForeground(color);
  return label;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DiffUtil.java

示例3: createSeparatorPanel

@Nonnull
private static JComponent createSeparatorPanel(@Nonnull LineSeparator separator) {
  JLabel label = new JLabel(separator.name());
  Color color;
  if (separator == LineSeparator.CRLF) {
    color = JBColor.RED;
  }
  else if (separator == LineSeparator.LF) {
    color = JBColor.BLUE;
  }
  else if (separator == LineSeparator.CR) {
    color = JBColor.MAGENTA;
  }
  else {
    color = JBColor.BLACK;
  }
  label.setForeground(color);
  return label;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:DiffUtil.java

示例4: detectLineSeparators

private static LineSeparator detectLineSeparators(String actual) {
  char[] chars = CharArrayUtil.fromSequence(actual);
  for (char c : chars) {
    if (c == '\r') {
      return LineSeparator.CRLF;
    }
    else if (c == '\n') {   // if we are here, there was no \r before
      return LineSeparator.LF;
    }
  }
  return LineSeparator.LF;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GitBranchWorkerTest.java

示例5: createTempFile

@Nonnull
private static File createTempFile(@Nonnull final DocumentContent content, @Nonnull FileNameInfo fileName) throws IOException {
  FileDocumentManager.getInstance().saveDocument(content.getDocument());

  LineSeparator separator = content.getLineSeparator();
  if (separator == null) separator = LineSeparator.getSystemLineSeparator();

  Charset charset = content.getCharset();
  if (charset == null) charset = Charset.defaultCharset();

  Boolean hasBom = content.hasBom();
  if (hasBom == null) hasBom = CharsetToolkit.getMandatoryBom(charset) != null;

  String contentData = ReadAction.compute(() -> {
    return content.getDocument().getText();
  });
  if (separator != LineSeparator.LF) {
    contentData = StringUtil.convertLineSeparators(contentData, separator.getSeparatorString());
  }

  byte[] bytes = contentData.getBytes(charset);

  byte[] bom = hasBom ? CharsetToolkit.getPossibleBom(charset) : null;
  if (bom != null) {
    bytes = ArrayUtil.mergeArrays(bom, bytes);
  }

  return createFile(bytes, fileName);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:29,代码来源:ExternalDiffToolUtil.java

示例6: detectLineSeparators

@Nonnull
public static LineSeparator detectLineSeparators(@Nonnull CharSequence chars, @Nullable LineSeparator defaultSeparator) {
  for (int i = 0, n = chars.length(); i < n; i++) {
    char c = chars.charAt(i);
    if (c == '\r') {
      return LineSeparator.CRLF;
    }
    else if (c == '\n') {
      // if we are here, there was no \r before
      return LineSeparator.LF;
    }
  }
  return defaultSeparator == null ? LineSeparator.getSystemLineSeparator() : defaultSeparator;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:StorageUtil.java

示例7: doSave

@Override
protected void doSave(@Nullable Element element) throws IOException {
  if (myLineSeparator == null) {
    myLineSeparator = isUseLfLineSeparatorByDefault() ? LineSeparator.LF : LineSeparator.getSystemLineSeparator();
  }

  BufferExposingByteArrayOutputStream content = element == null ? null : StorageUtil.writeToBytes(element, myLineSeparator.getSeparatorString());
  if (ApplicationManager.getApplication().isUnitTestMode() && StringUtil.startsWithChar(myFile.getPath(), '$')) {
    throw new StateStorageException("It seems like some macros were not expanded for path: " + myFile.getPath());
  }

  try {
    if (myStreamProvider != null && myStreamProvider.isEnabled()) {
      // stream provider always use LF separator
      saveForProvider(myLineSeparator == LineSeparator.LF ? content : null, element);
    }
  }
  catch (Throwable e) {
    LOG.error(e);
  }

  if (content == null) {
    StorageUtil.deleteFile(myFile, this, getVirtualFile());
    myCachedVirtualFile = null;
  }
  else {
    VirtualFile file = getVirtualFile();
    if (file == null || !file.exists()) {
      FileUtil.createParentDirs(myFile);
      file = null;
    }
    myCachedVirtualFile = StorageUtil.writeFile(myFile, this, file, content, isUseXmlProlog() ? myLineSeparator : null);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:34,代码来源:FileBasedStorage.java

示例8: ConvertToUnixLineSeparatorsAction

public ConvertToUnixLineSeparatorsAction() {
  super(ApplicationBundle.message("combobox.crlf.unix"), LineSeparator.LF);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:3,代码来源:ConvertToUnixLineSeparatorsAction.java


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