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


Java TextAttributes.clone方法代码示例

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


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

示例1: highlightUsages

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private void highlightUsages() {
  if (mySearchResults.getEditor() == null) return;
  if (mySearchResults.getMatchesCount() >= mySearchResults.getMatchesLimit())
    return;
  for (FindResult range : mySearchResults.getOccurrences()) {
    if (range.getEndOffset() > mySearchResults.getEditor().getDocument().getTextLength()) continue;
    TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);
    if (range.getLength() == 0) {
      attributes = attributes.clone();
      attributes.setEffectType(EffectType.BOXED);
      attributes.setEffectColor(attributes.getBackgroundColor());
    }
    if (mySearchResults.isExcluded(range)) {
      highlightRange(range, strikeout(), myHighlighters);
    } else {
      highlightRange(range, attributes, myHighlighters);
    }
  }
  updateInSelectionHighlighters();
  if (!myListeningSelection) {
    mySearchResults.getEditor().getSelectionModel().addSelectionListener(this);
    myListeningSelection = true;
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:LivePreview.java

示例2: convertAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@NotNull
private TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
  TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);

  for (TextAttributesKey key : keys) {
    TextAttributes attrs2 = myColorsScheme.getAttributes(key);
    if (attrs2 != null) {
      attrs = TextAttributes.merge(attrs, attrs2);
    }
  }

  attrs = attrs.clone();
  return attrs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ChunkExtractor.java

示例3: testSaveNoInheritanceAndDefaults

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
public void testSaveNoInheritanceAndDefaults() throws Exception {
  TextAttributes identifierAttrs = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME)
    .getAttributes(DefaultLanguageHighlighterColors.IDENTIFIER);
  TextAttributes declarationAttrs = identifierAttrs.clone();
  Pair<EditorColorsScheme, TextAttributes> result =
    doTestWriteRead(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION, declarationAttrs);
  TextAttributes fallbackAttrs = result.first.getAttributes(
    DefaultLanguageHighlighterColors.FUNCTION_DECLARATION.getFallbackAttributeKey()
  );
  assertEquals(result.second, fallbackAttrs);
  assertNotSame(result.second, fallbackAttrs);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:EditorColorsSchemeImplTest.java

示例4: getGrayedHyperlinkAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
@Nullable
private static TextAttributes getGrayedHyperlinkAttributes(@NotNull TextAttributesKey normalHyperlinkAttrsKey) {
  EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
  TextAttributes grayedHyperlinkAttrs = GRAYED_BY_NORMAL_CACHE.get(normalHyperlinkAttrsKey);
  if (grayedHyperlinkAttrs == null) {
    TextAttributes normalHyperlinkAttrs = globalScheme.getAttributes(normalHyperlinkAttrsKey);
    if (normalHyperlinkAttrs != null) {
      grayedHyperlinkAttrs = normalHyperlinkAttrs.clone();
      grayedHyperlinkAttrs.setForegroundColor(UIUtil.getInactiveTextColor());
      grayedHyperlinkAttrs.setEffectColor(UIUtil.getInactiveTextColor());
      GRAYED_BY_NORMAL_CACHE.put(normalHyperlinkAttrsKey, grayedHyperlinkAttrs);
    }
  }
  return grayedHyperlinkAttrs;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:Filter.java

示例5: showInEditor

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
  TextAttributes attributes =
    EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);

  DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);

  if (state.equals(panel.getEditorState())) {
    return;
  }

  panel.navigateInPreviewEditor(state);

  TextAttributes softerAttributes = attributes.clone();
  Color backgroundColor = softerAttributes.getBackgroundColor();
  if (backgroundColor != null) {
    softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
  }

  final Editor editor = panel.getEditor();
  if (editor != null) {
    final MarkupModel editorModel = editor.getMarkupModel();
    final MarkupModel documentModel =
      DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);

    for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
      if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
        final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
        if (line1 != line) {
          editorModel.addLineHighlighter(line1,
                                         DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:BreakpointItem.java

示例6: patchAttributesColor

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
/**
 * Patches attributes to be visible under debugger active line
 */
@SuppressWarnings("UseJBColor")
public static TextAttributes patchAttributesColor(TextAttributes attributes, @NotNull TextRange range, @NotNull Editor editor) {
  MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
  if (model != null) {
    if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(),
         new Processor<RangeHighlighterEx>() {
           @Override
           public boolean process(RangeHighlighterEx highlighter) {
             if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
               TextAttributes textAttributes = highlighter.getTextAttributes();
               if (textAttributes != null) {
                 Color color = textAttributes.getBackgroundColor();
                 return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128);
               }
             }
             return true;
           }
         })) {
      TextAttributes clone = attributes.clone();
      clone.setForegroundColor(Color.orange);
      clone.setEffectColor(Color.orange);
      return clone;
    }
  }
  return attributes;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:NavigationUtil.java

示例7: execute

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
public void execute(final String line, final int textEndOffset) {
  myResult = null;
  myInfo = parseExceptionLine(line);
  if (myInfo == null) {
    return;
  }

  myMethod = myInfo.getSecond().substring(line);

  final int lparenthIndex = myInfo.third.getStartOffset();
  final int rparenthIndex = myInfo.third.getEndOffset();
  final String fileAndLine = line.substring(lparenthIndex + 1, rparenthIndex).trim();

  final int colonIndex = fileAndLine.lastIndexOf(':');
  if (colonIndex < 0) return;

  final int lineNumber = getLineNumber(fileAndLine.substring(colonIndex + 1));
  if (lineNumber < 0) return;

  Pair<PsiClass[], PsiFile[]> pair = myCache.resolveClass(myInfo.first.substring(line).trim());
  myClasses = pair.first;
  myFiles = pair.second;
  if (myFiles.length == 0) {
    // try find the file with the required name
    //todo[nik] it would be better to use FilenameIndex here to honor the scope by it isn't accessible in Open API
    myFiles = PsiShortNamesCache.getInstance(myProject).getFilesByName(fileAndLine.substring(0, colonIndex).trim());
  }
  if (myFiles.length == 0) return;

  /*
   IDEADEV-4976: Some scramblers put something like SourceFile mock instead of real class name.
  final String filePath = fileAndLine.substring(0, colonIndex).replace('/', File.separatorChar);
  final int slashIndex = filePath.lastIndexOf(File.separatorChar);
  final String shortFileName = slashIndex < 0 ? filePath : filePath.substring(slashIndex + 1);
  if (!file.getName().equalsIgnoreCase(shortFileName)) return null;
  */

  final int textStartOffset = textEndOffset - line.length();

  final int highlightStartOffset = textStartOffset + lparenthIndex + 1;
  final int highlightEndOffset = textStartOffset + rparenthIndex;

  ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
  List<VirtualFile> virtualFilesInLibraries = new ArrayList<VirtualFile>();
  List<VirtualFile> virtualFilesInContent = new ArrayList<VirtualFile>();
  for (PsiFile file : myFiles) {
    VirtualFile virtualFile = file.getVirtualFile();
    if (index.isInContent(virtualFile)) {
      virtualFilesInContent.add(virtualFile);
    }
    else {
      virtualFilesInLibraries.add(virtualFile);
    }
  }

  List<VirtualFile> virtualFiles;
  TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES);
  if (virtualFilesInContent.isEmpty()) {
    Color libTextColor = UIUtil.getInactiveTextColor();
    attributes = attributes.clone();
    attributes.setForegroundColor(libTextColor);
    attributes.setEffectColor(libTextColor);

    virtualFiles = virtualFilesInLibraries;
  }
  else {
    virtualFiles = virtualFilesInContent;
  }
  HyperlinkInfo linkInfo = HyperlinkInfoFactory.getInstance().createMultipleFilesHyperlinkInfo(virtualFiles, lineNumber - 1, myProject);
  myResult = new Filter.Result(highlightStartOffset, highlightEndOffset, linkInfo, attributes);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:72,代码来源:ExceptionWorker.java

示例8: getTextAttributes

import com.intellij.openapi.editor.markup.TextAttributes; //导入方法依赖的package包/类
private SimpleTextAttributes getTextAttributes(final int row, final Property property) {
  // 1. Text
  ErrorInfo errInfo = getErrorInfoForRow(row);

  SimpleTextAttributes result;
  boolean modified;
  try {
    modified = isModifiedForSelection(property);
  }
  catch(Exception ex) {
    // ignore exceptions here - they'll be reported as red property values
    modified = false;
  }
  if (errInfo == null) {
    result = modified ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES;
  }
  else {
    final HighlightSeverity severity = errInfo.getHighlightDisplayLevel().getSeverity();
    Map<HighlightSeverity, SimpleTextAttributes> cache = modified ? myModifiedHighlightAttributes : myHighlightAttributes;
    result = cache.get(severity);
    if (result == null) {
      final TextAttributesKey attrKey = SeverityRegistrar.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey();
      TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey);
      if (modified) {
        textAttrs = textAttrs.clone();
        textAttrs.setFontType(textAttrs.getFontType() | Font.BOLD);
      }
      result = SimpleTextAttributes.fromTextAttributes(textAttrs);
      cache.put(severity, result);
    }
  }

  if (property instanceof IntrospectedProperty) {
    final RadComponent c = mySelection.get(0);
    if (Properties.getInstance().isPropertyDeprecated(c.getModule(), c.getComponentClass(), property.getName())) {
      return new SimpleTextAttributes(result.getBgColor(), result.getFgColor(), result.getWaveColor(),
                                      result.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT);
    }
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:PropertyInspectorTable.java


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