From d2cba1ffb6bfa8beedbd530fa0ec0e879da374ee Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 5 May 2003 15:10:46 +0000 Subject: NPE guard --- .../org/aspectj/ajde/ui/swing/BrowserViewManager.java | 9 +++++++-- .../aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java | 9 ++++++--- asm/src/org/aspectj/asm/StructureModelManager.java | 16 ++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java index 68f7741aa..a1798c125 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/BrowserViewManager.java @@ -27,6 +27,7 @@ import org.aspectj.asm.InheritanceAssociation; import org.aspectj.asm.LinkNode; import org.aspectj.asm.ProgramElementNode; import org.aspectj.asm.StructureNode; +import org.aspectj.bridge.ISourceLocation; /** * Responsible for displaying and controlling the configuration and output of a @@ -74,8 +75,12 @@ public class BrowserViewManager { } else { currNode = (ProgramElementNode)structureNode; } - Ajde.getDefault().getEditorManager().addViewForSourceLine(currNode.getSourceLocation().getSourceFile().getAbsolutePath(), - currNode.getSourceLocation().getLine()); + ISourceLocation sourceLoc = currNode.getSourceLocation(); + if (null != sourceLoc) { + Ajde.getDefault().getEditorManager().addViewForSourceLine( + sourceLoc.getSourceFile().getAbsolutePath(), + sourceLoc.getLine()); + } } } diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java index 66f73fb69..a2ba8a601 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java @@ -27,6 +27,7 @@ import org.aspectj.asm.ProgramElementNode; import org.aspectj.asm.RelationNode; import org.aspectj.asm.StructureNode; import org.aspectj.bridge.IMessage; +import org.aspectj.bridge.ISourceLocation; /** * @author Mik Kersten @@ -45,10 +46,12 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { StructureNode node = viewNode.getStructureNode(); if (node instanceof LinkNode) { - if (((LinkNode)node).getProgramElementNode().getSourceLocation().getSourceFile().getAbsolutePath() == null) { - setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_NO_SOURCE_COLOR); - } else { + ISourceLocation sourceLoc = ((LinkNode)node).getProgramElementNode().getSourceLocation(); + if ((null != sourceLoc) + && (null != sourceLoc.getSourceFile().getAbsolutePath())) { setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_COLOR); + } else { + setTextNonSelectionColor(AjdeWidgetStyles.LINK_NODE_NO_SOURCE_COLOR); } } else { setTextNonSelectionColor(new Color(0, 0, 0)); diff --git a/asm/src/org/aspectj/asm/StructureModelManager.java b/asm/src/org/aspectj/asm/StructureModelManager.java index 4a868d9fe..1dbf2981d 100644 --- a/asm/src/org/aspectj/asm/StructureModelManager.java +++ b/asm/src/org/aspectj/asm/StructureModelManager.java @@ -16,7 +16,8 @@ package org.aspectj.asm; import java.util.*; import java.io.*; -import org.aspectj.asm.*; + +import org.aspectj.bridge.ISourceLocation; /** * @author Mik Kersten @@ -72,12 +73,15 @@ public class StructureModelManager { ProgramElementNode peNode = (ProgramElementNode)it.next(); List entries = new ArrayList(); entries.add(peNode); - Integer hash = new Integer(peNode.getSourceLocation().getLine()); - List existingEntry = (List)annotations.get(hash); - if (existingEntry != null) { - entries.addAll(existingEntry); + ISourceLocation sourceLoc = peNode.getSourceLocation(); + if (null != sourceLoc) { + Integer hash = new Integer(sourceLoc.getLine()); + List existingEntry = (List)annotations.get(hash); + if (existingEntry != null) { + entries.addAll(existingEntry); + } + annotations.put(hash, entries); } - annotations.put(hash, entries); } return annotations; } -- cgit v1.2.3