private static CompilationInfoImpl createCurrentInfo (final JavacParser parser, final FileObject file, final FileObject root, final Snapshot snapshot, final JavacTaskImpl javac, final DiagnosticListener<JavaFileObject> diagnosticListener) throws IOException { CompilationInfoImpl info = new CompilationInfoImpl(parser, file, root, javac, diagnosticListener, snapshot, false); if (file != null) { Logger.getLogger("TIMER").log(Level.FINE, "CompilationInfo", //NOI18N new Object[] {file, info}); } return info; }
/** * Returns {@link ClasspathInfo} for which this {@link CompilationInfo} was created. * @return ClasspathInfo */ public @NonNull ClasspathInfo getClasspathInfo() { checkConfinement(); return this.impl.getClasspathInfo(); }
/** * Returns the javac tree representing the source file. * @return {@link CompilationUnitTree} the compilation unit containing the top level classes contained in the, * java source file. * @throws java.lang.IllegalStateException when the phase is less than {@link JavaSource.Phase#PARSED} */ public CompilationUnitTree getCompilationUnit() { checkConfinement(); return this.impl.getCompilationUnit(); }
/**Return {@link PositionConverter} binding virtual Java source and the real source. * Please note that this method is needed only for clients that need to work * in non-Java files (e.g. JSP files) or in dialogs, like code completion. * Most clients do not need to use {@link PositionConverter}. * * @return PositionConverter binding the virtual Java source and the real source. * @since 0.21 * @deprecated as of 0.42, this is superseded by Parsing API. */ @Deprecated public PositionConverter getPositionConverter() { checkConfinement(); if (this.impl.getFileObject() == null) { throw new IllegalStateException (); } return new PositionConverter(impl.getSnapshot()); }
final String newBody) throws IOException { assert ci != null; final FileObject fo = ci.getFileObject(); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, "Reparse method in: {0}", fo); //NOI18N final Phase currentPhase = ci.getPhase(); if (Phase.PARSED.compareTo(currentPhase) > 0) { return false; final CompilationUnitTree cu = ci.getCompilationUnit(); if (cu == null || newBody == null) { return false; final JavacTaskImpl task = ci.getJavacTask(); if (Options.instance(task.getContext()).isSet(LOMBOK_DETECTED)) { return false; JCBlock block; try { DiagnosticListener dl = ci.getDiagnosticListener(); assert dl instanceof CompilationInfoImpl.DiagnosticListenerImpl; ((CompilationInfoImpl.DiagnosticListenerImpl)dl).startPartialReparse(origStartPos, origEndPos); if (fl != null && fl.hasFlowCompleted(fo)) { if (LOGGER.isLoggable(Level.FINER)) { final List<? extends Diagnostic> diag = ci.getDiagnostics(); if (!diag.isEmpty()) { LOGGER.log(Level.FINER, "Reflow with errors: {0} {1}", new Object[]{fo, diag}); //NOI18N
JavaSource.Phase parserError = currentInfo.parserCrashed; assert parserError != null; Phase currentPhase = currentInfo.getPhase(); try { if (currentPhase.compareTo(Phase.PARSED)<0 && phase.compareTo(Phase.PARSED)>=0 && phase.compareTo(parserError)<=0) { Iterable<? extends CompilationUnitTree> trees = currentInfo.getJavacTask().parse(new JavaFileObject[] {currentInfo.jfo}); if (trees == null) { LOGGER.log( Level.INFO, "Did not parse anything for: {0}", currentInfo.jfo.toUri()); //NOI18N currentInfo.setCompilationUnit(unit); assert !it.hasNext(); final Document doc = currentInfo.getDocument(); if (doc != null && supportsReparse) { final FindMethodRegionsVisitor v = new FindMethodRegionsVisitor(doc,Trees.instance(currentInfo.getJavacTask()).getSourcePositions(),this.parserCanceled, unit); doc.render(v); synchronized (positions) { FileObject currentFile = currentInfo.getFileObject(); TIME_LOGGER.log(Level.FINE, "Compilation Unit", new Object[] {currentFile, unit}); currentInfo.getJavacTask().enter(); currentPhase = Phase.ELEMENTS_RESOLVED; long end = System.currentTimeMillis(); logTime(currentInfo.getFileObject(),currentPhase,(end-start)); JavacTaskImpl jti = currentInfo.getJavacTask(); PostFlowAnalysis.analyze(jti.analyze(), jti.getContext());
if (shouldParse(task)) { init(task); ciImpl = new CompilationInfoImpl(cpInfo); needsFullReparse = !reparseMethod(ciImpl, snapshot, _changedMethod.second(), _changedMethod.first().getText()); if (!needsFullReparse) { ciImpl.setChangedMethod(_changedMethod); init (snapshot, task, false); ciImpl = createCurrentInfo(this, file, root, snapshot, ciImpl == null ? null : ciImpl.getJavacTask(), ciImpl == null ? null : ciImpl.getDiagnosticListener()); invalid = !success; if (oldInfo != ciImpl && oldInfo != null) { oldInfo.dispose();
String src = info.getText(); FileObject file = info.getFileObject(); String fileName = FileUtil.getFileDisplayName(file); String origName = file.getName(); writer.println("----- Classpath: ---------------------------------------------"); // NOI18N final ClassPath bootPath = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT); final ClassPath classPath = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE); final ClassPath sourcePath = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
/** * Returns tree which was reparsed by an incremental reparse. * When the source file wasn't parsed yet or the parse was a full parse * this method returns null. * <p class="nonnormative"> * Currently the leaf tree is a MethodTree but this may change in the future. * Client of this method is responsible to check the corresponding TreeKind * to find out if it may perform on the changed subtree or it needs to * reprocess the whole tree. * </p> * @return {@link TreePath} or null * @since 0.31 */ public @CheckForNull @CheckReturnValue TreePath getChangedTree () { checkConfinement(); if (JavaSource.Phase.PARSED.compareTo (impl.getPhase())>0) { return null; } final Pair<DocPositionRegion,MethodTree> changedTree = impl.getChangedTree(); if (changedTree == null) { return null; } final CompilationUnitTree cu = impl.getCompilationUnit(); if (cu == null) { return null; } return TreePath.getPath(cu, changedTree.second()); }
if (this.impl.getFileObject() == null) { throw new IllegalStateException (); if (this.impl.isClassFile()) { Elements elements = getElements(); assert elements != null; assert this.impl.getRoot() != null; String name = FileObjects.convertFolder2Package(FileObjects.stripExtension(FileUtil.getRelativePath(this.impl.getRoot(), this.impl.getFileObject()))); TypeElement e = ((JavacElements)elements).getTypeElementByBinaryName(name); if (e != null) {
final DefaultCancelService cancelService = DefaultCancelService.instance(ciImpl.getJavacTask().getContext()); if (cancelService != null) { cancelService.mayCancel.set(true); try { nct.setCompilationController( JavaSourceAccessor.getINSTANCE().createCompilationController(new CompilationInfoImpl(this, file, root, null, null, cachedSnapShot, true)), parseId); } catch (IOException ioe) {
/** * Returns the {@link FileObject} represented by this {@link CompilationInfo}. * @return FileObject */ public @NullUnknown FileObject getFileObject() { checkConfinement(); return impl.getFileObject(); }
/** * Returns {@link Document} of this {@link CompilationInfoImpl} * @return Document or null when the {@link DataObject} doesn't * exist or has no {@link EditorCookie}. * @throws java.io.IOException */ public @CheckForNull Document getDocument() throws IOException { //XXX cleanup: IOException is no longer required? Used by PositionEstimator, DiffFacility checkConfinement(); return this.impl.getDocument(); }
/** * Returns the errors in the file represented by the {@link JavaSource}. * @return an list of {@link Diagnostic} */ public @NonNull List<Diagnostic> getDiagnostics() { checkConfinement(); return this.impl.getDiagnostics(); }
/**Retrieve a value cached under the given key using the * {@link #putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy)} method. * * @param key for which the cached value should be retrieved * @return value originally passed to {@link #putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy)}, or null if none * @since 0.90 */ public @CheckForNull Object getCachedValue(@NonNull Object key) { Parameters.notNull("key", key); return impl.getCachedValue(key); }
this.ciImpl = new CompilationInfoImpl(info,file,root); } catch (final IOException ioe) { throw new ParseException ("ClassParser failure", ioe); //NOI18N