1 16 package com.google.gwt.dev.jjs; 17 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 26 public class InternalCompilerException extends RuntimeException { 27 28 32 public static final class NodeInfo { 33 34 private final String className; 35 private final String description; 36 private final SourceInfo sourceInfo; 37 38 private NodeInfo(String className, String description, SourceInfo sourceInfo) { 39 this.className = className; 40 this.description = description; 41 this.sourceInfo = sourceInfo; 42 } 43 44 47 public String getClassName() { 48 return className; 49 } 50 51 54 public String getDescription() { 55 return description; 56 } 57 58 61 public SourceInfo getSourceInfo() { 62 return sourceInfo; 63 } 64 } 65 66 69 private static final ThreadLocal pendingICE = new ThreadLocal (); 70 71 private final List nodeTrace = new ArrayList (); 72 73 76 public InternalCompilerException(HasSourceInfo node, String message, 77 Throwable cause) { 78 this(message, cause); 79 addNode(node); 80 } 81 82 85 public InternalCompilerException(String message) { 86 super(message); 87 } 88 89 92 public InternalCompilerException(String message, Throwable cause) { 93 super(message, cause); 94 } 95 96 100 public void addNode(HasSourceInfo node) { 101 InternalCompilerException other = (InternalCompilerException) pendingICE.get(); 102 if (other != null) { 103 return; 106 } 107 108 String className = null; 109 String description = null; 110 SourceInfo sourceInfo = null; 111 try { 112 pendingICE.set(this); 113 className = node.getClass().getName(); 114 sourceInfo = node.getSourceInfo(); 115 description = node.toString(); 116 } catch (Throwable e) { 117 if (description == null) { 119 description = "<source info not available>"; 120 } 121 } finally { 122 pendingICE.set(null); 123 } 124 addNode(className, description, sourceInfo); 125 } 126 127 131 public void addNode(String className, String description, 132 SourceInfo sourceInfo) { 133 nodeTrace.add(new NodeInfo(className, description, sourceInfo)); 134 } 135 136 143 public List getNodeTrace() { 144 return nodeTrace; 145 } 146 147 } 148 | Popular Tags |