Permalink
Browse files

Rewritten version

  • Loading branch information...
1 parent 6de6e81 commit e048c68d0e4fc35055d5c4419be61eb2ac0b91b1 Sebastian Hörl committed Jun 5, 2011
Showing with 3,296 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 CHANGELOG
  3. +674 −0 LICENSE
  4. +2 −0 README
  5. +8 −0 build.xml
  6. +1,036 −0 hs_err_pid27421.log
  7. +6 −0 manifest.mf
  8. +42 −0 nbproject/build-impl.xml
  9. +8 −0 nbproject/genfiles.properties
  10. +13 −0 nbproject/platform.properties
  11. +7 −0 nbproject/project.properties
  12. +119 −0 nbproject/project.xml
  13. +21 −0 src/org/netbeans/modules/php/twig/Bundle.properties
  14. +40 −0 src/org/netbeans/modules/php/twig/editor/TwigDataObject.java
  15. +81 −0 src/org/netbeans/modules/php/twig/editor/embedding/TwigEmbeddingProvider.java
  16. +55 −0 src/org/netbeans/modules/php/twig/editor/gsf/TwigLanguage.java
  17. +55 −0 src/org/netbeans/modules/php/twig/editor/gsf/TwigParser.java
  18. +30 −0 src/org/netbeans/modules/php/twig/editor/gsf/TwigStructureScanner.java
  19. +337 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigLexer.java
  20. +58 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigLexerState.java
  21. +93 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigTokenId.java
  22. +189 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigTopLexer.java
  23. +65 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigTopLexerState.java
  24. +92 −0 src/org/netbeans/modules/php/twig/editor/lexer/TwigTopTokenId.java
  25. +1 −0 src/org/netbeans/modules/php/twig/resources/TwigTemplate.html.twig
  26. +11 −0 src/org/netbeans/modules/php/twig/resources/example.html.twig
  27. +24 −0 src/org/netbeans/modules/php/twig/resources/highlighting.xml
  28. BIN src/org/netbeans/modules/php/twig/resources/icon.png
  29. +214 −0 src/org/netbeans/modules/php/twig/resources/layer.xml
  30. +8 −0 src/org/netbeans/modules/php/twig/resources/mime.xml
View
@@ -0,0 +1,2 @@
+/nbproject/private/
+/build/
View
@@ -0,0 +1,5 @@
+Version 1.2
+- Complete rewrite of the plugin
+- Code highlighting for large templates
+- Error parsing dropped (maybe will be added again)
+- Css & Js embedded highlighting in HTML
View
674 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
View
2 README
@@ -0,0 +1,2 @@
+Twig syntax highlighting for Netbeans!
+For current version information see CHANGELOG.
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
+<!-- for some information on what you could do (e.g. targets to override). -->
+<!-- If you delete this file and reopen the project it will be recreated. -->
+<project name="org.netbeans.modules.php.twig" default="netbeans" basedir=".">
+ <description>Builds, tests, and runs the project org.netbeans.modules.php.twig.</description>
+ <import file="nbproject/build-impl.xml"/>
+</project>
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.modules.php.twig/2
+OpenIDE-Module-Implementation-Version: 0
+OpenIDE-Module-Layer: org/netbeans/modules/php/twig/resources/layer.xml
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/php/twig/Bundle.properties
+
View
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT ***
+*** EDIT ../build.xml INSTEAD ***
+-->
+<project name="org.netbeans.modules.php.twig-impl" basedir="..">
+ <fail message="Please build using Ant 1.7.1 or higher.">
+ <condition>
+ <not>
+ <antversion atleast="1.7.1"/>
+ </not>
+ </condition>
+ </fail>
+ <property file="nbproject/private/platform-private.properties"/>
+ <property file="nbproject/platform.properties"/>
+ <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="name"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{name}" value="${@{value}}"/>
+ </sequential>
+ </macrodef>
+ <macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
+ <attribute name="property"/>
+ <attribute name="value"/>
+ <sequential>
+ <property name="@{property}" value="@{value}"/>
+ </sequential>
+ </macrodef>
+ <property file="${user.properties.file}"/>
+ <nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
+ <fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
+ <condition>
+ <not>
+ <contains string="${cluster.path.evaluated}" substring="platform"/>
+ </not>
+ </condition>
+ </fail>
+ <import file="${harness.dir}/build.xml"/>
+</project>
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=46f309b0
+build.xml.script.CRC32=12d8ce43
+build.xml.stylesheet.CRC32=a56c6a5b@1.45.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=46f309b0
+nbproject/build-impl.xml.script.CRC32=0502fb72
+nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1
@@ -0,0 +1,13 @@
+cluster.path=\
+ ${nbplatform.active.dir}/websvccommon:\
+ ${nbplatform.active.dir}/php:\
+ ${nbplatform.active.dir}/java:\
+ ${nbplatform.active.dir}/ide:\
+ ${nbplatform.active.dir}/harness:\
+ ${nbplatform.active.dir}/profiler:\
+ ${nbplatform.active.dir}/platform:\
+ ${nbplatform.active.dir}/cnd:\
+ ${nbplatform.active.dir}/apisupport:\
+ ${nbplatform.active.dir}/dlight:\
+ ${nbplatform.active.dir}/nb
+nbplatform.active=default
@@ -0,0 +1,7 @@
+javac.source=1.6
+javac.compilerargs=-Xlint -Xlint:-serial
+nbm.homepage=http://blogsh.de/twig-for-netbeans
+nbm.module.author=Sebastian H\u00f6rl
+spec.version.base=1
+keystore=nbproject/private/keystore
+nbm_alias=blogsh
View
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.apisupport.project</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+ <code-name-base>org.netbeans.modules.php.twig</code-name-base>
+ <standalone/>
+ <module-dependencies>
+ <dependency>
+ <code-name-base>org.netbeans.modules.csl.api</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>2</release-version>
+ <specification-version>2.14.2.2.1.1.6</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.editor.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.41.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.html.lexer</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.12.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.lexer</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>2</release-version>
+ <specification-version>1.38.1.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <release-version>1</release-version>
+ <specification-version>1.39.2.6</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.filesystems</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.46.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.loaders</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.20.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.nodes</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>7.20.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.text</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.36.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>8.14.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.util.lookup</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>8.6.1</specification-version>
+ </run-dependency>
+ </dependency>
+ <dependency>
+ <code-name-base>org.openide.windows</code-name-base>
+ <build-prerequisite/>
+ <compile-dependency/>
+ <run-dependency>
+ <specification-version>6.39.1</specification-version>
+ </run-dependency>
+ </dependency>
+ </module-dependencies>
+ <public-packages>
+ <package>org.netbeans.modules.php.twig.editor</package>
+ <package>org.netbeans.modules.php.twig.editor.embedding</package>
+ <package>org.netbeans.modules.php.twig.editor.gsf</package>
+ <package>org.netbeans.modules.php.twig.editor.lexer</package>
+ </public-packages>
+ </data>
+ </configuration>
+</project>
@@ -0,0 +1,21 @@
+LBL_Twig_loader_name=Twig Files
+OpenIDE-Module-Display-Category=Languages Support
+OpenIDE-Module-Long-Description=\
+ Syntax highlighting plugin for the Twig template language used by Symfony.
+OpenIDE-Module-Name=Twig for Netbeans
+OpenIDE-Module-Short-Description=Twig template language
+Services/MIMEResolver/TwigResolver.xml=Twig Files
+Templates/Other/TwigTemplate.html.twig=Twig HTML file
+
+text/twig=Twig
+
+twig_comment=Comment
+twig_instruction=Block
+twig_variable=Variable
+twig_operator=Operator
+twig_name=Name
+twig_number=Number
+twig_string=String
+twig_function=Function
+twig_punctuation=Punctuation
+twig_other=Error
@@ -0,0 +1,40 @@
+/**
+ * Twig for Netbeans
+ *
+ * Copyright (c) 2011 Sebastian Hörl
+ *
+ * For warranty and licesning information, view the LICENSE file.
+ */
+
+package org.netbeans.modules.php.twig.editor;
+
+import java.io.IOException;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataNode;
+import org.openide.loaders.DataObjectExistsException;
+import org.openide.loaders.MultiDataObject;
+import org.openide.loaders.MultiFileLoader;
+import org.openide.nodes.CookieSet;
+import org.openide.nodes.Node;
+import org.openide.nodes.Children;
+import org.openide.util.Lookup;
+import org.openide.text.DataEditorSupport;
+
+public class TwigDataObject extends MultiDataObject {
+
+ public TwigDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
+ super(pf, loader);
+ CookieSet cookies = getCookieSet();
+ cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
+ }
+
+ @Override
+ protected Node createNodeDelegate() {
+ return new DataNode(this, Children.LEAF, getLookup());
+ }
+
+ @Override
+ public Lookup getLookup() {
+ return getCookieSet().getLookup();
+ }
+}
@@ -0,0 +1,81 @@
+/**
+ * Twig for Netbeans
+ *
+ * Copyright (c) 2011 Sebastian Hörl
+ *
+ * For warranty and licesning information, view the LICENSE file.
+ */
+
+package org.netbeans.modules.php.twig.editor.embedding;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.lexer.Token;
+import org.netbeans.api.lexer.TokenHierarchy;
+import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.modules.parsing.api.Embedding;
+import org.netbeans.modules.parsing.api.Snapshot;
+import org.netbeans.modules.parsing.spi.EmbeddingProvider;
+import org.netbeans.modules.parsing.spi.SchedulerTask;
+import org.netbeans.modules.parsing.spi.TaskFactory;
+import org.netbeans.modules.php.twig.editor.lexer.TwigTopTokenId;
+
+public class TwigEmbeddingProvider extends EmbeddingProvider {
+
+ public static final String GENERATED_CODE = "@@@"; //NOI18N
+
+ @Override
+ public List<Embedding> getEmbeddings(Snapshot snapshot) {
+
+ TokenHierarchy<CharSequence> th = TokenHierarchy.create(snapshot.getText(), TwigTopTokenId.language());
+ TokenSequence<TwigTopTokenId> sequence = th.tokenSequence(TwigTopTokenId.language());
+ if (sequence == null) return Collections.emptyList();
+
+ sequence.moveStart();
+ List<Embedding> embeddings = new ArrayList<Embedding>();
+
+ int offset = -1;
+ int length = 0;
+ while ( sequence.moveNext() ) {
+ Token t = sequence.token();
+
+ if ( t.id() == TwigTopTokenId.T_HTML ) {
+ if ( offset < 0 ) offset = sequence.offset();
+ length += t.length();
+ } else if ( offset >= 0 ) {
+ embeddings.add( snapshot.create( offset, length, "text/xhtml" ) );
+ offset = -1;
+ length = 0;
+ }
+ }
+
+ if ( offset >= 0 ) {
+ embeddings.add( snapshot.create( offset, length, "text/xhtml" ) );
+ }
+
+ if (embeddings.isEmpty()) {
+ return Collections.emptyList();
+ } else {
+ return Collections.singletonList( Embedding.create(embeddings) );
+ }
+ }
+
+ @Override
+ public int getPriority() {
+ return 200;
+ }
+
+ @Override
+ public void cancel() {}
+
+ public static final class Factory extends TaskFactory {
+
+ @Override
+ public Collection<SchedulerTask> create(final Snapshot snapshot) {
+ return Collections.<SchedulerTask>singletonList(new TwigEmbeddingProvider());
+ }
+ }
+
+}
Oops, something went wrong.

0 comments on commit e048c68

Please sign in to comment.