diff options
author | Chris Goldthorpe | 2009-04-24 17:35:54 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-04-24 17:35:54 +0000 |
commit | 13f02c48b24b0c67560eb1921185e16d31399f11 (patch) | |
tree | 20ec3b0649d26e26e567d63c692d90620c15a028 /org.eclipse.help.base | |
parent | 468527267259865bb582eed742354c91733b9af5 (diff) | |
download | eclipse.platform.ua-13f02c48b24b0c67560eb1921185e16d31399f11.tar.gz eclipse.platform.ua-13f02c48b24b0c67560eb1921185e16d31399f11.tar.xz eclipse.platform.ua-13f02c48b24b0c67560eb1921185e16d31399f11.zip |
Bug 266649 [Help] htmlparser doesn't tell filename when complaning about parsing error
Diffstat (limited to 'org.eclipse.help.base')
4 files changed, 77 insertions, 20 deletions
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java index 136bb579f..a80ba976d 100644 --- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java +++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLDocParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -361,4 +361,11 @@ public class HTMLDocParser { } return null; } + + public Exception getException() { + if (htmlParser != null) { + return htmlParser.getException(); + } + return null; + } } diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java index d83c11ce4..128bb57e7 100644 --- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java +++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/HTMLSearchParticipant.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,7 +60,7 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant { return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, "Help document " //$NON-NLS-1$ + name + " cannot be opened.", //$NON-NLS-1$ - null); + ioe); } ParsedDocument parsed = new ParsedDocument(parser.getContentReader()); doc.add(new Field("contents", parsed.newContentReader())); //$NON-NLS-1$ @@ -70,13 +70,19 @@ public class HTMLSearchParticipant extends LuceneSearchParticipant { doc.add(new Field("exact_title", title, Field.Store.NO, Field.Index.TOKENIZED)); //$NON-NLS-1$ doc.add(new Field("raw_title", title, Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ doc.add(new Field("summary", parser.getSummary(title), Field.Store.YES, Field.Index.NO)); //$NON-NLS-1$ + if (parser.getException() != null) { + return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, + "Parse error occurred while adding document " + name //$NON-NLS-1$ + + " to search index " + indexPath + ".", //$NON-NLS-1$ //$NON-NLS-2$ + parser.getException()); + } } finally { parser.closeDocument(); } } catch (IOException e) { return new Status(IStatus.ERROR, HelpBasePlugin.PLUGIN_ID, IStatus.ERROR, "IO exception occurred while adding document " + name //$NON-NLS-1$ - + " to index " + indexPath + ".", //$NON-NLS-1$ //$NON-NLS-2$ + + " to search index " + indexPath + ".", //$NON-NLS-1$ //$NON-NLS-2$ e); } return Status.OK_STATUS; diff --git a/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java b/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java index 7d71b39cc..7d65fc835 100644 --- a/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java +++ b/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/HTMLParser.java @@ -1,4 +1,33 @@ +/** + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright (c) 2003, 2009 IBM Corp. + * All rights reserved. + * + * Contributors: + * Apache Software Foundation - Initial contribution + * Konrad Kolosowski, IBM - skipping XML decl, merging meta keywords + * content with main text, encoding read and write to piped stream, + * returning summary if starts with title. + * Curtis d'Entremont, IBM - added missing serialVersionUIDs, removed + * unused imports, labels, variables, methods from javacc *generated* + * code, strip title off summary. + * Chris Goldthorpe, IBM - Bugs 223860, 210991, 246095, 245411, 269380, 266649 + /* Generated By:JavaCC: Do not edit this line. HTMLParser.java */ + package org.apache.lucene.demo.html; import java.io.*; @@ -25,6 +54,7 @@ public class HTMLParser implements HTMLParserConstants { Writer pipeOut; private MyPipedInputStream pipeInStream = null; private PipedOutputStream pipeOutStream = null; + private Exception exception = null; private class MyPipedInputStream extends PipedInputStream{ @@ -737,7 +767,15 @@ null) p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } - static final class JJCalls { + public void setException(Exception exception) { + this.exception = exception; + } + + public Exception getException() { + return exception; + } + +static final class JJCalls { int gen; Token first; int arg; diff --git a/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/ParserThread.java b/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/ParserThread.java index 8d7cdb408..bdbb2e287 100644 --- a/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/ParserThread.java +++ b/org.eclipse.help.base/src_demo/org/apache/lucene/demo/html/ParserThread.java @@ -1,7 +1,7 @@ package org.apache.lucene.demo.html; /** - * Copyright 2004 The Apache Software Foundation + * Copyright 2004, The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,16 @@ package org.apache.lucene.demo.html; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * Copyright (c) 2009 IBM Corp. + * All rights reserved. */ + +/** +* History +* 2004 Initial contribution The Apache Software Foundation +* 2009 Chris Goldthorpe, IBM Corporation, fix for bug 266649 +*/ import java.io.*; @@ -26,23 +35,20 @@ class ParserThread extends Thread { } public void run() { // convert pipeOut to pipeIn - try { + try { // parse document to pipeOut parser.HTMLDocument(); - } catch (ParseException e) { - System.out.println("Parse Aborted: " + e.getMessage()); //$NON-NLS-1$ - } catch (TokenMgrError e) { - System.out.println("Parse Aborted: " + e.getMessage()); //$NON-NLS-1$ - } finally { - parser.pipeOut.close(); - synchronized (parser) { - parser.summary.setLength(HTMLParser.SUMMARY_LENGTH); - parser.titleComplete = true; - parser.notifyAll(); - } + } catch (Exception e) { + parser.setException(e); } - } catch (IOException e) { - e.printStackTrace(); + + try { + parser.summary.setLength(HTMLParser.SUMMARY_LENGTH); + parser.titleComplete = true; + parser.pipeOut.close(); + } catch (IOException e) { + e.printStackTrace(); } + parser.notifyAll(); } } |