private static ErrorDescription annotationWarning(HintContext ctx, String artifactId, String hintMex, boolean optional) { final TreePath tp = ctx.getPath(); final TreePath tpParent = tp.getParentPath(); if (tpParent != null) { if (tpParent.getLeaf().getKind() == ANNOTATION) { Project prj = FileOwnerQuery.getOwner(ctx.getInfo().getFileObject()); if (prj != null) { SpringBootService sbs = prj.getLookup().lookup(SpringBootService.class); if (sbs != null) { // check first if the pom has at least one spring boot dependencies if (sbs.hasPomDependency("spring-boot") && !sbs.hasPomDependency(artifactId)) { NbMavenProject mPrj = prj.getLookup().lookup(NbMavenProject.class); if (mPrj != null) { return ErrorDescriptionFactory.forName(ctx, tp, hintMex, new AddDepFix(mPrj, artifactId, optional)); } else { return ErrorDescriptionFactory.forName(ctx, tp, hintMex); } } } } } } return null; }
return ErrorDescriptionFactory.forTree(context, context.getPath(), Bundle.ERR_CreateTestClassHint(), fixes.toArray(new Fix[fixes.size()]));
private static ErrorDescription importWarning(HintContext ctx, String artifactId, String hintMex, String[] fixArtifactIds) { final TreePath tp = ctx.getPath(); final TreePath tpParent = tp.getParentPath(); if (tpParent != null) { if (tpParent.getLeaf().getKind() == IMPORT) { Project prj = FileOwnerQuery.getOwner(ctx.getInfo().getFileObject()); if (prj != null) { SpringBootService sbs = prj.getLookup().lookup(SpringBootService.class); if (sbs != null) { // check first if the pom has at least one spring boot dependencies if (sbs.hasPomDependency("spring-boot") && !sbs.hasPomDependency(artifactId)) { NbMavenProject mPrj = prj.getLookup().lookup(NbMavenProject.class); if (mPrj != null) { Fix[] fixes = new Fix[fixArtifactIds.length]; for (int i = 0; i < fixArtifactIds.length; i++) { fixes[i] = new AddDepFix(mPrj, fixArtifactIds[i], false); } return ErrorDescriptionFactory.forName(ctx, tp, hintMex, fixes); } else { return ErrorDescriptionFactory.forName(ctx, tp, hintMex); } } } } } } return null; }
return ErrorDescriptionFactory.forTree(context, context.getPath(), Bundle.ERR_CreateTestMethodsHint(), fixes.toArray(new Fix[fixes.size()]));