Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 8df55241a1b23765203b883029d84fc5161b00ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.eclipse.jst.jsp.core.internal.java;

import org.eclipse.jdt.core.WorkingCopyOwner;

/**
 * To ensure there is only one instance of ProblemRequestor and WorkingCopyOwner
 * for JSP plugins.  These were removed from JSPTranslation to ensure that the
 * JSPTranslation was not held in memory by any type of JDT lists (caching
 * search results, etc...)
 * 
 * @author pavery
 */
public class CompilationUnitHelper {

    private JSPProblemRequestor fProblemRequestor = null;
    private WorkingCopyOwner fWorkingCopyOwner = null;
    private static CompilationUnitHelper instance;

    private CompilationUnitHelper() {
        // force use of instance
    }

    public synchronized static final CompilationUnitHelper getInstance() {

        if (instance == null)
            instance = new CompilationUnitHelper();
        return instance;
    }

    public JSPProblemRequestor getProblemRequestor() {

        if (fProblemRequestor == null)
            fProblemRequestor = new JSPProblemRequestor();
        return fProblemRequestor;
    }

    public WorkingCopyOwner getWorkingCopyOwner() {

        if (fWorkingCopyOwner == null) {
            fWorkingCopyOwner = new WorkingCopyOwner() {
                public String toString() {
                    return "JSP Working copy owner"; //$NON-NLS-1$
                }
            };
        }
        return fWorkingCopyOwner;
    }
}

Back to the top