2 * Copyright (c) 2003-2004 Christopher Lenz and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API
11 * $Id: ICssParser.java,v 1.1 2004-09-02 18:07:12 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.core.parser;
16 import net.sourceforge.phpeclipse.core.model.ISourceReference;
17 import net.sourceforge.phpeclipse.css.core.model.IDeclaration;
18 import net.sourceforge.phpeclipse.css.core.model.IRule;
19 import net.sourceforge.phpeclipse.css.core.model.IStyleSheet;
21 import org.eclipse.jface.text.IDocument;
24 * Interface for classes that implement the parsing of CSS source code into a
27 * TODO Add a way to only parse a specific range of an IDocument
29 public interface ICssParser extends IProblemReporter {
32 * Parses the given document as a CSS style sheet. If a problem collector
33 * is provided, lexical and syntax errors are reported to it rather than
34 * throwing exceptions.
36 * @return a list containing the parsed style rules
37 * @throws LexicalErrorException if a lexical error is reported by the
39 * @throws SyntaxErrorException if a syntax error has been encountered from
40 * which recovery is not possible
42 IRule[] parseRules(IStyleSheet styleSheet)
43 throws LexicalErrorException, SyntaxErrorException;
46 * Parses the source at the current position to extract a single rule.
48 * @param parentRule the parent of the rule to parse, or <code>null</code>
49 * if there is no parent
50 * @return the parsed rule
51 * @throws LexicalErrorException if a lexical error is reported by the
53 * @throws SyntaxErrorException if a syntax error has been encountered from
54 * which recovery is not possible
56 IRule parseRule(IStyleSheet styleSheet, IRule parentRule)
57 throws LexicalErrorException, SyntaxErrorException;
60 * Parses the source at the current position to extract a selector.
62 * @return the parsed selector
63 * @throws LexicalErrorException if a lexical error is reported by the
65 * @throws SyntaxErrorException if a syntax error has been encountered from
66 * which recovery is not possible
68 ISourceReference parseSelector(IRule rule)
69 throws LexicalErrorException, SyntaxErrorException;
72 * Parses the source at the current position to extract a single
75 * @return the parsed declaration
76 * @throws LexicalErrorException if a lexical error is reported by the
78 * @throws SyntaxErrorException if a syntax error has been encountered from
79 * which recovery is not possible
81 IDeclaration parseDeclaration(IRule rule)
82 throws LexicalErrorException, SyntaxErrorException;
85 * Sets the document containing the style sheet source to process.
87 * @param document the document containing the source
89 void setSource(IDocument document);