From aedc98ce14cda9b1dc0e32c6127be8508b3ad47e Mon Sep 17 00:00:00 2001 From: Louis Vignier Date: Mon, 16 Jun 2025 16:06:35 +0200 Subject: [PATCH] [java-inspections] Detect dashes in MismatchedJavadocCodeInspection #IDEA-374566 Fixed GitOrigin-RevId: 7e7466f2143e23a58d1d159a8759c50aaf0fa95b --- .../javaDoc/MismatchedJavadocCodeInspection.java | 4 ++-- .../javadocMismatchCode/MismatchedJavadocCode.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/javaDoc/MismatchedJavadocCodeInspection.java b/java/java-impl/src/com/intellij/codeInspection/javaDoc/MismatchedJavadocCodeInspection.java index 86f8b7f228ba..338bb2349046 100644 --- a/java/java-impl/src/com/intellij/codeInspection/javaDoc/MismatchedJavadocCodeInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/javaDoc/MismatchedJavadocCodeInspection.java @@ -1,4 +1,4 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInspection.javaDoc; import com.intellij.codeInsight.Nullability; @@ -39,7 +39,7 @@ public final class MismatchedJavadocCodeInspection extends AbstractBaseJavaLocal public static final Pattern RETURN_LINE_START_TYPE_SINGULAR = Pattern.compile("@return\\s+an? (\\S+) (that |describing |containing |of |with |whose |which )"); public static final Pattern - RETURN_LINE_MIDDLE = Pattern.compile("(?:\n\\s*\\*|;|,)\\s+(\\S+) (iff?\\s|when\\s|otherwise|in case of|in the case of)", + RETURN_LINE_MIDDLE = Pattern.compile("(?:\n\\s*\\*|;|,|–|—)\\s+(\\S+) (iff?\\s|when\\s|otherwise|in case of|in the case of)", Pattern.MULTILINE); public static final Pattern DESCRIPTION = Pattern.compile("^\\s+Returns (\\S+) (iff?\\s|when\\s|in case of|in the case of)", Pattern.CASE_INSENSITIVE); diff --git a/java/java-tests/testData/inspection/javadocMismatchCode/MismatchedJavadocCode.java b/java/java-tests/testData/inspection/javadocMismatchCode/MismatchedJavadocCode.java index 3b7c15b0511e..325037c9ac9a 100644 --- a/java/java-tests/testData/inspection/javadocMismatchCode/MismatchedJavadocCode.java +++ b/java/java-tests/testData/inspection/javadocMismatchCode/MismatchedJavadocCode.java @@ -19,6 +19,16 @@ public interface MismatchedJavadocCode { */ int getData2(); + /** + * @return foo — false otherwise + */ + int getDataEmDash(); + + /** + * @return foo - false otherwise + */ + int getDataDash(); + /** * @return true if data is found; false otherwise */