blob: c61e02eb67913609518fc844a223da7fd148fb14 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*******************************************************************************
* Copyright (c) 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.wst.jsdt.debug.internal.core.model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference;
import org.eclipse.wst.jsdt.debug.core.model.IScriptResolver;
import org.eclipse.wst.jsdt.debug.internal.core.Constants;
/**
* Default implementation of the delegate class for all {@link IScriptResolver}s
*
* @since 3.4
*/
public class ScriptResolverExtension implements IScriptResolver {
private IConfigurationElement element = null;
private IScriptResolver delegate = null;
/**
* Constructor
* @param element the backing {@link IConfigurationElement} to lazily load and delegate to
*/
public ScriptResolverExtension(IConfigurationElement element) {
this.element = element;
}
/**
* Returns the delegate {@link IScriptResolver} from the backing {@link IConfigurationElement}
*
* @return the delegate {@link IScriptResolver}
* @throws CoreException thrown if the delegate class fails to be created
*/
synchronized IScriptResolver getDelegate() throws CoreException {
if(delegate == null) {
delegate = (IScriptResolver) element.createExecutableExtension(Constants.CLASS);
}
return delegate;
}
/* (non-Javadoc)
* @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#matches(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference, org.eclipse.core.runtime.IPath)
*/
public boolean matches(ScriptReference script, IPath path) {
try {
return getDelegate().matches(script, path);
}
catch(CoreException ce) {
return false;
}
}
/* (non-Javadoc)
* @see org.eclipse.wst.jsdt.debug.core.model.IScriptPathResolver#getFile(org.eclipse.wst.jsdt.debug.core.jsdi.ScriptReference)
*/
public IFile getFile(ScriptReference script) {
try {
return getDelegate().getFile(script);
}
catch(CoreException ce) {
return null;
}
}
}
|