private boolean checkProject(CompilationInfo info){ final FileObject fileObject = info.getFileObject(); return WebBeansActionHelper.isEnabled( fileObject ); }
private static ErrorDescription createNotification( Severity severity, Tree tree, CompilationInfo info, String description, Fix fix ) { List<Fix> fixes; if ( fix != null ){ fixes = Collections.singletonList( fix ); } else { fixes = Collections.<Fix>emptyList(); } if (tree != null){ List<Integer> position = getElementPosition(info, tree); if(position.get(1) > position.get(0)) { return ErrorDescriptionFactory.createErrorDescription( severity, description, fixes, info.getFileObject(), position.get(0), position.get(1)); } } return null; }
public static EditorAnnotationsHelper getInstance( CdiAnalysisResult result ){ return getInstance( result.getInfo().getFileObject()); }
/** * Resolves an {@link Element} from the {@link TreePathHandle}. * @param compilationInfo representing the {@link javax.tools.CompilationTask} * @return resolved subclass of {@link Element} or null if the element does not exist on * the classpath/sourcepath of {@link javax.tools.CompilationTask}. */ public Element resolveElement(final CompilationInfo info) { if (correspondingEl != null) { return correspondingEl.resolve(info); } if ((this.file != null && info.getFileObject() != null) && info.getFileObject().equals(this.file) && this.position != null) { TreePath tp = this.resolve(info); if (tp == null) { return null; } Element el = info.getTrees().getElement(tp); if (el == null) { Logger.getLogger(TreePathHandle.class.toString()).fine("info.getTrees().getElement(tp) returned null for " + tp); Element staticallyImported = getStaticallyImportedElement(tp, info); if (staticallyImported!=null) { return staticallyImported; } } else { return el; } } return null; }
private static String getPreffiledName(CompilationInfo info, String selectedFramework) { FileObject fileObj = info.getFileObject(); ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE); String className = cp.getResourceName(fileObj, '.', false); return className + getTestingFrameworkSuffix(selectedFramework) + TEST_CLASS_SUFFIX; }
return null; populateLocations(info.getFileObject()); Map<Object, List<String>> validCombinations = new HashMap<Object, List<String>>(); for (Object location : locations) {
protected MetadataModel<WebBeansModel> getModel(CompilationInfo compInfo){ Project project = FileOwnerQuery.getOwner( compInfo.getFileObject() ); if ( project == null ){ return null; } MetaModelSupport support = new MetaModelSupport(project); return support.getMetaModel(); }
private static JsfHintsContext createJsfHintsContext(HintContext context) { return new JsfHintsContext(context.getInfo().getFileObject(), context.getInfo()); }
@Override public void run(CompilationInfo p) throws Exception { final CompilationUnitTree compilationUnitTree = p.getCompilationUnit(); final TreePath rootPath = new TreePath(compilationUnitTree); mappedElementExtractor = new MappedElementExtractor(p.getFileObject(), compilationUnitTree, p.getTrees(), rootPath); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { targetModel.refresh(compilationUnitTree.accept(mappedElementExtractor, null)); table.setModel(targetModel); } }); } }
public static ErrorDescription createProblem(Tree tree, CompilationInfo cinfo, String description, Severity severity, List<Fix> fixes) { TextSpan underlineSpan = getUnderlineSpan(cinfo, tree); return ErrorDescriptionFactory.createErrorDescription( severity, description, fixes, cinfo.getFileObject(), underlineSpan.getStartOffset(), underlineSpan.getEndOffset()); }
/** * Creates a new instance of ElementGrip */ public ElementGrip(TreePath treePath, CompilationInfo info) { this.delegateElementHandle = TreePathHandle.create(treePath, info); this.toString = UiUtils.getHeader(treePath, info, UiUtils.PrintPart.NAME); this.fileObject = info.getFileObject(); this.icon = UiUtils.getDeclarationIcon(info.getTrees().getElement(treePath)); }
public void requireCdiEnabled( Element element ){ if ( isCdiRequired ){ return; } isCdiRequired = true; FileObject fileObject = getInfo().getFileObject(); if ( fileObject ==null ){ return; } Project project = FileOwnerQuery.getOwner( fileObject ); if ( project == null ){ return; } CdiUtil lookup = project.getLookup().lookup( CdiUtil.class ); boolean needFix = false; if ( lookup == null ){ //in general main use is is when lookup!=null, if lookup == null nly some general hevavior is supported needFix = !CdiUtil.isCdiEnabled(project); } else { needFix = !lookup.isCdiEnabled(); } if ( needFix) { Fix fix = new BeansXmlFix( project , fileObject , myFactory ); addError(element, NbBundle.getMessage(CdiAnalysisResult.class, "ERR_RequireWebBeans"), fix ); // NOI18N } }
public static final CodeStyle getCodeStyle(CompilationInfo info) { if (info != null) { try { Document doc = info.getDocument(); if (doc != null) { CodeStyle cs = (CodeStyle)doc.getProperty(CodeStyle.class); return cs != null ? cs : CodeStyle.getDefault(doc); } } catch (IOException ioe) { // ignore } FileObject file = info.getFileObject(); if (file != null) { return CodeStyle.getDefault(file); } } return CodeStyle.getDefault((Document)null); }
FileObject fileObject = info.getFileObject(); if(!fileObject.isValid()) { //File is probably deleted return null;
FileObject fileObject = info.getFileObject(); if(!fileObject.isValid()) { //File is probably deleted return null;
.findOwnerRoot(myInfo.getFileObject()); FileObject pakage = FileUtil.createFolder(root, getPackage().replace('.', '/')); Project project = FileOwnerQuery.getOwner( myInfo.getFileObject() ); if ( project != null ){ CdiUtil logger = project.getLookup().lookup(CdiUtil.class);
Bundle.OptionalEE7APIsHint_DisplayName(), fixes, info.getFileObject(), start, end));
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; }
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; }
public DiffContext(CompilationInfo copy, Set<Tree> syntheticTrees) { this.tokenSequence = copy.getTokenHierarchy().tokenSequence(JavaTokenId.language()); this.mainCode = this.origText = copy.getText(); this.style = getCodeStyle(copy); this.context = JavaSourceAccessor.getINSTANCE().getJavacTask(copy).getContext(); this.mainUnit = this.origUnit = (JCCompilationUnit) copy.getCompilationUnit(); this.trees = copy.getTrees(); this.doc = copy.getSnapshot().getSource().getDocument(false); //TODO: true or false? this.positionConverter = copy.getPositionConverter(); this.file = copy.getFileObject(); this.syntheticTrees = syntheticTrees; this.textLength = copy.getSnapshot() == null ? Integer.MAX_VALUE : copy.getSnapshot().getOriginalOffset(copy.getSnapshot().getText().length()); this.blockSequences = new BlockSequences(this.tokenSequence, doc, textLength); this.forceInitialComment = false; }