Java 类com.intellij.util.xml.highlighting.DomElementAnnotationHolder 实例源码

项目:intellij-ce-playground    文件:ExtendsClassChecker.java   
public List<DomElementProblemDescriptor> checkForProblems(@NotNull final ExtendClass extend, @NotNull final DomElement _element, @NotNull final DomElementAnnotationHolder holder,
                          @NotNull final DomHighlightingHelper helper) {
  if (!(_element instanceof GenericDomValue)) return Collections.emptyList();
  GenericDomValue element = (GenericDomValue)_element;

  if (!isPsiClassType(element)) return Collections.emptyList();

  final Object valueObject = element.getValue();
  PsiClass psiClass = null;

  if (valueObject instanceof PsiClass) {
    psiClass = (PsiClass)valueObject;
  } else if (valueObject instanceof PsiClassType) {
    psiClass = ((PsiClassType)valueObject).resolve();
  }

  if (psiClass != null) {
      return checkExtendClass(element, psiClass, extend.value(),
                              extend.instantiatable(), extend.canBeDecorator(), extend.allowInterface(),
                              extend.allowNonPublic(), extend.allowAbstract(), extend.allowEnum(), holder);
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:MavenDomAnnotator.java   
private static void addProblems(DomElement element, MavenDomProjectModel model, DomElementAnnotationHolder holder,
                                MavenProjectProblem.ProblemType... types) {
  MavenProject mavenProject = MavenDomUtil.findProject(model);
  if (mavenProject != null) {
    for (MavenProjectProblem each : mavenProject.getProblems()) {
      MavenProjectProblem.ProblemType type = each.getType();
      if (!Arrays.asList(types).contains(type)) continue;
      VirtualFile problemFile = LocalFileSystem.getInstance().findFileByPath(each.getPath());

      LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
      if (problemFile != null && !Comparing.equal(mavenProject.getFile(), problemFile)) {
        fixes = new LocalQuickFix[]{new OpenProblemFileFix(problemFile)};
      }
      holder.createProblem(element, HighlightSeverity.ERROR, each.getDescription(), fixes);
    }
  }
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
private static void addProblem(@NotNull MavenDomDependency dependency,
                               @NotNull Collection<MavenDomDependency> dependencies,
                               @NotNull DomElementAnnotationHolder holder) {
  StringBuilder sb = new StringBuilder();
  Set<MavenDomProjectModel> processed = new HashSet<MavenDomProjectModel>();
  for (MavenDomDependency domDependency : dependencies) {
    if (dependency.equals(domDependency)) continue;
    MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model != null && !processed.contains(model)) {
      if (processed.size() > 0) sb.append(", ");
      sb.append(createLinkText(model, domDependency));

      processed.add(model);
    }
  }
  holder.createProblem(dependency, HighlightSeverity.WARNING,
                       MavenDomBundle.message("MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
}
项目:intellij-ce-playground    文件:AntMissingPropertiesFileInspection.java   
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof AntDomProperty) {
    final AntDomProperty property = (AntDomProperty)element;
    final GenericAttributeValue<PsiFileSystemItem> fileValue = property.getFile();
    final String fileName = fileValue.getStringValue();
    if (fileName != null) {
      final PropertiesFile propertiesFile = property.getPropertiesFile();
      if (propertiesFile == null) {
        final PsiFileSystemItem file = fileValue.getValue();
        if (file instanceof XmlFile) {
          holder.createProblem(fileValue, AntBundle.message("file.type.xml.not.supported", fileName));
        }
        else if (file instanceof PsiFile) {
          holder.createProblem(fileValue, AntBundle.message("file.type.not.supported", fileName));
        }
        else {
          holder.createProblem(fileValue, AntBundle.message("file.doesnt.exist", fileName));
        }
      }
    }
  }
}
项目:tools-idea    文件:ExtendsClassChecker.java   
public List<DomElementProblemDescriptor> checkForProblems(@NotNull final ExtendClass extend, @NotNull final DomElement _element, @NotNull final DomElementAnnotationHolder holder,
                          @NotNull final DomHighlightingHelper helper) {
  if (!(_element instanceof GenericDomValue)) return Collections.emptyList();
  GenericDomValue element = (GenericDomValue)_element;

  if (!isPsiClassType(element)) return Collections.emptyList();

  final Object valueObject = element.getValue();
  PsiClass psiClass = null;

  if (valueObject instanceof PsiClass) {
    psiClass = (PsiClass)valueObject;
  } else if (valueObject instanceof PsiClassType) {
    psiClass = ((PsiClassType)valueObject).resolve();
  }

  if (psiClass != null) {
      return checkExtendClass(element, psiClass, extend.value(),
                              extend.instantiatable(), extend.canBeDecorator(), extend.allowInterface(),
                              extend.allowNonPublic(), extend.allowAbstract(), extend.allowEnum(), holder);
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:MavenDomAnnotator.java   
private void addProblems(DomElement element, MavenDomProjectModel model, DomElementAnnotationHolder holder,
                         MavenProjectProblem.ProblemType... types) {
  MavenProject mavenProject = MavenDomUtil.findProject(model);
  if (mavenProject != null) {
    for (MavenProjectProblem each : mavenProject.getProblems()) {
      MavenProjectProblem.ProblemType type = each.getType();
      if (!Arrays.asList(types).contains(type)) continue;
      VirtualFile problemFile = LocalFileSystem.getInstance().findFileByPath(each.getPath());

      LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
      if (problemFile != null && !Comparing.equal(mavenProject.getFile(), problemFile)) {
        fixes = new LocalQuickFix[]{new OpenProblemFileFix(problemFile)};
      }
      holder.createProblem(element, HighlightSeverity.ERROR, each.getDescription(), fixes);
    }
  }
}
项目:tools-idea    文件:MavenDuplicateDependenciesInspection.java   
private static void addProblem(@NotNull MavenDomDependency dependency,
                               @NotNull Collection<MavenDomDependency> dependencies,
                               @NotNull DomElementAnnotationHolder holder) {
  StringBuilder sb = new StringBuilder();
  Set<MavenDomProjectModel> processed = new HashSet<MavenDomProjectModel>();
  for (MavenDomDependency domDependency : dependencies) {
    if (dependency.equals(domDependency)) continue;
    MavenDomProjectModel model = domDependency.getParentOfType(MavenDomProjectModel.class, false);
    if (model != null && !processed.contains(model)) {
      if (processed.size() > 0) sb.append(", ");
      sb.append(createLinkText(model, domDependency));

      processed.add(model);
    }
  }
  holder.createProblem(dependency, HighlightSeverity.WARNING,
                       MavenDomBundle.message("MavenDuplicateDependenciesInspection.has.duplicates", sb.toString()));
}
项目:ibatis-plugin    文件:SymbolInSQLInspection.java   
protected void checkSymbol(IbatisSqlMapModel sqlMapModel, SqlMap sqlMap, DomElement domElement, DomElementAnnotationHolder holder, PsiClass parameterClass) {
    if (parameterClass == null) return;
    Set<String> inlineParameters = new HashSet<String>();
    String[] words = getAllTextInTag(domElement.getXmlTag()).trim().split("\\s+");
    if (words != null) {
        for (String word : words) {
            if (word.startsWith("#") && word.endsWith("#"))  // symbol
            {
                String parameterName = getParameterRealName(word);
                inlineParameters.add(parameterName);
            }
        }
    }
    //domain class validation
    if (IbatisClassShortcutsReferenceProvider.isDomain(parameterClass.getName())) {
        for (String inlineParameter : inlineParameters) {
            if (!isFieldOfPsiClass(parameterClass, inlineParameter.split("\\."))) { //not a valid field for domain class
                holder.createProblem(domElement, HighlightSeverity.WARNING, IbatisBundle.message("ibatis.sqlmap.inspection.symbolinsql.error", inlineParameter));
            }
        }
    }
}
项目:consulo-java    文件:ExtendsClassChecker.java   
public List<DomElementProblemDescriptor> checkForProblems(@NotNull final ExtendClass extend, @NotNull final DomElement _element, @NotNull final DomElementAnnotationHolder holder,
                          @NotNull final DomHighlightingHelper helper) {
  if (!(_element instanceof GenericDomValue)) return Collections.emptyList();
  GenericDomValue element = (GenericDomValue)_element;

  if (!isPsiClassType(element)) return Collections.emptyList();

  final Object valueObject = element.getValue();
  PsiClass psiClass = null;

  if (valueObject instanceof PsiClass) {
    psiClass = (PsiClass)valueObject;
  } else if (valueObject instanceof PsiClassType) {
    psiClass = ((PsiClassType)valueObject).resolve();
  }

  if (psiClass != null) {
      return checkExtendClass(element, psiClass, extend.value(),
                              extend.instantiatable(), extend.canBeDecorator(), extend.allowInterface(),
                              extend.allowNonPublic(), extend.allowAbstract(), extend.allowEnum(), holder);
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final XmlElement valueElement = DomUtil.getValueElement(element);
  if (valueElement == null) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(valueElement, new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:MavenDomAnnotator.java   
public void annotate(DomElement element, DomElementAnnotationHolder holder) {
  if (element instanceof MavenDomProjectModel) {
    addProblems(element, (MavenDomProjectModel)element, holder,
                MavenProjectProblem.ProblemType.STRUCTURE,
                MavenProjectProblem.ProblemType.SETTINGS_OR_PROFILES);
  }
  else if (element instanceof MavenDomParent) {
    addProblems(element, DomUtil.getParentOfType(element, MavenDomProjectModel.class, true), holder,
                MavenProjectProblem.ProblemType.PARENT);
  }
}
项目:intellij-ce-playground    文件:MavenDuplicatePluginInspection.java   
@Override
public void checkFileElement(DomFileElement<MavenDomProjectModel> domFileElement,
                             DomElementAnnotationHolder holder) {
  MavenDomProjectModel projectModel = domFileElement.getRootElement();

  MultiMap<Pair<String,String>, MavenDomPlugin> duplicates = MultiMap.createSet();

  for (MavenDomPlugin plugin : projectModel.getBuild().getPlugins().getPlugins()) {
    String groupId = plugin.getGroupId().getStringValue();
    String artifactId = plugin.getArtifactId().getStringValue();

    if (StringUtil.isEmptyOrSpaces(artifactId)) continue;

    if ("".equals(groupId) || "org.apache.maven.plugins".equals(groupId) || "org.codehaus.mojo".equals(groupId)) {
      groupId = null;
    }

    duplicates.putValue(Pair.create(groupId, artifactId), plugin);
  }

  for (Map.Entry<Pair<String,String>, Collection<MavenDomPlugin>> entry : duplicates.entrySet()) {
    Collection<MavenDomPlugin> set = entry.getValue();
    if (set.size() <= 1) continue;

    for (MavenDomPlugin dependency : set) {
      holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated plugin declaration");
    }
  }
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
@Override
public void checkFileElement(DomFileElement<MavenDomProjectModel> domFileElement,
                             DomElementAnnotationHolder holder) {
  MavenDomProjectModel projectModel = domFileElement.getRootElement();

  checkManagedDependencies(projectModel, holder);
  checkDependencies(projectModel, holder);
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
private static void checkDependencies(@NotNull MavenDomProjectModel projectModel,
                                      @NotNull DomElementAnnotationHolder holder) {
  MultiMap<DependencyConflictId, MavenDomDependency> allDuplicates = getDuplicateDependenciesMap(projectModel);

  for (MavenDomDependency dependency : projectModel.getDependencies().getDependencies()) {
    DependencyConflictId id = DependencyConflictId.create(dependency);
    if (id != null) {
      Collection<MavenDomDependency> dependencies = allDuplicates.get(id);
      if (dependencies.size() > 1) {

        List<MavenDomDependency> duplicatedDependencies = new ArrayList<MavenDomDependency>();

        for (MavenDomDependency d : dependencies) {
          if (d == dependency) continue;

          if (d.getParent() == dependency.getParent()) {
            duplicatedDependencies.add(d); // Dependencies in the same file must be unique by groupId:artifactId:type:classifier
          }
          else {
            if (scope(d).equals(scope(dependency))
                && Comparing.equal(d.getVersion().getStringValue(), dependency.getVersion().getStringValue())) {
              duplicatedDependencies.add(d); // Dependencies in different files must not have same groupId:artifactId:VERSION:type:classifier:SCOPE
            }
          }
        }

        if (duplicatedDependencies.size() > 0) {
          addProblem(dependency, duplicatedDependencies, holder);
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:MavenDuplicateDependenciesInspection.java   
private static void checkManagedDependencies(@NotNull MavenDomProjectModel projectModel,
                                             @NotNull DomElementAnnotationHolder holder) {
  MultiMap<DependencyConflictId, MavenDomDependency> duplicates = MultiMap.createSet();
  collect(duplicates, projectModel.getDependencyManagement().getDependencies());

  for (Map.Entry<DependencyConflictId, Collection<MavenDomDependency>> entry : duplicates.entrySet()) {
    Collection<MavenDomDependency> set = entry.getValue();
    if (set.size() <= 1) continue;

    for (MavenDomDependency dependency : set) {
      holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated dependency");
    }
  }
}
项目:intellij-ce-playground    文件:AntAnnotator.java   
private static void createAnnotationOnTag(AntDomElement custom, String failedMessage, DomElementAnnotationHolder holder) {
  final XmlTag tag = custom.getXmlTag();
  if (tag == null) {
    return;
  }
  final String name = custom.getXmlElementName();
  final TextRange absoluteRange = new TextRange(0, name.length()).shiftRight(tag.getTextRange().getStartOffset() + 1);
  holder.createProblem(custom, failedMessage);
  //holder.createErrorAnnotation(absoluteRange, failedMessage);
}
项目:intellij-ce-playground    文件:ExtensionPointBeanClassInspection.java   
@Override
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof ExtensionPoint) {
    ExtensionPoint extensionPoint = (ExtensionPoint)element;
    if (extensionPoint.getWithElements().isEmpty() && !collectMissingWithTags(extensionPoint).isEmpty()) {
      holder.createProblem(extensionPoint,
                           "<extensionPoint> does not have <with> tags to specify the types of class fields",
                           new AddWithTagFix());
    }
  }
}
项目:tools-idea    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(DomUtil.getValueElement(element), new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:MavenDomAnnotator.java   
public void annotate(DomElement element, DomElementAnnotationHolder holder) {
  if (element instanceof MavenDomProjectModel) {
    addProblems(element, (MavenDomProjectModel)element, holder,
                MavenProjectProblem.ProblemType.STRUCTURE,
                MavenProjectProblem.ProblemType.SETTINGS_OR_PROFILES);
  }
  else if (element instanceof MavenDomParent) {
    addProblems(element, DomUtil.getParentOfType(element, MavenDomProjectModel.class, true), holder,
                MavenProjectProblem.ProblemType.PARENT);
  }
}
项目:tools-idea    文件:MavenDuplicateDependenciesInspection.java   
@Override
public void checkFileElement(DomFileElement<MavenDomProjectModel> domFileElement,
                             DomElementAnnotationHolder holder) {
  MavenDomProjectModel projectModel = domFileElement.getRootElement();

  checkManagedDependencies(projectModel, holder);
  checkDependencies(projectModel, holder);
}
项目:tools-idea    文件:MavenDuplicateDependenciesInspection.java   
private static void checkDependencies(@NotNull MavenDomProjectModel projectModel,
                                      @NotNull DomElementAnnotationHolder holder) {
  final Map<DependencyConflictId, Set<MavenDomDependency>> allDuplicates = getDuplicateDependenciesMap(projectModel);

  for (MavenDomDependency dependency : projectModel.getDependencies().getDependencies()) {
    DependencyConflictId id = DependencyConflictId.create(dependency);
    if (id != null) {
      Set<MavenDomDependency> dependencies = allDuplicates.get(id);
      if (dependencies != null && dependencies.size() > 1) {

        List<MavenDomDependency> duplicatedDependencies = new ArrayList<MavenDomDependency>();

        for (MavenDomDependency d : dependencies) {
          if (d == dependency) continue;

          if (d.getParent() == dependency.getParent()) {
            duplicatedDependencies.add(d); // Dependencies in the same file must be unique by groupId:artifactId:type:classifier
          }
          else {
            if (scope(d).equals(scope(dependency))
                && Comparing.equal(d.getVersion().getStringValue(), dependency.getVersion().getStringValue())) {
              duplicatedDependencies.add(d); // Dependencies in different files must not have same groupId:artifactId:VERSION:type:classifier:SCOPE
            }
          }
        }

        if (duplicatedDependencies.size() > 0) {
          addProblem(dependency, duplicatedDependencies, holder);
        }
      }
    }
  }
}
项目:tools-idea    文件:MavenDuplicateDependenciesInspection.java   
private static void checkManagedDependencies(@NotNull MavenDomProjectModel projectModel,
                                             @NotNull DomElementAnnotationHolder holder) {
  final Map<DependencyConflictId, Set<MavenDomDependency>> duplicates = new THashMap<DependencyConflictId, Set<MavenDomDependency>>();
  collect(duplicates, projectModel.getDependencyManagement().getDependencies());

  for (Map.Entry<DependencyConflictId, Set<MavenDomDependency>> entry : duplicates.entrySet()) {
    Set<MavenDomDependency> set = entry.getValue();
    if (set.size() <= 1) continue;

    for (MavenDomDependency dependency : set) {
      holder.createProblem(dependency, HighlightSeverity.WARNING, "Duplicated dependency");
    }
  }
}
项目:tools-idea    文件:AntAnnotator.java   
private static void createAnnotationOnTag(AntDomElement custom, String failedMessage, DomElementAnnotationHolder holder) {
  final XmlTag tag = custom.getXmlTag();
  if (tag == null) {
    return;
  }
  final String name = custom.getXmlElementName();
  final TextRange absoluteRange = new TextRange(0, name.length()).shiftRight(tag.getTextRange().getStartOffset() + 1);
  holder.createProblem(custom, failedMessage);
  //holder.createErrorAnnotation(absoluteRange, failedMessage);
}
项目:tools-idea    文件:AntMissingPropertiesFileInspection.java   
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof AntDomProperty) {
    final AntDomProperty property = (AntDomProperty)element;
    final String fileName = property.getFile().getStringValue();
    if (fileName != null) {
      final PsiFileSystemItem file = property.getFile().getValue();
      if (!(file instanceof PropertiesFile)) {
        holder.createProblem(property.getFile(), AntBundle.message("file.doesnt.exist", fileName));
      }
    }
  }
}
项目:tools-idea    文件:AntResolveInspection.java   
private static void checkReferences(final XmlElement xmlElement, final @NonNls DomElementAnnotationHolder holder, DomElement domElement) {
  if (xmlElement == null) {
    return;
  }
  Set<PsiReference> processed = null;
  for (final PsiReference ref : xmlElement.getReferences()) {
    if (!(ref instanceof AntDomReference)) {
      continue;
    }
    final AntDomReference antDomRef = (AntDomReference)ref;
    if (antDomRef.shouldBeSkippedByAnnotator()) {
      continue;
    }
    if (processed != null && processed.contains(ref)) {
      continue;
    }
    if (!isResolvable(ref)) {

      holder.createProblem(domElement, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, antDomRef.getUnresolvedMessagePattern(), ref.getRangeInElement(), new AntChangeContextLocalFix());

      if (ref instanceof AntDomFileReference) {
        if (processed == null) {
          processed = new HashSet<PsiReference>();
        }
        ContainerUtil.addAll(processed, ((AntDomFileReference)ref).getFileReferenceSet().getAllReferences());
      }
    }
  }
}
项目:tools-idea    文件:ExtensionPointBeanClassInspection.java   
@Override
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof ExtensionPoint) {
    ExtensionPoint extensionPoint = (ExtensionPoint)element;
    if (extensionPoint.getWithElements().isEmpty() && !collectMissingWithTags(extensionPoint).isEmpty()) {
      holder.createProblem(extensionPoint,
                           "<extensionPoint> does not have <with> tags to specify the types of class fields",
                           new AddWithTagFix());
    }
  }
}
项目:ibatis-plugin    文件:SqlMapFileInConfigurationInspection.java   
@SuppressWarnings({"ConstantConditions", "SuspiciousMethodCalls"})
public void checkFileElement(DomFileElement<SqlMap> fileElement, DomElementAnnotationHolder holder) {
    SqlMap sqlMap = fileElement.getRootElement();
    Module module = ModuleUtil.findModuleForPsiElement(fileElement.getXmlElement());
    IbatisConfigurationModel configurationModel = IbatisManager.getInstance().getConfigurationModel(module);
    if (configurationModel != null) {
        Set<XmlFile> sqlMapFiles = configurationModel.getSqlMapFiles();
        if (!sqlMapFiles.contains(sqlMap.getContainingFile())) {
            SqlMapConfig sqlMapConfig = configurationModel.getMergedModel();
            holder.createProblem(sqlMap, HighlightSeverity.WARNING, IbatisBundle.message("ibatis.sqlmap.inspection.notinconfiguration.error"), new InsertSqlMapIntoConfigurationQuickFix(sqlMapConfig, sqlMap));
        }
    }
}
项目:ibatis-plugin    文件:SqlMapInspection.java   
@SuppressWarnings({"ConstantConditions"})
public void checkFileElement(DomFileElement<SqlMap> fileElement, DomElementAnnotationHolder holder) {
    Module module = ModuleUtil.findModuleForPsiElement(fileElement.getXmlElement());
    IbatisProjectComponent projectComponent = IbatisProjectComponent.getInstance(module.getProject());
    List<IbatisSqlMapModel> models = projectComponent.getSqlMapModelFactory().getAllModels(module);
    if (models.size() < 1) return;
    IbatisSqlMapModel model = models.get(0);
    SqlMap sqlMap = fileElement.getRootElement();
    for (Select select : sqlMap.getSelects()) {
        checkSelect(model, sqlMap, select, holder);
    }
    for (Update update : sqlMap.getUpdates()) {
        checkUpdate(model, sqlMap, update, holder);
    }
    for (Delete delete : sqlMap.getDeletes()) {
        checkDelete(model, sqlMap, delete, holder);
    }
    for (Insert insert : sqlMap.getInserts()) {
        checkInsert(model, sqlMap, insert, holder);
    }
    for (Procedure procedure : sqlMap.getProcedures()) {
        checkProcedure(model, sqlMap, procedure, holder);
    }
    for (Statement statement : sqlMap.getStatements()) {
        checkStatement(model, sqlMap, statement, holder);
    }
    for (ResultMap resultMap : sqlMap.getResultMaps()) {
        checkResultMap(model, sqlMap, resultMap, holder);
    }
}
项目:ibatis-plugin    文件:ParameterMapInStatementInspection.java   
protected void checkParameterMap(IbatisSqlMapModel sqlMapModel, SqlMap sqlMap, DomElement domElement, DomElementAnnotationHolder holder, ParameterMap parameterMap) {
    if (parameterMap == null) return;
    String sql = IbatisUtil.getSQLForXmlTag(domElement.getXmlTag());
    int count = (sql + " ").split("\\?").length - 1;
    int count2 = parameterMap.getParameters().size();
    if (count != count2) {
        holder.createProblem(domElement, HighlightSeverity.WARNING, IbatisBundle.message("ibatis.sqlmap.inspection.parametermapinstatement.error"));
    }
}
项目:idea-dozer-plugin    文件:FieldExpression.java   
public void annotate(DomElementAnnotationHolder holder) {
  for (ProblemDescription description : expressionProblems) {
    description.toDomProblem(holder);
  }

  checkPropertyAccess(holder);
}
项目:idea-dozer-plugin    文件:FieldExpression.java   
private void checkPropertyAccess(DomElementAnnotationHolder holder) {
  ListIterator<Term> termIt = terms.listIterator();
  while (termIt.hasNext()) {
    Term term = termIt.next();
    boolean isLastTerm = !termIt.hasNext();
    PropertyDescriptor property = term.getProperty();

    boolean requireWritable;

    if ("a".equals(fieldDefinition.getXmlElementName())) {
      requireWritable = getMappingType() == Type.BI_DIRECTIONAL && isLastTerm;
    }
    else {
      requireWritable = isLastTerm;
    }

    if (!property.isReadable()) {
      holder.createProblem(fieldDefinition,
                           HighlightSeverity.ERROR,
                           Messages.getMessage("FieldExpression.unreadable", property.getPropertyName())); //$NON-NLS-1$
    }
    if (requireWritable && !property.isWritable()) {
      holder.createProblem(fieldDefinition,
                           HighlightSeverity.ERROR,
                           Messages.getMessage("FieldExpression.unwritable", property.getPropertyName())); //$NON-NLS-1$
    }
  }
}
项目:idea-dozer-plugin    文件:FieldExpression.java   
public DomElementProblemDescriptor toDomProblem(DomElementAnnotationHolder holder) {
  if (textRange == null) {
    return holder.createProblem(FieldExpression.this.fieldDefinition, severity, message);
  }
  else {
    return holder.createProblem(FieldExpression.this.fieldDefinition, severity, message, textRange);
  }
}
项目:consulo-apache-ant    文件:AntAnnotator.java   
private static void createAnnotationOnTag(AntDomElement custom, String failedMessage, DomElementAnnotationHolder holder) {
  final XmlTag tag = custom.getXmlTag();
  if (tag == null) {
    return;
  }
  final String name = custom.getXmlElementName();
  final TextRange absoluteRange = new TextRange(0, name.length()).shiftRight(tag.getTextRange().getStartOffset() + 1);
  holder.createProblem(custom, failedMessage);
  //holder.createErrorAnnotation(absoluteRange, failedMessage);
}
项目:consulo-apache-ant    文件:AntMissingPropertiesFileInspection.java   
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof AntDomProperty) {
    final AntDomProperty property = (AntDomProperty)element;
    final String fileName = property.getFile().getStringValue();
    if (fileName != null) {
      final PsiFileSystemItem file = property.getFile().getValue();
      if (!(file instanceof PropertiesFile)) {
        holder.createProblem(property.getFile(), AntBundle.message("file.doesnt.exist", fileName));
      }
    }
  }
}
项目:consulo-apache-ant    文件:AntResolveInspection.java   
private static void checkReferences(final XmlElement xmlElement, final @NonNls DomElementAnnotationHolder holder, DomElement domElement) {
  if (xmlElement == null) {
    return;
  }
  Set<PsiReference> processed = null;
  for (final PsiReference ref : xmlElement.getReferences()) {
    if (!(ref instanceof AntDomReference)) {
      continue;
    }
    final AntDomReference antDomRef = (AntDomReference)ref;
    if (antDomRef.shouldBeSkippedByAnnotator()) {
      continue;
    }
    if (processed != null && processed.contains(ref)) {
      continue;
    }
    if (!isResolvable(ref)) {

      holder.createProblem(domElement, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, antDomRef.getUnresolvedMessagePattern(), ref.getRangeInElement(), new AntChangeContextLocalFix());

      if (ref instanceof AntDomFileReference) {
        if (processed == null) {
          processed = new HashSet<PsiReference>();
        }
        ContainerUtil.addAll(processed, ((AntDomFileReference)ref).getFileReferenceSet().getAllReferences());
      }
    }
  }
}
项目:consulo-java    文件:ExtendsClassChecker.java   
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
  if (!isPsiClassType(element)) {
    return Collections.emptyList();
  }

  final Object valueObject = element.getValue();
  if (!(valueObject instanceof PsiClass)) return Collections.emptyList();

  final PsiReference[] references = ourProvider.getReferencesByElement(DomUtil.getValueElement(element), new ProcessingContext());
  for (PsiReference reference : references) {
    if (reference instanceof JavaClassReference) {
      final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference)reference).getProvider();
      final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES
        .getValue(((JavaClassReferenceProvider)psiReferenceProvider).getOptions()) : null;
      if (value != null && value.length != 0) {
        for (String className : value) {
          final List<DomElementProblemDescriptor> problemDescriptors =
            checkExtendClass(element, ((PsiClass)valueObject), className, false, false, true, false, true, true, holder);
          if (!problemDescriptors.isEmpty()) {
            return problemDescriptors;
          }
        }
      }
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:ExtendsClassChecker.java   
@NotNull
public static List<DomElementProblemDescriptor> checkExtendClass(final GenericDomValue element, final PsiClass value, final String name,
                                                                 final boolean instantiatable, final boolean canBeDecorator, final boolean allowInterface,
                                                                 final boolean allowNonPublic,
                                                                 final boolean allowAbstract,
                                                                 final boolean allowEnum,
                                                                 final DomElementAnnotationHolder holder) {
  final Project project = element.getManager().getProject();
  PsiClass extendClass = JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
  final SmartList<DomElementProblemDescriptor> list = new SmartList<DomElementProblemDescriptor>();
  if (extendClass != null) {
    if (!name.equals(value.getQualifiedName()) && !value.isInheritor(extendClass, true)) {
      String message = DomBundle.message("class.is.not.a.subclass", value.getQualifiedName(), extendClass.getQualifiedName());
      list.add(holder.createProblem(element, message));
    }
  }

  if (instantiatable) {
    if (value.hasModifierProperty(PsiModifier.ABSTRACT)) {
      list.add(holder.createProblem(element, DomBundle.message("class.is.not.concrete", value.getQualifiedName())));
    }
    else if (!allowNonPublic && !value.hasModifierProperty(PsiModifier.PUBLIC)) {
      list.add(holder.createProblem(element, DomBundle.message("class.is.not.public", value.getQualifiedName())));
    }
    else if (!PsiUtil.hasDefaultConstructor(value, true)) {
      if (canBeDecorator) {
        boolean hasConstructor = false;

        for (PsiMethod method : value.getConstructors()) {
          final PsiParameterList psiParameterList = method.getParameterList();
          if (psiParameterList.getParametersCount() != 1) continue;
          PsiTypeElement typeElement = psiParameterList.getParameters()[0].getTypeElement();
          if (typeElement != null) {
            final PsiType psiType = typeElement.getType();
            if (psiType instanceof PsiClassType) {
              final PsiClass psiClass = ((PsiClassType)psiType).resolve();
              if (psiClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, extendClass, true)) {
                hasConstructor = true;
                break;
              }
            }
          }
        }
        if (!hasConstructor) {
          list.add(holder.createProblem(element, DomBundle.message("class.decorator.or.has.default.constructor", value.getQualifiedName())));
        }
      }
      else {
        list.add(holder.createProblem(element, DomBundle.message("class.has.no.default.constructor", value.getQualifiedName())));
      }
    }
  }
  if (!allowInterface && value.isInterface()) {
    list.add(holder.createProblem(element, DomBundle.message("interface.not.allowed", value.getQualifiedName())));
  }
  if (!allowEnum && value.isEnum()) {
    list.add(holder.createProblem(element, DomBundle.message("enum.not.allowed", value.getQualifiedName())));
  }
  if (!allowAbstract && value.hasModifierProperty(PsiModifier.ABSTRACT) && !value.isInterface()) {
    list.add(holder.createProblem(element, DomBundle.message("abstract.class.not.allowed", value.getQualifiedName())));
  }
  return list;
}
项目:intellij-ce-playground    文件:NavigationGutterIconBuilder.java   
@Nullable
public Annotation install(@NotNull DomElementAnnotationHolder holder, @Nullable DomElement element) {
  if (!myLazy && myTargets.getValue().isEmpty() || element == null) return null;
  return doInstall(holder.createAnnotation(element, HighlightSeverity.INFORMATION, null), element.getManager().getProject());
}
项目:intellij-ce-playground    文件:CommonAnnotationHolder.java   
public static <T extends DomElement> CommonAnnotationHolder<T> create(DomElementAnnotationHolder holder) {
  return new DomHolderAdapter<T>(holder);
}
项目:intellij-ce-playground    文件:CommonAnnotationHolder.java   
DomHolderAdapter(DomElementAnnotationHolder holder) {
  myHolder = holder;
}