aboutsummaryrefslogtreecommitdiffstats
path: root/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java
diff options
context:
space:
mode:
authorKen Gilmer <kgilmer@gmail.com>2010-05-18 21:53:22 -0400
committerKen Gilmer <kgilmer@gmail.com>2010-05-18 21:53:22 -0400
commita7e84830627e50adac5c81ae4dad69aa350933fb (patch)
tree219aa86f4d5f03b29d7bc56f8cdba2702d67082c /org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java
parente27a6dcce13930bfa711a6e72992597a8d1d07c5 (diff)
downloadeclipsetools-a7e84830627e50adac5c81ae4dad69aa350933fb.tar.gz
eclipsetools-a7e84830627e50adac5c81ae4dad69aa350933fb.tar.bz2
eclipsetools-a7e84830627e50adac5c81ae4dad69aa350933fb.zip
org.openembedded.bc.ui: initial commit
Diffstat (limited to 'org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java')
-rw-r--r--org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java
new file mode 100644
index 0000000..dba29c2
--- /dev/null
+++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/editors/bitbake/BitBakeDocumentProvider.java
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (c) 2009 Ken Gilmer
+ * 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:
+ * Ken Gilmer - initial API and implementation
+ *******************************************************************************/package org.openembedded.bc.ui.editors.bitbake;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+
+/**
+ * Document provider for BB recipe.
+ * @author kgilmer
+ *
+ */
+public class BitBakeDocumentProvider extends FileDocumentProvider {
+ /**
+ * The recipe partitioning. It contains two partition types: {@link #RECIPE_CODE} and
+ * {@link #RECIPE_COMMENT}.
+ */
+ public static final String RECIPE_PARTITIONING= "org.recipeeditor.recipepartitioning"; //$NON-NLS-1$
+
+ public static final String RECIPE_CODE= IDocument.DEFAULT_CONTENT_TYPE;
+ public static final String RECIPE_COMMENT= "RECIPE_COMMENT"; //$NON-NLS-1$
+
+ private static final String[] CONTENT_TYPES= {
+ RECIPE_CODE,
+ RECIPE_COMMENT
+ };
+
+ private IDocumentPartitioner createRecipePartitioner() {
+ IPredicateRule[] rules= { new SingleLineRule("#", null, new Token(RECIPE_COMMENT), (char) 0, true, false) }; //$NON-NLS-1$
+
+ RuleBasedPartitionScanner scanner= new RuleBasedPartitionScanner();
+ scanner.setPredicateRules(rules);
+
+ return new FastPartitioner(scanner, CONTENT_TYPES);
+ }
+
+ @Override
+ protected void setupDocument(Object element,IDocument document) {
+ if (document instanceof IDocumentExtension3) {
+ IDocumentExtension3 ext= (IDocumentExtension3) document;
+ IDocumentPartitioner partitioner= createRecipePartitioner();
+ ext.setDocumentPartitioner(RECIPE_PARTITIONING, partitioner);
+ partitioner.connect(document);
+ }
+ }
+
+}