removed unused private methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / ASTSyntaxErrorPropagator.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.core.dom;
13
14 import org.eclipse.jdt.core.compiler.CategorizedProblem;
15 import net.sourceforge.phpdt.core.compiler.IProblem;
16
17 /**
18  * Internal AST visitor for propagating syntax errors.
19  */
20 class ASTSyntaxErrorPropagator extends ASTVisitor {
21
22         private CategorizedProblem[] problems;
23         
24         ASTSyntaxErrorPropagator(CategorizedProblem[] problems) {
25                 // visit Javadoc.tags() as well
26                 super(true);
27                 this.problems = problems;
28         }
29
30         private boolean checkAndTagAsMalformed(ASTNode node) {
31                 boolean tagWithErrors = false;
32                 search: for (int i = 0, max = this.problems.length; i < max; i++) {
33                         CategorizedProblem problem = this.problems[i];
34                         switch(problem.getID()) {
35                                 case IProblem.ParsingErrorOnKeywordNoSuggestion :
36                                 case IProblem.ParsingErrorOnKeyword :
37                                 case IProblem.ParsingError :
38                                 case IProblem.ParsingErrorNoSuggestion :
39                                 case IProblem.ParsingErrorInsertTokenBefore :
40                                 case IProblem.ParsingErrorInsertTokenAfter :
41                                 case IProblem.ParsingErrorDeleteToken :
42                                 case IProblem.ParsingErrorDeleteTokens :
43                                 case IProblem.ParsingErrorMergeTokens :
44                                 case IProblem.ParsingErrorInvalidToken :
45                                 case IProblem.ParsingErrorMisplacedConstruct :
46                                 case IProblem.ParsingErrorReplaceTokens :
47                                 case IProblem.ParsingErrorNoSuggestionForTokens :
48                                 case IProblem.ParsingErrorUnexpectedEOF :
49                                 case IProblem.ParsingErrorInsertToComplete :
50                                 case IProblem.ParsingErrorInsertToCompleteScope :
51                                 case IProblem.ParsingErrorInsertToCompletePhrase :
52                                 case IProblem.EndOfSource :
53                                 case IProblem.InvalidHexa :
54                                 case IProblem.InvalidOctal :
55                                 case IProblem.InvalidCharacterConstant :
56                                 case IProblem.InvalidEscape :
57                                 case IProblem.InvalidInput :
58                                 case IProblem.InvalidUnicodeEscape :
59                                 case IProblem.InvalidFloat :
60                                 case IProblem.NullSourceString :
61                                 case IProblem.UnterminatedString :
62                                 case IProblem.UnterminatedComment :
63                                 case IProblem.InvalidDigit :
64                                         break;
65                                 default:
66                                         continue search;
67                         }
68                         int position = problem.getSourceStart();
69                         int start = node.getStartPosition();
70                         int end = start + node.getLength();
71                         if ((start <= position) && (position <= end)) {
72                                 node.setFlags(node.getFlags() | ASTNode.MALFORMED);
73                                 // clear the bits on parent
74                                 ASTNode currentNode = node.getParent();
75                                 while (currentNode != null) {
76                                         currentNode.setFlags(currentNode.getFlags() & ~ASTNode.MALFORMED);
77                                         currentNode = currentNode.getParent();
78                                 }
79                                 tagWithErrors = true;
80                         }
81                 }
82                 return tagWithErrors;
83         }
84
85         /*
86          * Method declared on ASTVisitor.
87          */
88         public boolean visit(FieldDeclaration node) {
89                 return checkAndTagAsMalformed(node);            
90         }
91
92         /*
93          * Method declared on ASTVisitor.
94          */
95         public boolean visit(MethodDeclaration node) {
96                 return checkAndTagAsMalformed(node);            
97         }
98
99         /*
100          * Method declared on ASTVisitor.
101          */
102         public boolean visit(PackageDeclaration node) {
103                 return checkAndTagAsMalformed(node);            
104         }
105
106         /*
107          * Method declared on ASTVisitor.
108          */
109         public boolean visit(ImportDeclaration node) {
110                 return checkAndTagAsMalformed(node);            
111         }
112
113         /*
114          * Method declared on ASTVisitor.
115          */
116         public boolean visit(CompilationUnit node) {
117                 return checkAndTagAsMalformed(node);            
118         }
119
120         /*
121          * Method declared on ASTVisitor.
122          */
123         public boolean visit(AnnotationTypeDeclaration node) {
124                 return checkAndTagAsMalformed(node);            
125         }
126         
127         /*
128          * Method declared on ASTVisitor.
129          */
130         public boolean visit(EnumDeclaration node) {
131                 return checkAndTagAsMalformed(node);            
132         }
133         
134         /*
135          * Method declared on ASTVisitor.
136          */
137         public boolean visit(TypeDeclaration node) {
138                 return checkAndTagAsMalformed(node);            
139         }
140         
141         /*
142          * Method declared on ASTVisitor.
143          */
144         public boolean visit(Initializer node) {
145                 return checkAndTagAsMalformed(node);            
146         }
147
148 }