From 0262828e86c8a99f1ebb6b80df179bbccfaa8e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Wed, 25 Dec 2024 20:54:28 +0100 Subject: [PATCH] m-m-m/base#8: scanner API changes for unicode --- .../parser/JavaSourceCodeReaderHighlevel.java | 16 +++---- .../parser/JavaSourceCodeReaderLowlevel.java | 46 +++++++++---------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderHighlevel.java b/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderHighlevel.java index ac08a66..2d3d55c 100644 --- a/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderHighlevel.java +++ b/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderHighlevel.java @@ -100,8 +100,8 @@ private void parsePackage() { consume(); String actualPkg = ""; - char c = peek(); - if ((c == 'p') && expect("package")) { + int cp = peek(); + if ((cp == 'p') && expect("package")) { skipWhile(CharFilter.WHITESPACE); actualPkg = readUntil(';', true).trim(); } @@ -668,24 +668,24 @@ private void applyCommentAndAnnotations(BaseElement element) { private CodeTypeCategory parseCategory() { consume(); - char c = peek(); - if (c == 'c') { + int cp = peek(); + if (cp == 'c') { if (expect("class")) { return CodeTypeCategory.CLASS; } - } else if (c == 'i') { + } else if (cp == 'i') { if (expect("interface")) { return CodeTypeCategory.INTERFACE; } - } else if (c == 'e') { + } else if (cp == 'e') { if (expect("enum")) { return CodeTypeCategory.ENUMERAION; } - } else if (c == 'r') { + } else if (cp == 'r') { if (expect("record")) { return CodeTypeCategory.RECORD; } - } else if (c == '@') { + } else if (cp == '@') { if (expect("@interface")) { return CodeTypeCategory.ANNOTATION; } diff --git a/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderLowlevel.java b/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderLowlevel.java index 209dc81..9ca0ce7 100644 --- a/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderLowlevel.java +++ b/java/impl/src/main/java/io/github/mmm/code/impl/java/parser/JavaSourceCodeReaderLowlevel.java @@ -175,12 +175,12 @@ public void consume() { // clearConsumeState(); skipWhile(CharFilter.WHITESPACE); - char c = peek(); - if (c == '/') { // comment or doc? + int cp = peek(); + if (cp == '/') { // comment or doc? next(); parseDocOrComment(); consume(); - } else if (c == '@') { // annotation? + } else if (cp == '@') { // annotation? next(); getElementComment(); parseAnnotations(); @@ -332,8 +332,8 @@ CodeExpression parseAssignmentValue() { List expressions = null; while (true) { parseWhitespacesAndComments(); - char c = peek(); - if (CHAR_FILTER_OPERATOR.accept(c)) { + int cp = peek(); + if (CHAR_FILTER_OPERATOR.accept(cp)) { String operatorName = readWhile(CHAR_FILTER_OPERATOR); CodeOperator nextOperator = BaseOperator.of(operatorName); if (operator == null) { @@ -431,14 +431,14 @@ private String getQualifiedName(String name) { private void parseDocOrComment() { - char c = peek(); - if (c == '/') { + int cp = peek(); + if (cp == '/') { String docLine = readLine(true); this.comments.add(new BaseSingleLineComment(docLine)); - } else if (c == '*') { + } else if (cp == '*') { next(); - c = peek(); - if (c == '*') { // JavaDoc or regular comment + cp = peek(); + if (cp == '*') { // JavaDoc or regular comment next(); if (!this.javaDocLines.isEmpty()) { LOG.warn("Duplicate JavaDoc in {}.", this.file); @@ -451,7 +451,7 @@ private void parseDocOrComment() { this.comments.add(comment); } } else { - LOG.warn("Illegal language: {} in {}.", "/" + c, this.file); + LOG.warn("Illegal language: {} in {}.", "/" + cp, this.file); } } @@ -466,11 +466,11 @@ private void parseDocOrBlockComment(List lines) { } while (true) { skipWhile(CharFilter.WHITESPACE); - char c = peek(); - if (c == '*') { + int cp = peek(); + if (cp == '*') { next(); - c = peek(); - if (c == '/') { + cp = peek(); + if (cp == '/') { next(); skipWhile(CharFilter.WHITESPACE); return; @@ -509,18 +509,18 @@ protected CodeModifiers parseModifiers(boolean inInterface) { boolean found = true; while (found) { skipWhile(CharFilter.WHITESPACE); - char c = peek(); - if (c == 'a') { + int cp = peek(); + if (cp == 'a') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_ABSTRACT); - } else if (c == 'd') { + } else if (cp == 'd') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_DEFAULT); - } else if (c == 'n') { + } else if (cp == 'n') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_NATIVE); - } else if (c == 'f') { + } else if (cp == 'f') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_FINAL); - } else if (c == 'v') { + } else if (cp == 'v') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_VOLATILE); - } else if (c == 's') { + } else if (cp == 's') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_STATIC); if (!found) { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_SYNCHRONIZED); @@ -528,7 +528,7 @@ protected CodeModifiers parseModifiers(boolean inInterface) { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_SYNCHRONIZED); } } - } else if (c == 't') { + } else if (cp == 't') { found = parseModifierKeyword(modifiers, CodeModifiers.KEY_TRANSIENT); } else { found = false;