diff --git a/ide/markdown/src/org/netbeans/modules/markdown/markdown.tmLanguage.json b/ide/markdown/src/org/netbeans/modules/markdown/markdown.tmLanguage.json index 463a3fbbbdec..77229d33dd9a 100644 --- a/ide/markdown/src/org/netbeans/modules/markdown/markdown.tmLanguage.json +++ b/ide/markdown/src/org/netbeans/modules/markdown/markdown.tmLanguage.json @@ -959,6 +959,39 @@ } ] }, + "fenced_code_block_ignore": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(gitignore|ignore)((\\s+|:|,|\\{|\\?)[^`]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.ignore", + "patterns": [ + { + "include": "source.ignore" + } + ] + } + ] + }, "fenced_code_block_js": { "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(js|jsx|javascript|es6|mjs|cjs|dataviewjs|\\{\\.js.+?\\})((\\s+|:|,|\\{|\\?)[^`]*)?$)", "name": "markup.fenced_code.block.markdown", @@ -1091,6 +1124,39 @@ } ] }, + "fenced_code_block_jsonl": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(jsonl|jsonlines)((\\s+|:|,|\\{|\\?)[^`]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.jsonl", + "patterns": [ + { + "include": "source.json.lines" + } + ] + } + ] + }, "fenced_code_block_less": { "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(less)((\\s+|:|,|\\{|\\?)[^`]*)?$)", "name": "markup.fenced_code.block.markdown", @@ -1916,6 +1982,105 @@ } ] }, + "fenced_code_block_yang": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(yang)((\\s+|:|,|\\{|\\?)[^`]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.yang", + "patterns": [ + { + "include": "source.yang" + } + ] + } + ] + }, + "fenced_code_block_abap": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(abap)((\\s+|:|,|\\{|\\?)[^`]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.abap", + "patterns": [ + { + "include": "source.abap" + } + ] + } + ] + }, + "fenced_code_block_restructuredtext": { + "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(restructuredtext|rst)((\\s+|:|,|\\{|\\?)[^`]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.restructuredtext", + "patterns": [ + { + "include": "source.rst" + } + ] + } + ] + }, "fenced_code_block": { "patterns": [ { @@ -2000,6 +2165,9 @@ "include": "#fenced_code_block_pug" }, { + "include": "#fenced_code_block_ignore" + }, + { "include": "#fenced_code_block_js" }, { @@ -2012,6 +2180,9 @@ "include": "#fenced_code_block_jsonc" }, { + "include": "#fenced_code_block_jsonl" + }, + { "include": "#fenced_code_block_less" }, { @@ -2087,6 +2258,15 @@ "include": "#fenced_code_block_twig" }, { + "include": "#fenced_code_block_yang" + }, + { + "include": "#fenced_code_block_abap" + }, + { + "include": "#fenced_code_block_restructuredtext" + }, + { "include": "#fenced_code_block_unknown" } ] @@ -3084,9 +3264,8 @@ "name": "punctuation.definition.strikethrough.markdown" } }, - "match": "(?external/joni-2.2.6.jar - ext/org.eclipse.tm4e.core-0.14.1.jar - external/org.eclipse.tm4e.core-0.14.1.jar + ext/org.eclipse.tm4e.core_0.17.1.jar + external/org.eclipse.tm4e.core_0.17.1.jar diff --git a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java index e0617d2e6a1b..d74a16f7e035 100644 --- a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java +++ b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.HashSet; @@ -145,17 +146,22 @@ private void process(Element toRegister, AnnotationMirror mimeRegistration) thro javax.tools.FileObject file = layer.validateResource(grammar, toRegister, null, null, false); try (InputStream in = file.openInputStream(); InputStreamReader isr = new InputStreamReader(in, StandardCharsets.UTF_8)) { - String finalGrammar = grammar; IGrammarSource referencedGrammar = new IGrammarSource() { + @Override - public String getFilePath() { - return finalGrammar; + public long getLastModified() { + return file.getLastModified(); } @Override public Reader getReader() throws IOException { return isr; } + + @Override + public URI getURI() { + return file.toUri(); + } }; String scopeName = RawGrammarReader.readGrammar(referencedGrammar).getScopeName(); String simpleName = grammar.lastIndexOf('/') != (-1) ? grammar.substring(grammar.lastIndexOf('/') + 1) : grammar; @@ -178,6 +184,8 @@ private void processInjection(Element toRegister, AnnotationMirror injectionRegi continue; } if (simpleName.contentEquals("injectTo")) { + // Warning removal requires class changes + @SuppressWarnings("unchecked") List values = (List) e.getValue().getValue(); for (AnnotationValue value : values) { if (injectTo == null) { @@ -194,18 +202,24 @@ private void processInjection(Element toRegister, AnnotationMirror injectionRegi javax.tools.FileObject file = layer.validateResource(grammar, toRegister, null, null, false); try (InputStream in = file.openInputStream(); InputStreamReader isr = new InputStreamReader(in, StandardCharsets.UTF_8)) { - String finalGrammar = grammar; IGrammarSource referencedGrammar = new IGrammarSource() { + @Override - public String getFilePath() { - return finalGrammar; + public long getLastModified() { + return file.getLastModified(); } @Override public Reader getReader() throws IOException { return isr; } + + @Override + public URI getURI() { + return file.toUri(); + } }; + String scopeName = RawGrammarReader.readGrammar(referencedGrammar).getScopeName(); String simpleName = grammar.lastIndexOf('/') != (-1) ? grammar.substring(grammar.lastIndexOf('/') + 1) : grammar; layer.file("Editors" + "/" + simpleName) @@ -249,7 +263,7 @@ private Iterable completeMimePath( userText = userText.substring(1); } - Set res = new HashSet(); + Set res = new HashSet<>(); if (COMPLETIONS == null) { String pathCompletions = System.getProperty("org.openide.awt.ActionReference.completion"); if (pathCompletions != null) { @@ -315,10 +329,12 @@ public TypeCompletion(String type) { this.type = type; } + @Override public String getValue() { return type; } + @Override public String getMessage() { return null; } diff --git a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/FileObjectGrammarSource.java b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/FileObjectGrammarSource.java index 2d7db78df749..4be9d0029b70 100644 --- a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/FileObjectGrammarSource.java +++ b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/FileObjectGrammarSource.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.net.URI; import java.nio.charset.StandardCharsets; import org.eclipse.tm4e.core.registry.IGrammarSource; import org.openide.filesystems.FileObject; @@ -34,8 +35,12 @@ public FileObjectGrammarSource(FileObject fileObject) { } @Override - public String getFilePath() { - return fileObject.getPath(); + public long getLastModified() { + if (fileObject == null) { + return 0; + } else { + return fileObject.lastModified().getTime(); + } } @Override @@ -43,4 +48,11 @@ public Reader getReader() throws IOException { return new InputStreamReader(fileObject.getInputStream(), StandardCharsets.UTF_8); } + @Override + public URI getURI() { + if (fileObject.isValid()) + return fileObject.toURI(); + else + return null; + } } diff --git a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/SyntaxHighlighting.java b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/SyntaxHighlighting.java index 6d35a8fc34ac..be6b3f173111 100644 --- a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/SyntaxHighlighting.java +++ b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/SyntaxHighlighting.java @@ -22,10 +22,8 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.event.ChangeEvent; @@ -35,7 +33,6 @@ import javax.swing.text.Document; import javax.swing.text.SimpleAttributeSet; import org.netbeans.api.editor.mimelookup.MimeLookup; -import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.api.editor.mimelookup.MimeRegistration; import org.netbeans.api.editor.settings.AttributesUtilities; import org.netbeans.api.editor.settings.EditorStyleConstants; @@ -136,7 +133,8 @@ public SyntaxHighlighting(Document document) { // TokenHierarchyListener implementation // ---------------------------------------------------------------------- - public @Override void tokenHierarchyChanged(TokenHierarchyEvent evt) { + @Override + public void tokenHierarchyChanged(TokenHierarchyEvent evt) { if (evt.type() == TokenHierarchyEventType.LANGUAGE_PATHS) { // ignore return; @@ -321,7 +319,7 @@ private static String attributeSet(AttributeSet as) { * @param t token to check * @return true, if token is normal text; false if block. */ - private static boolean noBlock(Token t) { + private static boolean noBlock(Token t) { return t.getProperty("highlight.block") != Boolean.TRUE; // NOI18N } @@ -356,7 +354,7 @@ public HSImpl(long version, TokenHierarchy scanner, int star this.scanner = scanner; startOffset = Math.max(startOffset, 0); // Tests may request Integer.MIN_VALUE for startOffset this.startOffset = startOffset; - this.sequences = new ArrayList>(4); + this.sequences = new ArrayList<>(4); this.hiStartOffset = startOffset; this.hiEndOffset = startOffset; Document doc = scanner.inputSource(); @@ -672,13 +670,16 @@ public FCSInfo(String mimePath, Language innerLanguage) { * @param token non-null token. * @return attributes for tokenId or null if none found. */ - synchronized AttributeSet findAttrs(Token token) { + synchronized AttributeSet findAttrs(Token token) { if (token.id() != TextmateTokenId.TEXTMATE) { return null; } List attrs = new ArrayList<>(); - List categories = (List) token.getProperty("categories"); + + // Warning removal requires Token class changes + @SuppressWarnings("unchecked") + List categories = (List)token.getProperty("categories"); for (String category : categories) { if (category.startsWith("meta.embedded")) {