model builder example
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.classpath b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.classpath
new file mode 100644
index 0000000..64c5e31
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.project b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.project
new file mode 100644
index 0000000..6809946
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.dltk.javascript.typeinfo.examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.settings/org.eclipse.jdt.core.prefs b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..783b0c7
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Thu Mar 04 17:28:23 NOVT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/META-INF/MANIFEST.MF b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..43e82c4
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Examples
+Bundle-SymbolicName: org.eclipse.dltk.javascript.typeinfo.examples;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.dltk.javascript.core,
+ org.eclipse.dltk.javascript.parser
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/build.properties b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/build.properties
new file mode 100644
index 0000000..e9863e2
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/plugin.xml b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/plugin.xml
new file mode 100644
index 0000000..0d578c1
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/plugin.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension point="org.eclipse.dltk.javascript.core.typeinfo">
+ <builder class="org.eclipse.dltk.javascript.typeinfo.examples.ExampleModelBuilder"/>
+ </extension>
+</plugin>
diff --git a/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/src/org/eclipse/dltk/javascript/typeinfo/examples/ExampleModelBuilder.java b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/src/org/eclipse/dltk/javascript/typeinfo/examples/ExampleModelBuilder.java
new file mode 100644
index 0000000..6bcdfe2
--- /dev/null
+++ b/javascript/examples/org.eclipse.dltk.javascript.typeinfo.examples/src/org/eclipse/dltk/javascript/typeinfo/examples/ExampleModelBuilder.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2010 xored software, Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * xored software, Inc. - initial API and Implementation (Alex Panchenko)
+ *******************************************************************************/
+package org.eclipse.dltk.javascript.typeinfo.examples;
+
+import org.eclipse.dltk.javascript.ast.FunctionStatement;
+import org.eclipse.dltk.javascript.typeinfo.IModelBuilder;
+import org.eclipse.dltk.javascript.typeinfo.ITypeNames;
+import org.eclipse.dltk.javascript.typeinfo.model.TypeInfoModelLoader;
+
+public class ExampleModelBuilder implements IModelBuilder {
+
+ public void processMethod(FunctionStatement statement, IMethod method) {
+ if (method.getType() == null) {
+ if (method.getName().toLowerCase().contains("string"))
+ method.setType(TypeInfoModelLoader.getInstance().getType(
+ ITypeNames.STRING));
+ else if (method.getName().toLowerCase().contains("number"))
+ method.setType(TypeInfoModelLoader.getInstance().getType(
+ ITypeNames.NUMBER));
+ }
+ if ("create".equals(method.getName())
+ && method.getParameterCount() == 0) {
+ IParameter p = method.createParameter();
+ p.setName("name");
+ p.setType(TypeInfoModelLoader.getInstance().getType(
+ ITypeNames.STRING));
+ method.getParameters().add(p);
+ }
+ }
+
+}