mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
EA-36715 (better detect doc comment before conversion)
This commit is contained in:
+2
-9
@@ -27,9 +27,9 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocToken;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.xml.XmlEntityDecl;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -44,7 +44,6 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.impl.ConvertToBasicLatinAction");
|
||||
|
||||
@@ -156,13 +155,7 @@ public class ConvertToBasicLatinAction extends PsiElementBaseIntentionAction {
|
||||
|
||||
@Override
|
||||
public PsiElement findApplicable(final PsiElement element) {
|
||||
if (element instanceof PsiDocComment) return element;
|
||||
if (element instanceof PsiDocToken) return element.getParent();
|
||||
if (element instanceof PsiWhiteSpace) {
|
||||
final PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiDocComment) return parent;
|
||||
}
|
||||
return null;
|
||||
return PsiTreeUtil.getParentOfType(element, PsiDocComment.class, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class C {
|
||||
/**
|
||||
* Some method.
|
||||
*
|
||||
* @param value some (©)<caret> param.
|
||||
*/
|
||||
abstract void m(int value);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
class C {
|
||||
/**
|
||||
* Some method.
|
||||
*
|
||||
* @param value some (©) param.
|
||||
*/
|
||||
abstract void m(int value);
|
||||
}
|
||||
+11
-18
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.intention;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -22,7 +21,6 @@ import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
|
||||
public class ConvertToBasicLatinTest extends JavaCodeInsightFixtureTestCase {
|
||||
private String myIntention;
|
||||
|
||||
@@ -33,24 +31,19 @@ public class ConvertToBasicLatinTest extends JavaCodeInsightFixtureTestCase {
|
||||
EncodingManager.getInstance().setDefaultCharsetName("UTF-8");
|
||||
}
|
||||
|
||||
public void testConvertCharLiteral() throws Exception {
|
||||
CodeInsightTestUtil.doIntentionTest(myFixture, myIntention, "CharLiteral.java", "CharLiteral_after.java");
|
||||
}
|
||||
|
||||
public void testConvertStringLiteral() throws Exception {
|
||||
CodeInsightTestUtil.doIntentionTest(myFixture, myIntention, "StringLiteral.java", "StringLiteral_after.java");
|
||||
}
|
||||
|
||||
public void testConvertPlainComment() throws Exception {
|
||||
CodeInsightTestUtil.doIntentionTest(myFixture, myIntention, "PlainComment.java", "PlainComment_after.java");
|
||||
}
|
||||
|
||||
public void testConvertDocComment() throws Exception {
|
||||
CodeInsightTestUtil.doIntentionTest(myFixture, myIntention, "DocComment.java", "DocComment_after.java");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/convertToBasicLatin/";
|
||||
}
|
||||
|
||||
public void testCharLiteral() { doTest(); }
|
||||
public void testStringLiteral() { doTest(); }
|
||||
public void testPlainComment() { doTest(); }
|
||||
public void testDocComment() { doTest(); }
|
||||
public void testDocTag() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
final String name = getTestName(false);
|
||||
CodeInsightTestUtil.doIntentionTest(myFixture, myIntention, name + ".java", name + "_after.java");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user