mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 13:21:07 +01:00
shorten names a little, move Interval out b/c used elsewhere
This commit is contained in:
@@ -21,16 +21,15 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
|
||||
|
||||
import processing.app.Messages;
|
||||
import processing.app.ui.ZoomTreeCellRenderer;
|
||||
import processing.mode.java.PreprocessedSketch.SketchInterval;
|
||||
|
||||
|
||||
class ASTViewer {
|
||||
final JDialog window;
|
||||
final JTree tree;
|
||||
final Consumer<PreprocessedSketch> updateListener;
|
||||
final Consumer<PreprocSketch> updateListener;
|
||||
|
||||
|
||||
ASTViewer(JavaEditor editor, PreprocessingService pps) {
|
||||
ASTViewer(JavaEditor editor, PreprocService pps) {
|
||||
updateListener = this::buildAndUpdateTree;
|
||||
|
||||
window = new JDialog(editor);
|
||||
@@ -95,7 +94,7 @@ class ASTViewer {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
void buildAndUpdateTree(PreprocessedSketch ps) {
|
||||
void buildAndUpdateTree(PreprocSketch ps) {
|
||||
CompilationUnit cu = ps.compilationUnit;
|
||||
if (cu.types().isEmpty()){
|
||||
Messages.loge("No Type found in CU");
|
||||
|
||||
@@ -195,7 +195,7 @@ public class CompletionGenerator {
|
||||
* @param astNode
|
||||
* @return
|
||||
*/
|
||||
public static ClassMember resolveExpression3rdParty(PreprocessedSketch ps, ASTNode nearestNode,
|
||||
public static ClassMember resolveExpression3rdParty(PreprocSketch ps, ASTNode nearestNode,
|
||||
ASTNode astNode, boolean noCompare) {
|
||||
log("Resolve 3rdParty expr-- " + getNodeAsString(astNode)
|
||||
+ " nearest node " + getNodeAsString(nearestNode));
|
||||
@@ -524,7 +524,7 @@ public class CompletionGenerator {
|
||||
* @param noCompare
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<CompletionCandidate> getMembersForType(PreprocessedSketch ps,
|
||||
public static ArrayList<CompletionCandidate> getMembersForType(PreprocSketch ps,
|
||||
String typeName,
|
||||
String child,
|
||||
boolean noCompare,
|
||||
@@ -542,7 +542,7 @@ public class CompletionGenerator {
|
||||
|
||||
}
|
||||
|
||||
public static ArrayList<CompletionCandidate> getMembersForType(PreprocessedSketch ps,
|
||||
public static ArrayList<CompletionCandidate> getMembersForType(PreprocSketch ps,
|
||||
ClassMember tehClass,
|
||||
String childToLookFor,
|
||||
boolean noCompare,
|
||||
@@ -682,7 +682,7 @@ public class CompletionGenerator {
|
||||
* @param className
|
||||
* @return
|
||||
*/
|
||||
protected static Class<?> findClassIfExists(PreprocessedSketch ps, String className){
|
||||
protected static Class<?> findClassIfExists(PreprocSketch ps, String className){
|
||||
if (className == null){
|
||||
return null;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ public class CompletionGenerator {
|
||||
return tehClass;
|
||||
}
|
||||
|
||||
public static ClassMember definedIn3rdPartyClass(PreprocessedSketch ps, String className,String memberName){
|
||||
public static ClassMember definedIn3rdPartyClass(PreprocSketch ps, String className,String memberName){
|
||||
Class<?> probableClass = findClassIfExists(ps, className);
|
||||
if (probableClass == null) {
|
||||
log("Couldn't load " + className);
|
||||
@@ -779,7 +779,7 @@ public class CompletionGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
public static ClassMember definedIn3rdPartyClass(PreprocessedSketch ps, ClassMember tehClass,String memberName){
|
||||
public static ClassMember definedIn3rdPartyClass(PreprocSketch ps, ClassMember tehClass,String memberName){
|
||||
if(tehClass == null)
|
||||
return null;
|
||||
log("definedIn3rdPartyClass-> Looking for " + memberName
|
||||
@@ -1317,7 +1317,7 @@ public class CompletionGenerator {
|
||||
}
|
||||
|
||||
|
||||
protected static boolean ignorableSuggestionImport(PreprocessedSketch ps, String impName) {
|
||||
protected static boolean ignorableSuggestionImport(PreprocSketch ps, String impName) {
|
||||
|
||||
String impNameLc = impName.toLowerCase();
|
||||
|
||||
@@ -1402,7 +1402,7 @@ public class CompletionGenerator {
|
||||
+ m.getDeclaringClass().getName();
|
||||
}
|
||||
|
||||
public ClassMember(PreprocessedSketch ps, ASTNode node){
|
||||
public ClassMember(PreprocSketch ps, ASTNode node){
|
||||
astNode = node;
|
||||
stringVal = getNodeAsString(node);
|
||||
if(node instanceof TypeDeclaration){
|
||||
@@ -1730,7 +1730,7 @@ public class CompletionGenerator {
|
||||
* @param line
|
||||
* @param lineStartNonWSOffset
|
||||
*/
|
||||
public List<CompletionCandidate> preparePredictions(final PreprocessedSketch ps,
|
||||
public List<CompletionCandidate> preparePredictions(final PreprocSketch ps,
|
||||
final String pdePhrase,
|
||||
final int lineNumber) {
|
||||
Messages.log("* preparePredictions");
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.classpath.RegExpResourceFilter;
|
||||
|
||||
import processing.app.Language;
|
||||
import processing.app.Problem;
|
||||
import processing.mode.java.PreprocessedSketch.SketchInterval;
|
||||
|
||||
|
||||
class ErrorChecker {
|
||||
@@ -38,13 +37,13 @@ class ErrorChecker {
|
||||
private volatile long nextUiUpdate = 0;
|
||||
private volatile boolean enabled = true;
|
||||
|
||||
private final Consumer<PreprocessedSketch> errorHandlerListener = this::handleSketchProblems;
|
||||
private final Consumer<PreprocSketch> errorHandlerListener = this::handleSketchProblems;
|
||||
|
||||
private JavaEditor editor;
|
||||
private PreprocessingService pps;
|
||||
private PreprocService pps;
|
||||
|
||||
|
||||
public ErrorChecker(JavaEditor editor, PreprocessingService pps) {
|
||||
public ErrorChecker(JavaEditor editor, PreprocService pps) {
|
||||
this.editor = editor;
|
||||
this.pps = pps;
|
||||
scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
@@ -81,7 +80,7 @@ class ErrorChecker {
|
||||
}
|
||||
|
||||
|
||||
private void handleSketchProblems(PreprocessedSketch ps) {
|
||||
private void handleSketchProblems(PreprocSketch ps) {
|
||||
|
||||
Map<String, String[]> suggCache =
|
||||
JavaMode.importSuggestEnabled ? new HashMap<>() : Collections.emptyMap();
|
||||
@@ -156,7 +155,7 @@ class ErrorChecker {
|
||||
}
|
||||
|
||||
|
||||
static private JavaProblem convertIProblem(IProblem iproblem, PreprocessedSketch ps) {
|
||||
static private JavaProblem convertIProblem(IProblem iproblem, PreprocSketch ps) {
|
||||
SketchInterval in = ps.mapJavaToSketch(iproblem);
|
||||
if (in != SketchInterval.BEFORE_START) {
|
||||
String badCode = ps.getPdeCode(in);
|
||||
@@ -193,7 +192,7 @@ class ErrorChecker {
|
||||
static private final Pattern CURLY_QUOTE_REGEX =
|
||||
Pattern.compile("([“”‘’])", Pattern.UNICODE_CHARACTER_CLASS);
|
||||
|
||||
static private List<JavaProblem> checkForCurlyQuotes(PreprocessedSketch ps) {
|
||||
static private List<JavaProblem> checkForCurlyQuotes(PreprocSketch ps) {
|
||||
if (ps.compilationUnit == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -261,7 +260,7 @@ class ErrorChecker {
|
||||
}
|
||||
|
||||
|
||||
static private List<JavaProblem> checkForMissingBraces(PreprocessedSketch ps) {
|
||||
static private List<JavaProblem> checkForMissingBraces(PreprocSketch ps) {
|
||||
List<JavaProblem> problems = new ArrayList<>(0);
|
||||
for (int tabIndex = 0; tabIndex < ps.tabStartOffsets.length; tabIndex++) {
|
||||
int tabStartOffset = ps.tabStartOffsets[tabIndex];
|
||||
|
||||
@@ -24,12 +24,11 @@ import org.eclipse.jdt.core.dom.VariableDeclaration;
|
||||
import processing.app.Language;
|
||||
import processing.app.Messages;
|
||||
import processing.app.Platform;
|
||||
import processing.mode.java.PreprocessedSketch.SketchInterval;
|
||||
|
||||
|
||||
class InspectMode {
|
||||
final JavaEditor editor;
|
||||
final PreprocessingService pps;
|
||||
final PreprocService pps;
|
||||
final ShowUsage usage;
|
||||
|
||||
boolean inspectModeEnabled;
|
||||
@@ -45,7 +44,7 @@ class InspectMode {
|
||||
e -> e.getKeyCode() == KeyEvent.VK_CONTROL;
|
||||
|
||||
|
||||
InspectMode(JavaEditor editor, PreprocessingService pps, ShowUsage usage) {
|
||||
InspectMode(JavaEditor editor, PreprocService pps, ShowUsage usage) {
|
||||
this.editor = editor;
|
||||
this.pps = pps;
|
||||
this.usage = usage;
|
||||
@@ -143,7 +142,7 @@ class InspectMode {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
private void handleInspect(PreprocessedSketch ps, int tabIndex, int offset) {
|
||||
private void handleInspect(PreprocSketch ps, int tabIndex, int offset) {
|
||||
ASTNode root = ps.compilationUnit;
|
||||
int javaOffset = ps.tabOffsetToJavaOffset(tabIndex, offset);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public class JavaEditor extends Editor {
|
||||
private boolean hasJavaTabs;
|
||||
private boolean javaTabWarned;
|
||||
|
||||
protected PreprocessingService preprocessingService;
|
||||
protected PreprocService preprocessingService;
|
||||
|
||||
private InspectMode inspect;
|
||||
private ShowUsage usage;
|
||||
@@ -136,7 +136,7 @@ public class JavaEditor extends Editor {
|
||||
box.add(textAndError);
|
||||
*/
|
||||
|
||||
preprocessingService = new PreprocessingService(this);
|
||||
preprocessingService = new PreprocService(this);
|
||||
|
||||
pdexEnabled = !hasJavaTabs();
|
||||
|
||||
@@ -154,8 +154,7 @@ public class JavaEditor extends Editor {
|
||||
Document document = code.getDocument();
|
||||
addDocumentListener(document);
|
||||
}
|
||||
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
|
||||
Toolkit.setMenuMnemonics(textarea.getRightClickPopup());
|
||||
|
||||
@@ -215,7 +214,7 @@ public class JavaEditor extends Editor {
|
||||
int currentTabCount = sketch.getCodeCount();
|
||||
if (currentTabCount != previousTabCount) {
|
||||
previousTabCount = currentTabCount;
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1328,11 +1327,6 @@ public class JavaEditor extends Editor {
|
||||
|
||||
@Override
|
||||
public void sketchChanged() {
|
||||
preprocessingService.notifySketchChanged();
|
||||
}
|
||||
|
||||
|
||||
public void sketchChangedX() {
|
||||
errorChecker.notifySketchChanged();
|
||||
preprocessingService.notifySketchChanged();
|
||||
}
|
||||
@@ -1343,17 +1337,17 @@ public class JavaEditor extends Editor {
|
||||
doc.addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1841,7 +1835,7 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
public PreprocessingService getPreprocessingService() {
|
||||
public PreprocService getPreprocessingService() {
|
||||
return preprocessingService;
|
||||
}
|
||||
|
||||
@@ -2535,13 +2529,14 @@ public class JavaEditor extends Editor {
|
||||
@Override
|
||||
protected void applyPreferences() {
|
||||
super.applyPreferences();
|
||||
|
||||
if (jmode != null) {
|
||||
jmode.loadPreferences();
|
||||
Messages.log("Applying prefs");
|
||||
// trigger it once to refresh UI
|
||||
//pdex.preferencesChanged();
|
||||
errorChecker.preferencesChanged();
|
||||
sketchChangedX();
|
||||
sketchChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,15 +61,13 @@ import processing.data.StringList;
|
||||
|
||||
/**
|
||||
* Service which preprocesses code to check for and report on issues.
|
||||
*
|
||||
* <p>
|
||||
* Service running in a background thread which checks for grammatical issues via ANTLR and performs
|
||||
* code analysis via the JDT to check for other issues and related development services. These are
|
||||
* reported as {Problem} instances via a callback registered by an {Editor}.
|
||||
* </p>
|
||||
* Service running in a background thread which checks for grammatical issues
|
||||
* via ANTLR and performs code analysis via the JDT to check for other issues
|
||||
* and related development services. These are reported as {Problem} instances
|
||||
* via a callback registered by an {Editor}.
|
||||
*/
|
||||
public class PreprocessingService {
|
||||
|
||||
public class PreprocService {
|
||||
private final static int TIMEOUT_MILLIS = 100;
|
||||
private final static int BLOCKING_TIMEOUT_SECONDS = 3000;
|
||||
|
||||
@@ -86,12 +84,12 @@ public class PreprocessingService {
|
||||
private final AtomicBoolean librariesChanged = new AtomicBoolean(true);
|
||||
|
||||
private volatile boolean running;
|
||||
private CompletableFuture<PreprocessedSketch> preprocessingTask = new CompletableFuture<>();
|
||||
private CompletableFuture<PreprocSketch> preprocessingTask = new CompletableFuture<>();
|
||||
|
||||
private CompletableFuture<?> lastCallback =
|
||||
new CompletableFuture<>() {{
|
||||
complete(null); // initialization block
|
||||
}};
|
||||
new CompletableFuture<>() {{
|
||||
complete(null); // initialization block
|
||||
}};
|
||||
|
||||
private volatile boolean isEnabled = true;
|
||||
|
||||
@@ -101,7 +99,7 @@ public class PreprocessingService {
|
||||
* @param editor The editor that will be supported by this service and to which issues should be
|
||||
* reported.
|
||||
*/
|
||||
public PreprocessingService(JavaEditor editor) {
|
||||
public PreprocService(JavaEditor editor) {
|
||||
this.editor = editor;
|
||||
isEnabled = !editor.hasJavaTabs();
|
||||
|
||||
@@ -117,7 +115,7 @@ public class PreprocessingService {
|
||||
*/
|
||||
private void mainLoop() {
|
||||
running = true;
|
||||
PreprocessedSketch prevResult = null;
|
||||
PreprocSketch prevResult = null;
|
||||
CompletableFuture<?> runningCallbacks = null;
|
||||
Messages.log("PPS: Hi!");
|
||||
while (running) {
|
||||
@@ -212,7 +210,7 @@ public class PreprocessingService {
|
||||
* {PreprocessedSketch} that has any {Problem} instances that were resultant.
|
||||
* @return A future that will be fulfilled when preprocessing is complete.
|
||||
*/
|
||||
private CompletableFuture<?> registerCallback(Consumer<PreprocessedSketch> callback) {
|
||||
private CompletableFuture<?> registerCallback(Consumer<PreprocSketch> callback) {
|
||||
synchronized (requestLock) {
|
||||
lastCallback = preprocessingTask
|
||||
// Run callback after both preprocessing task and previous callback
|
||||
@@ -239,7 +237,7 @@ public class PreprocessingService {
|
||||
* @param callback The consumer to inform when preprocessing is complete which will provide a
|
||||
* {PreprocessedSketch} that has any {Problem} instances that were resultant.
|
||||
*/
|
||||
public void whenDone(Consumer<PreprocessedSketch> callback) {
|
||||
public void whenDone(Consumer<PreprocSketch> callback) {
|
||||
if (!isEnabled) return;
|
||||
registerCallback(callback);
|
||||
}
|
||||
@@ -257,7 +255,7 @@ public class PreprocessingService {
|
||||
*
|
||||
* @param callback
|
||||
*/
|
||||
public void whenDoneBlocking(Consumer<PreprocessedSketch> callback) {
|
||||
public void whenDoneBlocking(Consumer<PreprocSketch> callback) {
|
||||
if (!isEnabled) return;
|
||||
try {
|
||||
registerCallback(callback).get(BLOCKING_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
@@ -271,14 +269,14 @@ public class PreprocessingService {
|
||||
/// LISTENERS ----------------------------------------------------------------
|
||||
|
||||
|
||||
private Set<Consumer<PreprocessedSketch>> listeners = new CopyOnWriteArraySet<>();
|
||||
private Set<Consumer<PreprocSketch>> listeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
/**
|
||||
* Register a consumer that will receive all {PreprocessedSketch}es produced from this service.
|
||||
*
|
||||
* @param listener The listener to receive all future {PreprocessedSketch}es.
|
||||
*/
|
||||
public void registerListener(Consumer<PreprocessedSketch> listener) {
|
||||
public void registerListener(Consumer<PreprocSketch> listener) {
|
||||
if (listener != null) listeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -292,7 +290,7 @@ public class PreprocessingService {
|
||||
*
|
||||
* @param listener The listener to remove.
|
||||
*/
|
||||
public void unregisterListener(Consumer<PreprocessedSketch> listener) {
|
||||
public void unregisterListener(Consumer<PreprocSketch> listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@@ -306,8 +304,8 @@ public class PreprocessingService {
|
||||
*
|
||||
* @param ps The sketch to be sent out to consumers.
|
||||
*/
|
||||
private void fireListeners(PreprocessedSketch ps) {
|
||||
for (Consumer<PreprocessedSketch> listener : listeners) {
|
||||
private void fireListeners(PreprocSketch ps) {
|
||||
for (Consumer<PreprocSketch> listener : listeners) {
|
||||
try {
|
||||
listener.accept(ps);
|
||||
} catch (Exception e) {
|
||||
@@ -333,11 +331,11 @@ public class PreprocessingService {
|
||||
* beforehand.
|
||||
* @return The newly generated preprocessed sketch.
|
||||
*/
|
||||
private PreprocessedSketch preprocessSketch(PreprocessedSketch prevResult) {
|
||||
private PreprocSketch preprocessSketch(PreprocSketch prevResult) {
|
||||
|
||||
boolean firstCheck = prevResult == null;
|
||||
|
||||
PreprocessedSketch.Builder result = new PreprocessedSketch.Builder();
|
||||
PreprocSketch.Builder result = new PreprocSketch.Builder();
|
||||
|
||||
List<ImportStatement> codeFolderImports = result.codeFolderImports;
|
||||
List<ImportStatement> programImports = result.programImports;
|
||||
@@ -17,7 +17,7 @@ import processing.app.Sketch;
|
||||
import processing.core.PApplet;
|
||||
import processing.mode.java.TextTransform.OffsetMapper;
|
||||
|
||||
public class PreprocessedSketch {
|
||||
public class PreprocSketch {
|
||||
|
||||
public final Sketch sketch;
|
||||
|
||||
@@ -48,29 +48,6 @@ public class PreprocessedSketch {
|
||||
/// JAVA -> SKETCH -----------------------------------------------------------
|
||||
|
||||
|
||||
public static class SketchInterval {
|
||||
|
||||
public static final SketchInterval BEFORE_START = new SketchInterval(-1, -1, -1, -1, -1);
|
||||
|
||||
private SketchInterval(int tabIndex,
|
||||
int startTabOffset, int stopTabOffset,
|
||||
int startPdeOffset, int stopPdeOffset) {
|
||||
this.tabIndex = tabIndex;
|
||||
this.startTabOffset = startTabOffset;
|
||||
this.stopTabOffset = stopTabOffset;
|
||||
this.startPdeOffset = startPdeOffset;
|
||||
this.stopPdeOffset = stopPdeOffset;
|
||||
}
|
||||
|
||||
final int tabIndex;
|
||||
final int startTabOffset;
|
||||
final int stopTabOffset;
|
||||
|
||||
final int startPdeOffset;
|
||||
final int stopPdeOffset;
|
||||
}
|
||||
|
||||
|
||||
public boolean inRange(SketchInterval interval) {
|
||||
return interval != SketchInterval.BEFORE_START &&
|
||||
interval.stopPdeOffset < pdeCode.length();
|
||||
@@ -237,16 +214,16 @@ public class PreprocessedSketch {
|
||||
public final List<ImportStatement> codeFolderImports = new ArrayList<>();
|
||||
public final List<Problem> otherProblems = new ArrayList<>();
|
||||
|
||||
public PreprocessedSketch build() {
|
||||
return new PreprocessedSketch(this);
|
||||
public PreprocSketch build() {
|
||||
return new PreprocSketch(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static PreprocessedSketch empty() {
|
||||
public static PreprocSketch empty() {
|
||||
return new Builder().build();
|
||||
}
|
||||
|
||||
private PreprocessedSketch(Builder b) {
|
||||
private PreprocSketch(Builder b) {
|
||||
sketch = b.sketch;
|
||||
|
||||
compilationUnit = b.compilationUnit;
|
||||
@@ -43,12 +43,11 @@ import processing.app.SketchCode;
|
||||
import processing.app.syntax.SyntaxDocument;
|
||||
import processing.app.ui.EditorStatus;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.mode.java.PreprocessedSketch.SketchInterval;
|
||||
|
||||
|
||||
class Rename {
|
||||
final JavaEditor editor;
|
||||
final PreprocessingService pps;
|
||||
final PreprocService pps;
|
||||
final ShowUsage showUsage;
|
||||
|
||||
final JDialog window;
|
||||
@@ -56,10 +55,10 @@ class Rename {
|
||||
final JLabel oldNameLabel;
|
||||
|
||||
IBinding binding;
|
||||
PreprocessedSketch ps;
|
||||
PreprocSketch ps;
|
||||
|
||||
|
||||
Rename(JavaEditor editor, PreprocessingService pps, ShowUsage showUsage) {
|
||||
Rename(JavaEditor editor, PreprocService pps, ShowUsage showUsage) {
|
||||
this.editor = editor;
|
||||
this.pps = pps;
|
||||
this.showUsage = showUsage;
|
||||
@@ -182,7 +181,7 @@ class Rename {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
void handleRename(PreprocessedSketch ps, int tabIndex, int startTabOffset, int stopTabOffset) {
|
||||
void handleRename(PreprocSketch ps, int tabIndex, int startTabOffset, int stopTabOffset) {
|
||||
if (ps.hasSyntaxErrors) {
|
||||
editor.statusMessage("Cannot rename until syntax errors are fixed",
|
||||
EditorStatus.WARNING);
|
||||
@@ -238,7 +237,7 @@ class Rename {
|
||||
|
||||
|
||||
// Thread: EDT (we can't allow user to mess with sketch while renaming)
|
||||
void rename(PreprocessedSketch ps, IBinding binding, String newName) {
|
||||
void rename(PreprocSketch ps, IBinding binding, String newName) {
|
||||
CompilationUnit root = ps.compilationUnit;
|
||||
|
||||
// Renaming constructor should rename class
|
||||
|
||||
@@ -282,7 +282,7 @@ public class RuntimePathBuilder {
|
||||
* @param result The {PreprocessedSketch.Builder} into which the classpath should be inserted.
|
||||
* @param mode The {JavaMode} for which the classpath should be generated.
|
||||
*/
|
||||
public void prepareClassPath(PreprocessedSketch.Builder result, JavaMode mode) {
|
||||
public void prepareClassPath(PreprocSketch.Builder result, JavaMode mode) {
|
||||
List<ImportStatement> programImports = result.programImports;
|
||||
Sketch sketch = result.sketch;
|
||||
|
||||
@@ -311,7 +311,7 @@ public class RuntimePathBuilder {
|
||||
* @param programImports The imports listed by the sketch (user imports).
|
||||
* @param sketch The sketch for which the classpath is being generated.
|
||||
*/
|
||||
private void prepareSketchClassPath(PreprocessedSketch.Builder result, JavaMode mode,
|
||||
private void prepareSketchClassPath(PreprocSketch.Builder result, JavaMode mode,
|
||||
List<ImportStatement> programImports, Sketch sketch) {
|
||||
|
||||
Stream<String> sketchClassPath = sketchClassPathStrategies.stream()
|
||||
@@ -344,7 +344,7 @@ public class RuntimePathBuilder {
|
||||
* @param programImports The imports listed by the sketch (user imports).
|
||||
* @param sketch The sketch for which the classpath is being generated.
|
||||
*/
|
||||
private void prepareSearchClassPath(PreprocessedSketch.Builder result, JavaMode mode,
|
||||
private void prepareSearchClassPath(PreprocSketch.Builder result, JavaMode mode,
|
||||
List<ImportStatement> programImports, Sketch sketch) {
|
||||
|
||||
Stream<String> searchClassPath = searchClassPathStrategies.stream()
|
||||
|
||||
@@ -33,7 +33,6 @@ import processing.app.Language;
|
||||
import processing.app.ui.EditorStatus;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.app.ui.ZoomTreeCellRenderer;
|
||||
import processing.mode.java.PreprocessedSketch.SketchInterval;
|
||||
|
||||
|
||||
class ShowUsage {
|
||||
@@ -41,14 +40,14 @@ class ShowUsage {
|
||||
final JTree tree;
|
||||
|
||||
final JavaEditor editor;
|
||||
final PreprocessingService pps;
|
||||
final PreprocService pps;
|
||||
|
||||
final Consumer<PreprocessedSketch> reloadListener;
|
||||
final Consumer<PreprocSketch> reloadListener;
|
||||
|
||||
IBinding binding;
|
||||
|
||||
|
||||
ShowUsage(JavaEditor editor, PreprocessingService pps) {
|
||||
ShowUsage(JavaEditor editor, PreprocService pps) {
|
||||
this.editor = editor;
|
||||
this.pps = pps;
|
||||
|
||||
@@ -120,7 +119,7 @@ class ShowUsage {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
void handleShowUsage(PreprocessedSketch ps, int tabIndex,
|
||||
void handleShowUsage(PreprocSketch ps, int tabIndex,
|
||||
int startTabOffset, int stopTabOffset) {
|
||||
// Map offsets
|
||||
int startJavaOffset = ps.tabOffsetToJavaOffset(tabIndex, startTabOffset);
|
||||
@@ -146,7 +145,7 @@ class ShowUsage {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
void findUsageAndUpdateTree(PreprocessedSketch ps, IBinding binding) {
|
||||
void findUsageAndUpdateTree(PreprocSketch ps, IBinding binding) {
|
||||
|
||||
this.binding = binding;
|
||||
|
||||
@@ -257,7 +256,7 @@ class ShowUsage {
|
||||
|
||||
|
||||
// Thread: worker
|
||||
void reloadShowUsage(PreprocessedSketch ps) {
|
||||
void reloadShowUsage(PreprocSketch ps) {
|
||||
if (binding != null) {
|
||||
findUsageAndUpdateTree(ps, binding);
|
||||
}
|
||||
@@ -293,7 +292,7 @@ class ShowUsageTreeNode {
|
||||
}
|
||||
|
||||
|
||||
static ShowUsageTreeNode fromSketchInterval(PreprocessedSketch ps, SketchInterval in) {
|
||||
static ShowUsageTreeNode fromSketchInterval(PreprocSketch ps, SketchInterval in) {
|
||||
int lineStartPdeOffset = ps.pdeCode.lastIndexOf('\n', in.startPdeOffset) + 1;
|
||||
int lineStopPdeOffset = ps.pdeCode.indexOf('\n', in.stopPdeOffset);
|
||||
if (lineStopPdeOffset == -1) lineStopPdeOffset = ps.pdeCode.length();
|
||||
|
||||
23
java/src/processing/mode/java/SketchInterval.java
Normal file
23
java/src/processing/mode/java/SketchInterval.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package processing.mode.java;
|
||||
|
||||
public class SketchInterval {
|
||||
|
||||
public static final SketchInterval BEFORE_START = new SketchInterval(-1, -1, -1, -1, -1);
|
||||
|
||||
SketchInterval(int tabIndex,
|
||||
int startTabOffset, int stopTabOffset,
|
||||
int startPdeOffset, int stopPdeOffset) {
|
||||
this.tabIndex = tabIndex;
|
||||
this.startTabOffset = startTabOffset;
|
||||
this.stopTabOffset = stopTabOffset;
|
||||
this.startPdeOffset = startPdeOffset;
|
||||
this.stopPdeOffset = stopPdeOffset;
|
||||
}
|
||||
|
||||
final int tabIndex;
|
||||
final int startTabOffset;
|
||||
final int stopTabOffset;
|
||||
|
||||
final int startPdeOffset;
|
||||
final int stopPdeOffset;
|
||||
}
|
||||
Reference in New Issue
Block a user