Skip to content

Instantly share code, notes, and snippets.

View rylan's full-sized avatar

Rylan Cottrell rylan

View GitHub Profile
@rylan
rylan / IndexedDBControl.js
Created July 29, 2012 15:35
Enyo IndexedDB component
/* This is an example of creating an Enyo component for handling calls to an IndexedDB.
* This example is pretty basic, the DB is based around a Road object that has
* a description and location (unique), the location is used as the key for the record.
*
* Tested and works in Chrome, however testing in Firefox seems to fail do not know why.
*/
enyo.kind({
name: "IndexedDBControl",
kind: "Component",
@rylan
rylan / GetICompilationUnits.java
Created February 14, 2012 21:21
Get a list of ICompilationUnits from an Eclipse IJavaProject object
import java.util.List;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
public class GetICompilationUnits {
public static List<ICompilationUnit> getCompilationUnits(IJavaProject javaProject) {
List<ICompilationUnit> units = new LinkedList<ICompilationUnit>();
@rylan
rylan / EclipseJavaProjects.java
Created February 14, 2012 21:05
Get a list of all java projects open in an Eclipse workspace
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
public class EclipseJavaProjects {
public static List<IJavaProject> getJavaProjects() {
List<IJavaProject> projectList = new LinkedList<IJavaProject>();
@rylan
rylan / gist:1285281
Created October 13, 2011 19:37
Get an ASTNode from an ICompilationUnit (Eclipse JDT)
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.AST;
public ASTUtil {
public static ASTNode getASTNode(ICompilationUnit unit) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(unit);
@rylan
rylan / CaptureEvents.java
Created August 25, 2010 14:53
Capturing Eclipse Java Editor events
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jface.text.ITextViewerExtension5;
@rylan
rylan / gist:511576
Created August 6, 2010 16:28
Fully qualified name to ICompilationUnit
/* Uses the fully qualified type name to search the Eclipse Workspace
* to find the type's ICompilationUnit
*/
public class FindICompilationUnit {
public ICompilationUnit unitLookup(String name){
ICompilationUnit unit = null;
SearchPattern sp = SearchPattern.createPattern(name, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_FULL_MATCH);
SearchEngine se = new SearchEngine();
UnitRequestor ur = new UnitRequestor();