blob: 6bb98b04fcf7ffd5a79529257bd18942f9cdcce0 [file] [log] [blame]
bchilds68f36fc2007-03-01 22:47:33 +00001package org.eclipse.wst.jsdt.web.core.internal.java;
2
3/**
4 * @author pavery
5 */
bchilds68f36fc2007-03-01 22:47:33 +00006import java.util.ArrayList;
7import java.util.List;
8
bchildsd01b1ea2007-03-02 16:52:19 +00009import org.eclipse.wst.jsdt.core.IProblemRequestor;
10import org.eclipse.wst.jsdt.core.compiler.IProblem;
bchilds68f36fc2007-03-01 22:47:33 +000011
bchildsa1181702007-06-14 21:47:04 +000012class JsProblemRequestor implements IProblemRequestor {
bchilds104d9592007-04-30 23:38:39 +000013 private List fCollectedProblems;
bchilds104d9592007-04-30 23:38:39 +000014 private boolean fIsActive = false;
bchilds68f36fc2007-03-01 22:47:33 +000015 private boolean fIsRunning = false;
bchildsa1181702007-06-14 21:47:04 +000016
bchilds68f36fc2007-03-01 22:47:33 +000017 public void acceptProblem(IProblem problem) {
bchilds68f36fc2007-03-01 22:47:33 +000018 if (isActive()) {
19 fCollectedProblems.add(problem);
20 }
21 }
bchildsa1181702007-06-14 21:47:04 +000022
bchilds133806a2007-03-27 15:52:39 +000023 public void beginReporting() {
bchilds133806a2007-03-27 15:52:39 +000024 fIsRunning = true;
25 fCollectedProblems = new ArrayList();
26 }
bchildsa1181702007-06-14 21:47:04 +000027
bchilds68f36fc2007-03-01 22:47:33 +000028 public void endReporting() {
bchilds68f36fc2007-03-01 22:47:33 +000029 fIsRunning = false;
30 }
bchildsa1181702007-06-14 21:47:04 +000031
bchilds133806a2007-03-27 15:52:39 +000032 /**
33 * @return the list of collected problems
34 */
35 public List getCollectedProblems() {
bchilds133806a2007-03-27 15:52:39 +000036 return fCollectedProblems;
37 }
bchildsa1181702007-06-14 21:47:04 +000038
bchilds68f36fc2007-03-01 22:47:33 +000039 public boolean isActive() {
bchilds68f36fc2007-03-01 22:47:33 +000040 return fIsActive && fCollectedProblems != null;
41 }
bchildsa1181702007-06-14 21:47:04 +000042
bchilds133806a2007-03-27 15:52:39 +000043 public boolean isRunning() {
bchilds133806a2007-03-27 15:52:39 +000044 return fIsRunning;
45 }
bchildsa1181702007-06-14 21:47:04 +000046
bchilds68f36fc2007-03-01 22:47:33 +000047 /**
48 * Sets the active state of this problem requestor.
49 *
50 * @param isActive
51 * the state of this problem requestor
52 */
53 public void setIsActive(boolean isActive) {
bchilds68f36fc2007-03-01 22:47:33 +000054 if (fIsActive != isActive) {
55 fIsActive = isActive;
56 if (fIsActive) {
57 startCollectingProblems();
58 } else {
59 stopCollectingProblems();
60 }
61 }
62 }
bchildsa1181702007-06-14 21:47:04 +000063
bchilds68f36fc2007-03-01 22:47:33 +000064 /**
65 * Tells this annotation model to collect temporary problems from now on.
66 */
67 private void startCollectingProblems() {
bchilds68f36fc2007-03-01 22:47:33 +000068 fCollectedProblems = new ArrayList();
69 }
bchildsa1181702007-06-14 21:47:04 +000070
bchilds68f36fc2007-03-01 22:47:33 +000071 /**
72 * Tells this annotation model to no longer collect temporary problems.
73 */
74 private void stopCollectingProblems() {
bchildsa1181702007-06-14 21:47:04 +000075 // do nothing
bchilds68f36fc2007-03-01 22:47:33 +000076 }
bchilds68f36fc2007-03-01 22:47:33 +000077}