mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.execution.remote.RemoteConfigurable">
|
||||
<grid id="715ea" binding="myPanel" layout-manager="GridBagLayout">
|
||||
<grid id="715ea" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="64" y="1" width="601" height="433"/>
|
||||
<xy x="64" y="1" width="330" height="324"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -11,7 +12,6 @@
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
@@ -19,25 +19,17 @@
|
||||
</clientProperties>
|
||||
<border type="etched" title-resource-bundle="messages/ExecutionBundle" title-key="remote.configuration.settings.border"/>
|
||||
<children>
|
||||
<grid id="d0319" binding="mySocketPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="d0319" binding="mySocketPanel" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="11a97" class="javax.swing.JTextField" binding="myPortField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="76d9b" class="javax.swing.JTextField" binding="myHostField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -53,18 +45,26 @@
|
||||
</component>
|
||||
<component id="24ab6" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/ExecutionBundle" key="remote.configuration.port.label"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="11a97" class="javax.swing.JTextField" binding="myPortField">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="446e3" binding="myShmemPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -79,7 +79,7 @@
|
||||
</component>
|
||||
<component id="d75e1" class="javax.swing.JTextField" binding="myAddressField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -141,34 +141,38 @@
|
||||
</grid>
|
||||
<component id="aa30e" class="com.intellij.execution.ui.ConfigurationArgumentsHelpArea" binding="myHelpArea">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag weightx="1.0" weighty="0.0"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4362c" class="com.intellij.execution.ui.ConfigurationArgumentsHelpArea" binding="myJDK13HelpArea">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="15" left="0" bottom="15" right="0" weightx="1.0" weighty="0.0"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="38070" class="com.intellij.openapi.ui.LabeledComponent" binding="myModule">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="15" left="0" bottom="0" right="0" weightx="1.0" weighty="0.0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<componentClass value="javax.swing.JComboBox"/>
|
||||
<text value="Search sources using the classpath of m&odule (select <no module> to search across the whole project):" noi18n="true"/>
|
||||
<labelLocation value="West"/>
|
||||
<text value="Search sources using m&odule's classpath:" noi18n="true"/>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2e3b8" class="com.intellij.execution.ui.ConfigurationArgumentsHelpArea" binding="myJDK14HelpArea">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<gridbag top="15" left="0" bottom="15" right="0" weightx="1.0" weighty="0.0"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
|
||||
@@ -128,20 +128,20 @@ public class RemoteConfigurable extends SettingsEditor<RemoteConfiguration> {
|
||||
myAddressField.addFocusListener(fieldFocusListener);
|
||||
myPortField.addFocusListener(fieldFocusListener);
|
||||
|
||||
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent());
|
||||
myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent(), "<whole project>");
|
||||
}
|
||||
|
||||
public void applyEditorTo(@NotNull final RemoteConfiguration configuration) throws ConfigurationException {
|
||||
configuration.HOST = (myHostField.isEditable() ? myHostField.getText() : myHostName).trim();
|
||||
if ("".equals(configuration.HOST)) {
|
||||
if (configuration.HOST != null && configuration.HOST.isEmpty()) {
|
||||
configuration.HOST = null;
|
||||
}
|
||||
configuration.PORT = myPortField.getText().trim();
|
||||
if ("".equals(configuration.PORT)) {
|
||||
if (configuration.PORT != null && configuration.PORT.isEmpty()) {
|
||||
configuration.PORT = null;
|
||||
}
|
||||
configuration.SHMEM_ADDRESS = myAddressField.getText().trim();
|
||||
if ("".equals(configuration.SHMEM_ADDRESS)) {
|
||||
if (configuration.SHMEM_ADDRESS != null && configuration.SHMEM_ADDRESS.isEmpty()) {
|
||||
configuration.SHMEM_ADDRESS = null;
|
||||
}
|
||||
configuration.USE_SOCKET_TRANSPORT = myRbSocket.isSelected();
|
||||
|
||||
+10
-5
@@ -3,14 +3,14 @@
|
||||
<grid id="f0e0b" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="47" y="46" width="488" height="239"/>
|
||||
<xy x="47" y="46" width="374" height="79"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="25a8e" class="javax.swing.JLabel" binding="myLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="2" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="9e177"/>
|
||||
@@ -19,9 +19,14 @@
|
||||
</component>
|
||||
<scrollpane id="f35c0" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="100" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<horizontalScrollBarPolicy value="31"/>
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9e177" class="javax.swing.JTextArea" binding="myHelpArea">
|
||||
@@ -29,7 +34,7 @@
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
<lineWrap value="true"/>
|
||||
<minimumSize width="250" height="16"/>
|
||||
<visible value="true"/>
|
||||
<wrapStyleWord value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
|
||||
+3
-1
@@ -19,6 +19,7 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
|
||||
@@ -37,6 +38,7 @@ public class ConfigurationArgumentsHelpArea extends JPanel {
|
||||
public ConfigurationArgumentsHelpArea() {
|
||||
super(new BorderLayout());
|
||||
add(myPanel);
|
||||
setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0));
|
||||
|
||||
final DefaultActionGroup group = new DefaultActionGroup();
|
||||
group.add(new MyCopyAction());
|
||||
@@ -64,7 +66,7 @@ public class ConfigurationArgumentsHelpArea extends JPanel {
|
||||
public void setToolbarVisible() {
|
||||
myToolbarPanel.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
private static ActionPopupMenu createPopupMenu(DefaultActionGroup group) {
|
||||
return ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigurationModuleSelector {
|
||||
private static final String NO_MODULE = "<no module>";
|
||||
|
||||
private final String myNoModule;
|
||||
private final Project myProject;
|
||||
private final JComboBox myModulesList;
|
||||
private final SortedComboBoxModel<Object> myModules = new SortedComboBoxModel<Object>(new Comparator<Object>() {
|
||||
@@ -49,6 +49,11 @@ public class ConfigurationModuleSelector {
|
||||
});
|
||||
|
||||
public ConfigurationModuleSelector(final Project project, final JComboBox modulesList) {
|
||||
this(project, modulesList, "<no module>");
|
||||
}
|
||||
|
||||
public ConfigurationModuleSelector(final Project project, final JComboBox modulesList, String noModule) {
|
||||
myNoModule = noModule;
|
||||
myProject = project;
|
||||
myModulesList = modulesList;
|
||||
new ComboboxSpeedSearch(modulesList){
|
||||
@@ -56,7 +61,7 @@ public class ConfigurationModuleSelector {
|
||||
if (element instanceof Module){
|
||||
return ((Module)element).getName();
|
||||
} else if (element == null) {
|
||||
return NO_MODULE;
|
||||
return myNoModule;
|
||||
}
|
||||
return super.getElementText(element);
|
||||
}
|
||||
@@ -71,7 +76,7 @@ public class ConfigurationModuleSelector {
|
||||
setText(module.getName());
|
||||
}
|
||||
else if (value == null) {
|
||||
setText(NO_MODULE);
|
||||
setText(myNoModule);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+12
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.search;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
@@ -44,7 +45,10 @@ public class VariableInIncompleteCodeSearcher extends QueryExecutorBase<PsiRefer
|
||||
final SearchScope scope = p.getEffectiveSearchScope();
|
||||
if (!(scope instanceof LocalSearchScope)) return;
|
||||
|
||||
PsiTreeUtil.processElements(new PsiElementProcessor() {
|
||||
PsiElement[] elements = ((LocalSearchScope)scope).getScope();
|
||||
if (elements == null || elements.length == 0) return;
|
||||
|
||||
PsiElementProcessor processor = new PsiElementProcessor() {
|
||||
@Override
|
||||
public boolean execute(@NotNull final PsiElement element) {
|
||||
if (element instanceof PsiJavaCodeReferenceElement) {
|
||||
@@ -56,6 +60,12 @@ public class VariableInIncompleteCodeSearcher extends QueryExecutorBase<PsiRefer
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}, ((LocalSearchScope)scope).getScope());
|
||||
};
|
||||
|
||||
for (PsiElement element : elements) {
|
||||
if (element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) {
|
||||
PsiTreeUtil.processElements(element, processor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "IdeaWin32.h"
|
||||
#include <windows.h>
|
||||
|
||||
typedef DWORD (WINAPI *GetFinalPathNameByHandlePtr) (HANDLE, LPCWSTR, DWORD, DWORD dwFlags);
|
||||
static GetFinalPathNameByHandlePtr __GetFinalPathNameByHandle = NULL;
|
||||
|
||||
static jfieldID nameID = NULL;
|
||||
static jfieldID attributesID = NULL;
|
||||
@@ -66,30 +68,38 @@ static jobject CreateFileInfo(JNIEnv *env, jstring path, bool append, LPWIN32_FI
|
||||
timestamp = 0;
|
||||
length = 0;
|
||||
|
||||
size_t nameLen = env->GetStringLength(path) + wcslen(lpData->cFileName) + 2;
|
||||
wchar_t *lpName = (wchar_t *)malloc(nameLen * sizeof(wchar_t));
|
||||
if (lpName != NULL) {
|
||||
const jchar *dirName = env->GetStringChars(path, 0);
|
||||
wcscpy_s(lpName, nameLen, (LPCWSTR)dirName);
|
||||
env->ReleaseStringChars(path, dirName);
|
||||
if (append) {
|
||||
wcscat_s(lpName, nameLen, L"\\");
|
||||
wcscat_s(lpName, nameLen, lpData->cFileName);
|
||||
}
|
||||
const jchar *dirName = env->GetStringChars(path, 0);
|
||||
wchar_t *fullPath = (wchar_t *)dirName;
|
||||
|
||||
if (append) {
|
||||
size_t nameLen = env->GetStringLength(path) + wcslen(lpData->cFileName) + 2;
|
||||
fullPath = (wchar_t *)malloc(nameLen * sizeof(wchar_t));
|
||||
if (fullPath != NULL) {
|
||||
wcscpy_s(fullPath, nameLen, (LPCWSTR)dirName);
|
||||
wcscat_s(fullPath, nameLen, L"\\");
|
||||
wcscat_s(fullPath, nameLen, lpData->cFileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (fullPath != NULL) {
|
||||
// read symlink target attributes
|
||||
HANDLE th = CreateFile(lpName, 0, FILE_SHARE_ATTRIBUTES, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
if (th != INVALID_HANDLE_VALUE) {
|
||||
HANDLE h = CreateFile(fullPath, 0, FILE_SHARE_ATTRIBUTES, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
BY_HANDLE_FILE_INFORMATION targetData;
|
||||
if (GetFileInformationByHandle(th, &targetData)) {
|
||||
if (GetFileInformationByHandle(h, &targetData)) {
|
||||
attributes = targetData.dwFileAttributes | FILE_ATTRIBUTE_REPARSE_POINT;
|
||||
timestamp = pairToInt64(targetData.ftLastWriteTime.dwLowDateTime, targetData.ftLastWriteTime.dwHighDateTime);
|
||||
length = pairToInt64(targetData.nFileSizeLow, targetData.nFileSizeHigh);
|
||||
}
|
||||
CloseHandle(th);
|
||||
CloseHandle(h);
|
||||
}
|
||||
|
||||
if (append) {
|
||||
free(fullPath);
|
||||
}
|
||||
free(lpName);
|
||||
}
|
||||
|
||||
env->ReleaseStringChars(path, dirName);
|
||||
}
|
||||
else {
|
||||
attributes &= (~ FILE_ATTRIBUTE_REPARSE_POINT); // keep reparse flag only for symlinks
|
||||
@@ -116,6 +126,9 @@ static jobject CreateFileInfo(JNIEnv *env, jstring path, bool append, LPWIN32_FI
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_initIDs(JNIEnv *env, jclass cls) {
|
||||
__GetFinalPathNameByHandle =
|
||||
(GetFinalPathNameByHandlePtr)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetFinalPathNameByHandleW");
|
||||
|
||||
jclass fileInfoClass = getFileInfoClass(env);
|
||||
if (fileInfoClass == NULL) {
|
||||
return;
|
||||
@@ -166,6 +179,10 @@ JNIEXPORT jobject JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_getI
|
||||
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_resolveSymLink0(JNIEnv *env, jobject method, jstring path) {
|
||||
if (__GetFinalPathNameByHandle == NULL) {
|
||||
return NULL; // XP
|
||||
}
|
||||
|
||||
WIN32_FIND_DATA data;
|
||||
HANDLE h = FindFileInner(env, path, &data);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
@@ -187,7 +204,7 @@ JNIEXPORT jstring JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_reso
|
||||
jstring result = NULL;
|
||||
|
||||
TCHAR name[MAX_PATH];
|
||||
DWORD len = GetFinalPathNameByHandle(th, name, MAX_PATH, 0);
|
||||
DWORD len = __GetFinalPathNameByHandle(th, name, MAX_PATH, 0);
|
||||
if (len > 0) {
|
||||
if (len < MAX_PATH) {
|
||||
result = env->NewString((jchar *)name, len);
|
||||
@@ -195,7 +212,7 @@ JNIEXPORT jstring JNICALL Java_com_intellij_openapi_util_io_win32_IdeaWin32_reso
|
||||
else {
|
||||
TCHAR *name = (TCHAR *)malloc(sizeof(TCHAR) * (len + 1));
|
||||
if (name != NULL) {
|
||||
len = GetFinalPathNameByHandle(th, name, len, 0);
|
||||
len = __GetFinalPathNameByHandle(th, name, len, 0);
|
||||
if (len > 0) {
|
||||
result = env->NewString((jchar *)name, len);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.indentation;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,8 +37,8 @@ public abstract class IndentationParser implements PsiParser {
|
||||
final PsiBuilder.Marker fileMarker = builder.mark();
|
||||
final PsiBuilder.Marker documentMarker = builder.mark();
|
||||
|
||||
final Stack<Pair<Integer, PsiBuilder.Marker>> stack = new Stack<Pair<Integer, PsiBuilder.Marker>>();
|
||||
stack.push(Pair.create(0, builder.mark()));
|
||||
final Stack<BlockInfo> stack = new Stack<BlockInfo>();
|
||||
stack.push(new BlockInfo(0, builder.mark()));
|
||||
|
||||
PsiBuilder.Marker startLineMarker = null;
|
||||
int currentIndent = 0;
|
||||
@@ -61,7 +60,7 @@ public abstract class IndentationParser implements PsiParser {
|
||||
currentIndent = builder.getTokenText().length();
|
||||
}
|
||||
else {
|
||||
if (!eolSeen && !stack.isEmpty() && currentIndent > 0 && currentIndent < stack.peek().first) {
|
||||
if (!eolSeen && !stack.isEmpty() && currentIndent > 0 && currentIndent < stack.peek().getIndent()) {
|
||||
// sometimes we do not have EOL between indents
|
||||
eolSeen = true;
|
||||
}
|
||||
@@ -71,18 +70,18 @@ public abstract class IndentationParser implements PsiParser {
|
||||
startLineMarker = null;
|
||||
}
|
||||
// Close indentation blocks
|
||||
while (!stack.isEmpty() && currentIndent < stack.peek().first) {
|
||||
closeBlock(builder, stack.pop().second);
|
||||
while (!stack.isEmpty() && currentIndent < stack.peek().getIndent()) {
|
||||
closeBlock(builder, stack.pop().getMarker());
|
||||
}
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
final Pair<Integer, PsiBuilder.Marker> pair = stack.peek();
|
||||
if (currentIndent >= pair.first) {
|
||||
if (currentIndent == pair.first) {
|
||||
closeBlock(builder, stack.pop().second);
|
||||
final BlockInfo blockInfo = stack.peek();
|
||||
if (currentIndent >= blockInfo.getIndent()) {
|
||||
if (currentIndent == blockInfo.getIndent()) {
|
||||
closeBlock(builder, stack.pop().getMarker());
|
||||
}
|
||||
passEOLsAndIndents(builder);
|
||||
stack.push(Pair.create(currentIndent, builder.mark()));
|
||||
stack.push(new BlockInfo(currentIndent, builder.mark()));
|
||||
}
|
||||
}
|
||||
eolSeen = false;
|
||||
@@ -98,7 +97,7 @@ public abstract class IndentationParser implements PsiParser {
|
||||
startLineMarker.drop();
|
||||
}
|
||||
while (!stack.isEmpty()){
|
||||
closeBlock(builder, stack.pop().second);
|
||||
closeBlock(builder, stack.pop().getMarker());
|
||||
}
|
||||
|
||||
documentMarker.done(myDocumentType);
|
||||
@@ -121,4 +120,24 @@ public abstract class IndentationParser implements PsiParser {
|
||||
tokenType = builder.getTokenType();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class BlockInfo {
|
||||
private final int myIndent;
|
||||
@NotNull
|
||||
private final PsiBuilder.Marker myMarker;
|
||||
|
||||
private BlockInfo(final int indent, final @NotNull PsiBuilder.Marker marker) {
|
||||
this.myIndent = indent;
|
||||
this.myMarker = marker;
|
||||
}
|
||||
|
||||
public int getIndent() {
|
||||
return myIndent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiBuilder.Marker getMarker() {
|
||||
return myMarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
|
||||
TreeUI actualUI = ui;
|
||||
if (!isCustomUI()) {
|
||||
if (!(ui instanceof WideSelectionTreeUI) && (UIUtil.isUnderAquaBasedLookAndFeel() || SystemInfo.isWindows) && isMacWideSelection()) { //todo[kb] fix on ubunty
|
||||
actualUI = new WideSelectionTreeUI(isMacWideSelection(), !isFileColorsEnabled());
|
||||
actualUI = new WideSelectionTreeUI(isMacWideSelection(), !SystemInfo.isMac);
|
||||
}
|
||||
}
|
||||
super.setUI(actualUI);
|
||||
|
||||
@@ -402,7 +402,7 @@ group.error.highlighting=Error highlighting
|
||||
editbox.autoreparse.delay.ms=Autoreparse delay (ms):
|
||||
editbox.error.stripe.mark.min.height.pixels=Error stripe mark min height (pixels):
|
||||
checkbox.suppress.with.suppresswarnings=Suppress with @SuppressWarnings (for Java 5.0 only)
|
||||
checkbox.next.error.action.goes.to.errors.first='Next Error' action goes to errors first
|
||||
checkbox.next.error.action.goes.to.errors.first='Next Error' action goes to high priority problems only
|
||||
checkbox.show.import.popup=Show import &popup
|
||||
checkbox.indent.use.tab.character=Use tab character
|
||||
checkbox.indent.smart.tabs=Smart tabs
|
||||
|
||||
@@ -252,11 +252,11 @@ remote.configuration.socket.radio=Socket
|
||||
remote.configuration.shared.memory.address.label=Shared memory address:
|
||||
remote.configuration.port.label=Port:
|
||||
remote.configuration.host.label=Host:
|
||||
remote.configuration.remote.debugging.allows.you.to.connect.idea.to.a.running.jvm.label=&Remote debugging allows you to connect IDEA to a running JVM started with the following command line arguments
|
||||
remote.configuration.remote.debugging.allows.you.to.connect.idea.to.a.running.jvm.label=&Command line arguments for running remote JVM
|
||||
standard.runner.description=Run selected configuration
|
||||
environment.variables.helper.use.arguments.label=<html><body>Use the following command line arguments for running remote JVM</body></html>
|
||||
environment.variables.helper.use.arguments.jdk13.label=<html><body>If the &application runs on JDK 1.3.x or earlier, use following arguments</body></html>
|
||||
environment.variables.helper.use.arguments.jdk14.label=<html><body>If the &application runs on JDK 1.4.x, use following arguments</body></html>
|
||||
environment.variables.helper.use.arguments.jdk13.label=<html><body>For JDK 1.3.x or earlier</body></html>
|
||||
environment.variables.helper.use.arguments.jdk14.label=<html><body>For JDK 1.4.x</body></html>
|
||||
select.run.configuration.for.item.action.name=Select ''{0}''
|
||||
save.run.configuration.for.item.action.name=Save ''{0}''
|
||||
junit.runing.info.status.done.count=Done: {0}
|
||||
|
||||
@@ -487,6 +487,6 @@ public class NameUtilTest extends UsefulTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}).cpuBound().assertTiming();
|
||||
}).cpuBound().attempts(20).assertTiming();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,8 +160,10 @@ public class TestsUIUtil {
|
||||
int failedCount = failed.size();
|
||||
final List<AbstractTestProxy> notStarted = Filter.NOT_PASSED.select(allTests);
|
||||
notStarted.removeAll(failed);
|
||||
final List ignored = Filter.IGNORED.select(allTests);
|
||||
notStarted.removeAll(ignored);
|
||||
int notStartedCount = notStarted.size();
|
||||
int passedCount = allTests.size() - failedCount - notStartedCount;
|
||||
int passedCount = allTests.size() - failedCount - notStartedCount - ignored.size();
|
||||
if (failedCount > 0) {
|
||||
myTitle = ExecutionBundle.message("junit.runing.info.tests.failed.label");
|
||||
myText = passedCount + " passed, " + failedCount + " failed" + (notStartedCount > 0 ? ", " + notStartedCount + " not started" : "");
|
||||
|
||||
@@ -46,11 +46,13 @@ public class IdeaWin32 {
|
||||
available = true;
|
||||
}
|
||||
catch (Throwable t0) {
|
||||
LOG.debug(t0);
|
||||
try {
|
||||
System.load(PathManager.getHomePath() + "/bin/win/" + libName + ".dll");
|
||||
available = true;
|
||||
}
|
||||
catch (Throwable t1) {
|
||||
LOG.debug(t1);
|
||||
try {
|
||||
System.loadLibrary(libName);
|
||||
available = true;
|
||||
|
||||
@@ -101,6 +101,8 @@ public class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void linkToFile() throws Exception {
|
||||
assumeTrue(SystemInfo.areSymLinksSupported);
|
||||
|
||||
final File file = FileUtil.createTempFile(myTempDirectory, "test.", ".txt", true);
|
||||
FileUtil.writeToFile(file, myTestData);
|
||||
assertTrue(file.setLastModified(file.lastModified() - 5000));
|
||||
@@ -120,6 +122,8 @@ public class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void doubleLink() throws Exception {
|
||||
assumeTrue(SystemInfo.areSymLinksSupported);
|
||||
|
||||
final File file = FileUtil.createTempFile(myTempDirectory, "test.", ".txt", true);
|
||||
FileUtil.writeToFile(file, myTestData);
|
||||
assertTrue(file.setLastModified(file.lastModified() - 5000));
|
||||
@@ -140,6 +144,8 @@ public class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void linkToDirectory() throws Exception {
|
||||
assumeTrue(SystemInfo.areSymLinksSupported);
|
||||
|
||||
final File file = FileUtil.createTempDirectory(myTempDirectory, "test.", ".tmp");
|
||||
if (SystemInfo.isUnix) assertTrue(file.setWritable(false, false));
|
||||
assertTrue(file.setLastModified(file.lastModified() - 5000));
|
||||
@@ -158,6 +164,8 @@ public class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void missingLink() throws Exception {
|
||||
assumeTrue(SystemInfo.areSymLinksSupported);
|
||||
|
||||
final File file = FileUtil.createTempFile(myTempDirectory, "test.", ".txt", false);
|
||||
final File link = IoTestUtil.createTempLink(file.getPath(), new File(myTempDirectory, "link").getPath());
|
||||
|
||||
|
||||
-3
@@ -24,7 +24,6 @@ import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.palette.DefaultPaletteItem;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -90,8 +89,6 @@ public final class AndroidTreeDecorator implements TreeComponentDecorator {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.android.designer.componentTree");
|
||||
|
||||
@Nullable
|
||||
private static String getPropertyValue(RadComponent component, String name) {
|
||||
if (component.getProperties() == null) {
|
||||
|
||||
@@ -191,7 +191,9 @@ public class ModelParser extends XmlRecursiveElementVisitor {
|
||||
addComponent(newComponent, ViewsMetaManager.getInstance(newComponent.getTag().getProject()), propertyParser);
|
||||
}
|
||||
|
||||
IdManager.get(container).ensureIds(newComponent);
|
||||
if (!(newComponent instanceof RadViewContainer)) {
|
||||
IdManager.get(container).ensureIds(newComponent);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addComponent(RadViewComponent parentComponent,
|
||||
|
||||
@@ -171,7 +171,7 @@ android.wizard.specify.tested.module.error=Please specify tested module
|
||||
android.wizard.tested.module.without.facet.error=Tested module must contain Android facet
|
||||
android.wizard.cannot.find.module.parent.dir.error=Cannot find module parent directory: {0}
|
||||
android.wizard.invalid.sdk.error=Android SDK is invalid
|
||||
android.facet.editor.is.library.checkbox=&Is Library project
|
||||
android.facet.editor.is.library.checkbox=Li&brary module
|
||||
android.run.sdk.manager.action.text=SDK Manager
|
||||
android.run.avd.manager.action.text=AVD Manager
|
||||
android.choose.sdk.label=Please choose Android SDK location
|
||||
@@ -220,7 +220,7 @@ android.keystore.password.label=Pa&ssword:
|
||||
android.keystore.confirm.password.label=C&onfirm:
|
||||
android.export.package.new.key.alias.label=&Alias:
|
||||
android.key.password.label=Pa&ssword:
|
||||
android.cannot.run.library.project.error=The module cannot be Android library project
|
||||
android.cannot.run.library.project.error=The module cannot be Android library
|
||||
android.compilation.error.specify.platform=[{0}] Android SDK is not specified or cannot be parsed
|
||||
android.compilation.error.manifest.not.found=[{0}] AndroidManifest.xml file not found. Please, check Android facet settings.
|
||||
android.compilation.error.apt.gen.not.specified=AAPT destination directory not specified for module {0}
|
||||
@@ -389,7 +389,7 @@ android.lint.inspections.use.sparsearray=HashMap can be replaced with SparseArra
|
||||
android.lint.inspections.value.of=Should use 'valueOf' instead of 'new'
|
||||
android.lint.inspections.multiple.uses.sdk=Multiple <uses-sdk> elements in the manifest
|
||||
android.lint.inspections.uses.min.sdk=Minimum SDK and target SDK attributes not defined
|
||||
android.lint.inspections.custom.view=Using custom namespace attributes in a library project
|
||||
android.lint.inspections.custom.view=Using custom namespace attributes in a library module
|
||||
android.lint.inspections.proguard.split.config=Proguard.cfg file contains generic Android rules
|
||||
android.lint.inspections.sd.card.path=Hardcoded reference to /sdcard
|
||||
android.lint.inspections.world,writable.files=openFileOutput() call passing MODE_WORLD_WRITEABLE
|
||||
|
||||
@@ -125,8 +125,10 @@ public class AndroidRenameResourceProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
}
|
||||
String name = AndroidResourceUtil.getResourceNameByReferenceText(newName);
|
||||
for (PsiField resField : AndroidResourceUtil.findIdFields(value)) {
|
||||
allRenames.put(resField, name);
|
||||
if (name != null) {
|
||||
for (PsiField resField : AndroidResourceUtil.findIdFields(value)) {
|
||||
allRenames.put(resField, AndroidResourceUtil.getFieldNameByResourceName(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +188,7 @@ public class AndroidRenameResourceProcessor extends RenamePsiElementProcessor {
|
||||
}
|
||||
PsiField[] resFields = AndroidResourceUtil.findResourceFieldsForValueResource(tag, false);
|
||||
for (PsiField resField : resFields) {
|
||||
allRenames.put(resField, newName);
|
||||
allRenames.put(resField, AndroidResourceUtil.getFieldNameByResourceName(newName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@ public class AndroidRenameResourceProcessor extends RenamePsiElementProcessor {
|
||||
PsiField[] resFields = AndroidResourceUtil.findResourceFieldsForFileResource(file, false);
|
||||
for (PsiField resField : resFields) {
|
||||
String newFieldName = AndroidCommonUtils.getResourceName(type, newName);
|
||||
allRenames.put(resField, newFieldName);
|
||||
allRenames.put(resField, AndroidResourceUtil.getFieldNameByResourceName(newFieldName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
|
||||
@Override
|
||||
protected void process(@NotNull ResourceEntry entry) {
|
||||
result.put(entry, Collections.<ResourceEntry>emptySet());
|
||||
addEntryToMap(entry, createTypeMarkerEntry(entry.getType()), result);
|
||||
addEntryToMap(entry, createTypeNameMarkerEntry(entry.getType(), entry.getName()), result);
|
||||
result.put(createKey(entry), Collections.<ResourceEntry>emptySet());
|
||||
addEntryToMap(entry, createTypeMarkerKey(entry.getType()), result);
|
||||
addEntryToMap(entry, createTypeNameMarkerKey(entry.getType(), entry.getName()), result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -76,12 +76,39 @@ public class AndroidValueResourcesIndex extends FileBasedIndexExtension<Resource
|
||||
set.add(entry);
|
||||
}
|
||||
|
||||
public static ResourceEntry createTypeMarkerEntry(String type) {
|
||||
return new ResourceEntry(type, "TYPE_MARKER_RESOURCE", "TYPE_MARKER_CONTEXT");
|
||||
@NotNull
|
||||
public static ResourceEntry createTypeMarkerKey(String type) {
|
||||
return createTypeNameMarkerKey(type, "TYPE_MARKER_RESOURCE");
|
||||
}
|
||||
|
||||
public static ResourceEntry createTypeNameMarkerEntry(String type, String name) {
|
||||
return new ResourceEntry(type, name, "TYPE_MARKER_CONTEXT");
|
||||
@NotNull
|
||||
public static ResourceEntry createTypeNameMarkerKey(String type, String name) {
|
||||
return createKey(type, name, "TYPE_MARKER_CONTEXT");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResourceEntry createKey(ResourceEntry entry) {
|
||||
return createKey(entry.getType(), entry.getName(), entry.getContext());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResourceEntry createKey(String type, String name, String context) {
|
||||
return new ResourceEntry(type, normalizeDelimiters(name), context);
|
||||
}
|
||||
|
||||
private static String normalizeDelimiters(String s) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
for (int i = 0, n = s.length(); i < n; i++) {
|
||||
final char c = s.charAt(i);
|
||||
if (Character.isLetterOrDigit(c)) {
|
||||
result.append(c);
|
||||
}
|
||||
else {
|
||||
result.append('_');
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private final KeyDescriptor<ResourceEntry> myKeyDescriptor = new KeyDescriptor<ResourceEntry>() {
|
||||
|
||||
+7
-2
@@ -85,9 +85,14 @@ public class AndroidResourceReference extends PsiReferenceBase.Poly<XmlElement>
|
||||
ResourceValue value = myValue.getValue();
|
||||
assert value != null;
|
||||
String resType = value.getResourceType();
|
||||
|
||||
if (resType != null && newElementName != null) {
|
||||
myValue.setValue(ResourceValue.referenceTo(value.getPrefix(), value.getPackage(), resType,
|
||||
AndroidCommonUtils.getResourceName(resType, newElementName)));
|
||||
// todo: do not allow new value resource name to contain dot, because it is impossible to check if it file or value otherwise
|
||||
|
||||
final String newResName = newElementName.contains(".") // it is file
|
||||
? AndroidCommonUtils.getResourceName(resType, newElementName)
|
||||
: newElementName;
|
||||
myValue.setValue(ResourceValue.referenceTo(value.getPrefix(), value.getPackage(), resType, newResName));
|
||||
}
|
||||
return myValue.getXmlTag();
|
||||
}
|
||||
|
||||
+3
-2
@@ -139,11 +139,12 @@ public class LocalResourceManager extends ResourceManager {
|
||||
final GlobalSearchScope scope = GlobalSearchScope.projectScope(myModule.getProject());
|
||||
|
||||
for (ResourceType resourceType : AndroidResourceUtil.ALL_VALUE_RESOURCE_TYPES) {
|
||||
final ResourceEntry typeMarkerEntry = AndroidValueResourcesIndex.createTypeMarkerEntry(resourceType.getName());
|
||||
final ResourceEntry typeMarkerEntry = AndroidValueResourcesIndex.createTypeMarkerKey(resourceType.getName());
|
||||
|
||||
for (Set<ResourceEntry> entrySet : index.getValues(AndroidValueResourcesIndex.INDEX_ID, typeMarkerEntry, scope)) {
|
||||
for (ResourceEntry entry : entrySet) {
|
||||
final Collection<VirtualFile> files = index.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, entry, scope);
|
||||
final Collection<VirtualFile> files =
|
||||
index.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, AndroidValueResourcesIndex.createKey(entry), scope);
|
||||
|
||||
for (VirtualFile file : files) {
|
||||
Set<String> resourcesInFile = file2Types.get(file);
|
||||
|
||||
@@ -281,13 +281,14 @@ public abstract class ResourceManager {
|
||||
}
|
||||
|
||||
final FileBasedIndex index = FileBasedIndex.getInstance();
|
||||
final ResourceEntry typeMarkerEntry = AndroidValueResourcesIndex.createTypeMarkerEntry(resourceType);
|
||||
final ResourceEntry typeMarkerEntry = AndroidValueResourcesIndex.createTypeMarkerKey(resourceType);
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(myModule.getProject());
|
||||
|
||||
final Map<VirtualFile, Set<ResourceEntry>> file2resourceSet = new HashMap<VirtualFile, Set<ResourceEntry>>();
|
||||
for (Set<ResourceEntry> entrySet : index.getValues(AndroidValueResourcesIndex.INDEX_ID, typeMarkerEntry, scope)) {
|
||||
for (ResourceEntry entry : entrySet) {
|
||||
final Collection<VirtualFile> files = index.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, entry, scope);
|
||||
final Collection<VirtualFile> files =
|
||||
index.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID, AndroidValueResourcesIndex.createKey(entry), scope);
|
||||
|
||||
for (VirtualFile file : files) {
|
||||
Set<ResourceEntry> resourcesInFile = file2resourceSet.get(file);
|
||||
@@ -438,7 +439,7 @@ public abstract class ResourceManager {
|
||||
|
||||
final Collection<VirtualFile> files = FileBasedIndex.getInstance()
|
||||
.getContainingFiles(AndroidValueResourcesIndex.INDEX_ID,
|
||||
AndroidValueResourcesIndex.createTypeNameMarkerEntry(resourceType, resourceName),
|
||||
AndroidValueResourcesIndex.createTypeNameMarkerKey(resourceType, resourceName),
|
||||
GlobalSearchScope.allScope(myModule.getProject()));
|
||||
|
||||
if (files.size() == 0) {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class AndroidDebugRunner extends DefaultProgramRunner {
|
||||
launcher.setRunDescriptor(runDescriptor);
|
||||
}
|
||||
if (runDescriptor == null) {
|
||||
throw new ExecutionException("Can't run an application");
|
||||
return null;
|
||||
}
|
||||
tryToCloseOldSessions(executor, project);
|
||||
runningState.getProcessHandler().putUserData(ANDROID_PROCESS_HANDLER, runDescriptor);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="dist.delims"></string>
|
||||
</resources>
|
||||
@@ -0,0 +1,7 @@
|
||||
package p1.p2;
|
||||
|
||||
class Java {
|
||||
public void g() {
|
||||
int a = R.string.dist_del<caret>ims;
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,11 @@ public class AndroidResourcesLineMarkerTest extends AndroidTestCase {
|
||||
doJavaFileNavigationTest(1, true, XmlAttributeValue.class);
|
||||
}
|
||||
|
||||
public void testJavaFileNavigation12() throws Exception {
|
||||
myFixture.copyFileToProject(BASE_PATH + "dist_delims.xml", "res/values/strings12.xml");
|
||||
doJavaFileNavigationTest(1, true, XmlAttributeValue.class);
|
||||
}
|
||||
|
||||
private void doJavaFileNavigationTest(int expectedTargets,
|
||||
boolean expectedEnabled,
|
||||
@Nullable Class<? extends PsiElement> targetElementClass)
|
||||
|
||||
@@ -240,13 +240,13 @@ public class AndroidLibraryProjectTest extends UsefulTestCase {
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesClass1.java", "app/src/p1/p2/lib/Class.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesClass1.java", "lib/src/p1/p2/lib/Class.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesStyles.xml", "app/res/values/styles.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "FindUsagesStyles2.xml", "lib/res/values/styles2.xml");
|
||||
//myFixture.copyFileToProject(BASE_PATH + "FindUsagesStyles2.xml", "lib/res/values/styles2.xml");
|
||||
myFixture.copyFileToProject(BASE_PATH + "picture1.png", "lib/res/drawable/picture1.png");
|
||||
myFixture.copyFileToProject("R.java", "app/src/p1/p2/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "LibR.java", "app/src/p1/p2/lib/R.java");
|
||||
myFixture.copyFileToProject(BASE_PATH + "LibR.java", "lib/src/p1/p2/lib/R.java");
|
||||
Collection<UsageInfo> references = findCodeUsages(getTestName(false) + "." + extension, dir);
|
||||
assertEquals(buildFileList(references), 6, references.size());
|
||||
assertEquals(buildFileList(references), 5, references.size());
|
||||
}
|
||||
|
||||
private List<UsageInfo> findCodeUsages(String path, String dir) throws Throwable {
|
||||
|
||||
@@ -64,7 +64,7 @@ public interface Action extends DomElement {
|
||||
* @return the value of the class child.
|
||||
*/
|
||||
@NotNull
|
||||
@com.intellij.util.xml.Attribute ("class")
|
||||
@Attribute ("class")
|
||||
@Required
|
||||
@ExtendClass(value = "com.intellij.openapi.actionSystem.AnAction",
|
||||
instantiatable = true, allowNonPublic = true, allowAbstract = false, allowInterface = false)
|
||||
|
||||
@@ -1,186 +1,190 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.PomDeclarationSearcher;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.CollectConsumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyUnresolvedHighlightFilter;
|
||||
import org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GrHighlightUtil {
|
||||
private static final Logger LOG = Logger.getInstance(GrHighlightUtil.class);
|
||||
|
||||
static boolean isReassigned(GrVariable var) {
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class);
|
||||
PsiNamedElement scope = method == null ? var.getContainingFile() : method;
|
||||
if (scope == null) {
|
||||
return false;
|
||||
}
|
||||
boolean hasAssignment = var.getInitializerGroovy() != null || var instanceof GrParameter;
|
||||
for (PsiReference reference : ReferencesSearch.search(var, new LocalSearchScope(scope)).findAll()) {
|
||||
if (reference instanceof GrReferenceExpression &&
|
||||
(PsiUtil.isLValue((GrReferenceExpression)reference) ||
|
||||
((GrReferenceExpression)reference).getParent() instanceof GrUnaryExpression &&
|
||||
((GrUnaryExpression)((GrReferenceExpression)reference).getParent()).isPostfix())) {
|
||||
if (hasAssignment) {
|
||||
return true;
|
||||
}
|
||||
hasAssignment = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static TextAttributesKey getDeclarationHighlightingAttribute(PsiElement resolved) {
|
||||
if (resolved instanceof PsiField || resolved instanceof GrVariable && ResolveUtil.isScriptField((GrVariable)resolved)) {
|
||||
boolean isStatic = ((PsiVariable)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
return isStatic ? DefaultHighlighter.STATIC_FIELD : DefaultHighlighter.INSTANCE_FIELD;
|
||||
}
|
||||
else if (resolved instanceof GrAccessorMethod) {
|
||||
boolean isStatic = ((GrAccessorMethod)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
return isStatic ? DefaultHighlighter.STATIC_PROPERTY_REFERENCE : DefaultHighlighter.INSTANCE_PROPERTY_REFERENCE;
|
||||
}
|
||||
else if (resolved instanceof PsiMethod) {
|
||||
if (!((PsiMethod)resolved).isConstructor()) {
|
||||
boolean isStatic = ((PsiMethod)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
if (GroovyPropertyUtils.isSimplePropertyAccessor((PsiMethod)resolved)) {
|
||||
return isStatic ? DefaultHighlighter.STATIC_PROPERTY_REFERENCE : DefaultHighlighter.INSTANCE_PROPERTY_REFERENCE;
|
||||
}
|
||||
else {
|
||||
return isStatic ? DefaultHighlighter.STATIC_METHOD_ACCESS : DefaultHighlighter.METHOD_CALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (resolved instanceof PsiTypeParameter) {
|
||||
return DefaultHighlighter.TYPE_PARAMETER;
|
||||
}
|
||||
else if (resolved instanceof PsiClass) {
|
||||
if (((PsiClass)resolved).isAnnotationType()) {
|
||||
return DefaultHighlighter.ANNOTATION;
|
||||
}
|
||||
else {
|
||||
return DefaultHighlighter.CLASS_REFERENCE;
|
||||
}
|
||||
}
|
||||
else if (resolved instanceof GrParameter) {
|
||||
boolean reassigned = isReassigned((GrParameter)resolved);
|
||||
return reassigned ? DefaultHighlighter.REASSIGNED_PARAMETER : DefaultHighlighter.PARAMETER;
|
||||
}
|
||||
else if (resolved instanceof GrVariable) {
|
||||
boolean reassigned = isReassigned((GrVariable)resolved);
|
||||
return reassigned ? DefaultHighlighter.REASSIGNED_LOCAL_VARIABLE : DefaultHighlighter.LOCAL_VARIABLE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isDeclarationAssignment(GrReferenceExpression refExpr) {
|
||||
if (isAssignmentLhs(refExpr)) {
|
||||
return isExpandoQualified(refExpr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isAssignmentLhs(GrReferenceExpression refExpr) {
|
||||
return refExpr.getParent() instanceof GrAssignmentExpression &&
|
||||
refExpr.equals(((GrAssignmentExpression)refExpr.getParent()).getLValue());
|
||||
}
|
||||
|
||||
private static boolean isExpandoQualified(GrReferenceExpression refExpr) {
|
||||
final GrExpression qualifier = refExpr.getQualifierExpression();
|
||||
if (qualifier == null) {
|
||||
final PsiClass clazz = PsiTreeUtil.getParentOfType(refExpr, PsiClass.class);
|
||||
if (clazz == null) { //script
|
||||
return true;
|
||||
}
|
||||
return false; //in class, a property should normally be defined, so it's not a declaration
|
||||
}
|
||||
|
||||
final PsiType type = qualifier.getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass instanceof GroovyScriptClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean shouldHighlightAsUnresolved(@NotNull GrReferenceExpression referenceExpression) {
|
||||
PsiElement refNameElement = referenceExpression.getReferenceNameElement();
|
||||
if (refNameElement != null && referenceExpression.getQualifier() == null) {
|
||||
final IElementType type = refNameElement.getNode().getElementType();
|
||||
if (TokenSets.STRING_LITERAL_SET.contains(type)) return false;
|
||||
}
|
||||
|
||||
if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression)) return false;
|
||||
|
||||
CollectConsumer<PomTarget> consumer = new CollectConsumer<PomTarget>();
|
||||
|
||||
for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) {
|
||||
searcher.findDeclarationsAt(referenceExpression, 0, consumer);
|
||||
if (consumer.getResult().size() > 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TextRange getMethodHeaderTextRange(PsiMethod method) {
|
||||
final PsiModifierList modifierList = method.getModifierList();
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
|
||||
final TextRange textRange = modifierList.getTextRange();
|
||||
LOG.assertTrue(textRange != null, method.getClass() + ":" + method.getText());
|
||||
int startOffset = textRange.getStartOffset();
|
||||
int endOffset = parameterList.getTextRange().getEndOffset() + 1;
|
||||
|
||||
return new TextRange(startOffset, endOffset);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiElement getElementToHighlight(@NotNull GrReferenceElement refElement) {
|
||||
final PsiElement refNameElement = refElement.getReferenceNameElement();
|
||||
return refNameElement != null ? refNameElement : refElement;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.PomDeclarationSearcher;
|
||||
import com.intellij.pom.PomTarget;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PsiElementProcessor;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.CollectConsumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.extensions.GroovyUnresolvedHighlightFilter;
|
||||
import org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GrHighlightUtil {
|
||||
private static final Logger LOG = Logger.getInstance(GrHighlightUtil.class);
|
||||
|
||||
static boolean isReassigned(final GrVariable var) {
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(var, PsiMethod.class);
|
||||
PsiNamedElement scope = method == null ? var.getContainingFile() : method;
|
||||
if (scope == null) {
|
||||
return false;
|
||||
}
|
||||
return !PsiTreeUtil.processElements(scope, new PsiElementProcessor() {
|
||||
boolean hasAssignment = var.getInitializerGroovy() != null || var instanceof GrParameter;
|
||||
@Override
|
||||
public boolean execute(@NotNull PsiElement element) {
|
||||
if (element instanceof GrReferenceExpression &&
|
||||
var.getName().equals(((GrReferenceExpression)element).getReferenceName()) &&
|
||||
((GrReferenceExpression)element).isReferenceTo(var)) {
|
||||
if (PsiUtil.isLValue((GrReferenceExpression)element) ||
|
||||
element.getParent() instanceof GrUnaryExpression && ((GrUnaryExpression)element.getParent()).isPostfix()) {
|
||||
if (hasAssignment) {
|
||||
return false;
|
||||
}
|
||||
hasAssignment = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static TextAttributesKey getDeclarationHighlightingAttribute(PsiElement resolved) {
|
||||
if (resolved instanceof PsiField || resolved instanceof GrVariable && ResolveUtil.isScriptField((GrVariable)resolved)) {
|
||||
boolean isStatic = ((PsiVariable)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
return isStatic ? DefaultHighlighter.STATIC_FIELD : DefaultHighlighter.INSTANCE_FIELD;
|
||||
}
|
||||
else if (resolved instanceof GrAccessorMethod) {
|
||||
boolean isStatic = ((GrAccessorMethod)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
return isStatic ? DefaultHighlighter.STATIC_PROPERTY_REFERENCE : DefaultHighlighter.INSTANCE_PROPERTY_REFERENCE;
|
||||
}
|
||||
else if (resolved instanceof PsiMethod) {
|
||||
if (!((PsiMethod)resolved).isConstructor()) {
|
||||
boolean isStatic = ((PsiMethod)resolved).hasModifierProperty(PsiModifier.STATIC);
|
||||
if (GroovyPropertyUtils.isSimplePropertyAccessor((PsiMethod)resolved)) {
|
||||
return isStatic ? DefaultHighlighter.STATIC_PROPERTY_REFERENCE : DefaultHighlighter.INSTANCE_PROPERTY_REFERENCE;
|
||||
}
|
||||
else {
|
||||
return isStatic ? DefaultHighlighter.STATIC_METHOD_ACCESS : DefaultHighlighter.METHOD_CALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (resolved instanceof PsiTypeParameter) {
|
||||
return DefaultHighlighter.TYPE_PARAMETER;
|
||||
}
|
||||
else if (resolved instanceof PsiClass) {
|
||||
if (((PsiClass)resolved).isAnnotationType()) {
|
||||
return DefaultHighlighter.ANNOTATION;
|
||||
}
|
||||
else {
|
||||
return DefaultHighlighter.CLASS_REFERENCE;
|
||||
}
|
||||
}
|
||||
else if (resolved instanceof GrParameter) {
|
||||
boolean reassigned = isReassigned((GrParameter)resolved);
|
||||
return reassigned ? DefaultHighlighter.REASSIGNED_PARAMETER : DefaultHighlighter.PARAMETER;
|
||||
}
|
||||
else if (resolved instanceof GrVariable) {
|
||||
boolean reassigned = isReassigned((GrVariable)resolved);
|
||||
return reassigned ? DefaultHighlighter.REASSIGNED_LOCAL_VARIABLE : DefaultHighlighter.LOCAL_VARIABLE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isDeclarationAssignment(GrReferenceExpression refExpr) {
|
||||
if (isAssignmentLhs(refExpr)) {
|
||||
return isExpandoQualified(refExpr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isAssignmentLhs(GrReferenceExpression refExpr) {
|
||||
return refExpr.getParent() instanceof GrAssignmentExpression &&
|
||||
refExpr.equals(((GrAssignmentExpression)refExpr.getParent()).getLValue());
|
||||
}
|
||||
|
||||
private static boolean isExpandoQualified(GrReferenceExpression refExpr) {
|
||||
final GrExpression qualifier = refExpr.getQualifierExpression();
|
||||
if (qualifier == null) {
|
||||
final PsiClass clazz = PsiTreeUtil.getParentOfType(refExpr, PsiClass.class);
|
||||
if (clazz == null) { //script
|
||||
return true;
|
||||
}
|
||||
return false; //in class, a property should normally be defined, so it's not a declaration
|
||||
}
|
||||
|
||||
final PsiType type = qualifier.getType();
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass instanceof GroovyScriptClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean shouldHighlightAsUnresolved(@NotNull GrReferenceExpression referenceExpression) {
|
||||
PsiElement refNameElement = referenceExpression.getReferenceNameElement();
|
||||
if (refNameElement != null && referenceExpression.getQualifier() == null) {
|
||||
final IElementType type = refNameElement.getNode().getElementType();
|
||||
if (TokenSets.STRING_LITERAL_SET.contains(type)) return false;
|
||||
}
|
||||
|
||||
if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression)) return false;
|
||||
|
||||
CollectConsumer<PomTarget> consumer = new CollectConsumer<PomTarget>();
|
||||
|
||||
for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) {
|
||||
searcher.findDeclarationsAt(referenceExpression, 0, consumer);
|
||||
if (consumer.getResult().size() > 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TextRange getMethodHeaderTextRange(PsiMethod method) {
|
||||
final PsiModifierList modifierList = method.getModifierList();
|
||||
final PsiParameterList parameterList = method.getParameterList();
|
||||
|
||||
final TextRange textRange = modifierList.getTextRange();
|
||||
LOG.assertTrue(textRange != null, method.getClass() + ":" + method.getText());
|
||||
int startOffset = textRange.getStartOffset();
|
||||
int endOffset = parameterList.getTextRange().getEndOffset() + 1;
|
||||
|
||||
return new TextRange(startOffset, endOffset);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PsiElement getElementToHighlight(@NotNull GrReferenceElement refElement) {
|
||||
final PsiElement refNameElement = refElement.getReferenceNameElement();
|
||||
return refNameElement != null ? refNameElement : refElement;
|
||||
}
|
||||
}
|
||||
|
||||
+74
-88
@@ -1,88 +1,74 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator;
|
||||
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GrReferenceHighlighter extends TextEditorHighlightingPass {
|
||||
@NotNull private final GroovyFile myFile;
|
||||
@Nullable private List<HighlightInfo> myInfos = null;
|
||||
|
||||
protected GrReferenceHighlighter(@Nullable Document document, @NotNull GroovyFile file) {
|
||||
super(file.getProject(), document);
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCollectInformation(@NotNull ProgressIndicator progress) {
|
||||
myInfos = new ArrayList<HighlightInfo>();
|
||||
myFile.accept(new GroovyRecursiveElementVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
|
||||
super.visitReferenceExpression(referenceExpression);
|
||||
visit(referenceExpression);
|
||||
}
|
||||
|
||||
private void visit(GrReferenceElement element) {
|
||||
final PsiElement resolved = element.resolve();
|
||||
final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(resolved);
|
||||
if (attribute != null) {
|
||||
final PsiElement refNameElement = GrHighlightUtil.getElementToHighlight(element);
|
||||
myInfos.add(HighlightInfo.createHighlightInfo(HighlightInfoType.INFORMATION, refNameElement, null, attribute));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCodeReferenceElement(GrCodeReferenceElement refElement) {
|
||||
super.visitCodeReferenceElement(refElement);
|
||||
visit(refElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitAnnotation(GrAnnotation annotation) {
|
||||
super.visitAnnotation(annotation);
|
||||
visit(annotation.getClassReference());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doApplyInformationToEditor() {
|
||||
if (myInfos == null) return;
|
||||
UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), myInfos, getColorsScheme(), getId());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator;
|
||||
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.daemon.impl.UpdateHighlightersUtil;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiRecursiveElementWalkingVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Max Medvedev
|
||||
*/
|
||||
public class GrReferenceHighlighter extends TextEditorHighlightingPass {
|
||||
@NotNull private final GroovyFile myFile;
|
||||
@Nullable private List<HighlightInfo> myInfos = null;
|
||||
|
||||
protected GrReferenceHighlighter(@Nullable Document document, @NotNull GroovyFile file) {
|
||||
super(file.getProject(), document);
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCollectInformation(@NotNull ProgressIndicator progress) {
|
||||
myInfos = new ArrayList<HighlightInfo>();
|
||||
myFile.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
super.visitElement(element);
|
||||
if (element instanceof GrReferenceElement) {
|
||||
visit((GrReferenceElement)element);
|
||||
}
|
||||
}
|
||||
private void visit(GrReferenceElement element) {
|
||||
final PsiElement resolved = element.resolve();
|
||||
final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(resolved);
|
||||
if (attribute != null) {
|
||||
final PsiElement refNameElement = GrHighlightUtil.getElementToHighlight(element);
|
||||
myInfos.add(HighlightInfo.createHighlightInfo(HighlightInfoType.INFORMATION, refNameElement, null, attribute));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doApplyInformationToEditor() {
|
||||
if (myInfos == null) return;
|
||||
UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), myInfos, getColorsScheme(), getId());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -56,7 +56,6 @@ import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
@@ -109,7 +108,6 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass {
|
||||
};
|
||||
|
||||
final List<HighlightInfo> unusedDeclarations = new ArrayList<HighlightInfo>();
|
||||
final Set<GrImportStatement> unusedImports = new HashSet<GrImportStatement>(PsiUtil.getValidImportStatements(myFile));
|
||||
|
||||
final Map<GrParameter, Boolean> usedParams = new HashMap<GrParameter, Boolean>();
|
||||
myFile.accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@@ -156,13 +154,11 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass {
|
||||
}
|
||||
}
|
||||
|
||||
for (GrImportStatement used : GroovyImportOptimizer.findUsedImports(myFile)) {
|
||||
unusedImports.remove(used);
|
||||
}
|
||||
|
||||
super.visitElement(element);
|
||||
}
|
||||
});
|
||||
final Set<GrImportStatement> unusedImports = new HashSet<GrImportStatement>(PsiUtil.getValidImportStatements(myFile));
|
||||
unusedImports.removeAll(GroovyImportOptimizer.findUsedImports(myFile));
|
||||
myUnusedImports = unusedImports;
|
||||
|
||||
if (deadCodeEnabled) {
|
||||
|
||||
+14
-13
@@ -29,9 +29,11 @@ import gnu.trove.TObjectIntProcedure;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
@@ -40,7 +42,8 @@ import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.plugins.groovy.lang.editor.GroovyImportHelper.*;
|
||||
import static org.jetbrains.plugins.groovy.lang.editor.GroovyImportHelper.isImplicitlyImported;
|
||||
import static org.jetbrains.plugins.groovy.lang.editor.GroovyImportHelper.processImports;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
@@ -72,16 +75,14 @@ public class GroovyImportOptimizer implements ImportOptimizer {
|
||||
@Nullable final Map<String, String> annotations) {
|
||||
if (!(file instanceof GroovyFile)) return;
|
||||
|
||||
((GroovyFile)file).accept(new GroovyRecursiveElementVisitor() {
|
||||
public void visitCodeReferenceElement(GrCodeReferenceElement refElement) {
|
||||
visitRefElement(refElement);
|
||||
super.visitCodeReferenceElement(refElement);
|
||||
}
|
||||
|
||||
public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
|
||||
visitRefElement(referenceExpression);
|
||||
super.visitReferenceExpression(referenceExpression);
|
||||
}
|
||||
((GroovyFile)file).accept(new PsiRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
super.visitElement(element);
|
||||
if (element instanceof GrReferenceElement) {
|
||||
visitRefElement((GrReferenceElement)element);
|
||||
}
|
||||
}
|
||||
|
||||
private void visitRefElement(GrReferenceElement refElement) {
|
||||
final GroovyResolveResult[] resolveResults = refElement.multiResolve(false);
|
||||
|
||||
+9
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
|
||||
import com.intellij.refactoring.rename.PsiElementRenameHandler;
|
||||
import com.intellij.lang.properties.references.PropertyReferenceBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -46,6 +47,14 @@ public class PropertyRenameHandler extends PsiElementRenameHandler {
|
||||
if (reference instanceof PropertyReferenceBase) {
|
||||
final ResolveResult[] resolveResults = ((PropertyReferenceBase)reference).multiResolve(false);
|
||||
return resolveResults.length > 0 ? resolveResults[0].getElement() : null;
|
||||
} else if (reference instanceof PsiMultiReference) {
|
||||
final PsiReference[] references = ((PsiMultiReference)reference).getReferences();
|
||||
for (PsiReference psiReference : references) {
|
||||
if (psiReference instanceof PropertyReferenceBase) {
|
||||
final ResolveResult[] resolveResults = ((PropertyReferenceBase)psiReference).multiResolve(false);
|
||||
if (resolveResults.length > 0) return resolveResults[0].getElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ public class TestNGConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
else if (data.TEST_OBJECT.equals(TestType.PACKAGE.getType())) {
|
||||
PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(data.getPackageName());
|
||||
if (psiPackage == null) throw new RuntimeConfigurationException("Package '" + data.getMainClassName() + "' not found");
|
||||
if (psiPackage == null) throw new RuntimeConfigurationException("Package '" + data.getPackageName() + "' not found");
|
||||
}
|
||||
else if (data.TEST_OBJECT.equals(TestType.SUITE.getType())) {
|
||||
try {
|
||||
|
||||
@@ -31,6 +31,11 @@
|
||||
<appender-ref ref="CONSOLE-ALL"/>
|
||||
</category>
|
||||
|
||||
<category name="#com.intellij.openapi.util.io.win32.Win32LocalFileSystem">
|
||||
<priority value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE-ALL"/>
|
||||
</category>
|
||||
|
||||
<root>
|
||||
<priority value="INFO"/>
|
||||
<appender-ref ref="CONSOLE-WARN"/>
|
||||
|
||||
Reference in New Issue
Block a user