blob: be242903373cdb3b88f70e7b2e536d04f372e8c3 [file] [log] [blame]
package org.eclipse.wst.jsdt.web.core.internal.java;
import org.eclipse.wst.jsdt.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 static CompilationUnitHelper instance;
public synchronized static final CompilationUnitHelper getInstance() {
if (CompilationUnitHelper.instance == null) {
CompilationUnitHelper.instance = new CompilationUnitHelper();
}
return CompilationUnitHelper.instance;
}
private JSPProblemRequestor fProblemRequestor = null;
private WorkingCopyOwner fWorkingCopyOwner = null;
private CompilationUnitHelper() {
// force use of instance
}
public JSPProblemRequestor getProblemRequestor() {
if (fProblemRequestor == null) {
fProblemRequestor = new JSPProblemRequestor();
}
return fProblemRequestor;
}
public WorkingCopyOwner getWorkingCopyOwner() {
if (fWorkingCopyOwner == null) {
fWorkingCopyOwner = new WorkingCopyOwner() {
@Override
public String toString() {
return "JSP Working copy owner"; //$NON-NLS-1$
}
};
}
return fWorkingCopyOwner;
}
}