Changeset 43
- Timestamp:
- 06/11/08 11:15:57 (7 months ago)
- Files:
-
- axdt/trunk/org.axdt.as3/META-INF/MANIFEST.MF (modified) (1 diff)
- axdt/trunk/org.axdt.as3/plugin.xml (modified) (1 diff)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/AS3Plugin.java (modified) (4 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/AS3Compiler.java (modified) (3 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/AS3CompilerTarget.java (modified) (3 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/IAS3Compiler.java (modified) (1 diff)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java (modified) (3 diffs)
- axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/contentProposer/AS3ContentProposer.java (modified) (3 diffs)
- axdt/trunk/org.axdt.feature/feature.xml (modified) (2 diffs)
- axdt/trunk/org.axdt.flex3sdk/META-INF/MANIFEST.MF (modified) (1 diff)
- axdt/trunk/org.axdt.flex3sdk/src/org/axdt/flex3sdk/Flex3Compiler.java (modified) (2 diffs)
- axdt/trunk/org.axdt.flex3sdk/src/org/axdt/flex3sdk/Flex3Target.java (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
axdt/trunk/org.axdt.as3/META-INF/MANIFEST.MF
r31 r43 3 3 Bundle-Name: Axdt Core Plug-in 4 4 Bundle-SymbolicName: org.axdt.as3;singleton:=true 5 Bundle-Version: 0.0. 15 Bundle-Version: 0.0.2 6 6 Bundle-Vendor: http://axdt.org 7 7 Require-Bundle: org.eclipse.ui, axdt/trunk/org.axdt.as3/plugin.xml
r31 r43 186 186 id="org.eclipse.ui.views.ContentOutline"> 187 187 </view> 188 <actionSet id="org.eclipse.debug.ui.launchActionSet"/> 188 189 </perspectiveExtension> 189 190 </extension> axdt/trunk/org.axdt.as3/src/org/axdt/as3/AS3Plugin.java
r31 r43 1 1 package org.axdt.as3; 2 2 3 import java.net.URL; 4 3 5 import org.eclipse.core.resources.ResourcesPlugin; 6 import org.eclipse.core.runtime.FileLocator; 7 import org.eclipse.core.runtime.IPath; 8 import org.eclipse.core.runtime.Path; 4 9 import org.eclipse.core.runtime.preferences.DefaultScope; 5 10 import org.eclipse.imp.preferences.PreferencesService; 6 11 import org.eclipse.imp.runtime.PluginBase; 7 12 import org.eclipse.jface.resource.ImageDescriptor; 13 import org.eclipse.jface.resource.ImageRegistry; 14 import org.osgi.framework.Bundle; 8 15 import org.osgi.framework.BundleContext; 9 16 … … 43 50 } 44 51 52 /* 53 * (non-Javadoc) 54 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) 55 */ 45 56 public void start(BundleContext context) throws Exception { 46 57 super.start(context); 47 48 58 } 49 59 … … 74 84 // Definitions for image management 75 85 76 public static final org.eclipse.core.runtime.IPath ICONS_PATH = new org.eclipse.core.runtime.Path( 77 "icons/"); //$NON-NLS-1$("icons/"); //$NON-NLS-1$ 86 public static final IPath ICONS_PATH = new Path("icons/"); //$NON-NLS-1$ 78 87 79 protected void initializeImageRegistry( 80 org.eclipse.jface.resource.ImageRegistry reg) { 88 protected void initializeImageRegistry(ImageRegistry reg) { 81 89 82 90 reg.put(IAS3Resources.AS3_DEFAULT_IMAGE, createImage("as3_default_image.gif"));//$NON-NLS-1$ … … 104 112 } 105 113 106 public static org.eclipse.jface.resource.ImageDescriptor createImageDescriptor( 107 org.osgi.framework.Bundle bundle, 108 org.eclipse.core.runtime.IPath path) { 109 java.net.URL url = org.eclipse.core.runtime.FileLocator.find(bundle, 110 path, null); 114 public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path) { 115 URL url = FileLocator.find(bundle, path, null); 111 116 if (url != null) { 112 return org.eclipse.jface.resource.ImageDescriptor 113 .createFromURL(url); 117 return ImageDescriptor.createFromURL(url); 114 118 } 115 119 return null; axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/AS3Compiler.java
r31 r43 1 1 package org.axdt.as3.compiler; 2 2 3 import java.util.ArrayList; 4 import java.util.List; 3 import java.util.HashMap; 5 4 6 5 import org.axdt.as3.AS3Plugin; … … 15 14 public class AS3Compiler implements IAS3Compiler { 16 15 17 private static List<Class<? extends IAS3Compiler>> compilers = new ArrayList<Class<? extends IAS3Compiler>>(); 18 private IAS3Compiler newInstance; 16 private static AS3Compiler instance = null; 17 18 private HashMap<String, AS3CompilerTarget> targets = null; 19 20 public static AS3Compiler getInstance() { 21 if (instance == null) { 22 instance = new AS3Compiler(); 23 } 24 return instance; 25 } 26 27 public AS3Compiler() { 28 targets = new HashMap<String, AS3CompilerTarget>(); 29 } 30 31 private IAS3Compiler defaultCompiler; 19 32 20 p rivate IAS3Compiler getDefaultCompiler() {33 public IExtension[] getComilersContributions() { 21 34 IExtensionRegistry reg = Platform.getExtensionRegistry(); 22 35 IExtensionPoint ep = reg.getExtensionPoint("org.axdt.as3.compilerContribution"); 23 IExtension[] extensions = ep.getExtensions(); 36 return ep.getExtensions(); 37 } 38 39 private IAS3Compiler getDefaultCompiler() { 40 IExtension[] extensions = getComilersContributions(); 24 41 for (int i = 0; i < extensions.length; i++) { 25 42 IExtension ext = extensions[i]; … … 35 52 return null; 36 53 } 54 55 public AS3CompilerTarget getTargetFor(IFile file) { 56 String key = file.getLocation().toOSString(); 57 if (!targets.containsKey(file.getLocation().toOSString())) { 58 targets.put(key, new AS3CompilerTarget(file)); 59 } 60 return targets.get(key); 61 } 37 62 38 63 @Override 39 public void compile AS(IFile file, IProgressMonitor monitor)64 public void compile(AS3CompilerTarget target, IProgressMonitor monitor) 40 65 throws Exception { 41 if ( newInstance== null) {42 newInstance= getDefaultCompiler();66 if (defaultCompiler == null) { 67 defaultCompiler = getDefaultCompiler(); 43 68 } 44 newInstance.compileAS(file, monitor); 45 } 46 47 public static void registerCompiler(Class<? extends IAS3Compiler> class1) { 48 compilers.add(class1); 69 defaultCompiler.compile(target, monitor); 49 70 } 50 71 axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/AS3CompilerTarget.java
r31 r43 11 11 public class AS3CompilerTarget { 12 12 13 protected Object context = null; 13 14 private IResource resource; 14 15 private String name; … … 20 21 } 21 22 22 public FilegetDeployFile() {23 return new File(getDeployPath().toOSString(),name);23 public IPath getDeployFile() { 24 return getDeployPath().append(name); 24 25 } 25 26 public IPath getDeployPath() { … … 48 49 return resource.getLocation().toOSString(); 49 50 } 50 public String get Name() {51 public String getDeployName() { 51 52 return name; 52 53 } 54 public Object getContext() { 55 return context; 56 } 57 @SuppressWarnings("unchecked") 58 public <T> T getAdapter(Class<T> clazz) { 59 if (context != null && clazz.isAssignableFrom(context.getClass())) { 60 return (T) context; 61 } 62 return null; 63 } 64 65 public void setContext(Object context) { 66 this.context = context; 67 } 53 68 } axdt/trunk/org.axdt.as3/src/org/axdt/as3/compiler/IAS3Compiler.java
r31 r43 1 1 package org.axdt.as3.compiler; 2 2 3 import org.axdt.as3.AS3Plugin;4 import org.eclipse.core.resources.IFile;5 3 import org.eclipse.core.runtime.IProgressMonitor; 6 4 7 5 public interface IAS3Compiler { 8 6 9 void compile AS(IFile file, IProgressMonitor monitor) throws Exception;7 void compile(AS3CompilerTarget target, IProgressMonitor monitor) throws Exception; 10 8 11 9 } axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/builders/AS3Builder.java
r31 r43 137 137 */ 138 138 protected void compile(final IFile file, IProgressMonitor monitor) { 139 monitor.beginTask("Building AS3 file: " + file.getName(), 100); 140 boolean doCompile = runParserForCompiler(file, monitor); 141 if (doCompile) { 142 getPlugin().writeInfoMsg("Building AS3 file: " + file.getName()); 143 try { 144 IAS3Compiler compiler = getCompiler(); 145 compiler.compileAS(file, monitor); 146 } catch (Exception e) { 147 // catch Exception, because any exception could break the 148 // builder infra-structure. 149 getPlugin().logException(e.getMessage(), e); 150 } 151 doRefresh(file.getParent()); 152 } 153 monitor.done(); 139 runParserForCompiler(file, monitor); 154 140 } 155 141 … … 166 152 * progress monitor 167 153 */ 168 protected booleanrunParserForCompiler(final IFile file,154 protected void runParserForCompiler(final IFile file, 169 155 IProgressMonitor monitor) { 170 156 try { … … 189 175 e); 190 176 } 191 return true;192 177 } 193 178 } axdt/trunk/org.axdt.as3/src/org/axdt/as3/imp/contentProposer/AS3ContentProposer.java
r41 r43 16 16 17 17 public class AS3ContentProposer implements IContentProposer { 18 private HashMap getVisibleVariables(AS3Parser parser, ASTNode n) {19 HashMap map = new HashMap();20 for (AS3Parser.SymbolTable s = parser.getEnclosingSymbolTable(n); s != null; s = s21 .getParent())22 for (Enumeration e = s.keys(); e.hasMoreElements();) {23 Object key = e.nextElement();24 if (!map.containsKey(key))25 map.put(key, s.get(key));26 }27 18 28 return map; 29 } 30 31 private String getVariableName(IAst decl) { 32 if (decl instanceof VariableDeclarator) 33 return ((VariableDeclarator) decl).getName().toString(); 34 else if (decl instanceof MethodDeclaration) 35 return ((MethodDeclaration) decl).getName().toString(); 36 return ""; 37 } 38 39 // SMS 23 Apr 2008: original 40 private String getVariableProposal(IAst decl) { 41 String string = ""; 42 if (decl instanceof VariableDeclarator) { 43 string = ((VariableDeclarator) decl).getName().toString() + " (" 44 + ((VariableDeclarator) decl).getType().toString() + ")"; 45 } else if (decl instanceof MethodDeclaration) { 46 MethodDeclaration fdecl = (MethodDeclaration) decl; 47 FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 48 string = fdecl.getReturnType().toString() + " " 49 + fdecl.getName().toString() + "("; 50 for (int i = 0; i < parameters.size(); i++) 51 string += parameters.getFormalParameterAt(i).getType().toString() 52 + (i < parameters.size() - 1 ? ", " : ""); 53 string += ")"; 54 } 55 return string; 56 } 57 58 // SMS 23 Apr 2008: which had been replaced by ... 59 private SourceProposal getDeclProposal(IAst decl, String prefix, int offset) { 60 if (decl instanceof VariableDeclarator) { 61 String s = ((VariableDeclarator) decl).getType().toString() + " " 62 + ((VariableDeclarator) decl).getName().toString(); 63 return new SourceProposal(s, s, prefix, offset); 64 } else if (decl instanceof MethodDeclaration) { 65 MethodDeclaration fdecl = (MethodDeclaration) decl; 66 FormalParameterList parameters = fdecl.getParameterBlock().getParameters(); 67 String newText; 68 69 newText = fdecl.getName().toString() 70 + "("; 71 for (int i = 0; i < parameters.size(); i++) 72 newText += parameters.getFormalParameterAt(i).getType() 73 + (i < parameters.size() - 1 ? ", " : ""); 74 newText += ")"; 75 String proposal = fdecl.getReturnType().toString() 76 + " " + newText; 77 return new SourceProposal(proposal, newText, prefix, offset); 78 } 79 return null; 80 } 81 82 private ArrayList filterSymbols(HashMap in_symbols, String prefix) { 83 ArrayList symbols = new ArrayList(); 84 for (Iterator i = in_symbols.values().iterator(); i.hasNext();) { 85 IAst decl = (IAst) i.next(); 86 String name = getVariableName(decl); 87 if (name.length() >= prefix.length() 88 && prefix.equals(name.substring(0, prefix.length()))) 89 symbols.add(decl); 90 } 91 92 return symbols; 93 } 19 private static final String[] keywords = new String[] {"public","private","protected","internal", 20 "static","final","dynamic","override", 21 "class","interface","use","namespace","function","var","const", 22 "import"}; 94 23 95 24 private IToken getToken(IParseController controller, int offset) { … … 113 42 return ""; 114 43 } 115 116 private static String[] keywords = new String[] {"public","private","protected","internal",117 "static","final","dynamic","override",118 "class","interface","use","namespace","function","var","const",119 "import"};120 44 /** 121 45 * Returns an array of content proposals applicable relative to the AST of the given … … 200 124 "no info available due to Syntax error(s)", "", offset)); 201 125 } 202 return (ICompletionProposal[]) list 203 .toArray(new ICompletionProposal[list.size()]); 126 return (ICompletionProposal[]) list.toArray(new ICompletionProposal[list.size()]); 204 127 } 205 128 } axdt/trunk/org.axdt.feature/feature.xml
r34 r43 3 3 id="org.axdt.feature" 4 4 label="AXDT Feature" 5 version="0.0. 1"5 version="0.0.2" 6 6 provider-name="http://axdt.org"> 7 7 … … 40 40 version="0.0.0"/> 41 41 42 <plugin 43 id="org.axdt.as3.launcher" 44 download-size="0" 45 install-size="0" 46 version="0.0.0" 47 unpack="false"/> 48 49 <plugin 50 id="org.axdt.swfview" 51 download-size="0" 52 install-size="0" 53 version="0.0.0" 54 unpack="false"/> 55 42 56 </feature> axdt/trunk/org.axdt.flex3sdk/META-INF/MANIFEST.MF
r31 r43 3 3 Bundle-Name: AXDT Flex3 SDK Integration Plug-in 4 4 Bundle-SymbolicName: org.axdt.flex3sdk;singleton:=true 5 Bundle-Version: 0.0. 15 Bundle-Version: 0.0.2 6 6 Bundle-Activator: org.axdt.flex3sdk.Activator 7 7 Bundle-Vendor: http://axdt.org 8 8 Require-Bundle: org.eclipse.core.runtime, 9 org.axdt.as3 ;bundle-version="0.0.1",9 org.axdt.as3, 10 10 org.eclipse.core.resources, 11 11 org.eclipse.imp.runtime axdt/trunk/org.axdt.flex3sdk/src/org/axdt/flex3sdk/Flex3Compiler.java
r38 r43 1 1 package org.axdt.flex3sdk; 2 2 3 import java. util.Collection;4 import java. util.HashMap;3 import java.io.File; 4 import java.io.FileNotFoundException; 5 5 6 6 import org.axdt.as3.AS3Plugin; 7 import org.axdt.as3.compiler.AS3CompilerTarget; 7 8 import org.axdt.as3.compiler.IAS3Compiler; 8 import org.eclipse.core.resources.IFile;9 import org.eclipse.core.resources.IProject;10 import org.eclipse.core.resources.IResource;11 import org.eclipse.core.resources.IResourceVisitor;12 import org.eclipse.core.runtime.CoreException;13 9 import org.eclipse.core.runtime.IProgressMonitor; 14 10 import org.eclipse.core.runtime.SubProgressMonitor; 15 11 16 12 import flex2.tools.oem.Application; 13 import flex2.tools.oem.Configuration; 17 14 import flex2.tools.oem.Logger; 18 15 import flex2.tools.oem.Message; … … 21 18 public class Flex3Compiler implements Logger, IAS3Compiler { 22 19 23 private HashMap<String, Flex3Target> appmap = null;24 25 20 public Flex3Compiler() { 26 appmap = new HashMap<String, Flex3Target>();27 21 } 28 22 29 private void updateTargets(IProject project) throws CoreException { 30 project.accept(new IResourceVisitor(){ 31 public boolean visit(IResource resource) throws CoreException { 32 String myext = resource.getFileExtension(); 33 if ("as".equals(myext)||"mxml".equals(myext)) { 34 String id = resource.getLocation().toOSString(); 35 if (!appmap.containsKey(id)) 36 appmap.put(id, new Flex3Target(resource)); 37 } 38 return true; 39 }}, 1, false); 40 } 41 42 public void compileAS(IFile file, IProgressMonitor monitor) throws Exception { 43 IProject project = file.getProject(); 44 updateTargets(project); 45 if (!appmap.containsKey(file.getLocation().toOSString())) 46 return; 47 Collection<Flex3Target> targets = appmap.values(); 48 monitor = new SubProgressMonitor(monitor,100); 49 monitor.beginTask("Compiling Targets", 100*targets.size()); 50 for (Flex3Target target:targets) { 51 if (monitor.isCanceled()) return; 52 Application app = target.getApplication(); 53 if (app == null) { 54 app = target.createApplication(); 55 app.getConfiguration().optimize(true); 56 app.setLogger(this); 57 } 58 app.setProgressMeter(new ProgressMonitor(monitor,target.getName())); 59 app.build(true); 60 app.setProgressMeter(null); 23 @Override 24 public void compile(AS3CompilerTarget target, IProgressMonitor monitor) 25 throws Exception { 26 Application app = target.getAdapter(Application.class); 27 if (app == null) { 28 app = createApplication(target); 29 app.getConfiguration().optimize(true); 30 app.setLogger(this); 31 target.setContext(app); 61 32 } 62 monitor.done(); 33 File parentFile = app.getOutput().getParentFile(); 34 if (!parentFile.exists()) { 35 parentFile.mkdir(); 36 } 37 app.setProgressMeter(new ProgressMonitor(monitor,target.getDeployName())); 38 app.build(true); 39 app.setProgressMeter(null); 63 40 } 64 41 42 43 private Application createApplication(AS3CompilerTarget target) throws FileNotFoundException { 44 Application app = new Application(target.getFile()); 45 File file = target.getDeployFile().toFile(); 46 app.setOutput(file); 47 Configuration config = app.getDefaultConfiguration(); 48 File[] sourcePaths = target.getSourcePaths(); 49 config.addSourcePath(sourcePaths); 50 config.allowSourcePathOverlap(true); 51 app.setConfiguration(config); 52 return app; 53 } 65 54 66 55 public void log(Message msg, int arg1, String arg2) {
