Package com.vaadin.copilot.rewriter
Interface ParsedSource
- All Known Implementing Classes:
JavaSource
public interface ParsedSource
A parsed source file that can report its edited content.
Deliberately says nothing about how the content is produced. The
Java implementation mutates a JavaParser tree and reconstructs the text from
it; the Kotlin one parses read-only and splices edits by offset with a
TextEditBuffer. Callers that only need to know whether a file changed
and what to write need neither detail.
-
Method Summary
Modifier and TypeMethodDescriptiongetFile()intThe first line that differs between the original source and the result, used to tell the IDE where to scroll.booleanbooleanvoidsetWritten(boolean written) Records that the result has been written to disk, so one operation touching a file twice does not write it twice.
-
Method Details
-
getFile
File getFile()- Returns:
- the file this source was read from, or
nullfor source that has no file, such as a template being prepared in memory
-
getSource
String getSource()- Returns:
- the original, unmodified source
-
getResult
String getResult()- Returns:
- the source with all recorded changes applied
-
getLanguage
SourceLanguage getLanguage()- Returns:
- the language of this source
-
isChanged
boolean isChanged()- Returns:
- true if anything has been changed
-
isWritten
boolean isWritten()- Returns:
- true if the result has already been written to disk
-
setWritten
void setWritten(boolean written) Records that the result has been written to disk, so one operation touching a file twice does not write it twice.- Parameters:
written- true once written
-
getFirstModifiedRow
int getFirstModifiedRow()The first line that differs between the original source and the result, used to tell the IDE where to scroll.- Returns:
- the 1-based line number, or -1 if nothing changed
-