public ParsingResult getParbResult() throws org.netbeans.modules.parsing.spi.ParseException { if (!valid) { throw new org.netbeans.modules.parsing.spi.ParseException(); } return parbResult; }
@Override public void cancel(CancelReason reason, SourceModificationEvent event) { super.cancel(reason, event); }
public static int getLexerOffset(Parser.Result result, int astOffset) { return result.getSnapshot().getOriginalOffset(astOffset); }
private void checkSourceModification(final SourceModificationEvent evt) { if (evt != null && evt.sourceChanged()) { Pair<DocPositionRegion,MethodTree> changedMethod = null; if (supportsReparse) { int start = evt.getAffectedStartOffset(); int end = evt.getAffectedEndOffset(); synchronized (positions) { for (Pair<DocPositionRegion,MethodTree> pe : positions) { PositionRegion p = pe.first(); if (start > p.getStartOffset() && end < p.getEndOffset()) { changedMethod = pe; break; } } // PENDING - changed method lbrace/rbrace handling ? positions.clear(); if (changedMethod!=null) { positions.add (changedMethod); } JavacParser.this.changedMethod.set(changedMethod); } } } else { positions.clear(); JavacParser.this.changedMethod.set(null); } }
private void runImpl(final CursorMovedSchedulerEvent event, final CsmFile csmFile, final Document doc, final AtomicBoolean canceled) { if (doc == null) { return; } Object obj = doc.getProperty(CsmMacroExpansion.USE_OWN_CARET_POSITION); if (obj != null) { if(!(Boolean) obj) { return; } } Runnable syncPositions = new Runnable() { @Override public void run() { if (!canceled.get()) { syncRelatedDocumentCaretPosition(event, doc); } } }; if (isMacroExpansionDoc(doc)) { SwingUtilities.invokeLater(syncPositions); } else { MacroExpansionViewUtils.updateView(doc, event.getCaretOffset(), csmFile, canceled, syncPositions); } }
@Override protected SchedulerEvent createSchedulerEvent (SourceModificationEvent event) { if (event.getModifiedSource () == getSource()) return new SchedulerEvent (this) {}; return null; }
@Override public void cancel (final @NonNull CancelReason reason, final @NonNull SourceModificationEvent event) { indexCanceled.set(true); if (reason == CancelReason.SOURCE_MODIFICATION_EVENT && event.sourceChanged()) { parserCanceled.set(true); } }
private void resolveNodesUnderCarret() { try { ParserManager.parse(Collections.singleton(Source.create(component.getDocument())), new UserTask() { @Override public void run(ResultIterator resultIterator) throws Exception { ParserResult info = (ParserResult) resultIterator.getParserResult(); if (info != null) { int caretOffset = component.getCaretPosition(); nodes = NavUtils.underCaret(info, caretOffset); } } }); } catch (ParseException ex) { LOGGER.log(Level.WARNING, "Error during resolving nodes under carret (codegens): {0}", ex.getMessage()); } }
long createTaggedController (final long timestamp, final Object[] controller) throws IOException { assert controller.length == 1; assert controller[0] == null || controller[0] instanceof CompilationController; try { CompilationController cc = (CompilationController) controller[0]; final NewComilerTask _task = new NewComilerTask(this.classpathInfo, cc, timestamp); ParserManager.parse(sources, _task); controller[0] = _task.getCompilationController(); return _task.getTimeStamp(); } catch (final ParseException pe) { final Throwable rootCase = pe.getCause(); if (rootCase instanceof CompletionFailure) { throw new IOException (rootCase); } else if (rootCase instanceof RuntimeException) { throw (RuntimeException) rootCase; } else { throw new IOException (rootCase); } } }
public static BaseDocument getDocument(Parser.Result info) { BaseDocument doc = null; if (info != null) { doc = (BaseDocument) info.getSnapshot().getSource().getDocument(true); } return doc; }
@Override public void parse(final Snapshot snapshot, final Task task, SourceModificationEvent event) throws ParseException { try { checkSourceModification(event); parseImpl(snapshot, task); } catch (FileObjects.InvalidFileException ife) { //pass - already invalidated in parseImpl } catch (IOException ioe) { throw new ParseException ("JavacParser failure", ioe); //NOI18N } }
@Override protected SchedulerEvent createSchedulerEvent (SourceModificationEvent event) { if (event.getModifiedSource () == getSource()) return new SchedulerEvent (this) {}; return null; } }
public static BaseDocument getDocument(Result result, boolean forceOpen) { return (BaseDocument) result.getSnapshot().getSource().getDocument(forceOpen); }
@Override protected SchedulerEvent createSchedulerEvent (SourceModificationEvent event) { final JTextComponent ce = currentEditor; final Caret caret = ce != null ? ce.getCaret() : null; final Source s = getSource(); if (event.getModifiedSource() == s && caret != null) { return new CursorMovedSchedulerEvent(this, caret.getDot(), caret.getMark()) { }; } return null; }
public static FileObject getFileObject(Result result) { return result.getSnapshot().getSource().getFileObject(); }
public static OffsetRange getLexerOffsets(Parser.Result result, OffsetRange astRange) { int rangeStart = astRange.getStart(); int start = result.getSnapshot().getOriginalOffset(rangeStart); if (start == rangeStart) { return astRange; } else if (start == -1) { return OffsetRange.NONE; } else { // Assumes the translated range maintains size return new OffsetRange(start, start + astRange.getLength()); } }
@Override public void run(Result result, SchedulerEvent event) { CompilationInfo info = CompilationInfo.get(result); if (info == null) { return ; } cancel.set(false); final Document doc = result.getSnapshot().getSource().getDocument(false); if (!verifyDocument(doc)) return; process(info, doc); }
@Override public void run (Result parseResult, SchedulerEvent event) { resume(); CompilationInfo info = CompilationInfo.get(parseResult); if (info == null) { return ; } Document doc = parseResult.getSnapshot().getSource().getDocument(false); process(info, doc, event); }
@Override public void run(ResultIterator resultIterator) throws Exception { ResultIterator ri = WebUtils.getResultIterator(resultIterator, "text/html"); // NOI18N if (ri != null) { Parser.Result result = ri.getParserResult(); delegate.setContext(file); org.netbeans.modules.html.editor.lib.api.elements.Node sourceNode = sourceElementHandle.resolve(result); if (sourceNode != null) { delegate.setHtmlSourceElementHandle((OpenTag)sourceNode, result.getSnapshot(), file); RP.post(new Runnable() { @Override public void run() { delegate.actionPerformed(null); } }); } } } });