~ubuntu-branches/ubuntu/utopic/eclipse-wtp/utopic-proposed

« back to all changes in this revision

Viewing changes to org.eclipse.wst.xml.xpath2.processor/src/org/eclipse/wst/xml/xpath2/processor/internal/InternalXPathParser.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-07-10 12:54:39 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140710125439-ixzeiqepu8m3e1z6
Tags: 3.6.0-1
* New upstream release.
* Refreshed d/patches/debian-custom-build.patch.
* Regenerate CSSTokenizer during build.
* Override codeless-jar warning in eclipse-wtp binary package.
* Override false positive source-is-missing lintian error in bundle
  org.eclipse.wst.jsdt.support.ie.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import org.eclipse.wst.xml.xpath2.processor.StaticError;
20
20
import org.eclipse.wst.xml.xpath2.processor.XPathParserException;
21
21
import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
 
22
import org.eclipse.wst.xml.xpath2.processor.internal.ast.XPathExpr;
22
23
 
23
24
/**
24
25
 * JFlexCupParser parses the xpath expression
25
26
 */
 
27
@SuppressWarnings("deprecation")
26
28
public class InternalXPathParser {
27
29
 
28
30
        /**
40
42
 
41
43
                XPathFlex lexer = new XPathFlex(new StringReader(xpath));
42
44
 
43
 
                XPathCup p = null;
44
 
                if (isRootlessAccess) {
45
 
                        p = new XPathCupRestricted(lexer); 
46
 
                }
47
 
                else {
48
 
                        p = new XPathCup(lexer); 
49
 
                }
50
45
                try {
 
46
                        XPathCup p = new XPathCup(lexer); 
51
47
                        Symbol res = p.parse();
52
 
                        return (XPath) res.value;
 
48
                        XPath xPath2 = (XPath) res.value;
 
49
                        if (isRootlessAccess) {
 
50
                                xPath2.accept(new DefaultVisitor() {
 
51
                                        public Object visit(XPathExpr e) {
 
52
                                                if (e.slashes() > 0) {
 
53
                                                        throw new XPathParserException("Access to root node is not allowed (set by caller)");
 
54
                                                }
 
55
                                                do {
 
56
                                                        e.expr().accept(this); // check the single step (may have filter with root access)
 
57
                                                        e = e.next(); // follow singly linked list of the path, it's all relative past the first one
 
58
                                                } while (e != null);
 
59
                                                return null;
 
60
                                        }
 
61
                                });
 
62
                        }
 
63
                        return xPath2;
53
64
                } catch (JFlexError e) {
54
65
                        throw new XPathParserException("JFlex lexer error: " + e.reason());
55
66
                } catch (CupError e) {
56
67
                        throw new XPathParserException("CUP parser error: " + e.reason());
 
68
                } catch (StaticError e) {
 
69
                        throw  new XPathParserException(e.code(), e.getMessage());
57
70
                } catch (Exception e) {
58
71
                        throw new XPathParserException(e.getMessage());
59
72
                }