--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java Wed Jun 09 14:44:32 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java Wed Jun 09 15:16:09 2010 -0700
@@ -37,58 +37,55 @@
import org.symbian.tools.wrttools.Activator;
public class PhoneGapInferrenceProvider implements InferrenceProvider {
- public static final String ID = "org.symbian.tools.wrttools.phonegap";
- private static final Collection<String> PHONEGAP_TYPES = new TreeSet<String>(
- Arrays.asList("Acceleration", "AccelerationOptions",
- "Accelerometer", "Camera", "DeviceError", "Contacts",
- "Contact", "Geolocation", "PositionOptions", "Coordinates",
- "Media", "Notification", "Orientation", "Position",
- "PositionError", "Sms", "Storage"));
-
- public int applysTo(IInferenceFile scriptFile) {
- String path = String.valueOf(scriptFile.getFileName());
+ public static final String ID = "org.symbian.tools.wrttools.phonegap";
+ private static final Collection<String> PHONEGAP_TYPES = new TreeSet<String>(Arrays.asList("Acceleration",
+ "AccelerationOptions", "Accelerometer", "Camera", "DeviceError", "Contacts", "Contact", "Geolocation",
+ "PositionOptions", "Coordinates", "Media", "Notification", "Orientation", "Position", "PositionError",
+ "Sms", "Storage"));
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
- new Path(path));
- if (file != null && file.isAccessible()) {
- IJavaScriptUnit unit = (IJavaScriptUnit) JavaScriptCore
- .create(file);
- try {
- IType[] types = unit.getAllTypes();
- int typeCount = 0;
- for (IType type : types) {
- if (PHONEGAP_TYPES.contains(type.getElementName())) {
- typeCount += 1;
- }
- }
- if (typeCount > 1) {
- return ONLY_THIS;
- }
- } catch (JavaScriptModelException e) {
- Activator.log(e);
- }
- }
- return NOT_THIS;
- }
+ public int applysTo(IInferenceFile scriptFile) {
+ Path path = new Path(String.valueOf(scriptFile.getFileName()));
+ if (path.segmentCount() > 1) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null && file.isAccessible()) {
+ IJavaScriptUnit unit = (IJavaScriptUnit) JavaScriptCore.create(file);
+ try {
+ IType[] types = unit.getAllTypes();
+ int typeCount = 0;
+ for (IType type : types) {
+ if (PHONEGAP_TYPES.contains(type.getElementName())) {
+ typeCount += 1;
+ }
+ }
+ if (typeCount > 1) {
+ return ONLY_THIS;
+ }
+ } catch (JavaScriptModelException e) {
+ Activator.log(e);
+ }
+ }
+ }
+ return NOT_THIS;
+ }
- public String getID() {
- return ID;
- }
+ public String getID() {
+ return ID;
+ }
- public InferEngine getInferEngine() {
- final InferEngine engine = new PhoneGapInferEngine();
- engine.inferenceProvider = this;
- return engine;
- }
+ public InferEngine getInferEngine() {
+ final InferEngine engine = new PhoneGapInferEngine();
+ engine.inferenceProvider = this;
+ return engine;
+ }
- public RefactoringSupport getRefactoringSupport() {
- // TODO Auto-generated method stub
- return null;
- }
+ public RefactoringSupport getRefactoringSupport() {
+ // TODO Auto-generated method stub
+ return null;
+ }
- public ResolutionConfiguration getResolutionConfiguration() {
- final ResolutionConfiguration configuration = new ResolutionConfiguration();
- return configuration;
- }
+ public ResolutionConfiguration getResolutionConfiguration() {
+ final ResolutionConfiguration configuration = new ResolutionConfiguration();
+ return configuration;
+ }
}