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


Java HighlightDisplayLevel类代码示例

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


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

示例1: checkUnderReadAction

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private boolean checkUnderReadAction(final MyValidatorProcessingItem item, final CompileContext context, final Computable<Map<ProblemDescriptor, HighlightDisplayLevel>> runnable) {
  return DumbService.getInstance(context.getProject()).runReadActionInSmartMode(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      final PsiFile file = item.getPsiFile();
      if (file == null) return false;

      final Document document = myPsiDocumentManager.getCachedDocument(file);
      if (document != null && myPsiDocumentManager.isUncommited(document)) {
        final String url = file.getViewProvider().getVirtualFile().getUrl();
        context.addMessage(CompilerMessageCategory.WARNING, CompilerBundle.message("warning.text.file.has.been.changed"), url, -1, -1);
        return false;
      }

      if (reportProblems(context, runnable.compute())) return false;
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InspectionValidatorWrapper.java

示例2: runInspectionTool

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private static Map<ProblemDescriptor, HighlightDisplayLevel> runInspectionTool(final PsiFile file,
                                                                               final LocalInspectionTool inspectionTool,
                                                                               final HighlightDisplayLevel level) {
  Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
  for (ProblemDescriptor descriptor : runInspectionOnFile(file, inspectionTool)) {
    final ProblemHighlightType highlightType = descriptor.getHighlightType();

    final HighlightDisplayLevel highlightDisplayLevel;
    if (highlightType == ProblemHighlightType.WEAK_WARNING) {
      highlightDisplayLevel = HighlightDisplayLevel.WEAK_WARNING;
    }
    else if (highlightType == ProblemHighlightType.INFORMATION) {
      highlightDisplayLevel = HighlightDisplayLevel.DO_NOT_SHOW;
    }
    else {
      highlightDisplayLevel = level;
    }
    problemsMap.put(descriptor, highlightDisplayLevel);
  }
  return problemsMap;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:InspectionValidatorWrapper.java

示例3: toHighlightDisplayLevel

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
@Nullable
static HighlightDisplayLevel toHighlightDisplayLevel(@NotNull Severity severity) {
  switch (severity) {
    case ERROR:
      return HighlightDisplayLevel.ERROR;
    case FATAL:
      return HighlightDisplayLevel.ERROR;
    case WARNING:
      return HighlightDisplayLevel.WARNING;
    case INFORMATIONAL:
      return HighlightDisplayLevel.WEAK_WARNING;
    case IGNORE:
      return null;
    default:
      LOG.error("Unknown severity " + severity);
      return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AndroidLintInspectionBase.java

示例4: getAttribute

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private SimpleTextAttributes getAttribute(@NotNull final SimpleTextAttributes attrs,
                                          @Nullable HighlightDisplayLevel level) {
  if (level == null) {
    return attrs;
  }

  Map<SimpleTextAttributes, SimpleTextAttributes> highlightMap = myHighlightAttributes.get(level.getSeverity());
  if (highlightMap == null) {
    highlightMap = new HashMap<SimpleTextAttributes, SimpleTextAttributes>();
    myHighlightAttributes.put(level.getSeverity(), highlightMap);
  }

  SimpleTextAttributes result = highlightMap.get(attrs);
  if (result == null) {
    final TextAttributesKey attrKey = SeverityRegistrar.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey();
    TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey);
    textAttrs = TextAttributes.merge(attrs.toTextAttributes(), textAttrs);
    result = SimpleTextAttributes.fromTextAttributes(textAttrs);
    highlightMap.put(attrs, result);
  }

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

示例5: fillErrorLevels

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
protected void fillErrorLevels(final ModifiableModel profile) {
  InspectionToolWrapper[] toolWrappers = profile.getInspectionTools(null);
  LOG.assertTrue(toolWrappers != null, "Profile was not correctly init");
  //fill error levels
  for (final String shortName : myDisplayLevelMap.keySet()) {
    //key <-> short name
    HighlightDisplayLevel level = myDisplayLevelMap.get(shortName);

    HighlightDisplayKey key = HighlightDisplayKey.find(shortName);

    if (key == null) continue;

    //set up tools for default profile
    if (level != HighlightDisplayLevel.DO_NOT_SHOW) {
      profile.enableTool(shortName, null, null);
    }

    if (level == null || level == HighlightDisplayLevel.DO_NOT_SHOW) {
      level = HighlightDisplayLevel.WARNING;
    }
    profile.setErrorLevel(key, level, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:InspectionProfileConvertor.java

示例6: createAnnotationForRef

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
public static HighlightInfo createAnnotationForRef(@NotNull GrReferenceElement ref,
                                                   @NotNull HighlightDisplayLevel displayLevel,
                                                   @NotNull String message) {
  PsiElement refNameElement = ref.getReferenceNameElement();
  assert refNameElement != null;

  if (displayLevel == HighlightDisplayLevel.ERROR) {
    return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refNameElement).descriptionAndTooltip(message).create();
  }

  if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) {
    boolean isTestMode = ApplicationManager.getApplication().isUnitTestMode();
    HighlightInfoType infotype = isTestMode ? HighlightInfoType.WARNING : HighlightInfoType.INFORMATION;

    HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(infotype).range(refNameElement);
    builder.descriptionAndTooltip(message);
    return builder.needsUpdateOnTyping(false).textAttributes(GroovySyntaxHighlighter.UNRESOLVED_ACCESS).create();
  }

  HighlightInfoType highlightInfoType = HighlightInfo.convertSeverity(displayLevel.getSeverity());
  return HighlightInfo.newHighlightInfo(highlightInfoType).range(refNameElement).descriptionAndTooltip(message).create();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GrInspectionUtil.java

示例7: getRelativeRootNode

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
@NotNull
private InspectionTreeNode getRelativeRootNode(boolean isGroupedBySeverity, HighlightDisplayLevel level) {
  if (isGroupedBySeverity) {
    InspectionSeverityGroupNode severityGroupNode = mySeverityGroupNodes.get(level);
    if (severityGroupNode == null) {
      InspectionSeverityGroupNode newNode = new InspectionSeverityGroupNode(myProject, level);
      severityGroupNode = ConcurrencyUtil.cacheOrGet(mySeverityGroupNodes, level, newNode);
      if (severityGroupNode == newNode) {
        InspectionTreeNode root = myTree.getRoot();
        addChildNodeInEDT(root, severityGroupNode);
      }
    }
    return severityGroupNode;
  }
  return myTree.getRoot();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InspectionResultsView.java

示例8: setNewHighlightingLevel

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private void setNewHighlightingLevel(@NotNull HighlightDisplayLevel level) {
  final int[] rows = myTreeTable.getTree().getSelectionRows();
  final boolean showOptionsAndDescriptorPanels = rows != null && rows.length == 1;
  for (int i = 0; rows != null && i < rows.length; i++) {
    final InspectionConfigTreeNode node = (InspectionConfigTreeNode)myTreeTable.getTree().getPathForRow(rows[i]).getLastPathComponent();
    final InspectionConfigTreeNode parent = (InspectionConfigTreeNode)node.getParent();
    final Object userObject = node.getUserObject();
    if (userObject instanceof ToolDescriptors && (node.getScopeName() != null || node.isLeaf())) {
      updateErrorLevel(node, showOptionsAndDescriptorPanels, level);
      updateUpHierarchy(parent);
    }
    else {
      updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node);
      updateUpHierarchy(parent);
    }
  }
  if (rows != null) {
    updateOptionsAndDescriptionPanel(myTreeTable.getTree().getSelectionPaths());
  }
  else {
    initOptionsAndDescriptionPanel();
  }
  repaintTableData();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SingleInspectionProfilePanel.java

示例9: getHighlighLevelAndInspection

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
@Nullable
public static Pair<AndroidLintInspectionBase, HighlightDisplayLevel> getHighlighLevelAndInspection(@NotNull Project project,
                                                                                                   @NotNull Issue issue,
                                                                                                   @NotNull PsiElement context) {
  final String inspectionShortName = AndroidLintInspectionBase.getInspectionShortNameByIssue(project, issue);
  if (inspectionShortName == null) {
    return null;
  }

  final HighlightDisplayKey key = HighlightDisplayKey.find(inspectionShortName);
  if (key == null) {
    return null;
  }

  final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
  if (!profile.isToolEnabled(key, context)) {
    return null;
  }

  final AndroidLintInspectionBase inspection = (AndroidLintInspectionBase)profile.getUnwrappedTool(inspectionShortName, context);
  if (inspection == null) return null;
  final HighlightDisplayLevel errorLevel = profile.getErrorLevel(key, context);
  return Pair.create(inspection,
                     errorLevel != null ? errorLevel : HighlightDisplayLevel.WARNING);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidLintUtil.java

示例10: MultiScopeSeverityIcon

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
public MultiScopeSeverityIcon(final Map<String, HighlightSeverity> scopeToAverageSeverityMap,
                              final String defaultScopeName,
                              final InspectionProfileImpl inspectionProfile) {
  myDefaultScopeName = defaultScopeName;
  final List<String> sortedScopeNames = new ArrayList<String>(scopeToAverageSeverityMap.keySet());
  myScopeToAverageSeverityMap = new LinkedHashMap<String, HighlightDisplayLevel>();
  Collections.sort(sortedScopeNames, new ScopeOrderComparator(inspectionProfile));
  sortedScopeNames.remove(defaultScopeName);
  sortedScopeNames.add(defaultScopeName);
  for (final String scopeName : sortedScopeNames) {
    final HighlightSeverity severity = scopeToAverageSeverityMap.get(scopeName);
    if (severity == null) {
      continue;
    }
    final HighlightDisplayLevel level = HighlightDisplayLevel.find(severity);
    if (level == null) {
      continue;
    }
    myScopeToAverageSeverityMap.put(scopeName, level);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MultiScopeSeverityIcon.java

示例11: putOne

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private void putOne(final ScopeToolState state) {
  if (!state.isEnabled()) {
    return;
  }
  final Icon icon = state.getLevel().getIcon();
  final String scopeName = state.getScopeName();
  if (icon instanceof HighlightDisplayLevel.ColoredIcon) {
    final SeverityAndOccurrences severityAndOccurrences = myScopeToAverageSeverityMap.get(scopeName);
    final String inspectionName = state.getTool().getShortName();
    if (severityAndOccurrences == null) {
      myScopeToAverageSeverityMap.put(scopeName, new SeverityAndOccurrences().incOccurrences(inspectionName, state.getLevel().getSeverity()));
    } else {
      severityAndOccurrences.incOccurrences(inspectionName, state.getLevel().getSeverity());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InspectionsConfigTreeTable.java

示例12: createAnnotationForRef

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
@Nullable
private static HighlightInfo createAnnotationForRef(@NotNull GrReferenceElement ref,
                                                    boolean strongError,
                                                    @NotNull String message) {
  HighlightDisplayLevel displayLevel = strongError ? HighlightDisplayLevel.ERROR
                                                   : GroovyAccessibilityInspection.getHighlightDisplayLevel(ref.getProject(), ref);
  return GrInspectionUtil.createAnnotationForRef(ref, displayLevel, message);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GrAccessibilityChecker.java

示例13: getHighlightDisplayLevel

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
@Nullable
public static HighlightDisplayLevel getHighlightDisplayLevel(final Project project, @NotNull final RadComponent component) {
  HighlightDisplayLevel displayLevel = null;
  for(ErrorInfo errInfo: getAllErrorsForComponent(component)) {
    if (displayLevel == null || SeverityRegistrar.getSeverityRegistrar(project).compare(errInfo.getHighlightDisplayLevel().getSeverity(), displayLevel.getSeverity()) > 0) {
      displayLevel = errInfo.getHighlightDisplayLevel();
    }
  }
  return displayLevel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ErrorAnalyzer.java

示例14: getCategoryByHighlightDisplayLevel

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
public CompilerMessageCategory getCategoryByHighlightDisplayLevel(@NotNull final HighlightDisplayLevel severity,
                                                                  @NotNull final VirtualFile virtualFile,
                                                                  @NotNull final CompileContext context) {
  if (severity == HighlightDisplayLevel.ERROR) return CompilerMessageCategory.ERROR;
  if (severity == HighlightDisplayLevel.WARNING) return CompilerMessageCategory.WARNING;
  return CompilerMessageCategory.INFORMATION;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:InspectionValidator.java

示例15: runXmlFileSchemaValidation

import com.intellij.codeHighlighting.HighlightDisplayLevel; //导入依赖的package包/类
private Map<ProblemDescriptor, HighlightDisplayLevel> runXmlFileSchemaValidation(@NotNull XmlFile xmlFile) {
  final AnnotationHolderImpl holder = new AnnotationHolderImpl(new AnnotationSession(xmlFile));

  final List<ExternalAnnotator> annotators = ExternalLanguageAnnotators.allForFile(StdLanguages.XML, xmlFile);
  for (ExternalAnnotator<?, ?> annotator : annotators) {
    processAnnotator(xmlFile, holder, annotator);
  }

  if (!holder.hasAnnotations()) return Collections.emptyMap();

  Map<ProblemDescriptor, HighlightDisplayLevel> problemsMap = new LinkedHashMap<ProblemDescriptor, HighlightDisplayLevel>();
  for (final Annotation annotation : holder) {
    final HighlightInfo info = HighlightInfo.fromAnnotation(annotation);
    if (info.getSeverity() == HighlightSeverity.INFORMATION) continue;

    final PsiElement startElement = xmlFile.findElementAt(info.startOffset);
    final PsiElement endElement = info.startOffset == info.endOffset ? startElement : xmlFile.findElementAt(info.endOffset - 1);
    if (startElement == null || endElement == null) continue;

    final ProblemDescriptor descriptor =
      myInspectionManager.createProblemDescriptor(startElement, endElement, info.getDescription(), ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                                                  false);
    final HighlightDisplayLevel level = info.getSeverity() == HighlightSeverity.ERROR? HighlightDisplayLevel.ERROR: HighlightDisplayLevel.WARNING;
    problemsMap.put(descriptor, level);
  }
  return problemsMap;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:InspectionValidatorWrapper.java


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