[prev in list] [next in list] [prev in thread] [next in thread]
List: jedit-cvs
Subject: [ jEdit-commits ] SF.net SVN: jedit:[23801] plugins/XML/trunk/sidekick/json/parser
From: daleanson () users ! sourceforge ! net
Date: 2014-12-22 4:26:46
Message-ID: E1Y2ua1-000265-SY () sfs-ml-3 ! v29 ! ch3 ! sourceforge ! com
[Download RAW message or body]
Revision: 23801
http://sourceforge.net/p/jedit/svn/23801
Author: daleanson
Date: 2014-12-22 04:26:45 +0000 (Mon, 22 Dec 2014)
Log Message:
-----------
Fixed NPE when object or array was empty.
Modified Paths:
--------------
plugins/XML/trunk/sidekick/json/parser/JSONNode.java
plugins/XML/trunk/sidekick/json/parser/JSONSideKickListener.java
Modified: plugins/XML/trunk/sidekick/json/parser/JSONNode.java
===================================================================
--- plugins/XML/trunk/sidekick/json/parser/JSONNode.java 2014-12-22 04:06:51 UTC (rev \
23800)
+++ plugins/XML/trunk/sidekick/json/parser/JSONNode.java 2014-12-22 04:26:45 UTC (rev \
23801) @@ -81,6 +81,10 @@
children.add(child);
}
+ public boolean hasChildren() {
+ return children != null && !children.isEmpty();
+ }
+
// this is useful when it is known that the node can have only one child
public JSONNode getFirstChild() {
if (children == null || children.isEmpty()) {
Modified: plugins/XML/trunk/sidekick/json/parser/JSONSideKickListener.java
===================================================================
--- plugins/XML/trunk/sidekick/json/parser/JSONSideKickListener.java 2014-12-22 \
04:06:51 UTC (rev 23800)
+++ plugins/XML/trunk/sidekick/json/parser/JSONSideKickListener.java 2014-12-22 \
04:26:45 UTC (rev 23801) @@ -64,8 +64,10 @@
@Override public void exitObject( @NotNull JSONParser.ObjectContext ctx ) {
JSONNode node = stack.pop();
JSONNode parent = stack.peek();
- for (JSONNode newKid : node.getChildren()) {
- parent.addChild(newKid);
+ if (node.hasChildren()) {
+ for (JSONNode newKid : node.getChildren()) {
+ parent.addChild(newKid);
+ }
}
}
@@ -82,8 +84,10 @@
@Override public void exitArray( @NotNull JSONParser.ArrayContext ctx ) {
JSONNode node = stack.pop();
JSONNode parent = stack.peek();
- for (JSONNode newKid : node.getChildren()) {
- parent.addChild(newKid);
+ if (node.hasChildren()) {
+ for (JSONNode newKid : node.getChildren()) {
+ parent.addChild(newKid);
+ }
}
}
@@ -107,13 +111,17 @@
node.setName(node.getName() + ": " + child.getName());
node.setIcon(pairIcon);
} else if (child.isObject()) {
- for (JSONNode newKid : child.getChildren()) {
- node.addChild(newKid);
+ if (child.hasChildren()) {
+ for (JSONNode newKid : child.getChildren()) {
+ node.addChild(newKid);
+ }
}
node.setIcon(objectIcon);
} else if (child.isArray()) {
- for (JSONNode newKid : child.getChildren()) {
- node.addChild(newKid);
+ if (child.hasChildren()) {
+ for (JSONNode newKid : child.getChildren()) {
+ node.addChild(newKid);
+ }
}
node.setIcon(arrayIcon);
}
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic