/* * The contents of this file are subject to the terms of the Common Development * and Distribution License (the License). You may not use this file except in * compliance with the License. * * You can obtain a copy of the License at http://www.netbeans.org/cddl.html * or http://www.netbeans.org/cddl.txt. * * When distributing Covered Code, include this CDDL Header Notice in each file * and include the License file at http://www.netbeans.org/cddl.txt. * If applicable, add the following below the CDDL Header, with the fields * enclosed by brackets [] replaced by your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" */ package org.netbeans.modules.gwt4nb; import org.netbeans.api.lexer.InputAttributes; import org.netbeans.api.lexer.Language; import org.netbeans.api.lexer.LanguagePath; import org.netbeans.api.lexer.Token; import org.netbeans.api.lexer.TokenUtilities; import org.netbeans.spi.lexer.LanguageEmbedding; import org.netbeans.spi.lexer.LanguageProvider; /** */ public class JSNILanguageProvider extends LanguageProvider { @Override public Language findLanguage(String mimeType) { return Language.find("text/javascript"); /* java.net.stop {} */ } @Override public LanguageEmbedding findLanguageEmbedding(Token token, LanguagePath languagePath, InputAttributes inputAttributes) { if (token.id() == org.netbeans.api.java.lexer.JavaTokenId.BLOCK_COMMENT) { // JavaScript embedding? JSNI - in GWT if (token.text() != null && TokenUtilities.startsWith(token.text(), "/*-{") && // NOI18N TokenUtilities.endsWith(token.text(), "}-*/")) { // NOI18N Language lang = Language.find("text/javascript"); if(lang != null) { return LanguageEmbedding.create(lang, 4, 4, true); } } } return null; } }