Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot construct a Paragraph with an empty list of segments #592

Closed
RedAdder opened this issue Sep 26, 2017 · 12 comments
Closed

Cannot construct a Paragraph with an empty list of segments #592

RedAdder opened this issue Sep 26, 2017 · 12 comments

Comments

@RedAdder
Copy link

I get this exception on some of the texts that i want to color:

java.lang.IllegalArgumentException:
Cannot construct a Paragraph with an empty list of segments

Is there anything I can do to stop the error?

My code is like:

codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));

protected StyleSpans<Collection<String>> computeHighlighting(String text)
	{
        Matcher matcher = PATTERN.matcher(text);
        int lastKwEnd = 0;
        StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
        while(matcher.find())
        {
            String styleClass =
                    matcher.group("KEYWORD") != null ? "keyword" :
                    matcher.group("PAREN") != null ? "paren" :
                    matcher.group("BRACE") != null ? "brace" :
                    matcher.group("BRACKET") != null ? "bracket" :
                    matcher.group("SEMICOLON") != null ? "semicolon" :
                    matcher.group("STRING") != null ? "string" :
                    matcher.group("COMMENT") != null ? "comment" :
                    null; /* never happens */ assert styleClass != null;
	            spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
	            spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
            lastKwEnd = matcher.end();
        }
        	spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
        return spansBuilder.create();
    }
@JordanMartinez
Copy link
Contributor

Which version are you using? This is an issue that has come up in previous versions (#345) but shouldn't be the case in the current master branch

@RedAdder
Copy link
Author

I am using the latest release:

lib/richtextfx-0.7-M5.jar
lib/richtextfx-0.7-M5-javadoc.jar
lib/richtextfx-0.7-M5-sources.jar

Also these:

lib/reactfx-2.0-M5.jar
lib/reactfx-2.0-M5-javadoc.jar
lib/reactfx-2.0-M5-sources.jar

@RedAdder
Copy link
Author

How can I build the master (i cloned it) so that I get all 3 jar files (jar, doc and sources)? A client reported an error I cannot reproduce: java.lang.NoSuchMethodError: org.fxmisc.richtext.TextExt.impl_selectionFillProperty()Ljavafx/beans/property/ObjectProperty;
at org.fxmisc.richtext.StyledTextArea.createStyledTextNode(StyledTextArea.java:118)

@JordanMartinez
Copy link
Contributor

Tomas recently gave me access to the Sonatype repo he uses to make snapshot and stable releases. So, we've made a new snapshot release as of yesterday that you could use. There is at least one breaking change at the source level in the type signature (Segment no longer includes its style as part of the segment object anymore), but I think that's it besides a few name changes. Everything else has either refactored the code or deprecated some things.

I plan on making another milestone release soon. However, I'm currently figuring out how to use the Next Staging plugin to do that and automate the process (otherwise, it's rather tedious).

Other than that, you could use Jitpack to compile any commit of this repo. See this project's ReadMe's section on that for more instructions. (This is more of a temporary solution because I've been using it in my own code and my IDE [IntelliJ] sometimes can't figure out where the dependencies are. Now that I can make releases, it changes the situation.)

@JordanMartinez
Copy link
Contributor

Did you try the default task? gradle build?

@RedAdder
Copy link
Author

Thanks, gradle build works. Just two tests fail:

UndoManagerTest. testForBug216
UndoManagerTest. testUndoWithWinNewlines

@RedAdder
Copy link
Author

With the new master jar files, my application now throws a java.lang.NoSuchMethodError: org.fxmisc.undo.UndoManagerFactory.create(Lorg/reactfx/EventStream;Ljava/util/function/Function;Ljava/util/function/Consumer;Ljava/util/function/BiFunction;Ljava/util/function/Predicate;)Lorg/fxmisc/undo/UndoManager;
error.

Do I need a new version of reactfx as well? I'm using M5.

@JordanMartinez
Copy link
Contributor

Ah.... That's probably a bug that occurs because of #590. I probably didn't update the type signature. I'll look into it.

@JordanMartinez
Copy link
Contributor

Nope, that doesn't seem to be the issue...

Could you post a reproducible demo and list your OS and Java version?

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Sep 29, 2017

Thanks, gradle build works. Just two tests fail:
UndoManagerTest. testForBug216
UndoManagerTest. testUndoWithWinNewlines

This shows up in the Windows CI Build, too (I'm adding it in #596). Seems like the JavaFX thread isn't started before the tests run, but it may be due to something else.

@RedAdder
Copy link
Author

Yes i'm using this on Windows with Java 8.

@JordanMartinez
Copy link
Contributor

This now works as of #601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants