From a3306f269ec75a617f7bf4ee6a292a961ba2c1f5 Mon Sep 17 00:00:00 2001 From: Shevek Date: Wed, 3 Dec 2014 00:01:47 -0800 Subject: SourceChangeEvent now uses an enum. -> gradle 2.2.1 --- src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java | 2 +- src/main/java/org/anarres/cpp/Preprocessor.java | 9 +++++---- src/main/java/org/anarres/cpp/PreprocessorListener.java | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/anarres') diff --git a/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java b/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java index 68f6e89..40a8686 100644 --- a/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java +++ b/src/main/java/org/anarres/cpp/DefaultPreprocessorListener.java @@ -91,7 +91,7 @@ public class DefaultPreprocessorListener implements PreprocessorListener { } @Override - public void handleSourceChange(Source source, String event) { + public void handleSourceChange(Source source, SourceChangeEvent event) { } } diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index 18a0605..f4e93cd 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -36,6 +36,7 @@ import javax.annotation.Nonnull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.anarres.cpp.PreprocessorCommand.*; +import org.anarres.cpp.PreprocessorListener.SourceChangeEvent; import static org.anarres.cpp.Token.*; /** @@ -526,10 +527,10 @@ public class Preprocessor implements Closeable { source.setParent(this.source, autopop); // source.setListener(listener); if (listener != null) - listener.handleSourceChange(this.source, "suspend"); + listener.handleSourceChange(this.source, SourceChangeEvent.SUSPEND); this.source = source; if (listener != null) - listener.handleSourceChange(this.source, "push"); + listener.handleSourceChange(this.source, SourceChangeEvent.PUSH); } /** @@ -542,13 +543,13 @@ public class Preprocessor implements Closeable { protected Token pop_source(boolean linemarker) throws IOException { if (listener != null) - listener.handleSourceChange(this.source, "pop"); + listener.handleSourceChange(this.source, SourceChangeEvent.POP); Source s = this.source; this.source = s.getParent(); /* Always a noop unless called externally. */ s.close(); if (listener != null && this.source != null) - listener.handleSourceChange(this.source, "resume"); + listener.handleSourceChange(this.source, SourceChangeEvent.RESUME); Source t = getSource(); if (getFeature(Feature.LINEMARKERS) diff --git a/src/main/java/org/anarres/cpp/PreprocessorListener.java b/src/main/java/org/anarres/cpp/PreprocessorListener.java index 3443714..0d3f7fc 100644 --- a/src/main/java/org/anarres/cpp/PreprocessorListener.java +++ b/src/main/java/org/anarres/cpp/PreprocessorListener.java @@ -49,6 +49,11 @@ public interface PreprocessorListener { @Nonnull String msg) throws LexerException; - public void handleSourceChange(@Nonnull Source source, @Nonnull String event); + public enum SourceChangeEvent { + + SUSPEND, PUSH, POP, RESUME; + } + + public void handleSourceChange(@Nonnull Source source, @Nonnull SourceChangeEvent event); } -- cgit v1.2.3