Giter Club home page Giter Club logo

java-syntax-highlighter's People

Contributors

cws1989 avatar

Stargazers

 avatar

Watchers

 avatar

java-syntax-highlighter's Issues

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: offset out of bounds

What steps will reproduce the problem?
1. I attached my small project that uses SyntaxHighlighter
2. To see the problem Please run model.Main class . 
Then, choose menu 'File' 
and 'Open' menuItem to open HTML file. Must be HTML file.

What is the expected output? What do you see instead?
The exception is :
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: 
offset out of bounds
    at java.text.RuleBasedBreakIterator.checkOffset(Unknown Source)
    at java.text.RuleBasedBreakIterator.preceding(Unknown Source)
    at javax.swing.text.GlyphView.getBreakSpot(Unknown Source)
    at javax.swing.text.GlyphView.getMinimumSpan(Unknown Source)
    at javax.swing.text.ParagraphView.calculateMinorAxisRequirements(Unknown Source)
    at javax.swing.text.BoxView.checkRequests(Unknown Source)
    at javax.swing.text.BoxView.getMinimumSpan(Unknown Source)
    at javax.swing.text.BoxView.calculateMinorAxisRequirements(Unknown Source)
    at javax.swing.text.BoxView.checkRequests(Unknown Source)
    at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
    at javax.swing.text.BoxView.layout(Unknown Source)
    at javax.swing.text.BoxView.setSize(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
    at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
    at javax.swing.JComponent.getPreferredSize(Unknown Source)
    at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
    at syntaxhighlight.JTextComponentRowHeader.getPreferredSize(JTextComponentRowHeader.java:271)
    at javax.swing.ViewportLayout.layoutContainer(Unknown Source)
    at java.awt.Container.layout(Unknown Source)
    at java.awt.Container.doLayout(Unknown Source)
    at syntaxhighlight.JTextComponentRowHeader.updatePanelSize(JTextComponentRowHeader.java:234)
    at syntaxhighlight.JTextComponentRowHeader.checkPanelSize(JTextComponentRowHeader.java:224)
    at syntaxhighlight.JTextComponentRowHeader$1.handleEvent(JTextComponentRowHeader.java:187)
    at syntaxhighlight.JTextComponentRowHeader$1.insertUpdate(JTextComponentRowHeader.java:168)
    at javax.swing.text.AbstractDocument.fireInsertUpdate(Unknown Source)
    at javax.swing.text.AbstractDocument.handleInsertString(Unknown Source)
    at javax.swing.text.AbstractDocument.insertString(Unknown Source)
    at syntaxhighlight.SyntaxHighlighterPane.setContent(SyntaxHighlighterPane.java:308)
    at syntaxhighlight.SyntaxHighlighter.setContent(SyntaxHighlighter.java:259)
    at syntaxhighlight.SyntaxHighlighter.setContent(SyntaxHighlighter.java:249)
    at model.SyntaxHighlighterManager.setContent(SyntaxHighlighterManager.java:50)
    at model.SyntaxHighlighterManager.viewHTML(SyntaxHighlighterManager.java:63)
    at model.FileViewerManager.viewFile(FileViewerManager.java:15)
    at model.FileMenuAction.openFile(FileMenuAction.java:41)
    at model.FileMenuAction.actionPerformed(FileMenuAction.java:31)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

What version of the product are you using? On what operating system?
JDK 1.7u51 and Windows 7.

Please provide any additional information below.
I attached my project. 

Original issue reported on code.google.com by [email protected] on 11 Apr 2014 at 4:25

Attachments:

StackOverflowError when parsing some scala files.

I get a StackOverflowError caused by an unmatched single quote when parsing 
scala files with a comment style such as: /* `123' */

This can be reproduced with:

    String s = "'"; for(int x = 0; x < 2000; x++) s += '\n';
    new SyntaxHighlighterParser(new BrushScala()).parse(null, s);

Which gives the same error as:

    Pattern multiLineSingleQuotedString = Pattern.compile("'((\\\\.)|([^\\\\']))*'", Pattern.DOTALL);
    String s = "'"; for(int x = 0; x < 2000; x++) s += '1';
    multiLineSingleQuotedString.matcher(s).find();

Exception in thread "main" java.lang.StackOverflowError
    at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3714)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4502)
    at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556)
    at java.util.regex.Pattern$Loop.match(Pattern.java:4683)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
    ...
    at java.util.regex.Pattern$BranchConn.match(Pattern.java:4466)
    at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615)

Running on OpenJDK 1.7.0_40 and ideone https://ideone.com/AnAJdf

This seems to be fixed by using a possessive quantifier in RegExpRule.java:

    public static final Pattern multiLineSingleQuotedString = Pattern.compile("'((\\\\.)|([^\\\\']))*+'", Pattern.DOTALL);

Some of the other rules here could have the same problem.

Original issue reported on code.google.com by [email protected] on 20 May 2014 at 12:56

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.