# HG changeset patch # User Eugene Ostroukhov # Date 1278711438 25200 # Node ID 413d1cc4e88adcf297ec53f84e4f49400990c975 # Parent d2f02b279cdd8f8a137bb75e7b8d5f6411f0183f# Parent c9364c38809d08e8dc056f322f95a40632a5e69f Bugfix and heads merge Fixed Bug 3026 - Content Assist not working for phonegap APIs diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Fri Jul 09 13:55:17 2010 -0700 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Fri Jul 09 14:37:18 2010 -0700 @@ -18,7 +18,6 @@ IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.15, editorArea); //$NON-NLS-1$ folder.addView(Activator.NAVIGATOR_ID); - folder.addView(JavaScriptUI.ID_TYPE_HIERARCHY); IFolderLayout snippetsFolder = layout.createFolder("snippets", IPageLayout.BOTTOM, (float) 0.5, "left"); //$NON-NLS-1$ snippetsFolder.addView("org.eclipse.wst.common.snippets.internal.ui.SnippetsView"); diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Fri Jul 09 13:55:17 2010 -0700 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Fri Jul 09 14:37:18 2010 -0700 @@ -28,7 +28,8 @@ org.eclipse.ltk.core.refactoring, org.eclipse.ui.editors, org.eclipse.wst.common.snippets, - org.eclipse.jface.text;bundle-version="3.6.0" + org.eclipse.jface.text;bundle-version="3.6.0", + org.eclipse.wst.jsdt.web.core;bundle-version="1.0.300" Bundle-RequiredExecutionEnvironment: J2SE-1.5, JavaSE-1.6 Bundle-ActivationPolicy: lazy diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Fri Jul 09 13:55:17 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Fri Jul 09 14:37:18 2010 -0700 @@ -859,14 +859,6 @@ - - - - empty = Collections.emptyMap(); try { - jsLibrary.install(jsProject.getProject(), empty, new NullProgressMonitor()); + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + public void run(IProgressMonitor arg0) throws CoreException { + Map empty = Collections.emptyMap(); + try { + jsLibrary.install(jsProject.getProject(), empty, new NullProgressMonitor()); + } catch (CoreException e1) { + Activator.log(e1); + } catch (IOException e1) { + Activator.log(e1); + } + } + }, new NullProgressMonitor()); } catch (CoreException e1) { Activator.log(e1); - } catch (IOException e1) { - Activator.log(e1); } } }); diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/WRTInferEngine.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/WRTInferEngine.java Fri Jul 09 13:55:17 2010 -0700 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/WRTInferEngine.java Fri Jul 09 14:37:18 2010 -0700 @@ -25,6 +25,7 @@ import org.eclipse.wst.jsdt.core.ast.IExpression; import org.eclipse.wst.jsdt.core.ast.IFunctionCall; import org.eclipse.wst.jsdt.core.ast.IFunctionDeclaration; +import org.eclipse.wst.jsdt.core.ast.ISingleNameReference; import org.eclipse.wst.jsdt.core.infer.InferEngine; import org.eclipse.wst.jsdt.core.infer.InferredType; import org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration; @@ -34,6 +35,7 @@ @SuppressWarnings("restriction") public class WRTInferEngine extends InferEngine { private final Map serviceIdToType = new TreeMap(); + private static final char[] NAVIGATOR_TYPE = "Navigator".toCharArray(); public WRTInferEngine() { serviceIdToType.put("Service.AppManager:IAppManager", "AppManager".toCharArray()); @@ -85,4 +87,15 @@ } return super.getTypeOf(expression); } + + @Override + protected InferredType getInferredType2(IExpression fieldReceiver) { + if (fieldReceiver.getASTType() == IASTNode.SINGLE_NAME_REFERENCE) { + ISingleNameReference nameReference = (ISingleNameReference) fieldReceiver; + if ("navigator".equals(String.valueOf(nameReference.getToken()))) { + return addType(NAVIGATOR_TYPE, true); + } + } + return super.getInferredType2(fieldReceiver); + } } diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferEngine.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferEngine.java Fri Jul 09 13:55:17 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of the License "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Symbian Foundation - initial contribution. - * Contributors: - * Description: - * Overview: - * Details: - * Platforms/Drives/Compatibility: - * Assumptions/Requirement/Pre-requisites: - * Failures and causes: - */ -package org.symbian.tools.wrttools.core.libraries.jsdt; - -import org.eclipse.wst.jsdt.core.ast.IASTNode; -import org.eclipse.wst.jsdt.core.ast.IExpression; -import org.eclipse.wst.jsdt.core.ast.ISingleNameReference; -import org.eclipse.wst.jsdt.core.infer.InferEngine; -import org.eclipse.wst.jsdt.core.infer.InferredType; - -public class PhoneGapInferEngine extends InferEngine { - private static final char[] NAVIGATOR_TYPE = "Navigator".toCharArray(); - - @Override - protected InferredType getInferredType2(IExpression fieldReceiver) { - if (fieldReceiver.getASTType() == IASTNode.SINGLE_NAME_REFERENCE) { - ISingleNameReference nameReference = (ISingleNameReference) fieldReceiver; - if ("navigator".equals(String.valueOf(nameReference.getToken()))) { - return addType(NAVIGATOR_TYPE, true); - } - } - return super.getInferredType2(fieldReceiver); - } -} diff -r c9364c38809d -r 413d1cc4e88a org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/jsdt/PhoneGapInferrenceProvider.java Fri Jul 09 13:55:17 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of the License "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Symbian Foundation - initial contribution. - * Contributors: - * Description: - * Overview: - * Details: - * Platforms/Drives/Compatibility: - * Assumptions/Requirement/Pre-requisites: - * Failures and causes: - */ -package org.symbian.tools.wrttools.core.libraries.jsdt; - -import java.util.Arrays; -import java.util.Collection; -import java.util.TreeSet; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.jsdt.core.IJavaScriptUnit; -import org.eclipse.wst.jsdt.core.IType; -import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; -import org.eclipse.wst.jsdt.core.infer.IInferenceFile; -import org.eclipse.wst.jsdt.core.infer.InferEngine; -import org.eclipse.wst.jsdt.core.infer.InferrenceProvider; -import org.eclipse.wst.jsdt.core.infer.RefactoringSupport; -import org.eclipse.wst.jsdt.core.infer.ResolutionConfiguration; -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 PHONEGAP_TYPES = new TreeSet(Arrays.asList("Acceleration", - "AccelerationOptions", "Accelerometer", "Camera", "DeviceError", "Contacts", "Contact", "Geolocation", - "PositionOptions", "Coordinates", "Media", "Notification", "Orientation", "Position", "PositionError", - "Sms", "Storage")); - - 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 InferEngine getInferEngine() { - final InferEngine engine = new PhoneGapInferEngine(); - engine.inferenceProvider = this; - return engine; - } - - public RefactoringSupport getRefactoringSupport() { - // TODO Auto-generated method stub - return null; - } - - public ResolutionConfiguration getResolutionConfiguration() { - final ResolutionConfiguration configuration = new ResolutionConfiguration(); - return configuration; - } - -}