intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.css.core / src / net / sourceforge / phpeclipse / css / core / parser / ICssParser.java
1 /*
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
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API
10  * 
11  * $Id: ICssParser.java,v 1.1 2004-09-02 18:07:12 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.css.core.parser;
15
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;
20
21 import org.eclipse.jface.text.IDocument;
22
23 /**
24  * Interface for classes that implement the parsing of CSS source code into a
25  * syntax tree.
26  * 
27  * TODO Add a way to only parse a specific range of an IDocument
28  */
29 public interface ICssParser extends IProblemReporter {
30
31         /**
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.
35          * 
36          * @return a list containing the parsed style rules
37          * @throws LexicalErrorException if a lexical error is reported by the
38          *         lexical scanner
39          * @throws SyntaxErrorException if a syntax error has been encountered from
40          *         which recovery is not possible
41          */
42         IRule[] parseRules(IStyleSheet styleSheet)
43                 throws LexicalErrorException, SyntaxErrorException;
44
45         /**
46          * Parses the source at the current position to extract a single rule.
47          * 
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
52          *         lexical scanner
53          * @throws SyntaxErrorException if a syntax error has been encountered from
54          *         which recovery is not possible
55          */
56         IRule parseRule(IStyleSheet styleSheet, IRule parentRule)
57                 throws LexicalErrorException, SyntaxErrorException;
58
59         /**
60          * Parses the source at the current position to extract a selector.
61          * 
62          * @return the parsed selector
63          * @throws LexicalErrorException if a lexical error is reported by the
64          *         lexical scanner
65          * @throws SyntaxErrorException if a syntax error has been encountered from
66          *         which recovery is not possible
67          */
68         ISourceReference parseSelector(IRule rule)
69                 throws LexicalErrorException, SyntaxErrorException;
70
71         /**
72          * Parses the source at the current position to extract a single
73          * declaration.
74          * 
75          * @return the parsed declaration
76          * @throws LexicalErrorException if a lexical error is reported by the
77          *         lexical scanner
78          * @throws SyntaxErrorException if a syntax error has been encountered from
79          *         which recovery is not possible
80          */
81         IDeclaration parseDeclaration(IRule rule)
82                 throws LexicalErrorException, SyntaxErrorException;
83
84         /**
85          * Sets the document containing the style sheet source to process.
86          * 
87          * @param document the document containing the source
88          */
89         void setSource(IDocument document);
90
91 }