Lines 33-38
Link Here
|
33 |
import org.netbeans.api.java.classpath.ClassPath; |
33 |
import org.netbeans.api.java.classpath.ClassPath; |
34 |
import org.netbeans.api.java.classpath.GlobalPathRegistry; |
34 |
import org.netbeans.api.java.classpath.GlobalPathRegistry; |
35 |
import org.netbeans.api.java.queries.SourceForBinaryQuery; |
35 |
import org.netbeans.api.java.queries.SourceForBinaryQuery; |
|
|
36 |
import org.netbeans.modules.web.api.webmodule.WebModule; |
36 |
import org.openide.filesystems.FileObject; |
37 |
import org.openide.filesystems.FileObject; |
37 |
import org.openide.filesystems.FileUtil; |
38 |
import org.openide.filesystems.FileUtil; |
38 |
|
39 |
|
Lines 43-48
Link Here
|
43 |
|
44 |
|
44 |
private String classpath = null; |
45 |
private String classpath = null; |
45 |
private Collection/*<FileObject>*/ classpathSourceRoots = null; |
46 |
private Collection/*<FileObject>*/ classpathSourceRoots = null; |
|
|
47 |
private String wmRootPath = null; |
48 |
private FileObject wmRoot = null; |
46 |
|
49 |
|
47 |
private String possibleExceptionText = null; |
50 |
private String possibleExceptionText = null; |
48 |
private String lastExceptionMessage = null; |
51 |
private String lastExceptionMessage = null; |
Lines 56-61
Link Here
|
56 |
classpathSourceRoots = null; |
59 |
classpathSourceRoots = null; |
57 |
} |
60 |
} |
58 |
|
61 |
|
|
|
62 |
/** Hack to detect web module used when running JSP compilation. */ |
63 |
public void setWebModuleRoot(String wm) { |
64 |
wmRootPath = wm; |
65 |
wmRoot = null; |
66 |
} |
67 |
|
59 |
// XXX handle Unicode elements as well |
68 |
// XXX handle Unicode elements as well |
60 |
// XXX handle unknown source too? or don't bother? |
69 |
// XXX handle unknown source too? or don't bother? |
61 |
|
70 |
|
Lines 65-70
Link Here
|
65 |
private static final Pattern EXCEPTION_MESSAGE = Pattern.compile( |
74 |
private static final Pattern EXCEPTION_MESSAGE = Pattern.compile( |
66 |
"(([a-zA-Z_$][a-zA-Z0-9_$]*\\.)+)([a-zA-Z_$][a-zA-Z0-9_$]*(: .+)?)"); // NOI18N |
75 |
"(([a-zA-Z_$][a-zA-Z0-9_$]*\\.)+)([a-zA-Z_$][a-zA-Z0-9_$]*(: .+)?)"); // NOI18N |
67 |
|
76 |
|
|
|
77 |
private static final Pattern JSP_COMPILER_ERROR = Pattern.compile( |
78 |
"(org.apache.jasper.JasperException:)([a-zA-Z0-9_$/\\. ]*)\\(([0-9]+),([0-9]+)\\)(.*)"); // NOI18N |
79 |
|
68 |
/** returns a hyperlink for the line, or null if not apropos */ |
80 |
/** returns a hyperlink for the line, or null if not apropos */ |
69 |
public AntOutputParser.Result parse(String line) { |
81 |
public AntOutputParser.Result parse(String line) { |
70 |
|
82 |
|
Lines 105-110
Link Here
|
105 |
lastExceptionMessage = null; |
117 |
lastExceptionMessage = null; |
106 |
} |
118 |
} |
107 |
|
119 |
|
|
|
120 |
// JSP compiler error messages |
121 |
m = JSP_COMPILER_ERROR.matcher(line); |
122 |
if (m.matches()) { |
123 |
// We have a stack trace. |
124 |
String jspResource = m.group(2).trim(); |
125 |
if (jspResource.startsWith("/")) // NOI18N; |
126 |
jspResource = jspResource.substring(1); |
127 |
int lineNumber = Integer.parseInt(m.group(3)) - 1; |
128 |
int columnNumber = Integer.parseInt(m.group(4)); |
129 |
String jspErrorText = m.group(5).trim(); |
130 |
// Check to see if this JSP is in the web module. |
131 |
FileObject wmRoot = getCurrentWebModuleRoot(); |
132 |
if (wmRoot != null) { |
133 |
FileObject source = wmRoot.getFileObject(jspResource); |
134 |
if (source != null) { |
135 |
// Got it! |
136 |
//debug("Found " + source + " in derived source root " + root); |
137 |
return new AntOutputParser.Result(source, lineNumber, -1 /*columnNumber*/, -1, -1, jspErrorText); |
138 |
} |
139 |
} |
140 |
} else { |
141 |
// Track the last line which was not a stack trace - probably the exception message. |
142 |
possibleExceptionText = line; |
143 |
lastExceptionMessage = null; |
144 |
} |
145 |
|
146 |
|
108 |
// Not a stack trace - check whether this line mentions an explicit file. |
147 |
// Not a stack trace - check whether this line mentions an explicit file. |
109 |
|
148 |
|
110 |
// do some heuristic whether the line contains a filename |
149 |
// do some heuristic whether the line contains a filename |
Lines 248-253
Link Here
|
248 |
return lastExceptionMessage; |
287 |
return lastExceptionMessage; |
249 |
} |
288 |
} |
250 |
return null; |
289 |
return null; |
|
|
290 |
} |
291 |
|
292 |
/** Returns the current web module root, or null if not known. |
293 |
*/ |
294 |
private FileObject getCurrentWebModuleRoot() { |
295 |
if (wmRootPath == null) { |
296 |
return null; |
297 |
} |
298 |
if (wmRoot == null) { |
299 |
wmRoot = findFO(wmRootPath); |
300 |
// not really the web module root, for now the project root |
301 |
WebModule wm = WebModule.getWebModule(wmRoot); |
302 |
return wm.getDocumentBase(); |
303 |
} |
304 |
return wmRoot; |
251 |
} |
305 |
} |
252 |
|
306 |
|
253 |
private FileObject findFO(String name) { |
307 |
private FileObject findFO(String name) { |