mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
formatter: field groups alignment: correctly process range (IDEA-98368; IDEA-98367)
This commit is contained in:
+1
-1
@@ -99,7 +99,7 @@ public class FieldInColumnsPreFormatProcessor implements PreFormatProcessor {
|
||||
|
||||
//region Calculating end offset to use by the end offset of the last field in a group located to the right of the current field.
|
||||
int endToUse = range.getEndOffset();
|
||||
for (PsiElement f = parent; f != null; f = f.getPrevSibling()) {
|
||||
for (PsiElement f = parent; f != null; f = f.getNextSibling()) {
|
||||
final ASTNode node = f.getNode();
|
||||
if (node == null) {
|
||||
break;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// "Create Field 'field'" "true"
|
||||
class A {
|
||||
public static final String NOTIFICATION_ENABLED = "NOTIFICATION_ENABLED";
|
||||
public static final String NOTIFICATION_DEVICE_NAME = "NOTIFICATION_DEVICE_NAME";
|
||||
public static String field;
|
||||
|
||||
public static String getString(String key)
|
||||
{
|
||||
return getString(key, "");
|
||||
}
|
||||
|
||||
public static String getString(String key, String defaultValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class B {
|
||||
{
|
||||
String s = A.field;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Create Field 'field'" "true"
|
||||
class A {
|
||||
public static final String NOTIFICATION_ENABLED = "NOTIFICATION_ENABLED";
|
||||
public static final String NOTIFICATION_DEVICE_NAME = "NOTIFICATION_DEVICE_NAME";
|
||||
|
||||
public static String getString(String key)
|
||||
{
|
||||
return getString(key, "");
|
||||
}
|
||||
|
||||
public static String getString(String key, String defaultValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class B {
|
||||
{
|
||||
String s = A.fi<caret>eld;
|
||||
}
|
||||
}
|
||||
+14
@@ -1,9 +1,12 @@
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
@@ -21,6 +24,17 @@ public class CreateFieldFromUsageTest extends LightQuickFixTestCase{
|
||||
public void testInsideStaticInnerClass() throws Exception { doSingleTest(); }
|
||||
public void testCreateFromEquals() throws Exception { doSingleTest(); }
|
||||
public void testCreateFromEqualsToPrimitiveType() throws Exception { doSingleTest(); }
|
||||
public void testWithAlignment() throws Exception {
|
||||
final CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
boolean old = settings.ALIGN_GROUP_FIELD_DECLARATIONS;
|
||||
try {
|
||||
settings.ALIGN_GROUP_FIELD_DECLARATIONS = true;
|
||||
doSingleTest();
|
||||
}
|
||||
finally {
|
||||
settings.ALIGN_GROUP_FIELD_DECLARATIONS = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testSortByRelevance() throws Exception {
|
||||
new WriteCommandAction(getProject()) {
|
||||
|
||||
Reference in New Issue
Block a user